/**
 * soma(som) — Design Tokens v0.1
 * Corporate Identity · WP-CI1 · C1
 *
 * Structure:
 *   1. Brand primitives  (--soma-*)
 *   2. Semantic aliases  (--color-*)
 *   3. Process / Env     (--env-*)
 *   4. Ring units        (--unit-*)
 *   5. Typography        (--text-*, --font-*)
 *   6. Spacing           (--space-*)
 *   7. Radius / Border   (--radius-*, --border-*)
 *   8. Motion            (--ease-*, --dur-*)
 *   9. Elevation / Shadow(--shadow-*)
 */

/* ─────────────────────────────────────────────────────────────────────────────
   1. BRAND PRIMITIVES
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  /* Aquamarine ramp — primary brand color */
  --soma-aqua-950:  #061F28;
  --soma-aqua-900:  #0A2F3C;
  --soma-aqua-800:  #0D3D4E;   /* ◀ Brand primary */
  --soma-aqua-700:  #115162;
  --soma-aqua-600:  #166678;
  --soma-aqua-500:  #1C7D91;
  --soma-aqua-400:  #2A9CB2;
  --soma-aqua-300:  #4DB8CC;
  --soma-aqua-200:  #85D3E0;
  --soma-aqua-100:  #C2EAF0;
  --soma-aqua-050:  #E8F7FA;

  /* Ruby ramp — accent brand color */
  --soma-ruby-950:  #2D060B;
  --soma-ruby-900:  #4A0D14;
  --soma-ruby-800:  #6B121D;   /* ◀ Brand accent */
  --soma-ruby-700:  #821726;
  --soma-ruby-600:  #9C1E2F;
  --soma-ruby-500:  #B82638;
  --soma-ruby-400:  #CE3E50;
  --soma-ruby-300:  #DE6E7A;
  --soma-ruby-200:  #ECA5AE;
  --soma-ruby-100:  #F5D0D5;
  --soma-ruby-050:  #FBF0F1;

  /* Neutral ramp */
  --soma-neutral-950: #0C1014;
  --soma-neutral-900: #161C21;
  --soma-neutral-800: #1E262D;
  --soma-neutral-700: #2C3840;
  --soma-neutral-600: #3D4A54;
  --soma-neutral-500: #546370;
  --soma-neutral-400: #6E7F8C;
  --soma-neutral-300: #94A3AE;
  --soma-neutral-200: #BCC6CC;
  --soma-neutral-100: #DDE2E6;
  --soma-neutral-050: #F2F4F5;
  --soma-white:       #FAFBFC;

  /* Observer-ink — off-both-axes deep indigo.
   * Fork-axis derivation (OPUS §sec:fork + §sec:observer):
   *   ring axis  = aqua  (vertical SOMA)
   *   SOM axis   = ruby  (horizontal presentation)
   *   observer   = entailed by Quad, off both axes — constitutively third hue.
   * Deep indigo-violet: neither aqua nor ruby family. 950-grade.
   * visual-identity-v2 · OT-2019 · VISUAL-IDENTITY-V2-DISCOVERY §3.4
   */
  --soma-observer-ink: #1E1040;
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. SEMANTIC ALIASES
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --color-bg:           var(--soma-white);
  --color-bg-subtle:    var(--soma-neutral-050);
  --color-bg-muted:     var(--soma-neutral-100);
  --color-bg-inverse:   var(--soma-neutral-950);

  /* Borders */
  --color-border:       var(--soma-neutral-200);
  --color-border-strong:var(--soma-neutral-400);

  /* Text */
  --color-text:         var(--soma-neutral-950);
  --color-text-muted:   var(--soma-neutral-500);
  --color-text-subtle:  var(--soma-neutral-400);
  --color-text-inverse: var(--soma-white);
  --color-text-brand:   var(--soma-aqua-800);
  --color-text-accent:  var(--soma-ruby-700);

  /* Interactive */
  --color-primary:      var(--soma-aqua-800);
  --color-primary-hover:var(--soma-aqua-700);
  --color-primary-active:var(--soma-aqua-900);
  --color-accent:       var(--soma-ruby-700);
  --color-accent-hover: var(--soma-ruby-600);
  --color-accent-active:var(--soma-ruby-800);
  --color-focus-ring:   var(--soma-aqua-400);

  /* Observer — off-ring position marker (light surfaces) */
  --color-observer:     rgba(30, 16, 64, 0.75);   /* observer-ink at 75% on light */
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg:           var(--soma-neutral-950);
    --color-bg-subtle:    var(--soma-neutral-900);
    --color-bg-muted:     var(--soma-neutral-800);
    --color-bg-inverse:   var(--soma-white);

    --color-border:       var(--soma-neutral-700);
    --color-border-strong:var(--soma-neutral-500);

    --color-text:         var(--soma-neutral-050);
    --color-text-muted:   var(--soma-neutral-300);
    --color-text-subtle:  var(--soma-neutral-400);
    --color-text-inverse: var(--soma-neutral-950);
    --color-text-brand:   var(--soma-aqua-300);
    --color-text-accent:  var(--soma-ruby-300);

    --color-primary:      var(--soma-aqua-400);
    --color-primary-hover:var(--soma-aqua-300);
    --color-primary-active:var(--soma-aqua-500);
    --color-accent:       var(--soma-ruby-400);
    --color-accent-hover: var(--soma-ruby-300);
    --color-accent-active:var(--soma-ruby-500);
    --color-focus-ring:   var(--soma-aqua-300);

    /* Observer — dark projection of observer-ink; stays in indigo-violet family
     * (fork:indigo, hue ~268°). rgba(160,140,220,0.85) ≈ 5.1:1 on neutral-950.
     * Contrast assumes placement on --color-bg; do not use over bg-subtle/bg-muted
     * without recomputing (alpha-composite is surface-dependent). */
    --color-observer:     rgba(160, 140, 220, 0.85);
  }
}

/* ─────────────────────────────────────────────────────────────────────────────
   3. PROCESS / ENVIRONMENT COLORS
   Derived from brand hues — not generic traffic-light red/yellow/green
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  /* Error / Alert — ruby-derived red, vivid but brand-coherent */
  --env-error-bg:     #FBF0F1;
  --env-error-border: #DE6E7A;
  --env-error-text:   #6B121D;
  --env-error-icon:   #9C1E2F;

  /* Warning — amber/ochre, warm neutral, complements aqua */
  --env-warn-bg:      #FDF8EC;
  --env-warn-border:  #D4A84B;
  --env-warn-text:    #6B4A0A;
  --env-warn-icon:    #B7841F;

  /* Success / OK — deep teal-green, echoes aquamarine */
  --env-ok-bg:        #EAF5F0;
  --env-ok-border:    #3DAA7E;
  --env-ok-text:      #0F4832;
  --env-ok-icon:      #1A7A54;

  /* Info — aqua mid, native brand token */
  --env-info-bg:      var(--soma-aqua-050);
  --env-info-border:  var(--soma-aqua-300);
  --env-info-text:    var(--soma-aqua-900);
  --env-info-icon:    var(--soma-aqua-600);

  /* Neutral / idle state */
  --env-neutral-bg:   var(--soma-neutral-050);
  --env-neutral-border:var(--soma-neutral-300);
  --env-neutral-text: var(--soma-neutral-700);
  --env-neutral-icon: var(--soma-neutral-500);
}

/* ─────────────────────────────────────────────────────────────────────────────
   4. RING UNIT COLORS — fork-axis anchoring (OT-2023)
   Substrate: VISUAL-IDENTITY-V2-DISCOVERY §3.4 (fork-axis palette theory).
   OPUS canon: v2 §sec:fork + §sec:two-axis.

   Fork axes:
     aqua    = vertical axis SOMA — ring of processing units (default for ring units)
     ruby    = horizontal axis SOM — four presentation layers per unit
     neutral = walls / static topology / structural scaffolding
     indigo  = observer (off-both-axes; entailed by Quad, not on ring or SOM)

   Per-unit anchoring:
     FU · WAI  fork:aqua-ring                — foundation / entry; canonical ring anchor
     MU · WIU  fork:aqua-ring                — meaning / deep-ring processing; aqua shifted deepest
     CU · WCN  fork:ruby-presentation-crossing — §3.4 explicit crossing; evaluative core
                                             sits on the presentation fork because it
                                             judges what comes next in output-frame
     OU · WAY  fork:aqua-ring                — auth/identity boundary; ring-canonical
     SU · WAW  fork:neutral-walls-crossing   — SU's motion primitive is GROUND (§3.7:
                                             4-directional grid-snap tick marks). GROUND
                                             is a walls-tier primitive (topology anchor).
                                             SU crosses into the walls-family because
                                             its identity is inseparable from the
                                             static-topology substrate it grounds against.
                                             (Interpretation open; §3.4 does not enumerate
                                             this crossing but the current asset substrate
                                             — soma-hex-unit-su.svg — renders neutral.)
     HU · WDW  fork:ruby-presentation-crossing — §3.4 explicit crossing; lifecycle/hub
                                             sits on the presentation fork because it
                                             affords action (AFFORD primitive is
                                             presentation-adjacent).

   Public-key restraint (§3.4 Q5 AMEND): the fork-axis grounding is INTERNAL
   theory-derivation. Public brand copy MUST NOT teach "aqua = ring / ruby = SOM"
   as a legible reading heuristic — two ring units (CU, HU) legitimately render
   ruby-family and would falsify the naive public key. The public brand signal
   is the four wordmark colours (soma aqua, (som) ruby); the extended per-unit
   hue system is technical-teaching-tier.
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  /* FU — Foundation Unit — WAI: Who Am I?  Entry point. */
  /* fork:aqua-ring */
  --unit-fu:        var(--soma-aqua-800);
  --unit-fu-light:  var(--soma-aqua-100);
  --unit-fu-text:   var(--soma-white);

  /* MU — Meaning Unit — WIU: What Is Up?  Aqua shifted deeper. */
  /* fork:aqua-ring */
  --unit-mu:        var(--soma-aqua-950);
  --unit-mu-light:  var(--soma-aqua-050);
  --unit-mu-text:   var(--soma-white);

  /* CU — Conscience Unit — WCN: What Comes Next?  Evaluative core. */
  /* fork:ruby-presentation-crossing (§3.4 explicit) */
  --unit-cu:        var(--soma-ruby-800);
  --unit-cu-light:  var(--soma-ruby-050);
  --unit-cu-text:   var(--soma-white);

  /* OU — Operator Unit — WAY: Who Are You?  Auth boundary. */
  /* fork:aqua-ring */
  --unit-ou:        var(--soma-aqua-500);
  --unit-ou-light:  var(--soma-aqua-050);
  --unit-ou-text:   var(--soma-white);

  /* SU — Surface Unit — WAW: Where Are We?  Grounded presentation. */
  /* fork:neutral-walls-crossing (GROUND primitive is walls-tier; see header) */
  --unit-su:        var(--soma-neutral-600);
  --unit-su-light:  var(--soma-neutral-050);
  --unit-su-text:   var(--soma-white);

  /* HU — Hub Unit — WDW: When Do What?  Lifecycle, events, orchestration. */
  /* fork:ruby-presentation-crossing (§3.4 explicit) */
  --unit-hu:        var(--soma-ruby-600);
  --unit-hu-light:  var(--soma-ruby-050);
  --unit-hu-text:   var(--soma-white);
}

/* ─────────────────────────────────────────────────────────────────────────────
   5. TYPOGRAPHY
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  /* Font families */
  --font-serif:   'EB Garamond', 'Garamond', 'Georgia', serif;
  --font-display: 'Playfair Display', 'EB Garamond', Georgia, serif;
  --font-mono:    'IBM Plex Mono', 'JetBrains Mono', 'Fira Code', monospace;
  --font-ui:      'EB Garamond', Georgia, serif;  /* UI uses serif — brand coherent */

  /* Scale — 16px base, major-third (1.25) modular scale */
  --text-xs:    0.640rem;   /*  ~10px */
  --text-sm:    0.800rem;   /*  ~13px */
  --text-base:  1.000rem;   /*   16px */
  --text-md:    1.250rem;   /*   20px */
  --text-lg:    1.563rem;   /*   25px */
  --text-xl:    1.953rem;   /*   31px */
  --text-2xl:   2.441rem;   /*   39px */
  --text-3xl:   3.052rem;   /*   49px */
  --text-display: 4.000rem; /*   64px */

  /* Line heights */
  --leading-tight:  1.2;
  --leading-snug:   1.35;
  --leading-normal: 1.6;
  --leading-loose:  1.8;

  /* Weights */
  --weight-regular: 400;
  --weight-medium:  500;
  --weight-semibold:600;
  --weight-bold:    700;

  /* Letter spacing */
  --tracking-tight:  -0.02em;
  --tracking-normal:  0em;
  --tracking-wide:    0.04em;
  --tracking-caps:    0.08em;
}

/* ─────────────────────────────────────────────────────────────────────────────
   6. SPACING — 4px base grid
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --space-1:   0.25rem;  /*  4px */
  --space-2:   0.5rem;   /*  8px */
  --space-3:   0.75rem;  /* 12px */
  --space-4:   1rem;     /* 16px */
  --space-5:   1.25rem;  /* 20px */
  --space-6:   1.5rem;   /* 24px */
  --space-8:   2rem;     /* 32px */
  --space-10:  2.5rem;   /* 40px */
  --space-12:  3rem;     /* 48px */
  --space-16:  4rem;     /* 64px */
  --space-20:  5rem;     /* 80px */
  --space-24:  6rem;     /* 96px */

  /* Editorial layout — §3.8 spatial-grammar (VISUAL-IDENTITY-V2-DISCOVERY) */
  --reading-measure: 72ch;         /* prose line-length cap; Editorial dialect */
  --gap-section:     5.5rem;       /* 88px @ 16px base; Editorial major-section gap */
}

/* ─────────────────────────────────────────────────────────────────────────────
   7. RADIUS / BORDER
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --radius-sm:   2px;
  --radius-md:   4px;
  --radius-lg:   8px;
  --radius-xl:  12px;
  --radius-full:9999px;

  --border-thin:   1px;
  --border-base:   1.5px;
  --border-thick:  2px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   8. MOTION
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --ease-default:  cubic-bezier(0.4, 0, 0.2, 1);
  --ease-in:       cubic-bezier(0.4, 0, 1, 1);
  --ease-out:      cubic-bezier(0, 0, 0.2, 1);
  --ease-spring:   cubic-bezier(0.34, 1.56, 0.64, 1);

  --dur-fast:      100ms;
  --dur-base:      180ms;
  --dur-slow:      300ms;
  --dur-ring:      600ms;   /* ring propagation animations */
}

/* ─────────────────────────────────────────────────────────────────────────────
   9. ELEVATION / SHADOW
   ───────────────────────────────────────────────────────────────────────────── */
:root {
  --shadow-xs:  0 1px 2px 0 rgb(12 16 20 / 0.06);
  --shadow-sm:  0 1px 3px 0 rgb(12 16 20 / 0.10), 0 1px 2px -1px rgb(12 16 20 / 0.10);
  --shadow-md:  0 4px 6px -1px rgb(12 16 20 / 0.10), 0 2px 4px -2px rgb(12 16 20 / 0.10);
  --shadow-lg:  0 10px 15px -3px rgb(12 16 20 / 0.10), 0 4px 6px -4px rgb(12 16 20 / 0.10);
  --shadow-xl:  0 20px 25px -5px rgb(12 16 20 / 0.12), 0 8px 10px -6px rgb(12 16 20 / 0.12);
  --shadow-ring:0 0 0 3px var(--color-focus-ring);
}
