/* Flat, solid colour throughout: no gradients, no glows. */

:root {
  --paper:   #f7f3ec;
  --paper-2: #efe9df;
  --ink:     #17150f;
  --ink-2:   #6a6355;
  --rule:    #ddd5c7;
  --accent:  #8c2f27;

  --e0: #8c2f27;   /* trikona      */
  --e1: #b5623a;   /* ashtakona    */
  --e2: #c08a3e;   /* antardasara  */
  --e3: #5f7a55;   /* bahirdasara  */
  --e4: #3f6377;   /* chaturdasara */

  --stage-bg: #efe9df;

  --ui: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
        system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo,
          monospace;
  --wrap: 1120px;
}

/* Dark is not the light theme inverted. A white-on-black yantra reads as a
   photographic negative; warming the line work to a gilt parchment and taking
   the enclosure fills up in both saturation and luminance makes it read as
   what it is - gold laid on a dark ground. Flat colour still, no glows.

   Two selectors carry the same values. The media query is the default and
   yields to an explicit choice; the attribute is that choice, set from
   localStorage before first paint. Keep the two blocks identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #12110e; --paper-2: #1a1815; --stage-bg: #0e0d0b;
    --ink: #ecdfc2; --ink-2: #a2957e; --rule: #37312a;
    --accent: #e0714f;
    --e0: #e04a30;   /* trikona      */
    --e1: #e5822f;   /* ashtakona    */
    --e2: #e0ab3e;   /* antardasara  */
    --e3: #7dab60;   /* bahirdasara  */
    --e4: #4f92c4;   /* chaturdasara */
  }
}
:root[data-theme="dark"] {
    --paper: #12110e; --paper-2: #1a1815; --stage-bg: #0e0d0b;
    --ink: #ecdfc2; --ink-2: #a2957e; --rule: #37312a;
    --accent: #e0714f;
    --e0: #e04a30;   /* trikona      */
    --e1: #e5822f;   /* ashtakona    */
    --e2: #e0ab3e;   /* antardasara  */
    --e3: #7dab60;   /* bahirdasara  */
    --e4: #4f92c4;   /* chaturdasara */
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 64px; }

body {
  margin: 0;
  background: var(--paper); color: var(--ink);
  font-family: var(--ui); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.18; letter-spacing: -0.015em; }
b { font-weight: 600; }

/* ---------------------------------------------------------------- icons */
/* Phosphor, regular weight, inlined as a sprite. They take the colour of the
   text they sit beside, so nothing needs restating per theme. */
.i {
  width: 1em; height: 1em; flex: 0 0 auto;
  fill: currentColor; vertical-align: -0.13em;
  margin-right: .45em;
}
.tool-label .i { width: 1.15em; height: 1.15em; opacity: .75; }
.card b .i { width: 1.15em; height: 1.15em; color: var(--accent); }
.topbar nav a { display: inline-flex; align-items: center; }
.segmented button { display: inline-flex; align-items: center; justify-content: center; }
.segmented button .i { margin-right: .35em; }

/* --------------------------------------------------------------- topbar */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 0 24px; height: 56px;
  background: var(--paper); border-bottom: 1px solid var(--rule);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 600; font-size: 15px; color: var(--ink); text-decoration: none;
}
/* the downward triangle - Shakti's, and the figure's dominant read */
.mark {
  width: 17px; height: 15px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}
.topbar nav { display: flex; gap: 22px; }
.topbar nav a {
  font-size: 13.5px; color: var(--ink-2); text-decoration: none;
  white-space: nowrap;
}
.topbar nav a:hover { color: var(--ink); }

/* ----------------------------------------------------------------- hero */

.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 56px; align-items: center;
  max-width: var(--wrap); margin: 0 auto; padding: 72px 24px 88px;
}
.hero-art { display: flex; justify-content: center; }
.hero-art > div { width: 100%; max-width: 460px; aspect-ratio: 1; }
.hero-art svg { width: 100%; height: 100%; }

.eyebrow {
  margin: 0 0 14px; font-size: 11.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2);
}
.hero h1 { margin: 0 0 20px; font-size: clamp(34px, 5vw, 52px); font-weight: 600; }
.sub { margin: 0 0 28px; font-size: 16.5px; color: var(--ink-2); max-width: 46ch; }
.sub b { color: var(--ink); font-family: var(--mono); font-size: 15px; }

.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 500; text-decoration: none;
  color: var(--ink); border: 1px solid var(--rule); background: var(--paper);
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }

/* ---------------------------------------------------------------- bands */

.band { padding: 72px 0; border-top: 1px solid var(--rule); }
.band.alt { background: var(--paper-2); }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.wrap.narrow { max-width: 720px; }

.band h2 { margin: 0 0 16px; font-size: clamp(25px, 3.2vw, 34px); font-weight: 600; }
.band h3 {
  margin: 40px 0 12px; font-size: 13px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
}
.intro { margin: 0 0 36px; font-size: 16.5px; color: var(--ink-2); max-width: 62ch; }

/* ---------------------------------------------------------------- stage */

.stage-wrap { display: flex; justify-content: center; }
.stage {
  width: 100%; max-width: 620px; aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
}
.stage-wrap.tall .stage {
  max-width: 100%; aspect-ratio: 16 / 9;
  border: 1px solid var(--rule); border-radius: 12px;
}
.stage svg { width: 100%; height: 100%; }
.stage.dark { background: var(--stage-bg); }
#gl { width: 100%; height: 100%; display: block; touch-action: none; }
.loading {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 13px; color: var(--ink-2); pointer-events: none;
}
.loading.done { display: none; }

/* -------------------------------------------------------------- toolbar */

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px 28px;
  margin: 28px 0 8px; padding: 16px 18px;
  border: 1px solid var(--rule); border-radius: 12px;
}
.tool { display: flex; align-items: center; gap: 12px; }
.tool.grow { flex: 1 1 auto; }
.tool-label {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-2); white-space: nowrap;
}
.hint { margin: 0; font-size: 12px; color: var(--ink-2); }
.ghost {
  font: inherit; font-size: 13px; padding: 6px 13px; cursor: pointer;
  color: var(--ink-2); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 999px;
}
.ghost:hover { color: var(--ink); border-color: var(--ink-2); }
.ghost.icon-only { padding: 6px; line-height: 0; border-radius: 50%; }
.ghost.icon-only .i { margin: 0; width: 1.05rem; height: 1.05rem; }
.topbar nav { align-items: center; }

select {
  font: inherit; font-size: 13.5px; padding: 7px 10px;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 7px;
}

.pills { display: flex; flex-wrap: wrap; gap: 7px; }
.pills label { cursor: pointer; }
.pills input { position: absolute; opacity: 0; pointer-events: none; }
.pills span {
  display: inline-block; padding: 6px 13px; border-radius: 999px;
  font-size: 13px; color: var(--ink-2);
  border: 1px solid var(--rule); background: var(--paper);
}
.pills label:hover span { color: var(--ink); border-color: var(--ink-2); }
.pills input:checked + span {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}
.pills input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented { display: flex; border: 1px solid var(--rule); border-radius: 7px; overflow: hidden; }
.segmented button {
  font: inherit; font-size: 13px; padding: 7px 15px;
  background: var(--paper); color: var(--ink-2);
  border: none; border-right: 1px solid var(--rule); cursor: pointer;
}
.segmented button:last-child { border-right: none; }
.segmented button.on { background: var(--ink); color: var(--paper); }

/* A rail: the chosen option is carried by a solid pill that slides behind
   the labels. Flat colour; the motion is the affordance. */
.rail {
  position: relative; display: flex; padding: 4px; gap: 2px;
  border: 1px solid var(--rule); border-radius: 999px; background: var(--paper);
  max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.rail button { white-space: nowrap; flex: 0 0 auto; }
.rail .thumb {
  position: absolute; background: var(--ink); border-radius: 999px;
  transition: left .22s cubic-bezier(.5, 0, .2, 1),
              width .22s cubic-bezier(.5, 0, .2, 1),
              top .22s cubic-bezier(.5, 0, .2, 1),
              height .22s cubic-bezier(.5, 0, .2, 1);
}
.rail button {
  position: relative; z-index: 1; font: inherit; font-size: 13px;
  padding: 7px 15px; border: none; border-radius: 999px;
  background: transparent; color: var(--ink-2); cursor: pointer;
  display: inline-flex; align-items: center; transition: color .22s;
}
.rail button.on { color: var(--paper); }
.rail button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .rail .thumb, .rail button { transition: none; }
}

/* the sixteen's transport: icon buttons and a per-act progress bar */
.player {
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: center; gap: 7px;
}
.pbtn {
  font: inherit; display: inline-flex; align-items: center;
  justify-content: center; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--paper);
  color: var(--ink-2); cursor: pointer;
}
.pbtn .i { margin: 0; width: 0.95em; height: 0.95em; }
.pbtn:hover { color: var(--ink); border-color: var(--ink-2); }
.pbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pbtn.main {
  width: 42px; height: 42px;
  background: var(--ink); border-color: var(--ink); color: var(--paper);
}
.pbtn.main:hover { background: var(--accent); border-color: var(--accent); }
.pbar {
  flex: 1 1 100%; height: 3px; border-radius: 2px; background: var(--rule);
  overflow: hidden;
}
.pbar i {
  display: block; height: 100%; background: var(--accent);
  transform-origin: left; transform: scaleX(0);
}

/* ----------------------------------------------------------- data bits */

.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; margin-top: 8px; }
.fine { font-size: 13.5px; color: var(--ink-2); margin: 14px 0 0; }

.legend { list-style: none; margin: 0; padding: 0; }
.legend li {
  display: flex; align-items: center; gap: 11px;
  font-size: 14px; padding: 7px 0; border-bottom: 1px solid var(--rule);
}
.legend i { width: 12px; height: 12px; flex: 0 0 auto; border-radius: 3px; }
.legend em { font-style: normal; color: var(--ink-2); font-size: 13px; }
.legend span { margin-left: auto; font-family: var(--mono); font-size: 13px; }

.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 12.5px; }
th, td { text-align: right; padding: 5px 8px; white-space: nowrap; }
th { color: var(--ink-2); font-weight: 500; border-bottom: 1px solid var(--rule); }
td:first-child, th:first-child { text-align: left; }
tbody tr:nth-child(even) { background: rgba(128, 118, 96, .09); }
#verify td:first-child { white-space: normal; font-family: var(--ui); }
#verify .ok { color: var(--e3); }
#verify .no { color: var(--accent); }

/* Nine tiers and six downloads. Auto-fill picks the column count from the
   available width and leaves a stranded card on the last row - 4+4+1 for the
   tiers, 4+2 for the downloads. Both counts have a factor of three, so three
   columns divides them evenly; below that, one. */
.tiers {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: tier;
}
.tiers li {
  padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px;
  font-size: 13.5px; counter-increment: tier;
}
.tiers li::before {
  content: counter(tier); display: block;
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
  margin-bottom: 3px;
}
.tiers li b { display: block; font-weight: 600; }
.tiers li em { font-style: normal; color: var(--ink-2); }

/* The sixteen sit beside the canvas, never below it: the whole point is to
   watch the offering happen while choosing it. */
/* Both columns are pinned to one height. Left to itself the panel's sixteen
   entries set the row height and stretch the canvas into a tall column, which
   crops the mountain; the list scrolls inside instead. */
.meru-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 16px;
  --meru-h: 560px;
}
.meru-layout .stage {
  max-width: none; aspect-ratio: auto; height: var(--meru-h);
  border: 1px solid var(--rule); border-radius: 12px;
}
.puja {
  display: flex; flex-direction: column; min-height: 0; height: var(--meru-h);
  border: 1px solid var(--rule); border-radius: 12px; padding: 16px;
}
/* The panel has a fixed height, so in a column flex box everything above the
   list gets shrunk to make room for it - which squashed the buttons to the
   height of their own padding. Only the list is allowed to give. */
.puja > * { flex: 0 0 auto; }
.puja h3 { display: flex; align-items: center; margin: 0 0 8px; }
.puja .fine { margin: 0 0 14px; }
.puja .player { margin-bottom: 10px; }
.puja .hint { margin: 0 0 12px; min-height: 2.4em; }

.upacharas {
  flex: 1 1 auto !important; overflow-y: auto; min-height: 0;
  display: flex; flex-direction: column; gap: 5px;
  margin: 0; padding: 0 2px 0 0; list-style: none; counter-reset: up;
}
.upacharas li {
  display: flex; gap: 9px; align-items: baseline; cursor: pointer;
  padding: 7px 10px; border: 1px solid var(--rule); border-radius: 8px;
  font-size: 12.5px; counter-increment: up;
}
.upacharas li::before {
  content: counter(up); font-family: var(--mono); font-size: 10.5px;
  color: var(--ink-2); min-width: 1.2em;
}
.upacharas li:hover { border-color: var(--ink-2); }
.upacharas li:focus-visible,
.segmented button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.upacharas li.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.upacharas li.on::before, .upacharas li.on em { color: var(--paper); opacity: .7; }
/* the prose rule `.band li b { color: var(--ink) }` would paint the selected
   card's heading ink-on-ink; the card's own colours must win */
.upacharas li.on b { color: var(--paper); }
.upacharas b { font-weight: 600; }
.upacharas em { font-style: normal; color: var(--ink-2); display: block;
  font-size: 12px; margin-top: 1px; }

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

.band p { margin: 0 0 16px; color: var(--ink-2); }
.band p b, .band li b { color: var(--ink); }
.conds { margin: 0 0 18px; padding-left: 22px; color: var(--ink-2); }
.conds li { margin-bottom: 8px; }
.refs { padding-left: 22px; color: var(--ink-2); font-size: 14px; }
.refs li { margin-bottom: 7px; }
.band a { color: var(--accent); }

/* ------------------------------------------------------------ downloads */

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card {
  display: block; padding: 18px; text-decoration: none;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--paper);
}
.card:hover { border-color: var(--ink); }
.card b { display: flex; align-items: center; font-size: 15px;
  color: var(--ink); margin-bottom: 5px; }
.card span { font-size: 13.5px; color: var(--ink-2); }

/* --------------------------------------------------------------- footer */

footer {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 20px 24px; border-top: 1px solid var(--rule);
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
}
footer a { color: var(--ink-2); }

/* --------------------------------------------------------------- narrow */

@media (max-width: 900px) {
  .meru-layout { grid-template-columns: minmax(0, 1fr); --meru-h: auto; }
  .meru-layout .stage { height: auto; aspect-ratio: 4 / 3; }
  .puja { height: auto; }
  .upacharas { max-height: 280px; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 32px; padding: 44px 24px 60px; }
  .hero-art { order: 2; }
  .cols { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .topbar nav { gap: 14px; }
  .topbar nav a:nth-child(3) { display: none; }
}
@media (max-width: 760px) {
  .tiers, .cards { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  /* the labels cannot fit beside the brand and the two round buttons, and
     wrapping them mid-word is worse - the icons carry the nav alone. The
     text stays in the markup, so screen readers and the language swap keep
     working. */
  .topbar { padding: 0 14px; gap: 10px; }
  .topbar nav { gap: 4px; }
  .topbar nav a { font-size: 0; padding: 8px 7px; }
  .topbar nav a .i { width: 19px; height: 19px; margin: 0; }
  .topbar nav a:nth-child(3) { display: inline-flex; }
}
@media (max-width: 600px) {
  .band { padding: 52px 0; }
  .stage-wrap.tall .stage { aspect-ratio: 4 / 3; }
  .toolbar { flex-direction: column; align-items: stretch; }
  /* A flex item will not shrink below its content by default, so a rail
     wider than the screen pushed the whole page sideways instead of
     scrolling inside its own pill. min-width:0 lets the rail take the
     column width and scroll within it, which is what it was built to do. */
  .tool { flex-direction: column; align-items: flex-start; min-width: 0; max-width: 100%; }
  .tool > .rail, .tool > .segmented, .tool > select { align-self: stretch; min-width: 0; }
  /* The rail is stretched, so let its buttons share the width instead of
     huddling at the left end - two-button rails were leaving over half the
     pill empty. They may grow but never shrink, so a label is never clipped;
     if the set is too wide to fit, the rail scrolls as before. */
  .rail button { flex: 1 0 auto; }
  .segmented { flex-wrap: wrap; }
  .segmented button { flex: 1 1 auto; }
}
