/* site/css/chalisa.css · Hanuman Chalisa page (2026-11-16)
   A temple manuscript by lamplight: one arched panel, large airy chant, gold only where it carries meaning.
   Builds on tokens.css and site.css. Every rule here is scoped to this page. */

:root {
  --chant-scale: 1;
  --hdr-h: 80px;            /* set from the real header height by chalisa.js */
  --ctl-h: 64px;            /* set from the real controls height by chalisa.js */
  --panel-w: 46rem;
  --chant-size: clamp(1.3rem, 0.95rem + 1.5vw, 1.8rem);
  --font-deva: "Anek Devanagari", var(--font-body);
}

/* ---------- Stillness: nothing in the header moves while chanting ---------- */
.page-chalisa .brand-glow { animation: glow-in 1200ms var(--ease-out) 500ms forwards; }
.page-chalisa .badge-ring, .page-chalisa .brand-gada { animation: none; }
.page-chalisa .bw { animation: bw-in 900ms var(--ease-out) calc(450ms + var(--i) * 110ms) forwards; }
.page-chalisa .rv { animation-duration: 900ms; animation-delay: calc(120ms + var(--i, 0) * 90ms); }
@media (max-width: 560px) { body.page-chalisa { padding-bottom: 0; } }

/* Header and controls step aside while reading (scrolling down) and return on scroll up */
.page-chalisa .topbar { transition: transform 320ms var(--ease-silk), background-color var(--dur-long) var(--ease-out); }
.hdr-hidden .page-chalisa .topbar { transform: translateY(-100%); }

/* ---------- Hero ---------- */
.ch-hero { padding: calc(var(--hdr-h) + clamp(1.5rem, 4vw, 3.5rem)) 0 clamp(2rem, 4vw, 3rem); }
.ch-hero-in { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: clamp(1.5rem, 4vw, 3.5rem); max-width: 52rem; }
.ch-arch {
  margin: 0; width: clamp(150px, 20vw, 220px); padding: 6px;
  border: var(--rule-thin) solid var(--color-rule);
  border-radius: 50% 50% var(--radius-md) var(--radius-md) / 32% 32% var(--radius-md) var(--radius-md);
  box-shadow: var(--frame-shadow);
}
.ch-arch img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 12%;
  border-radius: 50% 50% calc(var(--radius-md) - 4px) calc(var(--radius-md) - 4px) / 31% 31% calc(var(--radius-md) - 4px) calc(var(--radius-md) - 4px); }
.ch-hero h1 { margin: var(--space-sm) 0 0; font-weight: 600; line-height: 1.15; }
.ch-t-te { display: block; font-family: var(--font-display-te); font-size: clamp(2.3rem, 1.5rem + 3.2vw, 3.75rem); color: var(--color-gold); text-wrap: balance; }
.ch-t-en { display: block; margin-top: var(--space-xs); font-size: clamp(1.05rem, 0.9rem + 0.7vw, 1.4rem); font-weight: 500; letter-spacing: 0.04em; color: var(--color-ink-soft); }
.ch-intro { margin: var(--space-md) 0 0; font-size: var(--text-lg); line-height: 1.7; color: var(--color-ink); max-width: 34rem; }
.ch-intro .en { font-size: var(--text-base); }
.ch-review { display: block; margin: var(--space-lg) 0 0; text-wrap: balance; font-size: var(--text-xs); color: var(--color-ink-mute); letter-spacing: 0.02em; }
.ch-review::before { content: ""; display: inline-block; vertical-align: middle; width: 6px; height: 6px; margin-right: 0.5em; border-radius: 50%; background: var(--color-gold-deep); }
@media (max-width: 640px) {
  .ch-hero-in { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .ch-arch { width: min(46vw, 190px); }
  .ch-intro { margin-inline: auto; }
  .page-chalisa .crumbs { display: none; }
}

/* ---------- Controls ---------- */
.ch-controls {
  position: sticky; top: var(--hdr-h); z-index: 15;
  background: var(--color-paper); border-bottom: var(--rule-thin) solid var(--color-rule-soft);
  transition: transform 320ms var(--ease-silk), top 320ms var(--ease-silk);
}
.hdr-hidden .ch-controls { top: 0; transform: translateY(-100%); }
.ch-ctl-in { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-xs) var(--space-md);
  width: min(var(--panel-w), 100% - 2 * var(--space-md)); margin-inline: auto; padding: var(--space-sm) 0; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border: var(--rule-thin) solid var(--color-rule); border-radius: var(--radius-pill); background: var(--color-paper-2); }
.seg button {
  font: 600 0.875rem/1 var(--font-body); color: var(--color-ink-soft); background: transparent; border: 0; cursor: pointer;
  min-height: 36px; padding: 0 0.95rem; border-radius: var(--radius-pill); white-space: nowrap;
  transition: background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out);
}
.seg button[lang="hi"] { font-family: system-ui, sans-serif; font-size: 0.95rem; }
.seg button span[lang="en"] { font-weight: 500; opacity: 0.85; margin-left: 0.3em; }
.seg button:hover { color: var(--color-gold); }
.seg button[aria-pressed="true"] { background: var(--color-gold); color: var(--color-paper); }
.seg button:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.seg--size button { min-width: 44px; padding: 0 0.6rem; }
@media (max-width: 1024px) { .seg button { min-height: 44px; } }
/* phones: two compact rows. Script across the top, view and size beneath */
@media (max-width: 600px) {
  .ch-ctl-in { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 6px 0; width: calc(100% - 2 * var(--space-sm)); }
  .ch-ctl-in > .seg:first-child { grid-column: 1 / -1; }
  .seg { width: 100%; }
  .seg--size { width: auto; }
  .seg button { flex: 1; padding: 0 0.55rem; font-size: 0.8125rem; min-height: 44px; }
  .seg button span[lang="en"] { display: none; }
}

/* ---------- The manuscript panel ---------- */
.ch-scroll {
  position: relative; width: min(var(--panel-w), 100% - 2 * clamp(14px, 4vw, 2rem));
  margin: clamp(2rem, 5vw, 3.5rem) auto clamp(3rem, 6vw, 5rem);
  padding: clamp(4rem, 9vw, 7rem) clamp(1rem, 5vw, 3.75rem) clamp(2.5rem, 5vw, 4rem);
  background: var(--color-paper-2);
  border: var(--rule-thin) solid var(--color-rule);
  outline: var(--rule-thin) solid var(--color-rule-soft); outline-offset: 6px;
  border-radius: 50% 50% var(--radius-md) var(--radius-md) / clamp(70px, 14vw, 150px) clamp(70px, 14vw, 150px) var(--radius-md) var(--radius-md);
  box-shadow: 0 40px 80px -40px oklch(6% 0.02 45 / 0.9);
}
/* a quiet pool of lamplight at the top of the arch */
.ch-scroll::before { content: ""; position: absolute; left: 50%; top: 0; width: 70%; height: 220px; translate: -50% 0; pointer-events: none;
  border-radius: 50%; background: radial-gradient(closest-side, var(--frame-glow), transparent); }

.ch-scroll .sec-h { margin: 0 0 clamp(1.5rem, 3vw, 2.25rem); text-align: center; font-family: var(--font-display-te); font-weight: 600;
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.6rem); color: var(--color-gold); line-height: 1.3; }
.ch-scroll .sec-h span { display: block; margin-top: 0.2rem; font-family: var(--font-body); font-size: var(--text-sm); font-weight: 500; letter-spacing: 0.06em; color: var(--color-ink-mute); }
.ch-part + .lotus-div, .lotus-div + .ch-part { margin-top: 0; }
.ch-scroll .lotus-div { margin: clamp(2.5rem, 5vw, 3.5rem) auto; max-width: 18rem; }

/* ---------- A verse: the chant, then a clearly labelled Meaning button ---------- */
.verse { position: relative; margin: 0 auto clamp(1.75rem, 3.2vw, 2.6rem); max-width: 38rem; text-align: center;
  scroll-margin-top: calc(var(--hdr-h) + var(--ctl-h) + 16px); }
.v-chant { position: relative; isolation: isolate; padding: 0.4rem 2.25rem 0.2rem; }
/* lamp-glow only behind the verse whose meaning is open */
.v-chant::before { content: ""; position: absolute; inset: -12% -6%; z-index: -1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(closest-side, var(--frame-glow), transparent); opacity: 0; transition: opacity 400ms var(--ease-out); }
.verse:has(> .v-more[open]) > .v-chant::before { opacity: 1; }

.v-num { position: absolute; left: 0; top: 0.85rem; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  border: var(--rule-thin) solid var(--color-rule); color: var(--color-gold); font: 500 var(--text-xs)/1 var(--font-body);
  font-variant-numeric: tabular-nums lining-nums; }
.v-lines { display: block; margin: 0; font-family: var(--font-display-te); font-weight: 500;
  font-size: calc(var(--chant-size) * var(--chant-scale)); line-height: 1.9; color: var(--color-ivory); text-wrap: balance; }
.v-lines .s-te, .v-lines .s-en, .v-lines .s-deva { line-height: inherit; color: inherit; font-style: normal; letter-spacing: normal; text-transform: none; }
.cz { display: inline-block; max-width: 100%; }
.v-lines .s-en { font-family: var(--font-body); font-size: 0.86em; font-weight: 450; letter-spacing: 0.01em; line-height: 2.05; }
.v-lines .s-deva { font-family: var(--font-deva); font-size: 1em; line-height: 1.85; }
.danda { color: var(--color-gold); padding-inline: 0.12em; }

/* script choice: Telugu is the default (also with JavaScript off) */
.v-lines .s-en, .v-lines .s-deva { display: none; }
.script-en .v-lines .s-te, .script-deva .v-lines .s-te { display: none; }
.script-en .v-lines .s-en, .script-deva .v-lines .s-deva { display: inline; }

/* the Meaning button: says what it does, sits under the couplet, never over the text */
.v-more > summary::-webkit-details-marker { display: none; }
.v-btn { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.5em; min-height: 44px; margin-top: 0.55rem;
  padding: 0 1.15rem; border: var(--rule-thin) solid var(--color-rule); border-radius: var(--radius-pill);
  font: 600 0.875rem/1 var(--font-body); color: var(--color-gold); background: transparent; -webkit-tap-highlight-color: transparent;
  transition: border-color var(--dur-short) var(--ease-out), background-color var(--dur-short) var(--ease-out), color var(--dur-short) var(--ease-out); }
.v-btn span { font-weight: 500; color: var(--color-ink-soft); }
.v-btn::after { content: ""; width: 7px; height: 7px; margin-left: 0.15em; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  rotate: 45deg; translate: 0 -2px; transition: rotate var(--dur-long) var(--ease-silk), translate var(--dur-long) var(--ease-silk); }
.v-btn:hover { border-color: var(--color-gold); }
.v-btn:active { background: var(--color-paper-3); }
.v-btn:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }
.v-more[open] > .v-btn { border-color: var(--color-gold); background: var(--color-paper-3); }
.v-more[open] > .v-btn::after { rotate: -135deg; translate: 0 2px; }

/* the meaning */
.v-meaning { margin: 0.7rem auto 0; max-width: 36rem; animation: ch-open 360ms var(--ease-silk); }
.v-meaning-in { padding: 1rem clamp(1rem, 3vw, 1.5rem) 1.1rem; background: var(--color-paper-3); border-top: var(--rule-thin) solid var(--color-rule);
  border-radius: 0 0 var(--radius-md) var(--radius-md); text-align: left; }
.v-meaning p { margin: 0; font-size: calc(var(--text-base) * (0.5 + var(--chant-scale) / 2)); line-height: 1.75; }
.v-meaning .m-te { color: var(--color-ink); }
.v-meaning .m-en { margin-top: 0.6rem; color: var(--color-ink-soft); }
.m-label { display: inline-block; margin-right: 0.5em; font-weight: 600; font-size: 0.82em; letter-spacing: 0.04em; color: var(--color-gold); }
.v-explain { margin-top: 0.8rem; }
.v-explain > summary { display: inline-flex; align-items: center; gap: 0.45em; min-height: 44px; cursor: pointer; list-style: none;
  font-size: var(--text-sm); font-weight: 600; color: var(--color-gold); }
.v-explain > summary::-webkit-details-marker { display: none; }
.v-explain > summary::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; rotate: -45deg; transition: rotate var(--dur-short) var(--ease-out); }
.v-explain[open] > summary::after { rotate: 45deg; }
.v-explain > summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; border-radius: 4px; }
.v-explain p { margin-top: 0.5rem; font-size: var(--text-sm); line-height: 1.75; color: var(--color-ink-soft); }
.v-explain p + p { color: var(--color-ink-mute); }
@keyframes ch-open { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

@media (max-width: 599px) {
  .v-chant { padding-inline: 0.25rem; }
  .v-num { position: static; margin: 0 auto 0.35rem; width: 28px; height: 28px; }
}

/* ---------- Learn view: every verse a card, meaning always shown ---------- */
.view-learn .verse { padding: 1.75rem clamp(0.75rem, 3vw, 1.5rem) 1.25rem; border: var(--rule-thin) solid var(--color-rule); border-radius: var(--radius-md); background: var(--color-paper); }
.view-learn .v-chant { padding-inline: 0.25rem; }
.view-learn .v-chant::before, .view-learn .v-btn { display: none; }
.view-learn .v-num { position: absolute; left: 50%; top: -15px; translate: -50% 0; margin: 0; background: var(--color-paper-2); }
.view-learn .v-meaning { animation: none; }
.view-learn .v-meaning-in { border-radius: var(--radius-sm); }

/* ---------- Optional invocation (Sanskrit, separate from the Chalisa) ---------- */
.invocation { margin: 0 auto clamp(2rem, 4vw, 3rem); max-width: 36rem; text-align: center; }
.invocation > summary { list-style: none; cursor: pointer; display: grid; gap: 0.2rem; justify-items: center; padding: 0.5rem; border-radius: var(--radius-md); }
.invocation > summary::-webkit-details-marker { display: none; }
.invocation > summary::after { content: ""; width: 8px; height: 8px; margin-top: 0.4rem; border-right: 1.5px solid var(--color-gold-deep); border-bottom: 1.5px solid var(--color-gold-deep); rotate: 45deg; transition: rotate var(--dur-long) var(--ease-silk); }
.invocation[open] > summary::after { rotate: -135deg; }
.invocation > summary:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }
.inv-h { font-weight: 600; color: var(--color-gold); font-size: var(--text-base); }
.inv-sub { font-size: var(--text-xs); color: var(--color-ink-mute); }
.inv-body { margin-top: var(--space-md); animation: ch-open 360ms var(--ease-silk); }
.inv-lines { margin: 0 0 var(--space-md); font-size: calc(var(--chant-size) * 0.86 * var(--chant-scale)); }
.invocation .m-te, .invocation .m-en { margin: 0.4rem 0 0; text-align: left; font-size: var(--text-sm); line-height: 1.75; color: var(--color-ink-soft); }
.invocation .m-te { color: var(--color-ink); }

/* ---------- After the panel: guide, FAQ, sources ---------- */
.ch-after { max-width: var(--panel-w); padding-bottom: var(--space-3xl); }
.ch-after .sec-h { font-family: var(--font-display-te); font-size: var(--text-xl); color: var(--color-gold); margin: var(--space-2xl) 0 var(--space-md); font-weight: 600; line-height: 1.3; }
.ch-after .sec-h span { display: block; font-family: var(--font-body); font-size: var(--text-sm); color: var(--color-ink-mute); font-weight: 500; letter-spacing: 0.05em; margin-top: 0.15rem; }
.ch-after .sub-h { margin: var(--space-xl) 0 var(--space-xs); font-size: var(--text-lg); color: var(--color-ink); font-weight: 600; }
.ch-after .sub-h span { color: var(--color-ink-mute); font-weight: 500; font-size: var(--text-sm); margin-left: 0.35em; }
.ch-after p { margin: 0 0 var(--space-xs); line-height: 1.8; color: var(--color-ink); max-width: 68ch; }
.ch-after p.en { color: var(--color-ink-soft); font-size: var(--text-base); margin-bottom: var(--space-md); }
.ch-lang-note { font-size: var(--text-sm); color: var(--color-ink-soft) !important; padding: var(--space-sm) var(--space-md); border: var(--rule-thin) solid var(--color-rule-soft); border-radius: var(--radius-sm); }
.faq { border-top: var(--rule-thin) solid var(--color-rule-soft); }
.faq:last-child { border-bottom: var(--rule-thin) solid var(--color-rule-soft); }
.faq-q { list-style: none; cursor: pointer; display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: var(--space-md);
  min-height: 48px; padding: var(--space-sm) 0; font-weight: 600; color: var(--color-ink); }
.faq-q::-webkit-details-marker { display: none; }
.faq-q span { grid-column: 1; font-weight: 500; font-size: var(--text-sm); color: var(--color-ink-mute); }
.faq-q::after { content: ""; grid-column: 2; grid-row: 1 / span 2; width: 8px; height: 8px; border-right: 1.5px solid var(--color-gold); border-bottom: 1.5px solid var(--color-gold); rotate: 45deg; transition: rotate var(--dur-short) var(--ease-out); }
.faq[open] .faq-q::after { rotate: -135deg; }
.faq-q:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.faq-a { padding: 0 0 var(--space-md); }
.src-list { margin: 0; padding-left: 1.1rem; color: var(--color-ink-soft); }
.src-list li { margin-bottom: var(--space-xs); line-height: 1.6; }
.src-list a { display: inline-block; min-height: 44px; padding-block: 0.6rem; box-sizing: border-box; color: var(--color-gold); text-underline-offset: 3px; }
.src-use { display: block; font-size: var(--text-sm); color: var(--color-ink-mute); }
.ch-reviewed { font-size: var(--text-xs); color: var(--color-ink-mute); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .page-chalisa .topbar, .ch-controls { transition: none; }
  .v-meaning, .inv-body { animation: none; }
  .v-chant::before, .v-btn, .v-btn::after { transition: none; }
}

/* ---------- Print: a clean reading copy ---------- */
@media print {
  :root { --chant-scale: 1; }
  body.page-chalisa { background: #fff; color: #111; padding: 0; }
  .page-chalisa .topbar, .ch-controls, .page-chalisa .footer, .page-chalisa .skip, .ch-arch, .v-btn, .ch-hint, .ch-scroll::before { display: none !important; }
  .ch-hero { padding: 0 0 12pt; }
  .ch-t-te, .m-label, .danda, .ch-scroll .sec-h, .v-num { color: #7a5a00 !important; }
  .ch-t-en, .ch-intro, .ch-review { color: #333 !important; }
  .ch-scroll { width: auto; margin: 0; padding: 0; background: none; border: 0; outline: 0; box-shadow: none; border-radius: 0; }
  .v-lines { color: #111; font-size: 15pt; }
  .v-meaning-in { background: none; border-top: 0.5pt solid #b08a2e; }
  .v-meaning p, .ch-after p { color: #222 !important; }
  .verse { break-inside: avoid; }
  .v-chant::before { display: none; }
  .view-learn .verse { border-color: #c9b07a; background: none; }
}

/* ---------- One-time hint: the options come back when you scroll up ---------- */
.ch-hint { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 12px); z-index: 30; translate: 0 -8px; opacity: 0; pointer-events: none;
  width: fit-content; max-width: calc(100% - 32px); margin-inline: auto; text-wrap: balance; padding: 0.55rem 1rem; border-radius: var(--radius-pill); text-align: center;
  background: var(--color-paper-3); border: var(--rule-thin) solid var(--color-rule); color: var(--color-ink); font-size: var(--text-sm); line-height: 1.4;
  box-shadow: 0 12px 30px -12px oklch(6% 0.02 45 / 0.9); transition: opacity 400ms var(--ease-out), translate 400ms var(--ease-silk); }
.ch-hint span { color: var(--color-ink-soft); }
.ch-hint.is-shown { opacity: 1; translate: 0 0; }
@media (prefers-reduced-motion: reduce) { .ch-hint { transition: none; } }

/* ---------- Review fixes (2026-11-16) ---------- */
/* the browser's smooth fragment scroll raced the page's own landing on #verse-N: jump instantly here, the script smooths in-page jumps itself */
html:has(body.page-chalisa) { scroll-behavior: auto; }
/* without JavaScript the switches cannot work, so do not show them (the head script adds .js) */
html:not(.js) .ch-controls { display: none; }
