/* =========================================================
   Latent Space Studio · theme tokens
   ---------------------------------------------------------
   Light lives on :root, dark on :root[data-theme="dark"]
   (theme-boot.js sets the attribute before first paint).
   This file is the only place literal colour values belong.
   Link it before studio.css on every page.

   Warm paper and clay. Text, accent and figure-mark colours
   are chosen to pass tests/theme/contrast.test.js in both
   themes (4.5:1 text, 3:1 accent fill, figure marks, focus).
   ========================================================= */

:root {
  color-scheme: light;

  /* Surfaces */
  --color-bg-base:     #FAF9F5;
  --color-bg-elevated: #F0EEE6;
  --color-bg-node:     #E8E6DC;

  /* Text */
  --color-text-primary:   #141413;
  --color-text-secondary: #3D3D3A;
  --color-text-tertiary:  #646259;   /* labels */

  /* Lines */
  --color-border:      #E2DFD4;
  --color-border-soft: rgba(var(--ink-rgb), 0.07);

  /* Clay accent: fill, text, and their tints */
  --color-accent:         #C8673F;
  --color-accent-text:    #A04428;
  --color-accent-active:  #141413;
  --color-accent-border:  rgba(var(--accent-rgb), 0.45);
  --color-accent-soft:    rgba(var(--accent-rgb), 0.10);
  --color-accent-glow:    rgba(var(--accent-rgb), 0.18);
  --color-on-accent:      #FFFFFF;   /* theme-ok: token value */
  --color-focus-ring:     #B04D2E;

  /* Neutral marks in figures */
  --color-fig-neutral: #86837A;

  /* RGB triplets, for rgba(var(--x-rgb), alpha) */
  --accent-rgb:      200, 103, 63;
  --accent-ink-rgb:  160, 68, 40;
  --ink-rgb:         20, 20, 19;
  --paper-rgb:       250, 249, 245;
  --muted-rgb:       100, 98, 89;
  --fig-neutral-rgb: 134, 131, 122;
  --danger-rgb:      170, 34, 72;
  --warm-rgb:        128, 84, 38;
  --shadow-rgb:      60, 50, 30;
  /* Categorical figure hues (R·022's value families): distinct hues in both themes */
  --fig-cat1-rgb:    160, 68, 40;
  --fig-cat2-rgb:    54, 94, 138;
  --fig-cat3-rgb:    88, 110, 52;

  /* Effects. Numbers and colours the effect scripts read.
     Light reads as calm paper first; the effects register on a second look. */
  --fx-particle-rgb:     var(--warm-rgb);
  --fx-particle-alpha:   0.5;     /* multiplies each particle's own alpha */
  --fx-particle-density: 0.5;     /* multiplies the particle count */
  --fx-grain-opacity:    0.03;
  --fx-warmth-opacity:   0.45;
  --fx-plasma-a:         #F0EEE6;
  --fx-plasma-b:         #E9D8C9;
  --fx-plasma-c:         #DDA98C;
  --fx-plasma-opacity:   0.45;

  /* Landing background scene (the Three.js canvas). Clay and sand, read by
     the inline script in Landing.html. Light is near-flat shading mixed most
     of the way into the paper colour, so it reads as a warm wash on paper. */
  --fx-bg-deep:          #E6DDCE;   /* blob core */
  --fx-bg-mid:           #EADFD0;   /* blob body */
  --fx-bg-clay:          #DFB59A;   /* blob warm patches */
  --fx-bg-glow:          #F2D2BC;   /* second light */
  --fx-bg-rim:           #FAF9F5;   /* rim: dissolves the edge into the paper */
  --fx-bg-halo-a:        #FAF9F5;
  --fx-bg-halo-b:        #F1E6D8;
  --fx-bg-mote-a:        #B98A62;
  --fx-bg-mote-b:        #C8673F;
  --fx-bg-mote-alpha:    0.14;
  --fx-bg-additive:      0;         /* 1 = motes blend additively (dark only) */
  --fx-bg-shade-floor:   0.8;       /* lighting: floor + gain * diffuse */
  --fx-bg-shade-gain:    0.2;
  --fx-bg-mix:           0.55;      /* how far the scene is mixed over the paper */

  /* Type */
  --font-sans:    'DM Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --font-display: 'Geist', sans-serif;
  --font-serif:   'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', ui-monospace, monospace;

  /* Layout and motion */
  --ease-spatial: cubic-bezier(0.16, 1, 0.3, 1);
  --max-w: 1280px;
  --gutter: 40px;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --color-bg-base:     #1F1E1D;
  --color-bg-elevated: #262624;
  --color-bg-node:     #2F2E2B;

  --color-text-primary:   #FAF9F5;
  --color-text-secondary: #C9C7BE;
  --color-text-tertiary:  #9C9A92;

  --color-border: #3A3936;

  --color-accent:        #D97757;
  --color-accent-text:   #E08A6B;
  --color-accent-active: #FAF9F5;
  --color-on-accent:     #1F1E1D;
  --color-focus-ring:    #E08A6B;

  --color-fig-neutral: #7A7870;

  --accent-rgb:      217, 119, 87;
  --accent-ink-rgb:  224, 138, 107;
  --ink-rgb:         250, 249, 245;
  --paper-rgb:       31, 30, 29;
  --muted-rgb:       156, 154, 146;
  --fig-neutral-rgb: 122, 120, 112;
  --danger-rgb:      232, 92, 124;
  --warm-rgb:        218, 172, 96;
  --shadow-rgb:      0, 0, 0;
  --fig-cat1-rgb:    224, 138, 107;
  --fig-cat2-rgb:    122, 162, 206;
  --fig-cat3-rgb:    160, 172, 98;

  /* Dark stays at or below the old intensity (grain 0.05, particles 1, plasma 1) */
  --fx-particle-alpha:   0.9;
  --fx-particle-density: 1;
  --fx-grain-opacity:    0.05;
  --fx-warmth-opacity:   0.8;
  --fx-plasma-a:         #1A1918;
  --fx-plasma-b:         #3B2A21;
  --fx-plasma-c:         #8C4F33;
  --fx-plasma-opacity:   0.9;

  --fx-bg-deep:          #0F0E0D;
  --fx-bg-mid:           #2A2019;
  --fx-bg-clay:          #7A4530;
  --fx-bg-glow:          #A8603F;
  --fx-bg-rim:           #E6C7AD;
  --fx-bg-halo-a:        #161413;
  --fx-bg-halo-b:        #2B1E16;
  --fx-bg-mote-a:        #C9A27F;
  --fx-bg-mote-b:        #E8B79A;
  --fx-bg-mote-alpha:    0.3;
  --fx-bg-additive:      1;
  --fx-bg-shade-floor:   0.18;
  --fx-bg-shade-gain:    0.85;
  --fx-bg-mix:           0.9;
}

@media (max-width: 880px) {
  :root { --gutter: 22px; }
}
