/* =====================================================================
   QURAN READER v2 — verse-by-verse surah reader styles, scoped to
   js/quran-reader.jsx classNames. Shares var(--gold*) tokens with the rest
   of the Quran tab (page-accents.css) but re-expresses every color through a
   scoped --qr-* token layer so the 3 reading themes (dark/grey/light) swap
   cleanly. Never touches Arabic text nodes.
   ===================================================================== */

/* ---- scoped reading-surface tokens (theme layer) ---- */
.q-reader {
  --qr-bg: transparent;
  --qr-bar-bg: #070c0a;
  --qr-ink: #eaf3ee;
  --qr-ink-dim: rgba(234,243,238,.55);
  --qr-border: rgba(255,255,255,.06);
  --qr-accent: var(--gold);
  --qr-accent-hi: var(--gold-hi);
  --qr-chip-bg: rgba(255,255,255,.04);
  --qr-highlight: var(--gold-10);
  --qr-highlight-ring: var(--gold-18);
  --qr-fscale: 1;

  display: flex;
  flex-direction: column;
  background: var(--qr-bg);
  border-radius: 16px;
  color: var(--qr-ink);
}
.q-reader[data-qr-theme="grey"] {
  --qr-bg: #1b1f1d;
  --qr-bar-bg: #1b1f1d;
  --qr-ink: #e6ece8;
  --qr-ink-dim: rgba(230,236,232,.55);
  --qr-border: rgba(255,255,255,.08);
  --qr-chip-bg: rgba(255,255,255,.05);
  --qr-highlight: rgba(14,145,89,.14);
  --qr-highlight-ring: rgba(14,145,89,.26);
  padding: 12px 12px 4px;
}
.q-reader[data-qr-theme="light"] {
  --qr-bg: #f7f4ec;
  --qr-bar-bg: #f7f4ec;
  --qr-ink: #1b2420;
  --qr-ink-dim: #5a6b62;
  --qr-border: rgba(20,40,30,.14);
  --qr-accent: var(--gold-lo);
  --qr-accent-hi: var(--gold-lo);
  --qr-chip-bg: rgba(20,40,30,.06);
  --qr-highlight: rgba(14,145,89,.10);
  --qr-highlight-ring: rgba(14,145,89,.22);
  padding: 12px 12px 4px;
}

/* ---- Arabic typography (CRITICAL, reader-scoped subset) ----
   Never apply positive letter-spacing (breaks Arabic ligatures), never justify,
   never transform the text. Generous line-height so the Quranic marks above/below
   letters are never clipped. Nastaleeq stacks tall — 2.15 clips, use 2.6. */
.q-ayah-ar, .q-basmala, .q-surah-title-ar {
  font-family: 'Indopak Nastaleeq','Amiri Quran',serif;
  direction: rtl;
  letter-spacing: 0;
  word-spacing: normal;
  line-height: 2.6;
  font-feature-settings: "liga" 1, "calt" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
/* Light theme: drop antialiasing on Arabic so glyph strokes stay crisp on the pale surface. */
.q-reader[data-qr-theme="light"] .q-ayah-ar,
.q-reader[data-qr-theme="light"] .q-basmala,
.q-reader[data-qr-theme="light"] .q-surah-title-ar {
  -webkit-font-smoothing: auto;
}

/* ---- toolbar ---- */
.q-reader-bar { display: flex; flex-direction: column; gap: 8px; padding: 4px 12px 12px; margin: 0 -12px; position: sticky; top: 0; z-index: 2; background: var(--qr-bar-bg); border-bottom: 1px solid var(--qr-border); }
.q-rbar-row { display: flex; align-items: center; gap: 10px; }
.q-rbar-tools { flex-wrap: wrap; }
.q-rnav { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink); cursor: pointer; flex-shrink: 0; }
.q-rnav:disabled { opacity: 0.3; cursor: default; }
.q-rselect { flex: 1; position: relative; }
.q-rselect select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.q-rselect-face { display: flex; flex-direction: column; padding: 7px 14px; border-radius: 10px; background: var(--qr-chip-bg); border: 1px solid var(--qr-border); pointer-events: none; }
.q-rselect-face b { font-size: 15px; color: var(--qr-ink); }
.q-rselect-face small { font-size: 11px; color: var(--qr-ink-dim); }

.q-transtoggle { width: 44px; height: 36px; border-radius: 10px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink-dim); font-size: 12px; font-weight: 800; cursor: pointer; flex-shrink: 0; }
.q-transtoggle.on { border-color: var(--qr-accent); color: var(--qr-accent-hi); background: var(--qr-highlight); }
.q-transtoggle:disabled { opacity: 0.35; cursor: default; }

/* segmented 3-way toggles (theme + font) */
.q-themetoggle, .q-fontsize { display: inline-flex; border: 1px solid var(--qr-border); border-radius: 10px; overflow: hidden; background: var(--qr-chip-bg); flex-shrink: 0; }
.q-themetoggle button, .q-fontsize button { width: 36px; height: 36px; border: none; background: transparent; color: var(--qr-ink-dim); cursor: pointer; font-size: 13px; display: inline-grid; place-items: center; }
.q-themetoggle button + button, .q-fontsize button + button { border-left: 1px solid var(--qr-border); }
.q-themetoggle button.on { color: var(--qr-accent-hi); background: var(--qr-highlight); }
.q-fontsize button { font-weight: 800; }
.q-fontsize button span { font-size: 10px; margin-left: 1px; }

.q-selftest, .q-repeatbtn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink-dim); font-size: 12px; font-weight: 700; cursor: pointer; flex-shrink: 0; }
.q-selftest.on, .q-repeatbtn.on { border-color: var(--qr-accent); color: var(--qr-accent-hi); background: var(--qr-highlight); }

/* go-to-ayah */
.q-goto { display: inline-flex; align-items: center; gap: 4px; }
.q-goto input { width: 74px; height: 36px; border-radius: 10px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink); padding: 0 10px; font-size: 13px; }
.q-goto.compact input { width: 52px; }
.q-goto button { width: 34px; height: 36px; border-radius: 10px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink-dim); cursor: pointer; }

/* repeat / loop panel (inline) */
.q-repeatpanel { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; margin: 0 0 10px; border: 1px solid var(--qr-accent); border-radius: 12px; background: var(--qr-highlight); }
.q-rp-fields { display: flex; gap: 12px; flex-wrap: wrap; }
.q-rp-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--qr-ink-dim); font-weight: 700; }
.q-rp-fields input, .q-rp-fields select { width: 72px; height: 34px; border-radius: 8px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink); padding: 0 8px; font-size: 13px; }
.q-rp-actions { display: flex; align-items: center; gap: 8px; }
.q-rp-go, .q-rp-stop { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--qr-accent); background: var(--qr-accent); color: #0a1a10; font-weight: 800; font-size: 12px; cursor: pointer; }
.q-rp-stop { background: transparent; color: var(--qr-accent-hi); }
.q-rp-close { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink-dim); cursor: pointer; }

/* looping status chip */
.q-loopchip { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; padding: 6px 12px; margin: 0 0 10px; border-radius: 999px; border: 1px solid var(--qr-accent); background: var(--qr-highlight); color: var(--qr-accent-hi); font-size: 12px; font-weight: 700; }
.q-loopchip button { display: inline-flex; align-items: center; gap: 4px; border: none; background: transparent; color: var(--qr-ink-dim); font-size: 11px; font-weight: 700; cursor: pointer; }

/* audio inline notice */
.q-audio-note { padding: 8px 12px; margin: 0 0 10px; border-radius: 10px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink-dim); font-size: 12px; }
.q-audio-note button { border: none; background: transparent; color: var(--qr-accent-hi); font-size: 12px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }

/* ---- ornamental surah header ---- */
.q-ornate {
  position: relative;
  padding: 22px 24px 18px;
  margin: 0 0 12px;
  border: 1px solid color-mix(in srgb, var(--qr-accent) 22%, transparent);
  border-radius: 14px;
  box-shadow: inset 0 0 0 3px var(--qr-bg), inset 0 0 0 4px color-mix(in srgb, var(--qr-accent) 14%, transparent);
}
.q-orn-corner { position: absolute; }
.q-orn-tl { top: 5px; left: 5px; }
.q-orn-tr { top: 5px; right: 5px; transform: scaleX(-1); }
.q-orn-bl { bottom: 5px; left: 5px; transform: scaleY(-1); }
.q-orn-br { bottom: 5px; right: 5px; transform: scale(-1, -1); }

.q-surah-title { text-align: center; }
.q-surah-title-ar { font-size: 30px; color: var(--qr-accent-hi); }
.q-surah-title-en { display: block; font-size: 12px; color: var(--qr-ink-dim); margin-top: 4px; }
.q-basmala { text-align: center; font-size: 26px; color: var(--qr-accent-hi); padding: 12px 0 2px; margin-top: 8px; border-top: 1px solid var(--qr-border); }

/* ---- ayah rows ---- */
.q-reader-body { display: flex; flex-direction: column; }
.q-ayah-wrap { display: block; }
.q-ayah { padding: 16px 4px; border-bottom: 1px solid var(--qr-border); }
.q-ayah.is-current { background: var(--qr-highlight); border-radius: 12px; box-shadow: inset 0 0 0 1px var(--qr-highlight-ring); padding: 16px 14px; }
.q-ayah.is-playing { border-radius: 12px; box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--qr-accent) 45%, transparent); padding: 16px 14px; }
.q-ayah.is-current.is-playing { box-shadow: inset 0 0 0 1px var(--qr-highlight-ring), inset 0 0 0 2px color-mix(in srgb, var(--qr-accent) 45%, transparent); }
.q-ayah-ar { font-size: calc(30px * var(--qr-fscale)); color: var(--qr-ink); text-align: right; }
.q-ayah-num { display: inline-grid; place-items: center; width: 30px; height: 30px; margin: 0 6px; font-family: 'Oswald', sans-serif; font-size: 12px; color: var(--qr-accent-hi); border: 1px solid color-mix(in srgb, var(--qr-accent) 30%, transparent); border-radius: 50%; vertical-align: middle; }
.q-ayah-en { font-size: 14px; line-height: 1.6; color: var(--qr-ink-dim); margin-top: 10px; }
.q-ayah-tools { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

.q-markhere { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 8px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink-dim); font-size: 11px; font-weight: 600; cursor: pointer; transition: all .18s; }
.q-markhere.on { border-color: var(--qr-accent); color: var(--qr-accent-hi); background: var(--qr-highlight); }
.q-atool { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 8px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink-dim); font-size: 11px; font-weight: 600; cursor: pointer; }
.q-atool.q-play { width: 34px; justify-content: center; padding: 5px 0; }
.q-atool.on { border-color: var(--qr-accent); color: var(--qr-accent-hi); background: var(--qr-highlight); }

/* ---- self-test masking (LOSSLESS: transparent text over a pill; textContent intact) ---- */
.q-mask {
  color: transparent;
  background: color-mix(in srgb, var(--qr-accent) 12%, var(--qr-chip-bg));
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--qr-border);
  user-select: none;
  cursor: pointer;
}
.q-ayah.is-selftest .q-ayah-ar { cursor: pointer; }

/* ---- bottom navigation ---- */
.q-reader-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 18px 4px 8px; margin-top: 4px; border-top: 1px solid var(--qr-border); }
.q-navbtn { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--qr-border); background: var(--qr-chip-bg); color: var(--qr-ink); font-size: 12px; font-weight: 700; cursor: pointer; }
.q-navbtn:disabled { opacity: 0.3; cursor: default; }

.q-reader-foot { text-align: center; font-size: 10px; color: var(--qr-ink-dim); padding: 16px 0 8px; }

/* ---- mobile ---- */
@media (max-width: 760px) {
  .q-ayah-ar { font-size: calc(28px * var(--qr-fscale)); }
  .q-surah-title-ar { font-size: 26px; }
  .q-basmala { font-size: 22px; }
  .q-ornate { padding: 20px 16px 16px; }
  .q-rbar-tools { row-gap: 8px; }
}
