/* ════════════════════════════════════════════════════════
   READING — The English Toolbox   Accent: Sky Blue #0EA5E9
════════════════════════════════════════════════════════ */

/* ── Mode Cards (override accent for sky-blue) ── */
.reading-mode-btns .tense-mode-btn:hover  { border-color: #0EA5E9; }
.reading-mode-btns .tense-mode-btn.active { border-color: #0EA5E9; background: rgba(14,165,233,.08); box-shadow: 0 0 0 3px rgba(14,165,233,.15); }

/* ── Level Groups ── */
.reading-grid { display: flex; flex-direction: column; gap: 0; }
.reading-level-group { margin-bottom: 20px; }
.reading-level-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.reading-level-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.reading-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Exercise Cards ── */
.reading-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-left: 3px solid transparent;
  border-radius: var(--r-md);
  padding: 11px 13px;
  cursor: pointer;
  transition: border-color .2s, background .15s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.reading-card:hover { background: rgba(14,165,233,.04); border-color: #0EA5E9; border-left-color: inherit; }
.reading-card.level-B1 { border-left-color: #10B981; }
.reading-card.level-B2 { border-left-color: #F59E0B; }
.reading-card.level-C1 { border-left-color: #EF4444; }
.rc-body  { flex: 1; min-width: 0; }
.rc-title { font-weight: 600; font-size: .88rem; color: var(--text-primary); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-meta  { font-size: .73rem; color: var(--text-secondary); display: flex; gap: 8px; flex-wrap: wrap; }
.rc-badge {
  font-size: .7rem; font-weight: 700;
  padding: 2px 8px; border-radius: 99px; color: #fff; flex-shrink: 0; align-self: center;
}
.rc-badge.B1 { background: #10B981; }
.rc-badge.B2 { background: #F59E0B; }
.rc-badge.C1 { background: #EF4444; }
.rc-arrow { color: var(--text-secondary); font-size: .95rem; flex-shrink: 0; }

/* ── Prose ── */
.r-text-header { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.r-text-header h2 { font-size: 1.1rem; font-weight: 700; margin: 0; flex: 1; min-width: 0; }
.r-meta-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.r-chip { font-size: .74rem; background: var(--bg-alt, #f3f4f6); border-radius: 99px; padding: 3px 10px; color: var(--text-secondary); }

.r-prose { font-size: .96rem; line-height: 1.9; color: var(--text-primary); margin-bottom: 18px; }
.r-prose p { margin: 0 0 14px 0; }
.r-prose p:last-child { margin-bottom: 0; }

/* ── Scaffold word ── */
.r-scaffold {
  border-bottom: 2px dashed #0EA5E9;
  color: #0369A1;
  cursor: pointer;
  border-radius: 2px;
  padding: 0 1px;
  transition: background .15s;
}
.r-scaffold:hover { background: rgba(14,165,233,.12); }
.r-scaffold.r-seen { border-style: solid; opacity: .85; }

/* ── Word popover ── */
/* Backdrop: dims content behind popover */
.r-popover-backdrop {
  position: fixed; inset: 0;
  z-index: 9998;
  background: rgba(0,0,0,.25);
}

.r-popover {
  position: fixed;
  z-index: 9999;
  /* Solid opaque background — never transparent */
  background: #ffffff;
  color: #111827;
  border: 2px solid #0EA5E9;
  border-radius: 12px;
  padding: 16px 18px 14px;
  max-width: 300px;
  width: max-content;
  box-shadow: 0 12px 32px rgba(0,0,0,.28), 0 2px 8px rgba(14,165,233,.15);
  font-size: .85rem;
  line-height: 1.55;
  /* Force new stacking context */
  isolation: isolate;
  transform: translateZ(0);
}

/* Dark mode override */
@media (prefers-color-scheme: dark) {
  .r-popover { background: #1e2433; color: #f1f5f9; }
  .r-popover-def { color: #f1f5f9; }
  .r-popover-ex  { color: #94a3b8; }
}

/* Also support app's own dark class if present */
.dark .r-popover,
[data-theme="dark"] .r-popover { background: #1e2433; color: #f1f5f9; }
.dark .r-popover-def,
[data-theme="dark"] .r-popover-def { color: #f1f5f9; }
.dark .r-popover-ex,
[data-theme="dark"] .r-popover-ex  { color: #94a3b8; }

.r-popover-word  { font-weight: 700; color: #0369A1; font-size: .95rem; margin-bottom: 6px; }
.r-popover-def   { color: #111827;   margin-bottom: 8px; }
.r-popover-ex    { color: #4B5563; font-style: italic; border-left: 3px solid #0EA5E9; padding-left: 8px; margin-bottom: 6px; }
.r-popover-close {
  position: absolute; top: 10px; right: 12px;
  cursor: pointer; font-size: 1.1rem; color: #6B7280;
  background: none; border: none; padding: 0; line-height: 1;
}
.r-popover-close:hover { color: #111827; }

/* ── Comprehension Questions ── */
.r-question { background: var(--card-bg); border: 1.5px solid var(--border); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 12px; }
.r-q-text   { font-weight: 600; font-size: .9rem; margin-bottom: 10px; color: var(--text-primary); }
.r-q-opts   { display: flex; flex-direction: column; gap: 7px; }
.r-opt {
  padding: 9px 13px; border: 1.5px solid var(--border); border-radius: var(--r-sm);
  cursor: pointer; font-size: .86rem;
  transition: border-color .15s, background .15s;
  color: var(--text-primary); text-align: left; background: none; width: 100%;
  font-family: var(--font-body);
}
.r-opt:hover    { border-color: #0EA5E9; background: rgba(14,165,233,.05); }
.r-opt.selected { border-color: #0EA5E9; background: rgba(14,165,233,.08); }
.r-opt.correct  { border-color: #10B981; background: rgba(16,185,129,.1); color: #065F46; }
.r-opt.wrong    { border-color: #EF4444; background: rgba(239,68,68,.08); color: #991B1B; }

.r-score-box { text-align: center; padding: 24px; background: var(--card-bg); border-radius: var(--r-lg); border: 2px solid var(--border); margin-top: 16px; }
.r-score-num   { font-size: 2.4rem; font-weight: 800; color: #0EA5E9; }
.r-score-label { font-size: .88rem; color: var(--text-secondary); margin-bottom: 14px; }

/* ── Jumbled Paragraphs ── */
.jumbled-area { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.jumbled-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 10px;
  transition: border-color .2s;
}
.jumbled-card.correct { border-color: #10B981; background: rgba(16,185,129,.05); }
.jumbled-card.wrong   { border-color: #EF4444; background: rgba(239,68,68,.04); }

.jc-controls { display: flex; flex-direction: column; gap: 3px; flex-shrink: 0; }
.jc-btn {
  width: 26px; height: 26px;
  border: 1.5px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-alt, #f3f4f6);
  cursor: pointer; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
  color: var(--text-primary);
}
.jc-btn:hover:not(:disabled) { background: rgba(14,165,233,.1); border-color: #0EA5E9; }
.jc-btn:disabled { opacity: .3; cursor: default; }
.jc-num  { font-weight: 700; font-size: .78rem; color: var(--text-secondary); text-align: center; padding: 3px 0; }
.jc-text { font-size: .88rem; line-height: 1.7; color: var(--text-primary); flex: 1; }
.jc-icon { font-size: 1.1rem; align-self: center; flex-shrink: 0; }

.r-marker { background: rgba(14,165,233,.15); color: #0369A1; border-radius: 3px; padding: 0 2px; font-weight: 600; }

.jumbled-result { margin-top: 14px; padding: 14px 18px; border-radius: var(--r-md); text-align: center; font-weight: 600; font-size: .92rem; }
.jumbled-result.perfect { background: rgba(16,185,129,.1);  color: #065F46; border: 1.5px solid #10B981; }
.jumbled-result.partial { background: rgba(245,158,11,.1);  color: #92400E; border: 1.5px solid #F59E0B; }
.jumbled-result.poor    { background: rgba(239,68,68,.08);  color: #991B1B; border: 1.5px solid #EF4444; }

/* ── Shared Buttons ── */
.r-btn-primary {
  background: #0EA5E9; color: #fff; border: none;
  border-radius: var(--r-md); padding: 10px 22px;
  font-weight: 600; font-size: .9rem; cursor: pointer;
  font-family: var(--font-body); transition: background .15s;
}
.r-btn-primary:hover:not(:disabled) { background: #0284C7; }
.r-btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.r-btn-secondary {
  background: none; color: var(--text-secondary);
  border: 1.5px solid var(--border); border-radius: var(--r-md);
  padding: 9px 18px; font-weight: 600; font-size: .88rem;
  cursor: pointer; font-family: var(--font-body); transition: border-color .15s, color .15s;
}
.r-btn-secondary:hover { border-color: #0EA5E9; color: #0EA5E9; }
.r-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ── Gap Fill ── */
.gapfill-text {
  font-size: .96rem;
  line-height: 2.1;
  color: var(--text-primary);
  margin-bottom: 20px;
}
.gapfill-text p { margin: 0 0 14px 0; }
.gapfill-text p:last-child { margin-bottom: 0; }

.gap-slot {
  display: inline-block;
  min-width: 90px;
  border-bottom: 2.5px dashed #0EA5E9;
  padding: 2px 8px;
  margin: 0 2px;
  text-align: center;
  cursor: pointer;
  border-radius: 4px;
  transition: background .15s, border-color .15s;
  vertical-align: baseline;
  font-weight: 600;
  color: var(--text-primary);
}
.gap-slot:hover { background: rgba(14,165,233,.08); }
.gap-slot.active {
  background: rgba(14,165,233,.12);
  border-color: #0369A1;
  box-shadow: 0 0 0 2px rgba(14,165,233,.2);
}
.gap-slot.filled {
  border-style: solid;
  background: rgba(14,165,233,.07);
  color: #0369A1;
}
.gap-slot.correct {
  border-color: #10B981;
  background: rgba(16,185,129,.1);
  color: #065F46;
}
.gap-slot.wrong {
  border-color: #EF4444;
  background: rgba(239,68,68,.08);
  color: #991B1B;
  text-decoration: line-through;
}
.gap-slot .gap-num {
  font-size: .72rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-right: 2px;
}
.gap-correction {
  font-size: .78rem;
  color: #065F46;
  font-weight: 600;
  margin-left: 4px;
  font-style: italic;
}

.gap-bank-label {
  font-weight: 700;
  font-size: .85rem;
  margin-bottom: 10px;
  color: var(--text-secondary);
}
.gap-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 18px;
}
.gap-word {
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  font-size: .86rem;
  font-weight: 500;
  font-family: var(--font-body);
  transition: border-color .15s, background .15s, opacity .15s;
  color: var(--text-primary);
  background: none;
  user-select: none;
}
.gap-word:hover:not(.used):not(:disabled) {
  border-color: #0EA5E9;
  background: rgba(14,165,233,.06);
}
.gap-word.used {
  opacity: .35;
  cursor: default;
  text-decoration: line-through;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .reading-modes { grid-template-columns: 1fr 1fr; }
  .rmc-desc { display: none; }
  .reading-cards-grid { grid-template-columns: 1fr; }
  .r-popover { max-width: calc(100vw - 32px); }
  .r-text-header h2 { font-size: .97rem; }
  .gap-slot { min-width: 70px; padding: 2px 5px; }
  .gap-word { padding: 5px 10px; font-size: .82rem; }
}
@media (max-width: 380px) {
  .reading-modes { grid-template-columns: 1fr; }
}
