/* «المصحف» — web reader. Pages are the KFQC artwork (SVG) with a hit layer built from the
   ayah polygons; two-page spread on wide screens (odd page on the right), one page on phones. */

body.reader-body { overflow: hidden; height: 100dvh; }
.reader { display: flex; flex-direction: column; height: 100dvh; background: var(--paper); }

.reader-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 58px; }
.reader-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.reader-title strong { font-family: var(--font-display); font-size: 1.25rem; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.riwaya-switch { display: flex; border: 1px solid var(--line-strong); border-radius: 999px; overflow: hidden; }
.riwaya-switch a { padding: 6px 14px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: .9rem; }
.riwaya-switch a.on { background: var(--green); color: var(--on-green); }

.stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.spread { display: flex; flex-direction: row; justify-content: center; align-items: center; gap: 0; }
.page { position: relative; aspect-ratio: 345 / 550; height: min(calc(100dvh - 128px), calc((100vw - 24px) * 550 / 345)); background: var(--surface); box-shadow: var(--shadow); border: 1px solid var(--line); display: grid; place-items: center; }
.spread.two .page { height: min(calc(100dvh - 128px), calc((100vw - 140px) / 2 * 550 / 345)); }
/* Book binding: the right page (odd, first in RTL order) and the left page (even) meet in the middle. */
.spread.two .page:first-child { border-start-start-radius: 0; box-shadow: inset 10px 0 14px -12px rgba(0, 0, 0, .25), var(--shadow); }
.spread.two .page:last-child { box-shadow: inset -10px 0 14px -12px rgba(0, 0, 0, .25), var(--shadow); }
.page .page-no { position: absolute; bottom: -24px; inset-inline: 0; text-align: center; font-size: .8rem; color: var(--ink-2); }
.page .loading { color: var(--ink-2); font-size: .9rem; }
.page .failed { text-align: center; padding: 16px; color: var(--ink-2); }

.page-svg { width: 100%; height: 100%; display: block; overflow: visible; }
/* Thumn / rub' marks at the page edge, in the margin: a ring with the part of the hizb already read
   filled in (heavier for a quarter); the start of a hizb is a solid disc with its number. */
.page-svg .mark .disc { fill: var(--surface); stroke: var(--green); stroke-width: 1; }
.page-svg .mark.rub .disc { stroke-width: 1.6; }
.page-svg .mark .fill { fill: var(--green); }
.page-svg .mark.hizb .disc { fill: var(--green); }
.page-svg .mark text { fill: var(--on-green); font-size: 7px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
/* The glyphs never take the pointer: only the hit layer does (Warsh polygons sit beneath the ink). */
.page-svg .art, .page-svg .art * { pointer-events: none; }
.page-svg .pic { pointer-events: none; }
.edition-toggle { font-size: .85rem; padding: .25rem .7rem; border: 1px solid var(--gold); border-radius: 999px; color: inherit; text-decoration: none; white-space: nowrap; }
.edition-toggle.on { background: var(--gold); color: #fff; }
.page-svg .hits path { fill: var(--gold); fill-opacity: 0; cursor: pointer; pointer-events: all; transition: fill-opacity .12s; }
.page-svg .hits path:hover { fill-opacity: .14; }
.page-svg .hits path.on { fill-opacity: .26; }

.turn { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 44px; height: 88px; border-radius: 14px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.turn svg { width: 24px; height: 24px; }
.turn:hover { background: var(--surface-3); }
.turn[disabled] { opacity: .3; cursor: default; }
/* RTL: the next page is on the left. */
.turn-next { left: 8px; }
.turn-prev { right: 8px; }
@media (max-width: 700px) { .turn { width: 34px; height: 64px; opacity: .75; } .turn-next { left: 2px; } .turn-prev { right: 2px; } }
/* Phones: the controls on one row, and the title (surah, juz and hizb, page) on a line of its own under
   them, so «الجزء ٣، الحزب ٥» is never squeezed into a few letters beside the buttons. */
@media (max-width: 640px) {
  .reader-bar { flex-wrap: wrap; row-gap: 2px; padding-bottom: 6px; }
  .reader-title { order: 10; flex: 1 0 100%; flex-direction: row; align-items: baseline; justify-content: space-between; gap: 12px; padding-inline: 4px; }
  .reader-title .muted { white-space: nowrap; }
  .riwaya-switch { margin-inline-start: auto; }
  .page { height: min(calc(100dvh - 164px), calc((100vw - 24px) * 550 / 345)); }
}

.ayah-bar { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; padding-inline-start: 18px; border-radius: 999px; background: var(--green); color: var(--on-green); box-shadow: var(--shadow); font-weight: 600; max-width: calc(100vw - 24px); }
.ayah-bar .icon-btn { width: 34px; height: 34px; background: transparent; border-color: transparent; color: inherit; }
/* «وصلتُ في الورد إلى هنا» / «حفظتُ إلى هنا» (NV5): a signed-in member's two actions in the bar. */
.ayah-bar { flex-wrap: wrap; justify-content: center; border-radius: 20px; }
.ayah-actions, .ayah-ask { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.ayah-act { min-height: 36px; padding: 4px 14px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--on-green) 55%, transparent); background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; }
.ayah-act:hover, .ayah-act:focus-visible { background: color-mix(in srgb, var(--on-green) 18%, transparent); }
.ayah-status { flex-basis: 100%; text-align: center; font-weight: 500; }
.ayah-status:empty { display: none; }
/* Where the plans stand, on the page edge opposite to the thumn / rub' marks: «و» wird, «ح» hifz. */
.page-svg .pmark circle { fill: var(--green); }
.page-svg .pmark.hifz circle { stroke: var(--on-green); stroke-width: 1; }
.page-svg .pmark text { fill: var(--on-green); font-size: 8px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }

.index-panel { position: fixed; top: 0; bottom: 0; right: 0; width: min(380px, 100vw); z-index: 30; background: var(--surface); border-inline-end: 1px solid var(--line); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.index-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.index-head .tabs { margin: 0; }
.goto { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.goto input { min-height: 38px; width: 90px; }
.index-list { list-style: none; margin: 0; padding: 4px 8px 24px; overflow-y: auto; flex: 1; }
.index-list a { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink); }
.index-list a:hover, .index-list a.on { background: var(--green-soft); color: var(--on-green-soft); }
.index-list .n { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--gold); color: var(--gold); display: grid; place-items: center; font-size: .8rem; flex: none; }
.index-list .nm { flex: 1; font-family: var(--font-display); font-size: 1.15rem; }
.index-list .pg { font-size: .8rem; color: var(--ink-2); }

.credit { text-align: center; margin: 0; padding: 4px 8px 6px; }

/* Night mode: the artwork's black ink turns light, ornaments keep their hue. */
:root[data-theme="dark"] .page { background: #1A1F1B; border-color: #2B322C; }
:root[data-theme="dark"] .page-svg .art { filter: invert(.92) hue-rotate(180deg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .page { background: #1A1F1B; border-color: #2B322C; }
  :root:not([data-theme="light"]) .page-svg .art { filter: invert(.92) hue-rotate(180deg); }
}

/* Full screen: the reader fills the screen on the site's own paper. */
.reader:fullscreen { background: var(--paper); }
