/* =========================================================
   Vedic layer: "from bindu to mandala"
   Light theme = Uṣas (dawn), from Samasta Purāṇa Sāram's ochre and gold.
   Dark theme  = Rātri (night), from The First Principles of Life's indigo and gold.
   Loaded after styles.css; overrides tokens and adds the motifs.
   ========================================================= */

:root {
  --bg: #f4eada;
  --surface: #fbf5ea;
  --ink: #2a1d12;
  --ink-2: #5c4936;
  --muted: #8b765e;
  --line: #e3d2b4;
  --accent: #b0471a;          /* kumkum */
  --accent-ink: #fff8ee;
  --accent-soft: #f6e2c9;
  --gold: #a87a1f;
  --live: #c9661a;
  --live-soft: #f8e3c6;
  --halo: rgba(236, 150, 60, .24);
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "Iowan Old Style", Georgia, serif;
  --deva: "Noto Serif Devanagari", "Tiro Devanagari Sanskrit", "Nirmala UI", "Kohinoor Devanagari", "Devanagari Sangam MN", Mangal, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1028; --surface: #161838; --ink: #f1e5cc; --ink-2: #cbbd9f; --muted: #958da9;
    --line: #2b2d5a; --accent: #eea04a; --accent-ink: #1b1222; --accent-soft: #29254a;
    --gold: #e2b458; --live: #f2a541; --live-soft: #2c2445; --halo: rgba(126, 136, 255, .14);
  }
}
:root[data-theme="dark"] {
  --bg: #0f1028; --surface: #161838; --ink: #f1e5cc; --ink-2: #cbbd9f; --muted: #958da9;
  --line: #2b2d5a; --accent: #eea04a; --accent-ink: #1b1222; --accent-soft: #29254a;
  --gold: #e2b458; --live: #f2a541; --live-soft: #2c2445; --halo: rgba(126, 136, 255, .14);
}

/* ---------- Atmosphere: dawn glow, paper grain, night stars ---------- */
body {
  background:
    radial-gradient(1100px 620px at 50% -240px, var(--halo), transparent 72%),
    var(--bg);
  position: relative;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1; opacity: .07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .22 0 0 0 0 .1 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body::before { opacity: .55; background-image:
    radial-gradient(1px 1px at 12% 18%, #fff3d6 50%, transparent 51%), radial-gradient(1px 1px at 78% 12%, #fff3d6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 42% 8%, #ffe9b8 50%, transparent 51%), radial-gradient(1px 1px at 88% 44%, #fff3d6 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 62%, #fff3d6 50%, transparent 51%), radial-gradient(1.5px 1.5px at 64% 72%, #ffe9b8 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 88%, #fff3d6 50%, transparent 51%), radial-gradient(1px 1px at 52% 36%, #fff3d6 50%, transparent 51%),
    radial-gradient(1px 1px at 94% 82%, #fff3d6 50%, transparent 51%), radial-gradient(1px 1px at 34% 92%, #fff3d6 50%, transparent 51%);
  }
}
:root[data-theme="dark"] body::before { opacity: .55; background-image:
  radial-gradient(1px 1px at 12% 18%, #fff3d6 50%, transparent 51%), radial-gradient(1px 1px at 78% 12%, #fff3d6 50%, transparent 51%),
  radial-gradient(1.5px 1.5px at 42% 8%, #ffe9b8 50%, transparent 51%), radial-gradient(1px 1px at 88% 44%, #fff3d6 50%, transparent 51%),
  radial-gradient(1px 1px at 22% 62%, #fff3d6 50%, transparent 51%), radial-gradient(1.5px 1.5px at 64% 72%, #ffe9b8 50%, transparent 51%),
  radial-gradient(1px 1px at 8% 88%, #fff3d6 50%, transparent 51%), radial-gradient(1px 1px at 52% 36%, #fff3d6 50%, transparent 51%),
  radial-gradient(1px 1px at 94% 82%, #fff3d6 50%, transparent 51%), radial-gradient(1px 1px at 34% 92%, #fff3d6 50%, transparent 51%);
}

/* ---------- Header: the SK mark becomes a small chakra ---------- */
.mark { position: relative; border-color: var(--gold); color: var(--ink); }
.mark::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 1px dashed var(--gold); opacity: .75; animation: v-spin 48s linear infinite;
}
@keyframes v-spin { to { transform: rotate(360deg); } }

/* Menu: English label, Sanskrit caption that turns into English on hover */
.menu-s { display: grid; font: 400 .82rem/1.15 var(--deva); letter-spacing: 0; text-transform: none; color: var(--gold); }
.menu-s > span { grid-area: 1 / 1; transition: opacity .35s ease, transform .35s ease; white-space: nowrap; }
.menu-s .s-en { font: 500 .6rem/1.9 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); opacity: 0; transform: translateY(4px); }
.menu-item:hover .s-deva, .menu-item:focus-visible .s-deva { opacity: 0; transform: translateY(-4px); }
.menu-item:hover .s-en, .menu-item:focus-visible .s-en { opacity: 1; transform: none; }
.menu-item[aria-current="page"]::after { background: linear-gradient(90deg, transparent, var(--accent), transparent); }

/* ---------- Type accents ---------- */
.eyebrow, .section-title span, .label, .kicker, .news-title, .detour-tag { color: var(--gold); }
.hero-x em, .story-head h1 em { color: var(--accent); }
.flow p:first-of-type::first-letter { color: var(--gold); }
[lang="sa"] { font-family: var(--deva); }

/* ---------- Lotus dividers between sections ---------- */
.section + .section, .site-footer, .flow { border-top: 0; }
.section + .section, .site-footer { position: relative; }
.section + .section::before, .site-footer::before {
  content: ""; position: absolute; top: 0; left: 50%; width: min(100%, 68rem); height: 1px; transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 42%, transparent 46%, transparent 54%, var(--line) 58%, var(--line) 82%, transparent);
}
.section + .section::after, .site-footer::after {
  content: ""; position: absolute; top: -11px; left: 50%; width: 56px; height: 22px; transform: translateX(-50%);
  background: var(--gold); opacity: .9;
  -webkit-mask: var(--lotus) center / contain no-repeat; mask: var(--lotus) center / contain no-repeat;
}
:root {
  --lotus: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 24'%3E%3Cpath d='M32 1C36.5 7 36.5 15 32 22C27.5 15 27.5 7 32 1Z M32 22C24 20 19 14 18 6C25 8.5 30 14 32 22Z M32 22C40 20 45 14 46 6C39 8.5 34 14 32 22Z M32 22C20 23.5 11 18.5 5 12C14.5 11.5 25 15 32 22Z M32 22C44 23.5 53 18.5 59 12C49.5 11.5 39 15 32 22Z'/%3E%3C/svg%3E");
}
.flow { position: relative; padding-top: 3.25rem; }
.flow::before {
  content: ""; position: absolute; top: 0; left: 50%; width: 56px; height: 22px; transform: translateX(-50%);
  background: var(--gold); -webkit-mask: var(--lotus) center / contain no-repeat; mask: var(--lotus) center / contain no-repeat;
}

/* ---------- Surfaces ---------- */
.card, .run, .news-card, .chain, .story-stats li {
  box-shadow: 0 1px 0 var(--line), 0 22px 44px -34px rgba(90, 45, 10, .45);
}
.run { border-color: color-mix(in srgb, var(--gold) 45%, var(--line)); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { opacity: .92; }
.tag { background: var(--accent-soft); color: var(--accent); }

/* ---------- The diya: every "live" light is a small flame ---------- */
.dot, .tag .live-dot {
  width: .58rem; height: .58rem; border-radius: 50% 0 50% 50%; transform: rotate(-45deg);
  background: radial-gradient(circle at 62% 38%, #fff6cf 0 22%, #ffc54d 46%, #e8641c 100%);
  box-shadow: 0 0 10px 2px rgba(255, 170, 60, .5);
  animation: v-flame 1.7s ease-in-out infinite;
}
.status { color: var(--live); background: var(--live-soft); }
@keyframes v-flame {
  0%, 100% { transform: rotate(-45deg) scale(1); box-shadow: 0 0 10px 2px rgba(255,170,60,.5); }
  30% { transform: rotate(-41deg) scale(1.12, .94); box-shadow: 0 0 14px 3px rgba(255,170,60,.62); }
  62% { transform: rotate(-49deg) scale(.94, 1.07); box-shadow: 0 0 8px 1px rgba(255,170,60,.42); }
}
.loop li.done::before { color: var(--gold); }

/* ---------- The mandala (built by main.js) ---------- */
.hero, .story-head { position: relative; isolation: isolate; }
.mandala {
  position: absolute; z-index: -1; pointer-events: none; color: var(--gold);
  width: min(560px, 78vw); aspect-ratio: 1; right: -110px; top: 1.5rem; opacity: .5;
}
.story-head .mandala { width: min(380px, 70vw); right: -60px; top: 1rem; opacity: .35; }
.mandala svg { width: 100%; height: 100%; overflow: visible; }
.mandala .m-ln { fill: none; stroke: currentColor; stroke-width: .45; }
.mandala .m-petal { fill: none; stroke: currentColor; stroke-width: .5; }
.mandala .m-bindu { fill: var(--accent); }
.mandala .m-ring-a { transform-origin: 0 0; animation: v-spin 220s linear infinite; }
.mandala .m-ring-b { transform-origin: 0 0; animation: v-spin 300s linear infinite reverse; }
.mandala .m-ring-c { transform-origin: 0 0; animation: v-spin 160s linear infinite; }
.mandala .m-breath { transform-origin: 0 0; animation: v-breath 6s ease-in-out infinite; }
@keyframes v-breath { 0%, 100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.7); opacity: .55; } }
/* bindu → mandala: rings draw outward on first load */
.mandala [pathLength] { stroke-dasharray: 1; stroke-dashoffset: 1; animation: v-draw 2.4s ease-out forwards; }
.mandala .d1 { animation-delay: .2s; } .mandala .d2 { animation-delay: .6s; } .mandala .d3 { animation-delay: 1s; } .mandala .d4 { animation-delay: 1.4s; }
@keyframes v-draw { to { stroke-dashoffset: 0; } }
@media (max-width: 760px) {
  .mandala { right: 50%; transform: translateX(50%); top: -1rem; opacity: .22; width: 120vw; }
  .story-head .mandala { opacity: .18; width: 110vw; }
}

/* ---------- Motes of light rising in the hero ---------- */
.motes { position: absolute; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.mote {
  position: absolute; bottom: -6px; width: 3px; height: 3px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 6px var(--gold); opacity: 0;
  animation: v-rise linear infinite;
}
@keyframes v-rise {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: .7; }
  100% { transform: translate(var(--dx, 12px), -420px); opacity: 0; }
}

/* ---------- Gentle reveal for blocks (classes added by main.js) ---------- */
.rv { opacity: 0; transform: translateY(16px); transition: opacity .9s ease, transform .9s ease; }
.rv.in { opacity: 1; transform: none; }

/* ---------- Writings: the two books ---------- */
.books { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
@media (max-width: 760px) { .books { grid-template-columns: 1fr; } }
.book {
  display: grid; grid-template-columns: 9.5rem 1fr; gap: 1.5rem; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem;
  box-shadow: 0 1px 0 var(--line), 0 22px 44px -34px rgba(90, 45, 10, .45);
}
@media (max-width: 420px) { .book { grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: 1.1rem; } }
.cover {
  position: relative; aspect-ratio: 2 / 3; border-radius: 3px 8px 8px 3px; overflow: hidden;
  box-shadow: inset 6px 0 8px -4px rgba(0,0,0,.35), 0 14px 26px -12px rgba(40, 20, 5, .55);
  transform: perspective(700px) rotateY(-8deg); transition: transform .5s ease;
  display: flex; flex-direction: column; justify-content: space-between; padding: .8rem .7rem; text-align: center;
}
.book:hover .cover { transform: perspective(700px) rotateY(0deg) translateY(-3px); }
.cover-t { font: 600 .82rem/1.15 var(--serif); letter-spacing: .06em; text-transform: uppercase; position: relative; }
.cover-a { font: 500 .5rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; position: relative; opacity: .85; }
.cover .mandala-mini { position: absolute; inset: 22% 10% auto; aspect-ratio: 1; opacity: .9; }
.cover-dawn { background: radial-gradient(120% 80% at 50% 30%, #d99a3a, #a8601c 60%, #6e3a12); color: #fbe6b0; }
.cover-dawn .cover-t { margin-top: .2rem; }
.cover-night { background: radial-gradient(120% 80% at 50% 35%, #2a2d6e, #15173d 70%); color: #f0cf7a; }
.cover-night .mandala-mini { color: #e2b458; }
.book h3 { font: 500 1.3rem/1.25 var(--serif); }
.book .book-sub { font-style: italic; color: var(--ink-2); margin-top: .25rem; font-family: var(--serif); }
.book .book-meta { font: 500 .72rem/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--gold); margin: .8rem 0 .7rem; }
.book p.book-lede { color: var(--ink-2); font-size: .97rem; }
.book .link { display: inline-block; margin-top: .9rem; }

/* ---------- Footer extras ---------- */
.footer-design { color: var(--muted); text-decoration: none; font-size: .85rem; }
.footer-design:hover { color: var(--accent); }

/* ---------- Calm for those who ask for it ---------- */
@media (prefers-reduced-motion: reduce) {
  .mark::after, .dot, .tag .live-dot, .mandala *, .mote { animation: none !important; }
  .mandala [pathLength] { stroke-dashoffset: 0; }
  .rv { opacity: 1; transform: none; transition: none; }
  .cover { transition: none; }
}
.section-title span[lang="sa"] { font: 400 1.05rem/1 var(--deva); letter-spacing: 0; text-transform: none; color: var(--gold); }

/* Design page glossary */
.glossary { margin: 1.5rem 0; display: grid; gap: .9rem; }
.glossary div { display: grid; grid-template-columns: 11rem 1fr; gap: 1rem; padding-bottom: .9rem; border-bottom: 1px dashed var(--line); }
.glossary dt { font: italic 500 1.1rem/1.4 var(--serif); color: var(--ink); }
.glossary dt span { font-style: normal; color: var(--gold); margin-right: .35rem; }
.glossary dd { margin: 0; color: var(--ink-2); }
@media (max-width: 520px) { .glossary div { grid-template-columns: 1fr; gap: .2rem; } }
/* the mandala may bleed off the edge; never let it cause sideways scrolling */
html, body { overflow-x: clip; }

/* Small mandala on the First Principles cover */
.mandala-mini svg { width: 100%; height: 100%; overflow: visible; }
.mandala-mini .m-ln, .mandala-mini .m-petal { fill: none; stroke: currentColor; stroke-width: 1.3; }
.mandala-mini .m-bindu { fill: currentColor; }
.mandala-mini .m-ring-b { transform-origin: 0 0; animation: v-spin 90s linear infinite reverse; }
.mandala-mini .m-ring-c { transform-origin: 0 0; animation: v-spin 60s linear infinite; }
.mandala-mini .m-breath { transform-origin: 0 0; animation: v-breath 6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .mandala-mini * { animation: none !important; } }

/* =========================================================
   White + Space Grotesk (2026-11-17)
   Pure white page; colour only in small touches. Grotesque type throughout.
   ========================================================= */
:root, :root[data-theme="light"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --ink: #121212;
  --ink-2: #474747;
  --muted: #8a8a8a;
  --line: #ebebeb;
  --accent: #b0471a;        /* kumkum */
  --accent-ink: #ffffff;
  --accent-soft: #fbefe7;
  --gold: #a87a1f;
  --live: #c9661a;
  --live-soft: #fdf1e3;
  --halo: transparent;
  --sans: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --serif: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: "Space Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}
body { background: #ffffff; font-family: var(--sans); letter-spacing: -0.005em; }
body::before { display: none; }
.site-header { background: color-mix(in srgb, #ffffff 88%, transparent); }
.theme-toggle { display: none; }

/* Grotesque headlines: tight, confident, no italics (Space Grotesk has none) */
h1, h2, h3, .hero-x, .story-head h1, .section-title, .chapter, .hypothesis, .stop-num, .stats strong,
.detour-what, .news-head, .story-q, .card h3, .book h3, .operator-lede, .yt-title {
  font-family: var(--sans); font-style: normal;
}
.hero-x, .story-head h1 { font-weight: 500; letter-spacing: -0.045em; line-height: .98; }
.section-title, .chapter { font-weight: 500; letter-spacing: -0.03em; }
.hypothesis, .operator-lede, .story-q, .news-head { font-weight: 400; letter-spacing: -0.02em; }
.stop-num, .stats strong { font-weight: 500; letter-spacing: -0.04em; }
em, i { font-style: normal; }
.hero-x em, .story-head h1 em { color: var(--accent); font-weight: 500; }
.prose em, .glossary em { font-weight: 500; color: var(--ink); }

/* Captions and quieter text: calm grotesque instead of serif italics */
figcaption, .flow .ill figcaption, .flow .photo figcaption, .flow .video figcaption, .flow .logo-fig figcaption,
.book .book-sub, .glossary dt {
  font-family: var(--sans) !important; font-style: normal !important; font-weight: 400;
  color: var(--muted); letter-spacing: 0;
}
.flow p:last-of-type { font-family: var(--sans); font-style: normal; font-weight: 500; color: var(--ink); font-size: 1.3rem; letter-spacing: -0.02em; }
.flow p { font-size: 1.15rem; line-height: 1.8; }
.flow p:first-of-type::first-letter { font-family: var(--sans); font-weight: 600; }

/* Mono labels use Space Mono */
.eyebrow, .label, .kicker, .news-title, .news-src, .stop-when, .when, .tag, .run-head, .loop li,
.log time, .log-kind, .story-no, .detour-tag, .book-meta, .s-en, .yt-sub, .ill text { font-family: var(--mono); }

/* Cards on white need a touch more definition */
.card, .run, .news-card, .book, .chain { border-color: #e6e6e6; box-shadow: 0 1px 2px rgba(0,0,0,.03), 0 18px 36px -30px rgba(0,0,0,.25); }
.impact { background: #fafafa; }
.loop { background: #fafafa; }
.detour a { background: var(--accent-soft); }
.mandala { opacity: .42; }
@media (max-width: 760px) { .mandala { opacity: .18; } }
