/* ============================================================================
   tokens.css — design system for Samuel Jo's portfolio
   One modern language across the work. Fraunces serif display, Inter UI/body, system mono labels.
   Themes: PAPER (ink on warm paper — the default), FOREST (bottle-green + tan) and INDIGO
   (deep indigo + periwinkle). A pre-paint head script stamps data-theme from the saved pref
   (else Paper); the nav toggle and ⌘K palette switch it live.
   All values flow through CSS custom properties — never hardcode.
   ========================================================================== */

/* ---- Fonts (self-hosted variable woff2) ---- */
@font-face {
  font-family: "Inter Variable";
  src: url("../assets/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces Variable";
  src: url("../assets/fonts/fraunces-latin-v2.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
/* Glyph override: Fraunces' eccentric J/F/j/f (descending-hook J etc.) read off at display
   sizes, so swap just those four for Newsreader's calmer forms via unicode-range. ~4.7KB,
   loads only because those glyphs appear; everything else stays Fraunces. */
@font-face {
  font-family: "Display Override";
  src: url("../assets/fonts/newsreader-jffj.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+004A, U+0046, U+006A, U+0066;
}

:root {
  /* ---- Type families (editorial-modern: Fraunces serif display, Inter UI/body, system mono labels) ---- */
  --font-display: "Display Override", "Fraunces Variable", "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-prose: "Inter Variable", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Menlo", monospace;

  /* ---- Fluid type scale (clamp: min @360px → max @1280px) ---- */
  --fs-2xs: 0.6875rem;                                     /* 11px — mono micro-labels */
  --fs-xs:  clamp(0.75rem, 0.72rem + 0.12vw, 0.8125rem);   /* 12 → 13 */
  --fs-sm:  clamp(0.8125rem, 0.78rem + 0.16vw, 0.9375rem); /* 13 → 15 */
  --fs-base: clamp(1rem, 0.96rem + 0.22vw, 1.125rem);      /* 16 → 18 prose */
  --fs-lg:  clamp(1.0625rem, 1rem + 0.32vw, 1.3125rem);    /* 17 → 21 */
  --fs-xl:  clamp(1.375rem, 1.2rem + 0.85vw, 1.875rem);    /* 22 → 30 */
  --fs-2xl: clamp(1.65rem, 1.35rem + 1.55vw, 2.5rem);      /* 26 → 40 */
  --fs-3xl: clamp(2.1rem, 1.55rem + 2.7vw, 3.5rem);        /* 34 → 56 */
  --fs-display: clamp(2.75rem, 1.6rem + 5.6vw, 5rem);      /* 44 → 80 hero */

  /* ---- Display weights (Fraunces serif display goes light; --w-strong is Inter body bold) ---- */
  --w-display: 360;
  --w-heading: 440;
  --w-strong: 600;

  --lh-tight: 1.02;
  --lh-snug: 1.1;
  --lh-prose: 1.6;
  --tracking-label: 0.14em;   /* mono kickers */
  --tracking-wide: 0.2em;

  /* ---- Spacing (4px base) ---- */
  --s-1: 0.25rem;  --s-2: 0.5rem;  --s-3: 0.75rem; --s-4: 1rem;
  --s-5: 1.5rem;   --s-6: 2rem;    --s-7: 2.5rem;  --s-8: 3rem;
  --s-10: 4rem;    --s-12: 6rem;   --s-16: 8rem;   --s-20: 10rem;

  /* ---- Radii (modern, soft) ---- */
  --r-sm: 7px; --r: 10px; --r-lg: 12px; --r-xl: 16px; --r-pill: 999px;

  /* ---- Layout ---- */
  --maxw: 1080px;
  --maxw-wide: 1180px;
  --prose: 64ch;
  --nav-h: 62px;
  --gutter: clamp(1.25rem, 4vw, 2.75rem);

  /* ---- Motion ---- */
  --t-fast: 130ms;
  --t: 240ms;
  --t-slow: 460ms;
  --t-slower: 760ms;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.2, 1.3, 0.4, 1);

  /* ---- Derived textures ---- */
  --grid-line: color-mix(in srgb, var(--text) 6%, transparent);
  --glass: color-mix(in srgb, var(--bg) 80%, transparent);  /* nav / palette backdrop */
}

/* ============================================================================
   PAPER — default. Ink on warm paper, forest-green accent (the light theme).
   This block owns :root, so it must stay FIRST — the [data-theme] blocks below
   have equal specificity and only win by coming later in source order.
   ========================================================================== */
:root, [data-theme="paper"] {
  color-scheme: light;
  --bg: #fbfaf7;
  --bg-tint: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #f6f3ec;
  --border: #e7e2d8;
  --border-strong: #d6cfc1;
  --rule: #d6cfc1;
  --text: #1a1813;
  --text-dim: #54504a;
  --text-mute: #6f695e;
  --accent: #1f6b49;
  --accent-strong: #175238;
  --accent-tint: rgba(31, 107, 73, 0.09);
  --on-accent: #ffffff;
  --up: #1f7a4d;
  --down: #b23a2e;
  --live: #1f7a4d;
  --felt: #1c5b40;        /* the Play table's cloth (deep casino green on paper) */
  --felt-deep: #113827;   /* its shaded rail/edge */
  --selection: rgba(31, 107, 73, 0.16);
  --shadow-1: 0 1px 0 var(--border);
  --shadow-2: 0 18px 40px rgba(28, 26, 22, 0.10);
  --shadow-3: 0 32px 70px rgba(28, 26, 22, 0.16);
}

/* ============================================================================
   FOREST — the deep bottle-green theme. Cream ink, warm tan/gold accent.
   ========================================================================== */
[data-theme="forest"] {
  color-scheme: dark;
  --bg: #0b1310;
  --bg-tint: #0f1814;
  --surface: #121d17;
  --surface-2: #17241d;
  --border: #243a30;
  --border-strong: #34503f;
  --rule: #34503f;
  --text: #edf1e7;
  --text-dim: #b5bdab;
  --text-mute: #828b79;
  --accent: #e0bc8c;
  --accent-strong: #eccfa3;
  --accent-tint: rgba(224, 188, 140, 0.14);
  --on-accent: #0b1310;
  --up: #5bbf86;
  --down: #e0796b;
  --live: #5bbf86;
  --felt: #16452f;        /* a lit table in the dark bottle-green room */
  --felt-deep: #0d2c1e;
  --selection: rgba(224, 188, 140, 0.22);
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-2: 0 22px 46px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 36px 80px rgba(0, 0, 0, 0.6);
}

/* ============================================================================
   INDIGO — deep indigo-black canvas, periwinkle accent.
   ========================================================================== */
[data-theme="indigo"] {
  color-scheme: dark;
  --bg: #0d0f24;
  --bg-tint: #12152e;
  --surface: #161a33;
  --surface-2: #1c2140;
  --border: #2a2f50;
  --border-strong: #3a4068;
  --rule: #3a4068;
  --text: #ececfb;
  --text-dim: #b3b4d8;
  --text-mute: #8284ab;
  --accent: #a6a2f7;
  --accent-strong: #c4c1fb;
  --accent-tint: rgba(166, 162, 247, 0.16);
  --on-accent: #0d0f24;
  --up: #6fd1a1;
  --down: #e0796b;
  --live: #6fd1a1;
  --felt: #262c5e;        /* indigo house → blue felt */
  --felt-deep: #171c44;
  --selection: rgba(166, 162, 247, 0.24);
  --shadow-1: 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-2: 0 22px 46px rgba(0, 0, 0, 0.45);
  --shadow-3: 0 36px 80px rgba(0, 0, 0, 0.6);
}

/* color-mix() fallback: keep nav/palette/grid from breaking on old engines */
@supports not (color: color-mix(in srgb, white, black)) {
  :root { --grid-line: rgba(127, 127, 127, 0.12); --glass: var(--bg); }
}

/* ---- Live accent tokens the work + case-study pages paint with ----
   Both resolve to the ACTIVE theme's accent, so every project reads in one color language
   (forest → gold, paper → green, indigo → periwinkle). --proj-ink is the higher-contrast
   variant for accent text/marks; --proj the base for fills, rules and glows. The data-proj
   attribute stays on the markup as a semantic tag — it no longer forks the color. */
:root { --proj: var(--accent); --proj-ink: var(--accent-strong); }
