/* Aarti, Marigold.

   Light mode carries the festival: warm white, solid marigold blocks, and
   sindoor for the one button that moves you on. Dark mode is for the evening
   aarti beside the lamp: plum night, with marigold only on the line being
   sung. One typeface, Baloo 2, drawn for Devanagari and Latin alike: rounded,
   friendly, and heavy where it needs to be.

   Colour has one job per screen. Home: every aarti card is the same soft
   marigold, so nothing competes with Start aarti. Reader: the title block and
   the line being sung. Text never sits on a pattern, and every pairing below
   meets WCAG AA for its size. */

:root {
  --ground: #fff8ec;
  --surface: #ffffff;
  --surface-2: #fff1d6;
  --ink: #231a2b;
  --ink-dim: #6b5872;
  --ink-faint: #7a6880;
  --line: #f0e2cc;

  --marigold: #ffc53d;
  --on-marigold: #231a2b;
  --sindoor: #d7351e;       /* white text on it is 4.8:1 */
  --on-sindoor: #ffffff;
  --accent: #c2311c;        /* sindoor deep enough to be text: 5.3:1 */

  --hero-bg: var(--marigold);
  --hero-fg: #231a2b;
  --card-bg: #fff1d6;
  --card-fg: #231a2b;
  --tile: #ffffff;          /* a tile sitting on a card */
  --cur-bg: var(--marigold);
  --cur-fg: #231a2b;
  --primary-bg: #231a2b;
  --primary-fg: #fff8ec;
  --display: #d7351e;       /* the wordmark and the 404 digits */
  --focus: #c2311c;

  --font: "Baloo 2", "Mukta", "Nirmala UI", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;

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

:root[data-theme="dark"] {
  --ground: #16111c;
  --surface: #211a29;
  --surface-2: #2a2033;
  --ink: #f6ede4;
  --ink-dim: #b3a4b8;
  --ink-faint: #9a8ba0;
  --line: #342a3d;

  --sindoor: #c93a24;
  --accent: #ffc53d;

  --hero-bg: #2a2033;
  --hero-fg: #ffc53d;
  --card-bg: #211a29;
  --card-fg: #f6ede4;
  --tile: #2a2033;
  --cur-bg: rgba(255, 197, 61, 0.14);
  --cur-fg: #ffc53d;
  --primary-bg: #ffc53d;
  --primary-fg: #231a2b;
  --display: #ffc53d;
  --focus: #ffc53d;
}

: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(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}
body { padding-bottom: env(safe-area-inset-bottom); }

a { color: var(--accent); text-underline-offset: 3px; }
.dim { color: var(--ink-dim); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 15px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, background-color 160ms ease;
}
.btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); font-weight: 700; }
.btn[aria-pressed="true"] { background: var(--marigold); border-color: var(--marigold); color: var(--on-marigold); }
.btn:active { transform: scale(0.97); }

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

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

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

.home-head h1 {
  margin: 10px 0 0;
  font-size: 42px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--display);
}
.tagline { margin: 8px 0 22px; color: var(--ink-dim); font-size: 16px; }

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

.home-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 30px; }
.home-actions .btn.primary { flex: 1 0 100%; min-height: 58px; border-radius: 20px; font-size: 18px; }

.lib-section + .lib-section { margin-top: 32px; }
.lib-section h2 { margin: 0 0 12px; font-size: 20px; font-weight: 700; color: var(--ink); }
/* 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; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 340px) { .cards { grid-template-columns: 1fr; } }
.card {
  height: 100%;
  min-height: 118px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 16px 16px 14px;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--card-fg);
  text-decoration: none;
  transition: transform 120ms ease;
}
:root[data-theme="dark"] .card { border-color: var(--line); }
.card:active { transform: scale(0.98); }
.card-dev { font-size: 20px; font-weight: 700; line-height: 1.2; }
.card-roman { font-size: 13px; font-weight: 600; color: var(--ink-dim); line-height: 1.3; }
.card-meta { font-size: 12px; color: var(--ink-faint); }
.card[hidden], li[hidden] { display: none; }

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

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

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

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

.reader-head { display: grid; gap: 10px; margin-bottom: 18px; }
.reader-head h1 {
  margin: 0;
  display: grid;
  gap: 4px;
  padding: 20px 22px 18px;
  border-radius: 26px;
  background: var(--hero-bg);
  color: var(--hero-fg);
  cursor: pointer; /* opens the order strip */
}
.reader-head .dev { font-size: clamp(28px, 8vw, 38px); font-weight: 800; line-height: 1.15; }
.reader-head .roman { font-size: 14px; font-weight: 600; opacity: 0.8; }
.meta { margin: 0; font-size: 13px; color: var(--ink-faint); }

.pending {
  margin: 0;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.5;
}

.lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.line {
  padding: 12px 14px;
  border-radius: 18px;
  transition: opacity 160ms ease, background-color 160ms ease;
}
.line .dev {
  display: block;
  font-size: calc(23px * var(--scale));
  font-weight: 500;
  line-height: 1.6;
  color: var(--ink);
}
.line .roman {
  display: block;
  margin-top: 2px;
  font-size: calc(14px * var(--scale));
  line-height: 1.5;
  color: var(--ink-dim);
}

/* Script preference. */
: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)); font-weight: 600; color: var(--ink); }

/* Ceremony: the other lines stay readable enough to glance back at mid-song;
   the line being sung is a solid marigold block. */
body.ceremony .line { opacity: 0.5; }
body.ceremony .line.current { opacity: 1; background: var(--cur-bg); }
body.ceremony .line.current .dev { color: var(--cur-fg); font-weight: 700; }
body.ceremony .line.current .roman { color: var(--cur-fg); opacity: 0.85; }

body.study .line { cursor: pointer; }
body.study .line:hover { background: var(--surface-2); }

.meaning {
  margin-top: 10px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface-2);
  font-size: 14.5px;
  line-height: 1.6;
}
.meaning p { margin: 0 0 6px; }
.meaning cite { display: block; font-size: 12px; color: var(--ink-faint); font-style: normal; overflow-wrap: anywhere; }
.meaning .variant { margin-top: 8px; color: var(--ink-dim); font-size: 13.5px; }

.reader-foot { margin-top: 40px; padding-top: 18px; border-top: 1.5px solid var(--line); font-size: 13.5px; }
.reader-foot h2 { margin: 0 0 8px; font-size: 15px; font-weight: 700; color: var(--ink-dim); }
.reader-foot ul { margin: 0; padding-left: 18px; }
.reader-foot li { margin-bottom: 4px; overflow-wrap: anywhere; }

/* 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;
  display: grid;
  gap: 8px;
  padding: 10px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}

.next-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
  padding: 0 20px;
  border-radius: 18px;
  background: var(--sindoor);
  color: var(--on-sindoor);
  text-decoration: none;
  font-size: 15px;
}
.next-pill .label { font-size: 13px; font-weight: 600; opacity: 0.85; }
.next-pill .title { flex: 1; text-align: right; font-weight: 700; }
/* The end of an order is information, not a link, so it goes quiet. */
div.next-pill { background: var(--surface); border: 1.5px solid var(--line); color: var(--ink-dim); }

.control-row { display: flex; gap: 8px; align-items: center; }
.control-row .btn { flex: 1; min-height: 44px; padding: 0 10px; font-size: 14px; }
.tempo-readout { min-width: 56px; text-align: center; font-size: 12px; color: var(--ink-faint); }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--controls-h, 0px) + 16px);
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100vw - 40px);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--ground);
  font-size: 14px;
  font-weight: 600;
}
.toast[hidden] { display: none; }

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

.prose { max-width: 680px; margin: 0 auto; padding: var(--gutter); line-height: 1.65; }
.prose h1 { margin: 12px 0 16px; font-size: 32px; font-weight: 800; line-height: 1.15; color: var(--ink); text-wrap: balance; }
.prose h2 { margin: 30px 0 8px; font-size: 20px; font-weight: 700; }
.prose h3 { margin: 22px 0 6px; font-size: 16px; font-weight: 700; color: var(--ink-dim); }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 6px; }
.prose code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); font-size: 0.9em; }
.prose pre { overflow-x: auto; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); }
.prose pre code { padding: 0; background: none; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 16px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1.5px solid var(--line); vertical-align: top; }
.prose th { color: var(--ink-dim); font-weight: 700; }
/* 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: 1.5px solid var(--line); font-size: 14px; color: var(--ink-dim); }

/* ----------------------------------------------------------- puja guide */

.guide h1 { font-weight: 800; }
.guide h2 { margin-top: 32px; font-size: 21px; font-weight: 700; color: var(--accent); }
.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: 1.5px solid var(--line);
  cursor: pointer;
}
.tasks input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--sindoor); }
.tasks input:checked + span { color: var(--ink-faint); text-decoration: line-through; }

.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: 16px 18px;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--card-fg);
  text-decoration: none;
}
:root[data-theme="dark"] .guide-index a { border-color: var(--line); }
.gi-title { font-size: 19px; font-weight: 700; }
.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: 1.5px solid var(--line); }
.guide-nav a { display: grid; gap: 2px; color: var(--ink); text-decoration: none; font-weight: 600; }
.guide-nav a.next { text-align: right; }
.guide-nav small { font-size: 12px; font-weight: 500; 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); }
.md-chaurang { background: var(--card-bg); }
.md-floor { border: 1.5px solid var(--line); }
.md-label { margin: 0; font-size: 12px; font-weight: 600; 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: 14px; background: var(--tile); }
.md-item span { font-size: 15px; font-weight: 600; line-height: 1.35; }
.md-item small { font-size: 11.5px; color: var(--ink-dim); line-height: 1.3; }
.md-murti { flex-grow: 1.6; background: var(--marigold); color: var(--on-marigold); }
.md-murti small { color: var(--on-marigold); opacity: 0.8; }
.md-thali { padding: 12px 16px; border-radius: 999px; border: 1.5px dashed var(--line); text-align: center; }
.md-thali p { margin: 0; font-size: 13.5px; color: var(--ink-dim); }
.md-thali .md-label { margin-bottom: 2px; }

/* ------------------------------------------------------------------- 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;
  margin-bottom: 20px;
  font-size: clamp(92px, 28vw, 168px);
  font-weight: 800;
  line-height: 1;
  color: var(--display);
}
.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(--marigold); stop-opacity: 0.4; }
.nf-glow-edge { stop-color: var(--marigold); stop-opacity: 0; }
.nf-shadow { fill: rgba(35, 26, 43, 0.18); }
.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: #8a7f76; 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 { margin: 6px 0 12px; font-size: clamp(26px, 6.4vw, 34px); font-weight: 800; line-height: 1.2; color: var(--ink); text-wrap: balance; }
.nf-lede { max-width: 30rem; margin: 0 0 26px; font-size: 16px; line-height: 1.6; 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: 50px;
  padding: 0 18px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 500 16px var(--font);
}
.nf-search input::placeholder { color: var(--ink-faint); }
.nf-home { display: inline-block; min-height: 44px; line-height: 44px; color: var(--ink-dim); font-size: 15px; font-weight: 600; }
.nf-quip { margin: 30px 0 6px; font-size: 14px; color: var(--ink-faint); text-wrap: balance; }
.nf-chant { margin: 0; font-size: 20px; font-weight: 700; color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
  .nf-mouse-head, .nf-crumb { animation: none; }
  .nf-hero:hover .nf-mouse { transform: none; }
}
