:root {
  --cream: #EAE3D3;
  --paper: #F4EEE2;
  --burgundy: #6B1A1A;
  --gold: #C4922A;
  --gold-text: #8A6214; /* gold darkened for readable small text on cream */
  --ink: #3A2E24;
  --muted: #6E5F4E;
  --rule: #D6CBB4;
  --sa: "Tiro Devanagari Sanskrit", "Noto Serif Devanagari", serif;
  --lat: "Gentium Book Plus", "Gentium Plus", Georgia, serif;
  --measure: 40rem;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 4.5rem; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font: 1.0625rem/1.65 var(--lat);
}
a { color: var(--burgundy); text-underline-offset: .18em; }
:focus-visible { outline: 2px solid var(--burgundy); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[lang="sa"] { font-family: var(--sa); }

/* Top bar */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1rem;
  padding: .55rem max(1rem, calc((100% - var(--measure)) / 2));
  background: var(--burgundy); color: var(--cream);
}
.bar a { color: var(--cream); text-decoration: none; }
.home { display: flex; align-items: center; gap: .5rem; font-weight: 700; }
.home img { border-radius: 50%; background: var(--cream); }
.toc { margin-left: auto; font-size: .95rem; }
.jump select {
  font: inherit; font-size: .95rem; color: var(--burgundy); background: var(--cream);
  border: 0; border-radius: 4px; padding: .3rem .4rem; max-width: 7.5rem;
}

main { max-width: var(--measure); margin: 0 auto; padding: 0 1rem 3rem; }

/* Chapter header */
.ch-head { padding: 2.5rem 0 1.5rem; border-bottom: 1px solid var(--rule); }
.ch-num { margin: 0; color: var(--gold-text); }
.ch-num span { margin-left: .5rem; }
h1 { margin: .4rem 0 1rem; font-weight: 400; font-size: 1.6rem; line-height: 1.3; color: var(--burgundy); }
h1 [lang="sa"] { display: block; font-size: 2.2rem; line-height: 1.4; }
.intro { margin: 0 0 1.25rem; color: var(--muted); }
.view { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .95rem; }
.view input { accent-color: var(--burgundy); width: 1.05rem; height: 1.05rem; vertical-align: -2px; }

/* Verse: the memorable element is the Sanskrit itself */
.verse {
  position: relative;
  padding: 2rem 0 1.75rem 3.25rem;
  border-bottom: 1px solid var(--rule);
}
.verse:target { background: linear-gradient(90deg, var(--paper), transparent 85%); }
.num {
  position: absolute; left: 0; top: 2.35rem;
  font-size: .9rem; color: var(--gold-text); text-decoration: none;
  font-variant-numeric: lining-nums;
}
.num::after { content: ""; display: block; width: 1.6rem; height: 2px; margin-top: .35rem; background: var(--gold); }
.spk { margin: 0 0 .5rem; font-style: italic; color: var(--burgundy); }
.sa {
  margin: 0 0 .9rem; font-size: 1.45rem; line-height: 1.75; color: var(--burgundy);
  overflow-wrap: anywhere;
}
.inl-spk { font-size: .82em; font-style: italic; opacity: .85; }
.tr { margin: 0 0 .9rem; font-style: italic; color: var(--ink); overflow-wrap: anywhere; }
.en { margin: 0; }
.acts { display: flex; align-items: center; gap: 1.25rem; margin-top: .9rem; }
.listen {
  display: inline-flex; align-items: center; gap: .4rem;
  font: inherit; font-size: .95rem; color: var(--burgundy); background: none;
  border: 1.5px solid var(--burgundy); border-radius: 999px; padding: .35rem .9rem .35rem .7rem; cursor: pointer;
}
.listen svg { width: .8rem; height: .8rem; fill: currentColor; }
.verse.playing .listen { background: var(--burgundy); color: var(--cream); }
.listen .i-pause, .verse.is-on .listen .i-play { display: none; }
.verse.is-on .listen .i-pause { display: inline; }
.verse.playing .sa { text-decoration: underline; text-decoration-color: var(--gold); text-decoration-thickness: 2px; text-underline-offset: .35em; }
.play-ch {
  margin-top: 1.1rem; font: inherit; padding: .55rem 1rem; border: 0; border-radius: 4px;
  background: var(--burgundy); color: var(--cream); cursor: pointer;
}
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; gap: .45rem;
  padding: .6rem max(1rem, calc((100% - var(--measure)) / 2)) calc(.6rem + env(safe-area-inset-bottom));
  background: var(--burgundy); color: var(--cream);
}
.player[hidden] { display: none; }
.player button {
  font: inherit; font-size: .9rem; color: var(--cream); background: none;
  border: 1px solid rgba(234,227,211,.5); border-radius: 4px; padding: .35rem .65rem; cursor: pointer;
}
.player .p-main { background: var(--cream); color: var(--burgundy); border-color: var(--cream); min-width: 4.2rem; }
.player button[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.p-now { flex: 1; min-width: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .p-x { font-size: 1.2rem; line-height: 1; padding: .3rem .55rem; border-color: transparent; }
body.has-player { padding-bottom: 5rem; }
.player :focus-visible { outline-color: var(--cream); }
.share {
  padding: 0; border: 0; background: none;
  font: inherit; font-size: .85rem; color: var(--muted); cursor: pointer;
  text-decoration: underline; text-underline-offset: .18em;
}
.share.done { color: var(--burgundy); text-decoration: none; }
body.hide-tr .tr, body.hide-en .en { display: none; }

.colophon { margin: 2.5rem 0 1rem; text-align: center; font-size: 1.1rem; color: var(--muted); line-height: 1.8; }

/* Prev / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2rem; }
.pager a { text-decoration: none; padding: .9rem 0; border-top: 2px solid var(--gold); }
.pager small { display: block; color: var(--muted); }
.pager a[rel="next"] { text-align: right; }

/* Index */
.opening { padding: 3rem 0 2rem; text-align: center; }
.opening h1 { font-size: 2rem; margin-bottom: 1.5rem; }
.sa.big { font-size: 1.7rem; }
.opening .en { color: var(--muted); max-width: 32rem; margin: 0 auto; }
.goto { padding: 1.25rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.goto label { display: block; margin-bottom: .4rem; }
.goto div { display: flex; gap: .5rem; }
.goto input {
  flex: 1; min-width: 0; font: inherit; padding: .55rem .7rem; color: var(--ink);
  background: var(--paper); border: 1px solid var(--rule); border-radius: 4px;
}
.goto button, .resume a {
  font: inherit; padding: .55rem 1rem; border: 0; border-radius: 4px;
  background: var(--burgundy); color: var(--cream); cursor: pointer;
}
.err { margin: .5rem 0 0; color: var(--burgundy); font-size: .95rem; }
.resume { margin: 1.25rem 0 0; }
.resume a { display: inline-block; text-decoration: none; }
.chapters { list-style: none; margin: 1.5rem 0; padding: 0; }
.chapters a {
  display: grid; grid-template-columns: 2.5rem 1fr auto; gap: .75rem; align-items: baseline;
  padding: 1rem 0; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink);
}
.chapters .n { font-size: 1.5rem; color: var(--gold-text); }
.chapters .t [lang="sa"] { display: block; font-size: 1.25rem; color: var(--burgundy); line-height: 1.5; }
.chapters .c { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.chapters a:hover .t [lang="sa"] { text-decoration: underline; text-underline-offset: .2em; }
.about { color: var(--muted); }

.foot {
  max-width: var(--measure); margin: 0 auto; padding: 2rem 1rem 3rem;
  font-size: .9rem; color: var(--muted); border-top: 1px solid var(--rule);
}
.foot a { margin-right: 1rem; }
.foot .small { font-size: .85rem; }

@media (max-width: 480px) {
  body { font-size: 1rem; }
  .verse { padding-left: 0; padding-top: 2.6rem; }
  .num { top: 1.1rem; }
  .num::after { display: none; }
  .sa { font-size: 1.3rem; }
  h1 [lang="sa"] { font-size: 1.85rem; }
  .bar { gap: .7rem; }
  .home span { display: none; }
  .chapters a { grid-template-columns: 2rem 1fr; }
  .chapters .c { grid-column: 2; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
