/*
 * Theme tokens. Three directions, switchable at runtime via <html data-theme="…" data-scheme="light|dark">
 * (set by js/theme.js before first paint). Components in styles.css only use these variables.
 *
 *   meadow  – soft pastel and rounded (sage, apricot, lavender). Default.
 *   journal – warm paper journal (cream paper, ink blue, terracotta, serif headings).
 *   dusk    – deep calm night (indigo to plum, amber lamplight). Always dark.
 */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("../fonts/atkinson-hyperlegible-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("../fonts/nunito-var.woff2") format("woff2");
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-var.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Figtree";
  src: url("../fonts/figtree-var.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- Shared defaults (also the no-JS fallback = Meadow light) ---------- */
:root {
  --font-body: "Atkinson Hyperlegible", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-display: "Nunito", "Atkinson Hyperlegible", ui-rounded, system-ui, -apple-system, sans-serif;
  --display-weight: 800;
  --display-tracking: -0.02em;

  --radius: 22px;
  --radius-sm: 14px;
  --radius-btn: 16px;
  --radius-input: 14px;
  --radius-rating: 16px;

  --space: 16px;
  --nav-h: calc(68px + env(safe-area-inset-bottom, 0px));
  --tap: 48px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  color-scheme: light;
}

/* Meadow · light (also on [data-theme="meadow"] so previews can use it anywhere) */
:root,
[data-theme="meadow"] {
  --bg: #f4f6ef;
  --bg-2: #e9eee4;
  --bg-image:
    radial-gradient(60% 40% at 100% 0%, rgba(250, 214, 186, 0.55), transparent 70%),
    radial-gradient(55% 35% at 0% 18%, rgba(196, 230, 210, 0.6), transparent 70%),
    radial-gradient(50% 30% at 90% 70%, rgba(221, 212, 245, 0.45), transparent 70%);
  --surface: #fffefb;
  --surface-2: #f6f8f2;
  --field-bg: #ffffff;
  --ink: #1f2b26;
  --ink-soft: #4f5d56;
  --line: #dfe6dc;
  --line-strong: #89958b;
  --accent: #2c735c;
  --accent-hover: #235f4b;
  --on-accent: #ffffff;
  --accent-soft: #dcf0e5;
  --accent-ink: #1d5442;
  --gold: #e0a458;
  --gold-soft: #fcefd9;
  --gold-ink: #6b4512;
  --clay: #9a3f2b;
  --clay-soft: #fde3d8;
  --clay-line: #be6d59;
  --lilac-soft: #ebe5fb;
  --focus: #3157b8;
  --header-bg: color-mix(in srgb, var(--bg) 82%, transparent);
  --nav-bg: color-mix(in srgb, var(--surface) 90%, transparent);
  --nav-active-bg: var(--accent-soft);
  --nav-active-ink: var(--accent-ink);
  --shadow: 0 1px 2px rgba(31, 43, 38, 0.05), 0 10px 28px -12px rgba(44, 115, 92, 0.22);
  --shadow-pop: 0 6px 18px -6px rgba(44, 115, 92, 0.45);
  --card-border: 1px solid rgba(31, 43, 38, 0.06);

  --c-focus: #2c735c;
  --c-mood: #c2603d;
  --c-energy: #b07d16;
  --c-sleep: #6b56b8;
  --c-appetite: #2f6f9f;
  --chart-grid: rgba(31, 43, 38, 0.09);
  --chart-text: #4f5d56;
  --chart-band: rgba(44, 115, 92, 0.07);
}

/* ---------- Meadow · dark ---------- */
[data-theme="meadow"][data-scheme="dark"] {
  color-scheme: dark;
  --bg: #121a17;
  --bg-2: #1a2420;
  --bg-image:
    radial-gradient(60% 40% at 100% 0%, rgba(224, 164, 88, 0.12), transparent 70%),
    radial-gradient(55% 35% at 0% 18%, rgba(127, 209, 178, 0.12), transparent 70%),
    radial-gradient(50% 30% at 90% 70%, rgba(170, 150, 240, 0.10), transparent 70%);
  --surface: #1b2521;
  --surface-2: #212d28;
  --field-bg: #15201b;
  --ink: #e8efeb;
  --ink-soft: #a8b8b0;
  --line: #2c3a34;
  --line-strong: #63726b;
  --accent: #7dd3b1;
  --accent-hover: #95e0c2;
  --on-accent: #0c2219;
  --accent-soft: #1d3b30;
  --accent-ink: #a9ebd1;
  --gold: #e8b572;
  --gold-soft: #332b1d;
  --gold-ink: #f4d8ad;
  --clay: #f4a991;
  --clay-soft: #3c2720;
  --clay-line: #a36855;
  --lilac-soft: #29253c;
  --focus: #9cb8ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 6px 18px -6px rgba(125, 211, 177, 0.35);
  --card-border: 1px solid rgba(255, 255, 255, 0.05);
  --c-focus: #7dd3b1;
  --c-mood: #f4a991;
  --c-energy: #e8c06a;
  --c-sleep: #b7a6ff;
  --c-appetite: #86c3f0;
  --chart-grid: rgba(232, 239, 235, 0.09);
  --chart-text: #a8b8b0;
  --chart-band: rgba(125, 211, 177, 0.08);
}

/* ---------- Journal · light (warm paper) ---------- */
[data-theme="journal"] {
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --display-weight: 650;
  --display-tracking: -0.01em;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-btn: 10px;
  --radius-input: 8px;
  --radius-rating: 10px;

  --bg: #f3ecdd;
  --bg-2: #e9e0cc;
  --bg-image:
    repeating-linear-gradient(0deg, rgba(90, 70, 40, 0.025) 0 1px, transparent 1px 3px),
    radial-gradient(80% 50% at 50% 0%, rgba(255, 250, 238, 0.9), transparent 70%);
  --surface: #fffaf0;
  --surface-2: #f8f1e2;
  --field-bg: #fffdf7;
  --ink: #2a2420;
  --ink-soft: #625649;
  --line: #e3d7bf;
  --line-strong: #9c8f78;
  --accent: #2d4a70;
  --accent-hover: #233b5b;
  --on-accent: #fffaf0;
  --accent-soft: #e2e8f1;
  --accent-ink: #213a5a;
  --gold: #c08a2e;
  --gold-soft: #f5e7c4;
  --gold-ink: #5e4210;
  --clay: #9b3d25;
  --clay-soft: #f6e0d4;
  --clay-line: #b96d55;
  --lilac-soft: #ece4f1;
  --focus: #2d4a70;
  --nav-active-bg: transparent;
  --nav-active-ink: var(--clay);
  --shadow: 0 1px 0 rgba(90, 70, 40, 0.08), 0 6px 16px -10px rgba(90, 70, 40, 0.35);
  --shadow-pop: 0 3px 10px -4px rgba(45, 74, 112, 0.45);
  --card-border: 1px solid var(--line);
  --c-focus: #2d4a70;
  --c-mood: #b5532f;
  --c-energy: #96701a;
  --c-sleep: #6c4a8a;
  --c-appetite: #3e7a5a;
  --chart-grid: rgba(90, 70, 40, 0.12);
  --chart-text: #625649;
  --chart-band: rgba(192, 138, 46, 0.09);
}

/* ---------- Journal · dark (lamplight) ---------- */
[data-theme="journal"][data-scheme="dark"] {
  color-scheme: dark;
  --bg: #1d1915;
  --bg-2: #26211b;
  --bg-image:
    repeating-linear-gradient(0deg, rgba(255, 240, 210, 0.018) 0 1px, transparent 1px 3px),
    radial-gradient(80% 50% at 50% 0%, rgba(232, 180, 110, 0.10), transparent 70%);
  --surface: #27221c;
  --surface-2: #2e2821;
  --field-bg: #201c17;
  --ink: #f0e7d8;
  --ink-soft: #c0b29e;
  --line: #3b342b;
  --line-strong: #756c5f;
  --accent: #a9c1e2;
  --accent-hover: #c0d3ec;
  --on-accent: #142033;
  --accent-soft: #2b3545;
  --accent-ink: #c6d7ef;
  --gold: #e0b062;
  --gold-soft: #3a3020;
  --gold-ink: #f2d9a8;
  --clay: #eda38b;
  --clay-soft: #41291f;
  --clay-line: #a56a57;
  --lilac-soft: #2f2834;
  --focus: #c0d3ec;
  --nav-active-ink: var(--clay);
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 8px 18px -12px rgba(0, 0, 0, 0.7);
  --shadow-pop: 0 3px 10px -4px rgba(0, 0, 0, 0.6);
  --c-focus: #a9c1e2;
  --c-mood: #eda38b;
  --c-energy: #e0c070;
  --c-sleep: #c6a6e6;
  --c-appetite: #8fcfa9;
  --chart-grid: rgba(240, 231, 216, 0.1);
  --chart-text: #c0b29e;
  --chart-band: rgba(224, 176, 98, 0.08);
}

/* ---------- Dusk (always dark: deep calm night) ---------- */
[data-theme="dusk"] {
  color-scheme: dark;
  --font-display: "Figtree", "Atkinson Hyperlegible", system-ui, sans-serif;
  --display-weight: 700;
  --display-tracking: -0.025em;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-btn: 999px;
  --radius-input: 14px;
  --radius-rating: 50%;

  --bg: #121430;
  --bg-2: #1b1d40;
  --bg-image:
    radial-gradient(1px 1px at 12% 8%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1px 1px at 78% 4%, rgba(255, 255, 255, 0.45), transparent 60%),
    radial-gradient(1.5px 1.5px at 62% 14%, rgba(255, 233, 196, 0.6), transparent 60%),
    radial-gradient(1px 1px at 30% 22%, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(1px 1px at 90% 30%, rgba(255, 255, 255, 0.3), transparent 60%),
    radial-gradient(70% 45% at 85% 0%, rgba(242, 184, 114, 0.16), transparent 70%),
    linear-gradient(180deg, #121430 0%, #1a1838 45%, #241a3c 100%);
  --surface: #1d2046;
  --surface-2: #252852;
  --field-bg: #171a3b;
  --ink: #eef0ff;
  --ink-soft: #b5b9de;
  --line: #31356a;
  --line-strong: #666b9d;
  --accent: #f4bb78;
  --accent-hover: #f8cb94;
  --on-accent: #2a1806;
  --accent-soft: #3a2f4e;
  --accent-ink: #ffd8a8;
  --gold: #f4bb78;
  --gold-soft: #2c2c58;
  --gold-ink: #e4e2ff;
  --clay: #ffa794;
  --clay-soft: #46284a;
  --clay-line: #ad6c7b;
  --lilac-soft: #2e2c5c;
  --focus: #c8b8ff;
  --header-bg: color-mix(in srgb, #121430 80%, transparent);
  --nav-bg: color-mix(in srgb, #181a3c 88%, transparent);
  --nav-active-bg: var(--accent-soft);
  --nav-active-ink: var(--accent-ink);
  --shadow: 0 1px 1px rgba(0, 0, 0, 0.3), 0 16px 34px -18px rgba(0, 0, 0, 0.8);
  --shadow-pop: 0 0 0 4px rgba(244, 187, 120, 0.18), 0 6px 20px -6px rgba(244, 187, 120, 0.5);
  --card-border: 1px solid rgba(200, 184, 255, 0.10);
  --c-focus: #f4bb78;
  --c-mood: #ff9fb2;
  --c-energy: #ffe08a;
  --c-sleep: #b9a8ff;
  --c-appetite: #7fd6e0;
  --chart-grid: rgba(238, 240, 255, 0.09);
  --chart-text: #b5b9de;
  --chart-band: rgba(185, 168, 255, 0.08);
}
