/* The whole mushaf — Madinah layout (King Fahd Complex QCF V2 glyphs), page after page */
@font-face { font-family: "Amiri Quran"; font-display: swap; src: url(../kahf/fonts/amiri-quran-arabic.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "qcf-hdr"; font-display: block; src: url(https://static-cdn.tarteel.ai/qul/fonts/surah-names/surah-header/QCF_SurahHeader_COLOR-Regular.woff2) format("woff2"); }
/* King Fahd Complex Hafs font (v3.0), served unchanged as its licence requires: quoted ayahs in the tafsir */
@font-face { font-family: "KFGQPC Hafs"; font-display: swap; src: url(../assets/qurancomplex/kfgqpc_hafs_v30.ttf) format("truetype"); }

:root {
  --paper: #f4eedf; --page: #fffdf7; --ink: #1b1b17; --gold: #9c7a2c; --gold-2: #c9a24f; --gold-3: #e6cf91; --line: #e6dabb; --muted: #7b6c4f;
  --sel: rgba(18, 90, 72, .12); --green: #155c48; --frame-1: #b48a35;
  --ui: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --fs: 20px; --lh: 40px; --pw: 680px; --lw: 600px;
  color-scheme: light;
}
body.sepia { --paper: #e9dcbd; --page: #f6ead0; --ink: #2f2412; --line: #d9c496; --green: #6b4510; }
body.night { --paper: #0c1411; --page: #121d19; --ink: #ece4cc; --gold: #d0ab5c; --gold-2: #b8954b; --gold-3: #6f5b2f; --line: #2a3832; --muted: #a99a77;
  --sel: rgba(140, 220, 190, .12); --green: #93d6bb; --frame-1: #a78339; color-scheme: dark; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: radial-gradient(1200px 600px at 50% -10%, rgba(201, 162, 79, .16), transparent 70%), var(--paper); color: var(--ink); font-family: var(--ui); line-height: 1.7; padding-bottom: 120px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { max-width: 900px; margin: 0 auto; padding: 14px 16px 6px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
/* the way back: home (the KulliQ mark) ‹ the Quran section */
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: .88rem; font-weight: 600; }
.crumbs a { display: inline-flex; align-items: center; gap: 7px; color: var(--ink); text-decoration: none; padding: 4px 8px; border-radius: 10px; white-space: nowrap; }
.crumbs a:hover, .crumbs a:focus-visible { background: var(--sel); outline: none; }
.crumbs .home { padding-inline-start: 2px; }
.crumbs svg { width: 28px; height: 28px; flex: none; }
.crumbs .sep { color: var(--gold-2); }
@media (max-width: 420px) { .crumbs { font-size: .8rem; gap: 2px; } .crumbs a { padding: 4px 5px; } .crumbs svg { width: 24px; height: 24px; } .where { font-size: .74rem; } }
.where { font-size: .85rem; color: var(--muted); font-weight: 600; }

/* today's portion (khatma) */
.wird { position: sticky; top: 0; z-index: 30; width: min(var(--pw), calc(100% - 12px)); margin: 0 auto 10px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center;
  background: var(--page); border: 1px solid var(--gold-3); border-radius: 0 0 16px 16px; padding: 8px 12px; box-shadow: 0 8px 20px rgba(60, 45, 15, .1); }
.wirdTxt b { display: block; font-size: .9rem; color: var(--green); }
.wirdTxt small { display: block; font-size: .76rem; color: var(--muted); }
.wirdBar { grid-column: 1 / -1; height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.wirdBar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-2), var(--green)); transition: width .3s ease; }
.wirdBtn { border: 0; border-radius: 12px; padding: .45rem .9rem; font: inherit; font-weight: 700; font-size: .85rem; color: #fff; background: #0f5a47; cursor: pointer; }
.wirdBtn.ok { background: transparent; color: var(--green); box-shadow: inset 0 0 0 1.5px var(--green); }

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 12px; }

/* pages */
.mushaf { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; justify-items: center; }
.mpage { position: relative; width: min(var(--pw), 100%); background: var(--page); padding: 10px 14px 8px; border-radius: 6px;
  box-shadow: 0 1px 2px rgba(60, 45, 15, .06), 0 18px 44px rgba(60, 45, 15, .10); scroll-margin-top: 70px; }
/* the ornamental frame (assets/ornament, one per colour theme), like a printed mushaf */
.frame { position: relative; --fb: 30px; border: var(--fb) solid #1c5878; border-image: url(../assets/ornament/frame-light.svg) 48 round; padding: 4px 6px; background: var(--page); }
body.sepia .frame { border-image-source: url(../assets/ornament/frame-sepia.svg); }
body.night .frame { border-image-source: url(../assets/ornament/frame-night.svg); }
.phead { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 6px; font-family: "Amiri Quran", "Amiri", serif; font-size: 1rem; color: var(--gold); }
.hizb { display: none; }
@media (min-width: 761px) {
  .mpage { padding-inline: 58px; }
  .hizb { position: absolute; right: calc(-1 * var(--fb) - 52px); top: calc(6px + var(--lh) * (var(--row) + .5)); transform: translateY(-50%); width: 46px; padding: 6px 2px;
    display: grid; justify-items: center; text-align: center; line-height: 1.25; border-radius: 40% / 22%; color: var(--gold);
    background: radial-gradient(circle at 50% 35%, var(--page), rgba(201, 162, 79, .12)); box-shadow: inset 0 0 0 1px var(--gold-2), inset 0 0 0 3px var(--page), inset 0 0 0 4px var(--gold-3); }
  .hizb b { font-size: .7rem; } .hizb small { font-size: .62rem; }
}
.phead i { font-style: normal; color: var(--gold-2); font-size: .6em; margin: 0 .35em; vertical-align: .15em; }
.lines { position: relative; padding: 2px 8px; min-width: 0; overflow-x: clip; overflow-y: visible; min-height: calc(var(--lh) * 15); }
.mpage.short .lines { min-height: calc(var(--lh) * 8); display: flex; flex-direction: column; justify-content: center; }
.mpage:not(.ready) .lines { visibility: hidden; }
.mpage:not(.ready)::after { content: ""; position: absolute; inset: 0; pointer-events: none; border-radius: 6px; background: linear-gradient(100deg, transparent 30%, rgba(201, 162, 79, .08) 50%, transparent 70%) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.ln { display: flex; justify-content: space-between; align-items: center; height: var(--lh); font-size: var(--fs); line-height: 1; white-space: nowrap; color: var(--ink); min-width: 0; }
.ln.c { justify-content: center; gap: .1em; }
.ln[data-l] { position: relative; }
.ln[data-l] .w { position: relative; z-index: 1; }
.w { cursor: pointer; border-radius: .2em; padding: .08em .015em; transition: color .2s ease; -webkit-tap-highlight-color: transparent; }
.w:hover { color: var(--gold); }
.ln.hdr { justify-content: center; font-family: "qcf-hdr"; font-size: calc(var(--lw) / 3.32); line-height: 1; overflow: visible;
  background: linear-gradient(180deg, #8a6420 0%, #d9b766 38%, #a77d2a 62%, #6f5016 100%); -webkit-background-clip: text; background-clip: text; color: transparent; }
body.night .ln.hdr { background-image: linear-gradient(180deg, #e9cf86, #b8913f 60%, #e2c676); }
.ln.bsml { justify-content: center; }
.ln.bsml i { display: block; width: calc(var(--lh) * 4.3); height: calc(var(--lh) * .88); background: var(--ink);
  -webkit-mask: url(basmala.svg) center / contain no-repeat; mask: url(basmala.svg) center / contain no-repeat; }
.pfoot { display: flex; justify-content: center; padding: 6px 0 2px; }
.pfoot span { min-width: 2.6em; padding: 0 .7em; height: 1.7em; display: grid; place-items: center; font-size: .78rem; font-weight: 700; color: var(--gold);
  border: 1px solid var(--gold-3); border-radius: 99px; background: var(--page); }
.mpage.inWird .pfoot span { background: rgba(201, 162, 79, .16); }
.mpage.read .pfoot span::after { content: " ✓"; color: var(--green); }

/* highlight bands */
.band { position: absolute; top: 9%; bottom: 9%; z-index: 0; border-radius: .38em; pointer-events: none; animation: bandIn .2s ease; }
@keyframes bandIn { from { opacity: 0; } }
.band.bmk { background: rgba(201, 162, 79, .16); box-shadow: inset 0 -2px 0 rgba(176, 132, 44, .55); }
.band.sel { background: rgba(201, 162, 79, .26); }
body.night .band.bmk { background: rgba(224, 189, 106, .12); box-shadow: inset 0 -2px 0 rgba(224, 189, 106, .5); }
body.night .band.sel { background: rgba(224, 189, 106, .2); }
.w.e.bm { position: relative; color: var(--gold); }
.w.e.bm::after { content: ""; position: absolute; left: 50%; top: -.42em; width: .36em; height: .62em; transform: translateX(-50%);
  background: linear-gradient(#d9b766, #a77d2a); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }

/* ayah actions */
.pop { position: absolute; z-index: 45; background: var(--page); border: 1px solid var(--line); border-radius: 16px; padding: 8px; box-shadow: 0 16px 40px rgba(0, 0, 0, .22); width: max-content; max-width: calc(100vw - 16px); }
.popTitle { display: block; text-align: center; font-size: .78rem; color: var(--muted); margin: 0 0 4px; }
.popBtns { display: flex; gap: 2px; }
.popBtns button { border: 0; background: transparent; color: var(--ink); font: inherit; display: flex; flex-direction: column; align-items: center; padding: 6px 8px; border-radius: 10px; cursor: pointer; min-width: 52px; }
.popBtns button span { font-size: .72rem; font-weight: 600; }
.popBtns button:hover { background: var(--sel); }
.popBtns svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; margin-bottom: 2px; }
.popBtns button[data-act="mark"] { color: var(--gold); }
.popBtns button[data-act="mark"] svg { fill: currentColor; stroke: none; }

.markPill { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 42; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--gold-2); background: var(--page); color: var(--gold); border-radius: 99px; padding: .4rem .95rem; font: inherit; font-weight: 700; font-size: .88rem;
  box-shadow: 0 8px 22px rgba(60, 45, 15, .18); cursor: pointer; }
.markPill svg { width: 14px; height: 14px; fill: currentColor; }
.wird:not([hidden]) ~ .markPill { top: 84px; }

.credit { width: min(var(--pw), 100%); margin: 18px auto 0; text-align: center; color: var(--muted); font-size: .72rem; line-height: 1.9; }
.credit a { color: inherit; }

/* toolbar */
.tools { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  display: flex; gap: 1px; background: rgba(18, 58, 48, .95); backdrop-filter: blur(6px); border-radius: 18px; padding: 5px; box-shadow: 0 12px 34px rgba(0, 0, 0, .28); }
.tools button, .tools a { position: relative; border: 0; background: transparent; color: #f3ead2; font: inherit; font-size: .7rem; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px; border-radius: 12px; cursor: pointer; min-width: 48px; text-decoration: none; }
.tools button:hover, .tools a:hover { background: rgba(255, 255, 255, .1); }
.tools svg { width: 20px; height: 20px; fill: currentColor; }
.tools b { font-size: 1rem; line-height: 20px; }
.tools #tKhatma { color: #FAC775; }

/* dialogs */
.sheetDlg { border: 0; border-radius: 20px; padding: 18px; width: min(480px, calc(100vw - 20px)); max-height: 86vh; background: var(--page); color: var(--ink); box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.sheetDlg::backdrop { background: rgba(10, 20, 16, .45); }
.sheetDlg h2 { margin: 0 0 8px; font-size: 1.08rem; }
.tabs { display: flex; gap: 4px; background: var(--sel); border-radius: 12px; padding: 4px; margin-bottom: 8px; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 600; font-size: .9rem; padding: .4rem; border-radius: 9px; cursor: pointer; }
.tabs button.on { background: var(--page); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); color: var(--green); }
.find { width: 100%; border: 1px solid var(--line); background: var(--page); color: var(--ink); border-radius: 12px; padding: .55rem .8rem; font: inherit; margin-bottom: 8px; }
.idxList { display: grid; gap: 4px; max-height: 50vh; overflow-y: auto; }
.idxList button { display: grid; grid-template-columns: 2.4em 1fr auto; align-items: center; gap: 8px; text-align: start; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 12px; padding: .5rem .7rem; font: inherit; cursor: pointer; }
.idxList button:hover { background: var(--sel); }
.idxList .n { width: 2.1em; height: 2.1em; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--gold-3); color: var(--gold); font-weight: 700; font-size: .8rem; }
.idxList b { font-size: 1rem; }
.idxList small { color: var(--muted); font-size: .76rem; }
.goPage { display: grid; gap: 8px; }
.goPage label { display: grid; gap: 4px; font-size: .9rem; font-weight: 600; }
.goPage input { border: 1px solid var(--line); background: var(--page); color: var(--ink); border-radius: 12px; padding: .6rem .8rem; font: inherit; font-size: 1.1rem; text-align: center; }
.dlgBtn { display: block; text-align: center; text-decoration: none; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 12px; padding: .55rem; font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; }
.dlgBtn.big { padding: .7rem; background: #0f5a47; border-color: #0f5a47; color: #fff; }
.dlgClose { margin-top: 12px; width: 100%; border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 12px; padding: .55rem; font: inherit; font-weight: 600; cursor: pointer; }
.tafAyah { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .2em .32em; font-size: 22px; line-height: 2.1; padding: 8px 6px; border-radius: 12px; background: var(--sel); max-height: 34vh; overflow-y: auto; }
.tafText { font-size: 1rem; line-height: 2; margin: 12px 0 4px; min-height: 2em; }
.tafSrc { color: var(--muted); font-size: .74rem; margin: 0; }
/* word meanings: in the tap menu, and listed with the tafsir */
.w.gw { color: var(--gold); }
.popMean { max-width: min(330px, calc(100vw - 40px)); margin: 0 auto 6px; padding: 4px 12px 8px; border-radius: 12px; background: var(--sel); text-align: center; line-height: 1.75; }
.popMean .pm { display: block; font-size: 26px; line-height: 1.9; font-weight: normal; color: var(--gold); }
.popMean > span { display: block; font-size: .93rem; }
.tafWords h3, .tafHead { margin: 14px 0 4px; font-size: .92rem; color: var(--gold); }
.tafWords ul { list-style: none; margin: 0; padding: 0; }
.tafWords li { display: flex; align-items: center; gap: 10px; padding: 3px 0 5px; border-bottom: 1px dashed var(--line); line-height: 1.8; }
.tafWords li:last-child { border-bottom: 0; }
.tafWords .pm { flex: none; max-width: 48%; font-size: 23px; font-weight: normal; color: var(--gold); line-height: 1.7; }
.tafWords li > span { font-size: .95rem; }
.qv { font-family: "KFGQPC Hafs", "Amiri Quran", serif; font-size: 1.18em; font-weight: normal; }

.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%) translateY(-20px); opacity: 0; z-index: 60; background: #123a30; color: #fff; border-radius: 99px; padding: .5rem 1.1rem; font-size: .9rem; transition: opacity .25s ease, transform .25s ease; pointer-events: none; max-width: calc(100vw - 24px); text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .wrap { padding: 0 6px; }
  .mpage { padding: 8px 6px 6px; }
  .frame { --fb: 16px; padding: 2px 3px; }
  .lines { padding: 0 6px; }
  .phead { padding: 0 4px 4px; font-size: .86rem; }
  .tools button, .tools a { min-width: 44px; padding: 6px 5px; }
  .popBtns button { min-width: 50px; padding: 6px 4px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.wirdTxt { grid-column: 1; grid-row: 1; min-width: 0; }
.wirdBtn { grid-column: 2; grid-row: 1; white-space: nowrap; }
.wirdBar { grid-row: 2; }
.wirdTxt b, .wirdTxt small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .wird { padding: 6px 10px; gap: 3px 8px; } .wirdTxt b { font-size: .84rem; } .wirdTxt small { font-size: .7rem; } .wirdBtn { padding: .35rem .7rem; font-size: .8rem; } }
/* the opening pages (al-Fatiha, the start of al-Baqarah): text in an arched panel on a floral ground, as in printed mushafs */
.mpage.short .frame { background: url(../assets/ornament/pattern-light.svg) center / 40px; padding: 18px 7%; }
body.sepia .mpage.short .frame { background-image: url(../assets/ornament/pattern-sepia.svg); }
body.night .mpage.short .frame { background-image: url(../assets/ornament/pattern-night.svg); }
.mpage.short .lines { background: var(--page); border-radius: 50% 50% 22px 22px / 22% 22% 22px 22px; padding: calc(var(--lh) * .9) 6px calc(var(--lh) * .5);
  box-shadow: 0 0 0 2px var(--gold-2), 0 0 0 6px var(--page), 0 0 0 7px var(--gold-2), 0 10px 30px rgba(28, 88, 120, .18); }
@media (max-width: 560px) { .mpage.short .frame { padding: 12px 3%; background-size: 30px; } }
.mpage.short .ln.hdr { font-size: calc(var(--lw) / 3.32 * .8); }
/* a heading for search engines and screen readers only */
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
