/* قصه‌های شاهنامه — styles. Night-lapis room, ivory pages, gold lines. */
@font-face { font-family: "Lalezar"; font-display: swap; src: url(../fonts/lalezar-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Lalezar"; font-display: swap; src: url(../fonts/lalezar-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-200B, U+200F-206F, U+20AC, U+2122; }
@font-face { font-family: "Vazirmatn"; font-display: swap; font-weight: 100 900; src: url(../fonts/vazirmatn-arabic-wght-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Vazirmatn"; font-display: swap; font-weight: 100 900; src: url(../fonts/vazirmatn-latin-wght-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-200B, U+200F-206F, U+20AC, U+2122; }
@font-face { font-family: "Nastaliq"; font-display: swap; src: url(../fonts/nastaliq-400.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+200C-200E, U+FB50-FDFF, U+FE70-FEFC; }

:root {
  --night: #0E1744; --lapis: #14215E; --lapis2: #1D2E7A; --lapis3: #2C4099;
  --turq: #15A39A; --turq2: #6FD6C5; --teal-ink: #0B6B65;
  --gold: #E2A82B; --gold2: #F7D56B; --gold3: #B57B12;
  --verm: #D6402D; --rose: #E96B86; --leaf: #3F9361;
  --ivory: #FFF6E3; --paper: #F7EBD0; --ink: #1B1B33;
  --display: "Lalezar", "Vazirmatn", system-ui, sans-serif;
  --body: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --nast: "Nastaliq", "Vazirmatn", serif;
  --fs: 1.4rem;
  --shadow: 0 14px 34px rgba(4, 8, 36, .5);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ivory); font-family: var(--body); font-size: 1rem; line-height: 1.9;
  background-color: var(--lapis);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='88' height='88' viewBox='0 0 88 88'%3E%3Cg fill='none' stroke='%23F7D56B' stroke-opacity='.075' stroke-width='1.4'%3E%3Cpath d='M80 44L64.3 52.4 69.5 69.5 52.4 64.3 44 80 35.6 64.3 18.5 69.5 23.7 52.4 8 44 23.7 35.6 18.5 18.5 35.6 23.7 44 8 52.4 23.7 69.5 18.5 64.3 35.6Z'/%3E%3Ccircle r='7'/%3E%3Ccircle cx='88' r='7'/%3E%3Ccircle cy='88' r='7'/%3E%3Ccircle cx='88' cy='88' r='7'/%3E%3C/g%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--night) 0, var(--lapis) 520px, var(--lapis) 100%);
  background-attachment: scroll, scroll;
}
h1, h2, h3 { font-family: var(--display); font-weight: 400; margin: 0; line-height: 1.3; }
a { color: var(--gold2); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold2); outline-offset: 3px; border-radius: 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: -60px; z-index: 50; background: var(--gold2); color: var(--lapis); padding: 8px 14px; border-radius: 10px; }
.skip:focus { top: 8px; }
#app { outline: none; }
.wrap { width: min(1040px, 100%); margin-inline: auto; padding-inline: 16px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 10px 26px; border: 0; border-radius: 999px; cursor: pointer; text-decoration: none;
  font: 700 1.1rem/1.2 var(--body); color: var(--lapis); background: linear-gradient(var(--gold2), var(--gold));
  box-shadow: 0 5px 0 var(--gold3), 0 14px 22px rgba(0, 0, 0, .3); transition: transform .12s, box-shadow .12s; }
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold3), 0 6px 10px rgba(0, 0, 0, .3); }
.btn.ghost { color: var(--ivory); background: rgba(255, 246, 227, .08); box-shadow: inset 0 0 0 2px rgba(255, 246, 227, .38); }
.btn.ghost:active { box-shadow: inset 0 0 0 2px rgba(255, 246, 227, .38); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 22px; height: 22px; flex: none; }
.ico { width: 46px; height: 46px; display: grid; place-items: center; flex: none; border: 0; border-radius: 50%; cursor: pointer; text-decoration: none; color: var(--ivory); background: rgba(255, 246, 227, .1); transition: background .15s; }
.ico:hover { background: rgba(255, 246, 227, .2); }
.ico svg { width: 24px; height: 24px; }
.ico[aria-pressed="true"] { background: var(--gold2); color: var(--lapis); }
.ico.fsz { font: 400 1.05rem/1 var(--display); }
.ico.fsz.big { font-size: 1.5rem; }

/* top bar + brand */
.top { display: flex; align-items: center; gap: 14px; padding-block: calc(14px + env(safe-area-inset-top)) 14px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--gold2); text-decoration: none; font: 400 1.5rem/1 var(--display); }
.brand svg { width: 34px; height: 38px; flex: none; }
.nav-links { display: flex; gap: 6px; }
.nav-links a { color: var(--ivory); text-decoration: none; padding: 8px 14px; border-radius: 999px; font-size: .95rem; }
.nav-links a:hover { background: rgba(255, 246, 227, .12); }

/* hero */
.hero { display: grid; gap: 22px; align-items: center; padding-block: 8px 26px; }
.hero .art { width: min(100%, 330px); margin-inline: auto; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, .45)); order: -1; }
.eyebrow { margin: 0 0 6px; font-size: .95rem; color: var(--turq2); letter-spacing: 0; }
.hero h1 { font-size: clamp(2.5rem, 9vw, 4.6rem); color: var(--gold2); line-height: 1.2; text-wrap: balance; }
.hero p.lead { margin: 14px 0 22px; font-size: 1.12rem; max-width: 34ch; opacity: .92; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.gems { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 22px; align-items: center; }
.gems small { width: 100%; opacity: .8; font-size: .92rem; }
.gem { width: 26px; height: 26px; }
.gem.off { opacity: .22; filter: grayscale(1); }

/* era headings + story cards */
.era { display: flex; align-items: center; gap: 14px; margin: 38px 0 16px; font: 400 1.7rem/1.2 var(--display); color: var(--gold2); }
.era::after { content: ""; flex: 1; height: 3px; opacity: .55; background: radial-gradient(circle, var(--gold) 1.6px, transparent 2px) 0 50% / 12px 3px repeat-x; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 16px; padding: 0; margin: 0; list-style: none; }
.card { position: relative; display: block; color: inherit; text-decoration: none; }
.card .art { filter: drop-shadow(0 12px 14px rgba(0, 0, 0, .38)); transition: transform .25s, filter .25s; }
.card:hover .art, .card:focus-visible .art { transform: translateY(-5px); filter: drop-shadow(0 18px 18px rgba(0, 0, 0, .45)); }
.card h3 { margin: 12px 4px 2px; font-size: 1.3rem; color: var(--ivory); }
.card p { margin: 0 4px; font-size: .9rem; line-height: 1.65; opacity: .82; }
.num { position: absolute; z-index: 2; top: -8px; inset-inline-start: -6px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--gold2); color: var(--lapis); font: 400 1.2rem/1 var(--display); box-shadow: 0 3px 0 var(--gold3); }
.meta { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 4px 0; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 1px 10px; border-radius: 999px; font-size: .8rem; background: rgba(255, 246, 227, .12); }
.chip.sad { background: rgba(233, 107, 134, .22); color: #FFC9D5; }
.chip.done { background: rgba(247, 213, 107, .2); color: var(--gold2); }
.chip svg { width: 14px; height: 14px; }
.foot { margin: 56px 0 34px; padding-top: 22px; border-top: 2px dotted rgba(247, 213, 107, .35); font-size: .92rem; opacity: .85; }

/* reader */
.reader { width: min(1040px, 100%); margin-inline: auto; padding: calc(6px + env(safe-area-inset-top)) 16px 0; }
.bar { display: flex; align-items: center; gap: 10px; padding-block: 8px; }
.bar .ttl { flex: 1; min-width: 0; text-align: center; }
.bar .ttl h1 { margin: 0; font-size: 1.35rem; line-height: 1.2; color: var(--gold2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .ttl span { font-size: .85rem; opacity: .8; }
.stage { display: grid; gap: 14px; align-items: center; padding-block: 8px 0; }
.stage .art { width: min(100%, max(220px, 38vh)); margin-inline: auto; filter: drop-shadow(0 16px 20px rgba(0, 0, 0, .45)); }
.paper { position: relative; padding: 24px 24px 18px; border-radius: 22px; color: var(--ink); background: var(--ivory); box-shadow: var(--shadow); }
.paper::before { content: ""; position: absolute; inset: 7px; border: 2px solid rgba(226, 168, 43, .6); border-radius: 16px; pointer-events: none; }
.story-text { margin: 0; font-size: var(--fs); line-height: 2.1; text-wrap: pretty; }
.s { border-radius: 6px; transition: background .2s; }
.s.on { background: linear-gradient(transparent 52%, rgba(226, 168, 43, .5) 52%); }
.gl { all: unset; cursor: pointer; color: var(--teal-ink); font-weight: 700; border-bottom: 2.5px dotted var(--turq); }
.gl:focus-visible { outline: 3px solid var(--lapis3); outline-offset: 2px; border-radius: 4px; }
.pager { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 12px; padding: 16px 0 calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--lapis) 38%); }
.pager .btn { min-width: 112px; }
.dots { flex: 1; display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.dot { width: 10px; height: 10px; padding: 0; border: 0; border-radius: 6px; background: rgba(255, 246, 227, .28); cursor: pointer; transition: width .2s, background .2s; }
.dot.past { background: var(--turq2); }
.dot.on { width: 28px; background: var(--gold2); }

/* glossary sheet */
.sheet { position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); pointer-events: none; }
.sheet > div { pointer-events: auto; width: min(560px, 100%); padding: 18px 20px; border-radius: 22px; color: var(--ink); background: var(--ivory); box-shadow: 0 -6px 40px rgba(0, 0, 0, .55), 0 0 0 3px var(--gold); animation: up .25s ease-out; }
.sheet h3 { font-size: 1.5rem; color: var(--lapis2); }
.sheet p { margin: 4px 0 12px; font-size: 1.1rem; line-height: 1.9; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }

/* verse + quiz + result */
.center { width: min(720px, 100%); margin-inline: auto; padding: 8px 16px 40px; }
.verse { position: relative; margin: 18px 0 22px; padding: 36px 20px 26px; text-align: center; border-radius: 26px; background: radial-gradient(120% 90% at 50% 0, var(--lapis3), var(--lapis2) 60%, var(--night)); box-shadow: inset 0 0 0 3px var(--gold), inset 0 0 0 9px var(--lapis2), inset 0 0 0 11px rgba(247, 213, 107, .5), var(--shadow); }
.verse .tag { position: absolute; top: -17px; left: 50%; translate: -50% 0; padding: 4px 22px; border-radius: 999px; background: var(--gold2); color: var(--lapis); font: 400 1.25rem/1.4 var(--display); }
.verse .b { margin: 8px 0 0; font-family: var(--nast); font-size: clamp(1.45rem, 5.6vw, 2.2rem); line-height: 2.75; color: var(--gold2); }
.verse .b span { display: block; }
.verse .b span + span { margin-top: .2em; }
.verse .gloss { margin: 12px auto 0; max-width: 40ch; font-size: 1.05rem; line-height: 1.9; color: var(--ivory); }
.verse .src { margin-top: 12px; font-size: .85rem; opacity: .8; }
.qhead { display: flex; justify-content: space-between; align-items: center; margin: 6px 0 12px; font-size: .95rem; opacity: .9; }
.q { padding: 22px 20px; border-radius: 22px; color: var(--ink); background: var(--ivory); box-shadow: var(--shadow); }
.q h1 { font-size: clamp(1.45rem, 5vw, 1.9rem); color: var(--lapis2); margin-bottom: 14px; }
.opts { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.opt { width: 100%; text-align: start; min-height: 58px; padding: 10px 16px; border-radius: 16px; cursor: pointer; font: 600 1.1rem/1.6 var(--body); color: var(--ink); background: #fff; border: 3px solid rgba(20, 33, 94, .16); transition: border-color .15s, background .15s, transform .1s; }
.opt:hover { border-color: var(--lapis3); }
.opt:active { transform: scale(.985); }
.opt.right { background: #D9F5EE; border-color: var(--turq); }
.opt.wrong { background: #FFE0E6; border-color: var(--rose); animation: shake .35s; }
.opt[disabled] { cursor: default; }
@keyframes shake { 25% { translate: 7px 0; } 75% { translate: -7px 0; } }
.fb { min-height: 3.4em; margin: 14px 2px 4px; font-size: 1.05rem; line-height: 1.8; }
.fb b { color: var(--teal-ink); }
.result { text-align: center; }
.result .big { width: 150px; height: 150px; margin: 6px auto; animation: pop .7s cubic-bezier(.2, 1.6, .4, 1); filter: drop-shadow(0 0 22px rgba(247, 213, 107, .7)); }
.result h1 { font-size: clamp(2.2rem, 8vw, 3.4rem); color: var(--gold2); }
.result p { margin: 8px 0 22px; font-size: 1.15rem; }
.result .cta-row { justify-content: center; }
@keyframes pop { from { transform: scale(.2) rotate(-25deg); opacity: 0; } }

/* glossary page + parents page */
.wlist { display: grid; gap: 12px; padding: 0; margin: 20px 0; list-style: none; }
.wlist li { padding: 14px 18px; border-radius: 18px; color: var(--ink); background: var(--ivory); }
.wlist b { font: 400 1.4rem/1.4 var(--display); color: var(--lapis2); }
.wlist p { margin: 2px 0 6px; }
.wlist a { color: var(--teal-ink); font-size: .92rem; }
.prose { margin: 14px 0 30px; padding: 26px 24px; border-radius: 24px; color: var(--ink); background: var(--ivory); box-shadow: var(--shadow); }
.prose h2 { margin: 26px 0 6px; font-size: 1.6rem; color: var(--lapis2); }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { font-size: 1.05rem; line-height: 2; }
.prose a { color: var(--teal-ink); }
.prose details { margin: 8px 0; padding: 8px 14px; border-radius: 14px; background: rgba(20, 33, 94, .06); }
.prose summary { cursor: pointer; font-weight: 700; }
.pageh { margin: 8px 0 4px; font-size: clamp(2rem, 7vw, 3rem); color: var(--gold2); }

/* page-turn feel */
.enter { animation: enter .45s ease-out both; }
@keyframes enter { from { opacity: 0; transform: translateY(14px) scale(.98); } }

@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 860px) {
  .hero { grid-template-columns: 1.05fr .95fr; gap: 48px; padding-block: 26px 36px; }
  .hero .art { order: 0; width: min(100%, 400px); }
  .stage { grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 38px; min-height: 66vh; }
  .stage .art { width: min(100%, 420px); }
  .paper { padding: 34px 34px 26px; }
}
@media (min-width: 980px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 420px) { .pager .btn { min-width: 0; padding-inline: 18px; } .brand { font-size: 1.3rem; } .nav-links a { padding-inline: 10px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* read-aloud button only appears when something can actually speak */
.voice { display: none; }
body.can-speak .voice, .reader.has-audio .voice { display: grid; }
.voice .i-off { display: none; }
.voice[aria-pressed="true"] .i-on { display: none; }
.voice[aria-pressed="true"] .i-off { display: block; }

/* progress strip (all sizes) + compact pager on phones */
.prog { height: 7px; margin: 2px 0 6px; border-radius: 6px; overflow: hidden; background: rgba(255, 246, 227, .16); }
.prog i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--gold2), var(--gold)); transition: width .35s; }
@media (max-width: 639px) {
  .dots { display: none; }
  .pager { gap: 10px; }
  .pager .btn[data-next] { flex: 1; }
  .stage .art { width: min(100%, max(210px, 34vh)); }
  .paper { padding: 20px 18px 14px; }
}
.brand span { white-space: nowrap; }
.fb:not(:empty) { padding: 14px 16px; border-radius: 16px; background: rgba(255, 246, 227, .1); }
@media (max-width: 420px) { .brand { font-size: 1.22rem; gap: 8px; } .brand svg { width: 28px; height: 32px; } }
@media (max-width: 639px) { .stage .art { width: min(100%, max(200px, 31vh)); } .stage { gap: 10px; } }
