/* ==========================================================
   Guhya — Personal Spiritual Practice
   Pass 3a design tokens.

   LIGHT parchment is the default — the cream of an open book.
   DARK aubergine shrine is the opt-in toggle — the small
   secret world entered through the lotus button.

   Rules: saturated, alive colours · no muted/dusty tones ·
   no gradients on primary text · no shimmer · no plastic gold.
   ========================================================== */

/* ----------------------------------------------------------
   :root / [data-theme="light"] — LIGHT PARCHMENT (default)
   ---------------------------------------------------------- */
:root, [data-theme="light"] {
  /* === SURFACES — warm parchment cream === */
  --color-bg: #f4ecd8;
  --color-surface: #faf3df;
  --color-surface-2: #fdf7e6;
  --color-surface-raised: #fdf7e6;
  --color-surface-offset: #ead9b3;
  --color-surface-dynamic: #e3d0a3;
  --color-divider: #d4be8a;
  --color-border: #c9962b;

  /* === TEXT — deep aubergine ink on cream === */
  --color-text: #3b1b2f;
  --color-text-muted: #6b4e2e;
  --color-text-faint: #a08766;
  --color-text-inverse: #faf3df;
  --color-heading: var(--color-text);

  /* === ACCENTS — saturated, jewel-toned === */
  --color-ruby: #6b1421;             /* deep oxblood */
  --color-ruby-deep: #4f0e18;
  --color-ruby-soft: #8a1f2e;
  --color-ruby-glow: #e7c0c8;

  --color-purple: #3b1b2f;           /* aubergine */
  --color-purple-deep: #2a1322;
  --color-purple-soft: #6b3055;
  --color-purple-glow: #d8c3e6;

  --color-gold: #c9962b;             /* saturated antique gold — NOT yellow */
  --color-gold-deep: #a87a1f;
  --color-gold-bright: #d4a017;
  --color-gold-highlight: #d4a017;
  --color-gold-glow: #f0d77f;

  --color-orange: #c2541e;
  --color-orange-deep: #8a3a14;
  --color-orange-soft: #e07c3a;
  --color-orange-glow: #f3d4b8;

  /* Semantic roles */
  --color-primary: var(--color-ruby);
  --color-primary-hover: var(--color-ruby-deep);
  --color-accent: var(--color-purple);
  --color-accent-hover: var(--color-purple-deep);

  /* === SHADOWS — soft, cream-friendly === */
  --shadow-sm: 0 1px 2px rgba(59, 27, 47, 0.08);
  --shadow-md: 0 6px 16px rgba(59, 27, 47, 0.12);
  --shadow-lg: 0 18px 40px rgba(59, 27, 47, 0.18);
  --shadow-glow: 0 0 32px rgba(201, 150, 43, 0.30);

  /* === TYPE SCALE (fluid) === */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl: clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl: clamp(2.5rem, 1rem + 4vw, 5rem);
  --text-hero: clamp(3rem, 0.5rem + 7vw, 7rem);

  --text-sanskrit: clamp(1.125rem, 0.95rem + 0.9vw, 1.625rem);
  --text-sanskrit-large: clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem);

  /* === SPACING === */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.75rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;
  --space-32: 8rem;

  /* === MISC === */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.25rem;
  --radius-full: 9999px;

  --transition-interactive: 220ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 600ms cubic-bezier(0.16, 1, 0.3, 1);

  --content-narrow: 640px;
  --content-default: 960px;
  --content-wide: 1200px;

  /* === FONTS === */
  --font-display: 'Cormorant Garamond', 'Cardo', Georgia, serif;
  --font-body: 'EB Garamond', 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;
  --font-serif: 'Cormorant Garamond', 'Cardo', Georgia, serif;
  --font-sanskrit: 'Tiro Devanagari Sanskrit', 'Sanskrit Text', 'Noto Sans Devanagari', serif;
  --font-iast: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;

  /* Gold-leaf token kept as a flat saturated gold for legacy classes;
     shimmer animation is disabled below. */
  --color-gold-leaf: #c9962b;
}

/* ==========================================================
   DARK OXBLOOD-VIOLET SHRINE — opt-in toggle only
   Deep merlot / dried-rose: red-dominant but with a real indigo
   undertone so it reads as ruby-jewel rather than blood-brown.
   Rule: R is largest. B is second — always present, never zero.
   G is smallest — keep it low to avoid the brown drift.
   ========================================================== */
[data-theme="dark"] {
  --color-bg: #2e1226;                 /* deep merlot — R 46  G 18  B 38 (R>B>>G) */
  --color-surface: #3d182f;            /* raised merlot — R 61  G 24  B 47 */
  --color-surface-2: #481c36;          /* card — R 72  G 28  B 54 */
  --color-surface-raised: #52203d;
  --color-surface-offset: #3d182f;
  --color-surface-dynamic: #5e2545;
  --color-divider: #4a1d35;
  --color-border: #5e2545;

  --color-text: #e8d5a0;               /* warm saturated gold ink */
  --color-text-muted: #c9a96e;
  --color-text-faint: #8a7048;
  --color-text-inverse: #2e1226;
  --color-heading: var(--color-text);

  --color-ruby: #c93a5e;               /* ruby on dark — jewel, slightly cool */
  --color-ruby-deep: #9e2545;
  --color-ruby-soft: #d96e85;          /* dried-rose glow */
  --color-ruby-glow: #3d0f24;

  /* Purple tokens repointed onto the merlot palette — kept as variable names
     so existing rules continue to work; values now read as deep oxblood-violet. */
  --color-purple: #5e2545;
  --color-purple-deep: #3d182f;
  --color-purple-soft: #7c3458;
  --color-purple-glow: #2a0f1f;

  --color-gold: #d4a017;               /* antique saturated, not pale */
  --color-gold-deep: #b8860b;
  --color-gold-bright: #e8d5a0;
  --color-gold-highlight: #e8d5a0;
  --color-gold-glow: #6b4e1a;

  --color-orange: #e88c52;
  --color-orange-deep: #c2541e;
  --color-orange-soft: #f3b486;
  --color-orange-glow: #4d2a18;

  --color-primary: var(--color-ruby);
  --color-primary-hover: var(--color-ruby-soft);
  --color-accent: var(--color-gold);
  --color-accent-hover: var(--color-gold-bright);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 36px rgba(212, 160, 23, 0.25);

  --color-gold-leaf: #d4a017;
}

/* ==========================================================
   BASE RESET
   ========================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  hanging-punctuation: first last;
  scroll-padding-top: var(--space-16);
}

body {
  min-height: 100dvh;
  line-height: 1.65;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-x: hidden;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }

button { cursor: pointer; background: none; border: none; color: inherit; font: inherit; }
input, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 500;
  text-wrap: balance;
  line-height: 1.15;
  letter-spacing: -0.005em;
  color: var(--color-heading);
}

p, li { text-wrap: pretty; }

a {
  color: var(--color-primary);
  text-decoration-color: rgba(107, 20, 33, 0.3);
  text-underline-offset: 3px;
  transition: color var(--transition-interactive);
}
a:hover { color: var(--color-primary-hover); }

::selection {
  background: var(--color-gold-glow);
  color: var(--color-text);
}

:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

a, button, [role="button"], input, textarea, select {
  transition:
    color var(--transition-interactive),
    background var(--transition-interactive),
    border-color var(--transition-interactive),
    transform var(--transition-interactive),
    box-shadow var(--transition-interactive);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

/* === SANSKRIT TEXT TREATMENT === */
.sanskrit {
  font-family: var(--font-sanskrit);
  font-size: var(--text-sanskrit);
  line-height: 1.9;
  color: var(--color-text);
  white-space: pre-wrap;
  letter-spacing: 0.01em;
}

.iast {
  font-family: var(--font-iast);
  font-style: italic;
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text-muted);
  white-space: pre-wrap;
}

.simple {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--color-text-faint);
  white-space: pre-wrap;
}

.meaning {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--color-text);
  white-space: pre-wrap;
  font-style: italic;
}

/* === GOLD LEAF — flat saturated gold, NO shimmer ===
   Pass 3a kills the 4-stop animated gradient that read as
   plastic. Saturated antique gold, applied as solid colour. */
.gold-leaf {
  color: var(--color-gold);
  background: none;
  -webkit-background-clip: initial;
  background-clip: initial;
  -webkit-text-fill-color: currentColor;
  animation: none;
}

/* ============================================================
   Tool card embedded inside a lesson (e.g. Sandhi generator)
   Pass 3e: keeps interactive tools inside the unit that owns them.
============================================================ */
.learn-toolcard {
  background: linear-gradient(155deg, color-mix(in oklab, var(--color-gold) 14%, var(--color-surface)) 0%, var(--color-surface) 100%);
  border: 1px solid var(--color-gold-deep);
  border-radius: 12px;
  padding: var(--space-4) var(--space-5);
  margin-top: var(--space-5);
}
.learn-toolcard-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-gold-deep);
  margin-bottom: var(--space-2);
}
.learn-toolcard-title {
  margin: 0 0 var(--space-2) 0;
  font-family: var(--font-serif);
  font-size: 1.25rem;
  color: var(--color-ruby);
}
[data-theme="dark"] .learn-toolcard-title { color: var(--color-gold-bright); }
.learn-toolcard-desc {
  margin: 0 0 var(--space-3) 0;
  color: var(--color-text);
  font-family: var(--font-serif);
  line-height: 1.6;
}
.learn-toolcard-btn {
  padding: 8px 18px;
  background: var(--color-ruby);
  color: #faf3df;
  border: none;
  border-radius: 8px;
  font: 600 0.95rem var(--font-serif);
  cursor: pointer;
  transition: background .15s ease;
}
.learn-toolcard-btn:hover { background: var(--color-ruby-deep); }
[data-theme="dark"] .learn-toolcard-btn { background: var(--color-gold); color: var(--color-bg); }
[data-theme="dark"] .learn-toolcard-btn:hover { background: var(--color-gold-bright); }

/* ============================================================
   Pass 3e — Devnote card
   A styled block holding a Devanāgarī line, IAST, translation,
   and source. Used in Guhya, Advaita, kleśa, cakra, avasthā,
   and mantra units. Quieter than a verse, weightier than a note.
============================================================ */
.learn-devnote {
  background: linear-gradient(155deg, color-mix(in oklab, var(--color-ruby) 8%, var(--color-surface)) 0%, var(--color-surface) 100%);
  border-left: 3px solid var(--color-ruby);
  border-radius: 10px;
  padding: var(--space-4) var(--space-5);
  margin-top: var(--space-4);
}
[data-theme="dark"] .learn-devnote {
  background: linear-gradient(155deg, color-mix(in oklab, var(--color-ruby) 18%, var(--color-surface)) 0%, var(--color-surface) 100%);
  border-left-color: var(--color-gold);
}
.learn-devnote-source {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-ruby-deep);
  margin-bottom: var(--space-3);
  font-weight: 600;
}
[data-theme="dark"] .learn-devnote-source { color: var(--color-gold-deep); }
.learn-devnote-deva {
  font-size: 1.55rem;
  line-height: 1.55;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.learn-devnote-iast {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--color-text-muted, var(--color-text));
  margin-bottom: var(--space-3);
}
.learn-devnote-trans {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
}

/* Pass 3e — Guhya + More-to-Come tile colour treatments */
.learn-card--guhya {
  background: linear-gradient(155deg, color-mix(in oklab, var(--color-ruby) 22%, var(--color-surface)) 0%, var(--color-surface) 100%);
  border: 1px solid var(--color-ruby);
}
.learn-card--guhya .learn-card-title { color: var(--color-ruby); }
[data-theme="dark"] .learn-card--guhya {
  background: linear-gradient(155deg, color-mix(in oklab, var(--color-gold) 18%, var(--color-surface)) 0%, var(--color-surface) 100%);
  border-color: var(--color-gold);
}
[data-theme="dark"] .learn-card--guhya .learn-card-title { color: var(--color-gold-bright); }

.learn-card--more {
  background: repeating-linear-gradient(45deg, var(--color-surface) 0 10px, color-mix(in oklab, var(--color-ruby) 6%, var(--color-surface)) 10px 20px);
  border: 1px dashed var(--color-ruby);
  opacity: 0.92;
}
.learn-card--more .learn-card-title { color: var(--color-ruby-deep); font-style: italic; }
[data-theme="dark"] .learn-card--more {
  background: repeating-linear-gradient(45deg, var(--color-surface) 0 10px, color-mix(in oklab, var(--color-gold) 8%, var(--color-surface)) 10px 20px);
  border-color: var(--color-gold-deep);
}
[data-theme="dark"] .learn-card--more .learn-card-title { color: var(--color-gold); }
