/* ==========================================================================
   CognivaSoft — Design tokens
   The single source of truth for colour, type, spacing and motion.

   THEMING
   -------
   Light is the canonical brand expression and is defined on :root.
   Dark is COMPOSED, not inverted: surfaces are re-elevated, the clay action
   colour is lifted so it still passes AA on a dark canvas, and pine moves from
   "the dark section" to "the elevated panel". Every role below exists in both.

   Resolution order: [data-theme] attribute (explicit user choice, set by
   site.js) wins over prefers-color-scheme (system default).
   ========================================================================== */

:root {
  /* --- Brand palette — LIGHT (canonical, unchanged) -----------------------
     Clay + Pine + Bone. Warm, editorial, printerly. Contrast-checked for AA.
     ---------------------------------------------------------------------- */
  --clay:          #b8462a;   /* primary action  — 5.3:1 with white text     */
  --clay-deep:     #93331c;   /* pressed button state                        */
  --accent-text:   #93331c;   /* clay as TEXT — 5.8:1 on bone                */
  --clay-bright:   #d9603a;   /* accents on dark surfaces (large text only)  */
  --clay-wash:     #f6e4dc;   /* tinted surface                              */
  --clay-fg:       #ffffff;   /* text on a clay action                       */
  --clay-hover:    #93331c;
  --clay-hover-fg: #ffffff;

  --pine:          #123a31;   /* dark surface — 11.1:1 with bone text        */
  --pine-deep:     #0b241e;
  --pine-soft:     #1d4f43;
  --pine-wash:     #e2ebe4;

  --ochre:         #e0a02b;   /* small accent text on dark — 5.5:1           */
  --ochre-wash:    #f7e9c9;
  --ochre-ink:     #7a5410;   /* readable ochre-family text on light         */

  /* --- Neutrals ---------------------------------------------------------- */
  --ink:           #121210;   /* warm near-black, primary text               */
  --ink-soft:      #2a2621;
  --muted:         #635d54;   /* secondary text — 6.4:1 on bone              */
  --faint:         #6b6559;   /* metadata — 4.8:1 even over the aurora peak   */
  --bone:          #f5f1e8;   /* page background                             */
  --bone-2:        #ece6d9;   /* alternating band                            */
  --bone-3:        #e2dbcb;
  --line:          #d8d0be;   /* hairlines                                   */
  --line-strong:   #bdb3a0;
  --surface:       #ffffff;   /* cards                                       */
  --surface-2:     #faf8f2;

  /* Text that sits on a dark (pine) band, in either theme */
  --on-dark:       #f5f1e8;
  --on-dark-soft:  rgba(245, 241, 232, 0.78);
  --on-dark-muted: rgba(245, 241, 232, 0.62);
  --on-dark-line:  rgba(245, 241, 232, 0.18);

  /* --- Semantic roles ---------------------------------------------------- */
  --bg:            var(--bone);
  --bg-alt:        var(--bone-2);
  --text:          var(--ink);
  --text-muted:    var(--muted);
  --border:        var(--line);
  --accent:        var(--clay);
  --link:          var(--accent-text);
  --focus:         #1d4f43;
  --scrollbar:     #c06a34;   /* Firefox flat fallback (clay→ochre midpoint) */
  --scrollbar-hover: var(--line-strong);

  --shadow-color:  18, 18, 16;   /* tinted to the background hue, not black  */
  --shadow-alpha:  0.16;

  color-scheme: light;

  /* --- Typography --------------------------------------------------------
     One family does the whole page. Archivo is a variable grotesque with a
     real width axis (62–125), so the display voice is the SAME typeface
     stretched wide — not a second family bolted on. Mono is reserved for
     numerals, metrics and metadata; it is never used as decoration.
     ---------------------------------------------------------------------- */
  --font-display: "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-body:    "Archivo", "Helvetica Neue", Arial, system-ui, sans-serif;
  --font-mono:    "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --wdth-display: 112%;   /* expanded — headlines                            */
  --wdth-body:    100%;   /* normal   — running text                         */

  /* Fluid type scale — clamp(min, preferred, max). Display caps at 6rem. */
  --fs-mega:  clamp(2.6rem, 1.15rem + 5.6vw, 6rem);
  --fs-h1:    clamp(2.15rem, 1.3rem + 3.6vw, 4rem);
  --fs-h2:    clamp(1.75rem, 1.2rem + 2.2vw, 2.9rem);
  --fs-h3:    clamp(1.28rem, 1.08rem + 0.9vw, 1.75rem);
  --fs-h4:    clamp(1.05rem, 1rem + 0.35vw, 1.22rem);
  --fs-lead:  clamp(1.05rem, 0.98rem + 0.42vw, 1.25rem);
  --fs-body:  1rem;
  --fs-small: 0.875rem;
  --fs-micro: 0.75rem;

  --lh-tight: 1.02;   /* display — clears descenders                         */
  --lh-snug:  1.12;
  --lh-body:  1.62;

  --measure:  68ch;   /* 65–75ch reading measure                             */
  --tracking-display: -0.035em;   /* floor is -0.04em                        */
  --tracking-label:   0.14em;

  /* --- Spacing (8px base, named by intent) -------------------------------- */
  --space-3xs: 0.25rem;
  --space-2xs: 0.5rem;
  --space-xs:  0.75rem;
  --space-s:   1rem;
  --space-m:   1.5rem;
  --space-l:   2.25rem;
  --space-xl:  3.5rem;
  --space-2xl: 5rem;
  --space-3xl: 7.5rem;

  --section-y: clamp(4rem, 2rem + 7vw, 8.5rem);

  /* --- Layout ------------------------------------------------------------- */
  --container:      1240px;
  --container-wide: 1480px;
  --gutter:         clamp(1.25rem, 0.6rem + 2.4vw, 3rem);
  --header-h:       72px;   /* cap is 80px */

  /* --- Shape ---------------------------------------------------------------
     Documented radius rule, followed everywhere:
       interactive (buttons, chips, pills) → full pill
       containers  (cards, panels, media)  → 16px
       inputs                              → 8px
       hairline details                    → 4px
     ---------------------------------------------------------------------- */
  --radius-s:  4px;
  --radius-m:  8px;
  --radius-l:  16px;
  --radius-pill: 100px;

  --shadow-s: 0 1px 2px rgba(var(--shadow-color), 0.06);
  --shadow-m: 0 8px 20px -10px rgba(var(--shadow-color), var(--shadow-alpha));
  --shadow-l: 0 24px 56px -26px rgba(var(--shadow-color), calc(var(--shadow-alpha) + 0.08));

  /* --- Motion ---------------------------------------------------------------
     Curves are taken from the animation reference, not hand-rolled.
     ease-out for entrances and exits, ease-in-out for on-screen movement,
     plain ease for hover and colour. ease-in is never used on UI. */
  --ease-out:    cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease:        ease;

  --dur-press: 120ms;   /* button press feedback   */
  --dur-fast:  160ms;   /* hover, colour           */
  --dur:       240ms;   /* small UI transitions    */
  --dur-slow:  620ms;   /* the authored entrance   */

  /* --- Z-index scale (documented; nothing outside this list) --------------- */
  --z-base:    0;
  --z-sticky:  20;   /* in-page jump nav        */
  --z-header: 100;
  --z-menu:   110;   /* mobile nav sheet        */

  /* --- Gradients & glass (light) --------------------------------------------
     Every gradient is built from the existing brand tokens, so the palette
     stays exactly as approved. Text gradients run dark → clay so BOTH ends
     clear AA; they never run into ochre, which is too light to read on bone. */
  --grad-action:  linear-gradient(180deg, var(--clay) 0%, var(--clay-deep) 100%);
  --grad-display: linear-gradient(102deg, var(--ink) 0%, var(--ink) 30%, var(--accent-text) 100%);
  --grad-accent:  linear-gradient(135deg, var(--clay) 0%, var(--ochre) 100%);
  --grad-pine:    linear-gradient(165deg, var(--pine-soft) 0%, var(--pine) 55%, var(--pine-deep) 100%);
  --grad-cta:     linear-gradient(150deg, #c95632 0%, var(--clay) 45%, #8f3218 100%);

  --glass-bg:     rgba(255, 255, 255, 0.58);
  --glass-edge:   rgba(255, 255, 255, 0.85);
  --glass-blur:   14px;

  /* Ambient wash strength. Kept low so it never moves text contrast. */
  --aura: 0.09;
}

/* ==========================================================================
   DARK — composed, not inverted.

   The canvas is a warm near-black that keeps the paper warmth of the light
   theme rather than going cold grey. Surfaces step UP in lightness to signal
   elevation. Clay is lifted just enough to hold AA against white button text
   and to separate from the canvas; pine stops being "the dark band" and
   becomes an elevated green panel that still reads as the brand.
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --clay:          #c74a2b;   /* action bg — white text 4.7:1, vs bg 4.0:1 */
    --clay-deep:     #b8462a;
    --accent-text:   #ec8a64;   /* 7.5:1 on the dark canvas                  */
    --clay-bright:   #ec8a64;   /* links & accents on dark — 7.5:1           */
    --clay-wash:     #2f1a12;
    --clay-fg:       #ffffff;
    --clay-hover:    #d95a37;   /* the button brightens, then takes ink text */
    --clay-hover-fg: #1b0e08;

    --pine:          #14352e;
    --pine-deep:     #0f2a23;
    --pine-soft:     #2f6153;
    --pine-wash:     #17302a;

    --ochre:         #e8b04a;
    --ochre-wash:    #33280f;
    --ochre-ink:     #e8b04a;

    --ink:           #f2ede3;
    --ink-soft:      #ddd6c8;
    --muted:         #a79e8e;   /* 7.1:1 on canvas                           */
    --faint:         #a09685;   /* 4.9:1 even over the aurora peak            */
    --bone:          #14120f;   /* canvas — warm off-black, never #000       */
    --bone-2:        #1b1815;   /* alternating band                          */
    --bone-3:        #232019;
    --line:          #302b24;
    --line-strong:   #473f35;
    --surface:       #1b1815;   /* cards sit above the canvas                */
    --surface-2:     #221e19;

    --link:          var(--accent-text);
    --focus:         #7fc3ac;
    --scrollbar:     #d07a3d;
    --scrollbar-hover: #4d453a;

    --shadow-color:  0, 0, 0;
    --shadow-alpha:  0.5;


    --grad-action:  linear-gradient(180deg, #d4522f 0%, var(--clay) 100%);
    --grad-display: linear-gradient(102deg, var(--ink) 0%, var(--ink) 30%, var(--accent-text) 100%);
    --grad-accent:  linear-gradient(135deg, var(--clay-bright) 0%, var(--ochre) 100%);
    --grad-pine:    linear-gradient(165deg, #1b463b 0%, var(--pine) 55%, var(--pine-deep) 100%);
    --grad-cta:     linear-gradient(150deg, #d0512c 0%, var(--clay) 45%, #8d3218 100%);

    --glass-bg:     rgba(38, 33, 28, 0.55);
    --glass-edge:   rgba(245, 241, 232, 0.10);
    --glass-blur:   14px;

    --aura: 0.10;

    color-scheme: dark;
  }
}

/* Explicit user choice — same values, higher specificity than the media query. */
:root[data-theme="dark"] {
  --clay:          #c74a2b;
  --clay-deep:     #b8462a;
  --accent-text:   #ec8a64;
  --clay-bright:   #ec8a64;
  --clay-wash:     #2f1a12;
  --clay-fg:       #ffffff;
  --clay-hover:    #d95a37;
  --clay-hover-fg: #1b0e08;

  --pine:          #14352e;
  --pine-deep:     #0f2a23;
  --pine-soft:     #2f6153;
  --pine-wash:     #17302a;

  --ochre:         #e8b04a;
  --ochre-wash:    #33280f;
  --ochre-ink:     #e8b04a;

  --ink:           #f2ede3;
  --ink-soft:      #ddd6c8;
  --muted:         #a79e8e;
  --faint:         #a09685;
  --bone:          #14120f;
  --bone-2:        #1b1815;
  --bone-3:        #232019;
  --line:          #302b24;
  --line-strong:   #473f35;
  --surface:       #1b1815;
  --surface-2:     #221e19;

  --link:          var(--accent-text);
  --focus:         #7fc3ac;
  --scrollbar:     #d07a3d;
  --scrollbar-hover: #4d453a;

  --shadow-color:  0, 0, 0;
  --shadow-alpha:  0.5;

  --grad-action:  linear-gradient(180deg, #d4522f 0%, var(--clay) 100%);
  --grad-display: linear-gradient(102deg, var(--ink) 0%, var(--ink) 30%, var(--accent-text) 100%);
  --grad-accent:  linear-gradient(135deg, var(--clay-bright) 0%, var(--ochre) 100%);
  --grad-pine:    linear-gradient(165deg, #1b463b 0%, var(--pine) 55%, var(--pine-deep) 100%);
  --grad-cta:     linear-gradient(150deg, #d0512c 0%, var(--clay) 45%, #8d3218 100%);

  --glass-bg:     rgba(38, 33, 28, 0.55);
  --glass-edge:   rgba(245, 241, 232, 0.10);
  --glass-blur:   14px;

  --aura: 0.10;

  color-scheme: dark;
}
