/* Aarti.
   Read in the evening, in a dim room, next to a lit lamp, at arm's length,
   by someone who is also holding something. Every choice here follows from
   that: warm dark ground, large type, high contrast on the current line only,
   and tap targets sized for a hand that is busy. */

/* Paithani. Peacock ground, gold zari for the line being sung, and magenta
   kept for the one navigation cue, Next up. Text is off-white on a dark
   ground at about 12:1: pure white on near-black blooms (halation) at night.
   Festive colour lives only at the edges and in the one highlight; the text
   column always sits on flat colour. */
:root {
  --ground: #0e2a2b;
  --surface: #123334;
  --surface-2: #1a3e3f;
  --ink: #f1e7d3;
  --ink-dim: #9fb5ae;
  --ink-faint: #7d958f;
  --accent: #e6be63;
  --accent-deep: #c9a04a;
  --on-accent: #10201f;
  --wash: transparent;
  --magenta: #c83c78;
  --on-magenta: #fff6f9;
  --zari: #d9ad55;
  --zari-field: #1c5c55;
  --line: #24494a;

  --dev-font: "Tiro Devanagari Marathi", "Noto Serif Devanagari", "Nirmala UI",
              "Kohinoor Devanagari", "Devanagari Sangam MN", "Mangal", serif;
  --ui-font: "Mukta", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --scale: 1;
  --gutter: clamp(16px, 5vw, 32px);
  --radius: 14px;
}

:root[data-theme="light"] {
  --ground: #f6f0e4;
  --surface: #fbf7ef;
  --surface-2: #ede3cf;
  --ink: #1c2b29;
  --ink-dim: #56645f;
  --ink-faint: #76817c;
  --accent: #133b39;
  --accent-deep: #1c5c55;
  --on-accent: #fbf7ef;
  --wash: #f2dfa4;
  --magenta: #a3245a;
  --on-magenta: #fff6f9;
  --zari: #c79b3f;
  --zari-field: #1c5c55;
  --line: #dccfb6;
}

:root[data-font="0"] { --scale: 0.85; }
:root[data-font="1"] { --scale: 1; }
:root[data-font="2"] { --scale: 1.28; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body { padding-bottom: env(safe-area-inset-bottom); }

a { color: var(--accent); }
.dim { color: var(--ink-dim); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  /* Gold in the dark theme, peacock in the light one, so the text colour
     comes from the theme too. */
  color: var(--on-accent);
  font-weight: 600;
}
.btn:active { transform: scale(0.98); }

.back {
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
  color: var(--ink-dim);
  text-decoration: none;
  font-size: 14px;
}
.back::before { content: "\2190"; margin-right: 6px; }

/* ------------------------------------------------------------------ home */

.home { padding: var(--gutter); max-width: 720px; margin: 0 auto; }

.home-head h1 {
  font-family: var(--dev-font);
  font-size: 34px;
  margin: 8px 0 4px;
  color: var(--accent);
  letter-spacing: 0.01em;
}
.tagline { margin: 0 0 22px; color: var(--ink-dim); font-size: 15px; line-height: 1.5; }

.search-wrap { margin-bottom: 16px; }
#search {
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* 16px or iOS zooms on focus */
}
#search::placeholder { color: var(--ink-faint); }

.home-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }

.lib-section + .lib-section { margin-top: 26px; }
.lib-section h2 { font-family: var(--dev-font); font-weight: 400; font-size: 18px; color: var(--accent); margin: 0 0 10px; }
/* While searching, a section whose every aarti is filtered out hides its heading too. */
.lib-section:not(:has(li:not([hidden]))) { display: none; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  display: grid;
  gap: 3px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
}
.card-dev { font-family: var(--dev-font); font-size: 21px; color: var(--ink); }
.card-roman { font-size: 14px; color: var(--accent); }
.card-meta { font-size: 12px; color: var(--ink-faint); text-transform: lowercase; }
.card[hidden] { display: none; }

.home-foot { margin-top: 28px; font-size: 13px; }
.home-foot a { color: var(--ink-dim); }

/* Order builder */
.builder { display: grid; gap: 8px; margin: 0 0 22px; padding: 0; list-style: none; }
.builder li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
}
.builder .name { flex: 1; font-size: 15px; }
.builder button {
  min-width: 44px; min-height: 44px;
  border: none; border-radius: 8px;
  background: var(--surface-2); color: var(--ink);
  font-size: 17px; cursor: pointer;
}

/* ---------------------------------------------------------------- reader */

.reader { max-width: 760px; margin: 0 auto; padding: var(--gutter); padding-bottom: calc(var(--controls-h, 220px) + 24px); }

.reader-head { margin-bottom: 22px; }
.reader-head h1 { margin: 10px 0 6px; display: grid; gap: 2px; }
.reader-head .dev { font-family: var(--dev-font); font-size: 30px; color: var(--accent); }
.reader-head .roman { font-size: 14px; color: var(--ink-dim); font-weight: 400; }
.meta { margin: 0; font-size: 12px; color: var(--ink-faint); }

.pending {
  margin: 16px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--accent-deep);
  border-left-width: 4px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}

.lines { list-style: none; margin: 0; padding: 0; }

.line {
  padding: 14px 4px;
  border-bottom: 1px solid transparent;
  transition: opacity 160ms ease, color 160ms ease;
}
.line .dev {
  display: block;
  font-family: var(--dev-font);
  font-size: calc(23px * var(--scale));
  line-height: 1.75;
  color: var(--ink);
}
.line .roman {
  display: block;
  font-size: calc(14px * var(--scale));
  line-height: 1.6;
  color: var(--ink-dim);
  margin-top: 3px;
}

/* Script preference. Dimming rather than hiding keeps the reader's place. */
:root[data-script="dev"] .line .roman,
:root[data-script="dev"] .card-roman { display: none; }
:root[data-script="roman"] .line .dev { display: none; }
:root[data-script="roman"] .line .roman { font-size: calc(20px * var(--scale)); color: var(--ink); }

/* In ceremony mode only the current line is at full strength. */
/* The other lines stay readable enough to glance back at mid-song; only the
   current one is at full strength, on a gold wash in daylight. */
body.ceremony .line { opacity: 0.5; }
body.ceremony .line.current { opacity: 1; background: var(--wash); border-radius: 10px; }
body.ceremony .line.current .dev { color: var(--accent); }
body.ceremony .line.current .roman { color: var(--ink); }

.meaning {
  margin-top: 10px;
  padding: 12px 14px;
  border-left: 3px solid var(--accent-deep);
  border-radius: 0 8px 8px 0;
  background: var(--surface);
  font-size: 14px;
  line-height: 1.6;
}
.meaning p { margin: 0 0 6px; }
.meaning cite { font-size: 12px; color: var(--ink-faint); font-style: normal; }
.meaning .variant { margin-top: 8px; color: var(--ink-dim); font-size: 13px; }

body.study .line { cursor: pointer; }
body.study .line:hover { background: var(--surface); border-radius: 8px; }

.reader-foot { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13px; }
.reader-foot h2 { font-size: 14px; font-weight: 600; color: var(--ink-dim); margin: 0 0 8px; }
.reader-foot ul { margin: 0; padding-left: 18px; }
.reader-foot li { margin-bottom: 4px; }

/* Learn mode word hiding */
.hidden-word {
  color: transparent;
  border-bottom: 2px solid var(--ink-faint);
  border-radius: 2px;
}

/* --------------------------------------------------------------- controls */

.controls {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--ground) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.next-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  /* Magenta is kept for this one job: the way to the next aarti. */
  background: var(--magenta);
  border: 1px solid var(--magenta);
  color: var(--on-magenta);
  text-decoration: none;
  font-size: 14px;
}
.next-pill .label { font-size: 13px; opacity: 0.85; }
.next-pill .title { flex: 1; text-align: right; font-weight: 600; }
/* The end of an order is information, not a link, so it goes quiet. */
div.next-pill { background: var(--surface); border-color: var(--line); color: var(--ink-dim); }

.control-row { display: flex; gap: 8px; align-items: center; }
.control-row .btn { flex: 1; padding: 0 12px; font-size: 14px; }
.control-row .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.tempo-readout { font-size: 12px; color: var(--ink-faint); min-width: 60px; text-align: center; }

/* Order strip */
.strip {
  position: fixed;
  left: 0; right: 0; top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px var(--gutter);
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip[hidden] { display: none; }
.chip {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--ground);
  color: var(--ink-dim);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
.chip.current { border-color: var(--accent); color: var(--accent); }


/* ----------------------------------------------------------------- prose */

.prose { max-width: 680px; margin: 0 auto; padding: var(--gutter); line-height: 1.65; }
.prose h1 { font-size: 26px; margin: 12px 0 16px; color: var(--accent); }
.prose h2 { font-size: 16px; margin: 28px 0 8px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 16px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose th { color: var(--ink-faint); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.06em; }
.prose h3 { font-size: 14px; margin: 22px 0 6px; color: var(--ink-dim); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose code { font-size: 0.92em; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); }
.prose pre { overflow-x: auto; padding: 12px 14px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); }
.prose pre code { padding: 0; background: none; }
/* The colophon's tables scroll inside their own wrapper so the page never
   scrolls sideways on a phone. */
.table-wrap { overflow-x: auto; margin-top: 16px; }
.table-wrap table { display: table; margin-top: 0; }
.build-stats { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-dim); }

.toast {
  position: fixed;
  left: 50%; bottom: 150px;
  transform: translateX(-50%);
  z-index: 50;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  max-width: calc(100vw - 40px);
}
.toast[hidden] { display: none; }

/* ------------------------------------------------------------------- 404 */
/* One picture carries the page: the zero in ४०४ is a bitten modak, with
   Mushak caught behind it. Everything else stays quiet. */

.nf {
  min-height: 100svh;
  max-width: 36rem;
  margin: 0 auto;
  padding-inline: var(--gutter);
  padding-block: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.nf-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--dev-font);
  font-size: clamp(92px, 28vw, 168px);
  line-height: 1;
  color: var(--accent);
  margin-bottom: 20px;
}
.nf-digit { display: block; transform: translateY(-0.06em); }
.nf-modak { height: 1.22em; width: auto; margin-inline: -0.08em; overflow: visible; }

.nf-glow-core { stop-color: var(--accent); stop-opacity: 0.32; }
.nf-glow-edge { stop-color: var(--accent); stop-opacity: 0; }
.nf-shadow { fill: rgba(0, 0, 0, 0.28); }
.nf-pleat { fill: none; stroke: #b8843c; stroke-width: 1.6; stroke-linecap: round; opacity: 0.55; }
.nf-tip { stroke-width: 2.4; opacity: 0.8; }
.nf-crumb { fill: #e0b25f; }
.nf-mouse-fur { fill: #a1968c; }
.nf-mouse-tail { fill: none; stroke: #a1968c; stroke-width: 4; stroke-linecap: round; }
.nf-mouse-ear { fill: #e8a0a0; }
.nf-mouse-nose { fill: #e38b8b; }
.nf-mouse-eye { fill: #241b12; }
.nf-mouse-whisker { fill: none; stroke: #e6ddd3; stroke-width: 1; stroke-linecap: round; opacity: 0.8; }

/* The single orchestrated moment: a few nibbles while the crumbs land. */
.nf-mouse-head {
  transform-box: fill-box;
  transform-origin: 70% 70%;
  animation: nf-nibble 0.32s ease-in-out 0.5s 6 alternate;
}
.nf-crumb { animation: nf-fall 0.9s cubic-bezier(0.4, 0, 0.9, 0.6) both; }
.nf-crumb:nth-of-type(1) { animation-delay: 0.7s; }
.nf-crumb:nth-of-type(2) { animation-delay: 1.1s; }
.nf-crumb:nth-of-type(3) { animation-delay: 1.5s; }

@keyframes nf-nibble {
  to { transform: translate(-3px, 1px) rotate(-5deg); }
}
@keyframes nf-fall {
  from { transform: translate(-6px, -70px); opacity: 0; }
  30% { opacity: 1; }
  to { transform: none; opacity: 1; }
}

/* Point at the modak and he ducks behind it. */
.nf-mouse { transition: transform 240ms ease; }
.nf-hero:hover .nf-mouse { transform: translate(-22px, 10px); }

.nf h1 {
  font-family: var(--dev-font);
  font-size: clamp(26px, 6.4vw, 34px);
  font-weight: 600;
  line-height: 1.25;
  margin: 6px 0 12px;
  color: var(--ink);
  /* At 360px the headline otherwise strands "first" on its own line. */
  text-wrap: balance;
}
.nf-lede {
  max-width: 30rem;
  margin: 0 0 26px;
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-dim);
}
.nf-search { display: flex; gap: 8px; width: 100%; max-width: 26rem; margin: 0 0 16px; }
.nf-search input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}
.nf-search input::placeholder { color: var(--ink-faint); }
.nf-search input:focus-visible,
.nf .btn:focus-visible,
.nf-home:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.nf-home {
  display: inline-block;
  min-height: 44px;
  line-height: 44px;
  color: var(--ink-dim);
  font-size: 15px;
  text-underline-offset: 4px;
}
.nf-quip { margin: 30px 0 6px; font-size: 14px; color: var(--ink-faint); text-wrap: balance; }
.nf-chant { margin: 0; font-family: var(--dev-font); font-size: 19px; color: var(--accent-deep); }

@media (prefers-reduced-motion: reduce) {
  .nf-mouse-head, .nf-crumb { animation: none; }
  .nf-hero:hover .nf-mouse { transform: none; }
}

/* ------------------------------------------------------------ zari band */
/* A Paithani border across the top edge of every page: gold rails around a
   peacock field of magenta diamonds. It is the only pattern in the app, and
   it sits above the content, never behind a word. */
.zari {
  height: 14px;
  background:
    linear-gradient(var(--zari), var(--zari)) 0 0 / 100% 3px no-repeat,
    linear-gradient(var(--zari), var(--zari)) 0 100% / 100% 2px no-repeat,
    linear-gradient(45deg, transparent 36%, var(--magenta) 36% 64%, transparent 64%) 0 4px / 10px 7px repeat-x,
    linear-gradient(-45deg, transparent 36%, var(--magenta) 36% 64%, transparent 64%) 0 4px / 10px 7px repeat-x,
    var(--zari-field);
}

/* ----------------------------------------------------------- puja guide */
.guide h1 { font-family: var(--dev-font); font-weight: 400; }
.guide h2 { font-family: var(--dev-font); font-weight: 400; font-size: 20px; color: var(--accent); margin-top: 32px; }
.guide ol > li { margin-bottom: 10px; }

.tasks { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 2px; }
.tasks label {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 44px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.tasks input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent-deep); }
.tasks input:checked + span { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--ink-faint); }
.tasks input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.task-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 8px;
  font-size: 14px;
  color: var(--ink-dim);
}
.task-bar .btn { min-height: 40px; padding: 0 16px; font-size: 14px; }

.guide-index { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 10px; }
.guide-index a {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
}
.gi-title { font-family: var(--dev-font); font-size: 19px; color: var(--ink); }
.gi-summary { font-size: 14px; color: var(--ink-dim); }

.guide-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.guide-nav a { display: grid; gap: 2px; text-decoration: none; color: var(--ink); }
.guide-nav a.next { text-align: right; }
.guide-nav small { font-size: 12px; color: var(--ink-faint); }

/* The mandani diagram: positions, not a picture. */
.mandani { margin: 22px 0; display: grid; gap: 14px; }
.md-chaurang, .md-floor {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.md-chaurang { background: var(--surface); border-color: var(--accent-deep); }
.md-label { margin: 0; font-size: 12px; color: var(--ink-faint); }
.md-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }
.md-sides { padding-inline: 4%; }
.md-item { flex: 1 1 0; min-width: 84px; display: grid; gap: 1px; justify-items: center; text-align: center; padding: 8px 6px; border-radius: 10px; background: var(--ground); }
.md-item span { font-family: var(--dev-font); font-size: 15px; line-height: 1.4; }
.md-item small { font-size: 11.5px; color: var(--ink-dim); line-height: 1.3; }
.md-murti { flex-grow: 1.6; background: var(--wash); outline: 1px solid var(--accent-deep); }
.md-murti span { color: var(--accent); font-size: 17px; }
.md-thali { padding: 12px 14px; border-radius: 999px; border: 1px dashed var(--accent-deep); text-align: center; }
.md-thali p { margin: 0; font-size: 13.5px; color: var(--ink-dim); }
.md-thali .md-label { margin-bottom: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
