:root {
  color-scheme: dark;
  --paper: #15120d;
  --ink: #f7f0df;
  --muted: #c6bda7;
  --rule: #dcc38d30;
  --gold: #efcc81;
  --opening-height: 100svh;
  font-family: Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; }
body { margin: 0; background: var(--paper); color: var(--ink); isolation: isolate; }
a { color: inherit; text-underline-offset: .25em; }
a:focus-visible { outline: 2px solid currentColor; outline-offset: 6px; }
.masthead {
  min-height: 66px;
  padding: 1.15rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--rule);
  color: #eee3cc;
}
.masthead a { text-decoration: none; }
.book-name { font-size: 1.12rem; }
.chapter-link, .eyebrow, .reading-headings, .speaker, .site-footer {
  font-family: ui-sans-serif, system-ui, sans-serif;
}
.chapter-link { font-size: .875rem; letter-spacing: .08em; }
.chapter-link span { margin-left: .7rem; color: var(--gold); }
.hero { position: fixed; z-index: -2; inset: 0; margin: 0; width: 100%; height: 100lvh; background: #302a1e; overflow: hidden; pointer-events: none; }
.hero img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; transform: scale(var(--scene-scale, 1)); }
.hero::after { content: ''; position: absolute; inset: 0; background: #0e0c08; opacity: var(--scene-shade, .84); }
main { padding-top: var(--opening-height); }
.scroll-cue {
  position: absolute;
  top: calc(var(--opening-height) - max(1.75rem, env(safe-area-inset-bottom)));
  left: 50%;
  transform: translate(-50%, -100%);
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 48px;
  padding: .65rem 1.35rem;
  border: 1px solid #f0d99b55;
  border-radius: 999px;
  background: #19150ed9;
  backdrop-filter: blur(8px);
  color: #f6e5bc;
  box-shadow: 0 4px 24px #0004;
  font: .875rem/1.5 ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .1em;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity .25s ease, visibility .25s ease, background .2s ease;
}
.scroll-cue:hover { background: #302518ed; }
.scroll-cue-arrow { font-size: 1.4rem; line-height: 1; animation: beckon-scroll 2.4s ease-in-out 2; }
.scroll-cue[data-dismissed] { opacity: 0; visibility: hidden; pointer-events: none; }
@keyframes beckon-scroll {
  0%, 100% { transform: translateY(-2px); }
  50% { transform: translateY(4px); }
}
.chapter { position: relative; max-width: 1320px; margin: 0 auto; padding: 0 clamp(1.25rem, 5vw, 5rem); text-shadow: 0 2px 14px #0009; }
.reading-progress { position: fixed; z-index: 12; top: 0; left: 0; width: 100%; height: 2px; background: var(--gold); box-shadow: 0 0 12px #efcc8177; transform: scaleX(var(--reading-progress, 0)); transform-origin: left; pointer-events: none; }
.chapter-heading { padding: clamp(3.5rem, 7vw, 7rem) 0 3.75rem; text-align: center; }
.eyebrow { margin: 0 0 1.5rem; color: var(--muted); font-size: .875rem; letter-spacing: .15em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(2.25rem, 4.4vw, 4.25rem); font-weight: 400; line-height: 1.13; letter-spacing: -.035em; }
.chapter-name { color: var(--muted); font-size: 1.25rem; font-style: italic; margin: 1.5rem 0 0; }
.reading-headings, .invocation, .verse, .colophon { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: clamp(2rem, 4vw, 4rem); }
.reading-headings { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 1.15rem 0; font-size: .875rem; color: var(--muted); letter-spacing: .07em; }
.invocation { padding: 2.25rem 0 2.75rem; color: var(--muted); font-size: 1.125rem; line-height: 1.8; }
.invocation p { margin: 0; }
.verse { position: relative; padding: 3.25rem 0; border-top: 1px solid var(--rule); scroll-margin-top: 2rem; }
.verse-number { position: absolute; top: .8rem; left: 0; color: var(--muted); text-decoration: none; font: .8rem/1.2 ui-sans-serif, system-ui, sans-serif; letter-spacing: .06em; }
.verse-reveal { opacity: 0; transform: translateY(20px); transition: opacity .75s ease, transform .75s cubic-bezier(.2,.7,.2,1); }
.verse-reveal.is-visible, .verse-reveal:focus-within, .verse-reveal:target { opacity: 1; transform: none; }
.verse:target { border-color: #9e7b38; }
.verse-text { min-width: 0; font-size: clamp(1.125rem, 1.55vw, 1.3125rem); line-height: 1.75; overflow-wrap: anywhere; }
.verse-text p { margin: 0; }
.translation p:not(.speaker) { text-wrap: pretty; }
.chant-line { display: block; text-wrap: balance; }
.chant-line + br { display: none; }
.chant-line ~ .chant-line { margin-top: .65em; }
.sanskrit { color: #e6d5af; }
.verse-text .speaker { color: var(--muted); font-size: .875rem; line-height: 1.5; margin: 0 0 1rem; }
.inline-speaker { color: var(--muted); font: .875rem/1.5 ui-sans-serif, system-ui, sans-serif; }
.colophon { border-top: 1px solid var(--rule); margin-top: 1rem; padding: 2.75rem 0 5rem; color: var(--muted); font-size: 1.05rem; line-height: 1.85; overflow-wrap: anywhere; }
.colophon p { margin: 0; }
.site-footer { border-top: 1px solid var(--rule); padding: 1.75rem clamp(1.25rem, 5vw, 5rem); display: flex; justify-content: space-between; gap: 1rem; font-size: .875rem; color: var(--muted); }
.skip-link { position: absolute; z-index: 2; padding: 1rem; background: var(--paper); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.reader-hint { margin: 1rem 0 0; color: var(--muted); font: .875rem/1.6 ui-sans-serif, system-ui, sans-serif; }
.hint-touch, .reading-mobile { display: none; }
.sanskrit-word {
  display: inline-block;
  max-width: 100%;
  vertical-align: baseline;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: inherit;
  overflow-wrap: anywhere;
  cursor: pointer;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  text-decoration: underline dotted #dac0874d;
  text-underline-offset: .24em;
  text-decoration-thickness: 1px;
  transition: color .18s ease, background .18s ease, text-shadow .18s ease, box-shadow .18s ease;
}
.sanskrit-word:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }
.sanskrit-word[data-active="true"], .word-match {
  background: #e9b84b1c;
  color: #ffe6a6;
  text-shadow: 0 0 9px #ffce7699, 0 0 24px #ffc45e66;
  box-shadow: 0 0 18px #f3bf521a;
  text-decoration-color: #ffe6a6a6;
}
.sanskrit-word[aria-pressed="true"] { text-decoration-style: solid; }
.word-match { border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.word-popup {
  position: fixed;
  z-index: 10;
  width: min(360px, calc(100vw - 24px));
  min-width: 0;
  margin: 0;
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem 2.75rem 1rem 1.2rem;
  border: 1px solid #e6c27b59;
  border-radius: 8px;
  background: #211b12f5;
  box-shadow: 0 8px 35px #0006, 0 0 28px #e9b95313;
  backdrop-filter: blur(16px);
  color: var(--ink);
  text-shadow: none;
  overflow-anchor: none;
  overflow-wrap: anywhere;
}
.word-popup[hidden], .reader-hint[hidden] { display: none; }
.word-popup p { margin: 0; }
.word-popup .meaning-label { margin: 0 1.5rem .7rem 0; font: .75rem/1.5 ui-sans-serif, system-ui, sans-serif; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.word-popup .selected-word { margin-bottom: .45rem; font-size: 1.1rem; line-height: 1.55; color: var(--gold); overflow-wrap: anywhere; }
.word-popup .selected-gloss { margin-bottom: .65rem; font: .875rem/1.45 ui-sans-serif, system-ui, sans-serif; color: var(--muted); }
.chapter-pager { display: flex; justify-content: space-between; gap: 1.5rem; padding: 2rem 0; border-top: 1px solid var(--rule); font: .9375rem/1.5 ui-sans-serif, system-ui, sans-serif; }
.chapter-pager a { max-width: 44%; }
.chapter-pager a:last-child { text-align: right; margin-left: auto; }
.edition-note { padding: 1.25rem 0 2.5rem; color: var(--muted); font: .8125rem/1.7 ui-sans-serif, system-ui, sans-serif; }
.all-chapters { font: .875rem/1.5 ui-sans-serif, system-ui, sans-serif; }
.word-popup .selected-meaning { max-width: 75ch; font-size: 1.0625rem; line-height: 1.65; color: #f2e7ce; }
.word-popup .meaning-note { margin-top: .85rem; padding-top: .75rem; border-top: 1px solid var(--rule); font: .875rem/1.6 ui-sans-serif, system-ui, sans-serif; color: var(--gold); }
.word-popup .meaning-source { display: inline-block; margin-top: .8rem; color: var(--muted); font: .8rem/1.5 ui-sans-serif, system-ui, sans-serif; }
.word-popup .meaning-note[hidden], .word-popup .meaning-source[hidden] { display: none; }
.word-popup[data-compact] { padding-block: .6rem; }
.word-popup[data-compact] .meaning-label,
.word-popup[data-compact] .selected-word { display: none; }
.word-popup[data-compact] .selected-meaning { font-size: 1rem; line-height: 1.45; }
.close-meaning { position: absolute; top: .3rem; right: .3rem; border: 0; background: none; color: var(--muted); width: 40px; height: 40px; cursor: pointer; font-size: 1.5rem; }
.close-meaning:focus-visible { outline: 2px solid var(--gold); outline-offset: -4px; }
.word-popup[data-touch] {
  position: fixed;
  inset: auto 12px calc(12px + env(safe-area-inset-bottom));
  width: auto;
  max-height: none;
  overflow: visible;
  padding: 1rem 3rem 1rem 1.1rem;
  background: #211b12;
}
.word-popup[data-touch] .meaning-label { display: none; }
.word-popup[data-touch] .meaning-note,
.word-popup[data-touch] .meaning-source { display: none; }
.word-popup[data-touch] .selected-meaning { font-size: 1rem; line-height: 1.5; }
@media (hover: none), (pointer: coarse) {
  html { scroll-behavior: auto; }
  .sanskrit-word { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
  .verse-reveal { opacity: 1; transform: none; transition: none; }
}
@media (max-width: 650px) {
  :root { --opening-height: calc(75vw + 84px); }
  .hero { background: #15120d; }
  .hero img {
    height: 75vw;
    object-fit: cover;
    object-position: 50% 50%;
    transform: none;
  }
  .hero::before {
    content: '';
    position: absolute;
    z-index: 1;
    top: 0;
    left: 0;
    width: 100%;
    height: 75vw;
    background: linear-gradient(transparent 76%, #15120d);
  }
  .hero::after { z-index: 2; }
  .scroll-cue {
    top: calc(var(--opening-height) - 14px);
    min-height: 46px;
    padding: .6rem 1.25rem;
    background: #211b12;
    font-size: .8125rem;
    letter-spacing: .08em;
  }
  .chapter { padding-inline: clamp(20px, 5.5vw, 32px); }
  .masthead { min-height: 52px; padding-block: .9rem; gap: .5rem; }
  .book-name { font-size: .95rem; }
  .chapter-link { font-size: .875rem; letter-spacing: 0; white-space: nowrap; }
  .chapter-link span { margin-left: .25rem; }
  .chapter-heading { padding: 2.5rem 0 2rem; }
  h1 { font-size: clamp(2rem, 8.4vw, 2.65rem); line-height: 1.16; text-wrap: balance; }
  .chapter-name { font-size: 1.05rem; line-height: 1.6; margin-top: 1.1rem; overflow-wrap: anywhere; }
  .desktop-break { display: none; }
  .eyebrow { font-size: .8125rem; line-height: 1.6; letter-spacing: .065em; margin-bottom: 1rem; }
  .reading-headings { display: block; padding: .95rem 0; font-size: .875rem; letter-spacing: .03em; }
  .reading-headings > span:not(.reading-mobile), .hint-pointer { display: none; }
  .reading-mobile, .hint-touch { display: inline; }
  .reader-hint { line-height: 1.65; }
  .invocation, .verse, .colophon { grid-template-columns: minmax(0, 1fr); row-gap: 1.5rem; }
  .invocation { font-size: 1.0625rem; padding-block: 1.75rem 2.25rem; row-gap: .9rem; }
  .verse { padding: 3rem 0 2.25rem; }
  .verse-text { font-size: 1.125rem; line-height: 1.85; }
  .sanskrit { line-height: 1.8; }
  .verse-text .speaker { margin-bottom: .6rem; }
  .translation { border-left: 2px solid #e6c27b40; padding-left: 1rem; color: #e2dccd; }
  .colophon { font-size: 1rem; padding-bottom: 3rem; }
  .site-footer { padding: 1.5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .word-popup .selected-word { padding-right: 1.5rem; font-size: 1.125rem; }
  .word-popup .selected-meaning { font-size: 1.0625rem; line-height: 1.65; }
  .close-meaning { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .verse-reveal { opacity: 1; transform: none; transition: none; }
  .hero img { transform: none; }
  .sanskrit-word { transition: none; }
  .scroll-cue { transition: none; }
  .scroll-cue-arrow { animation: none; }
}
@media (hover: hover) {
  .sanskrit-word:hover { color: #ffe6a6; text-shadow: 0 0 9px #ffce7699, 0 0 24px #ffc45e66; }
}
@media print {
  :root { --ink: #222; --muted: #555; --rule: #ddd; }
  body { background: white; color: #222; }
  main { padding-top: 0; }
  .hero, .word-popup, .reading-progress, .reader-hint, .scroll-cue { display: none; }
  .chapter { text-shadow: none; }
  .sanskrit { color: #222; }
  .verse-reveal { opacity: 1; transform: none; }
}
