/* ==========================================================================
   01 · DESIGN TOKENS
   --------------------------------------------------------------------------
   Base colours (--brand, --accent, --black, --grey, --white) are injected
   from .env in partials/head.php. Everything below is DERIVED from them,
   so changing one value in .env recolours the whole site.

   Palette:  white · black · grey · #83C5C8 (brand, + tints/shades) ·
             #FE947E (accent, highlights only)
   ========================================================================== */

/* ---------- Fonts (self-hosted, variable) ---------- */
@font-face {
    font-family: "Space Grotesk";
    src: url("../fonts/space-grotesk-latin-wght.woff2") format("woff2");
    font-weight: 300 700;
    font-display: swap;
}
@font-face {
    font-family: "Inter";
    src: url("../fonts/inter-latin-wght.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}
@font-face {
    font-family: "JetBrains Mono";
    src: url("../fonts/jetbrains-mono-latin-wght.woff2") format("woff2");
    font-weight: 100 800;
    font-display: swap;
}

/*
 * Solid fallbacks first. Browsers that do not understand color-mix()
 * (or oklab) keep these and still lay the page out. The @supports block
 * below refines the same tokens when the function is available.
 * color-mix uses srgb: oklab is dropped by some Safari versions and can
 * discard the rest of the rule, which leaves the site unstyled.
 */
:root {
    /* ---------- Brand scale ---------- */
    --brand-50:  #f3fafa;
    --brand-100: #e4f3f4;
    --brand-200: #c5e4e6;
    --brand-300: #a8d6d8;
    --brand-400: var(--brand);
    --brand-500: #6fadb0;
    --brand-600: #4e8e92;
    --brand-700: #3a6c70;
    --brand-800: #28484b;
    --brand-900: #1a2e30;
    --brand-glow: rgb(131 197 200 / .35);

    --accent-soft: rgb(254 148 126 / .16);
    --accent-glow: rgb(254 148 126 / .40);

    /* ---------- Greys ---------- */
    --grey-50:  #f6f7f7;
    --grey-100: #eeeff0;
    --grey-200: #dee1e2;
    --grey-400: #9aa1a3;
    --grey-700: #3d4547;
    --grey-800: #1c2223;
    --grey-900: #121617;

    /* ---------- Semantic (LIGHT theme default) ---------- */
    --bg:          var(--white);
    --bg-alt:      var(--grey-50);
    --surface:     var(--white);
    --surface-2:   var(--grey-100);
    --text:        var(--black);
    --text-muted:  var(--grey-700);
    --border:      rgb(11 15 16 / .09);
    --border-strong: rgb(11 15 16 / .16);
    --brand-text:  var(--brand-600);     /* brand colour readable on light bg */
    --glass:       rgb(255 255 255 / .72);
    --shadow-sm:   0 1px 2px rgb(0 0 0 / .05), 0 2px 8px rgb(0 0 0 / .04);
    --shadow-md:   0 10px 30px -10px rgb(11 15 16 / .18);
    --shadow-lg:   0 30px 60px -20px rgb(11 15 16 / .28);

    /* Always-dark sections (hero, principles, world, contact, footer) */
    --dark-bg:     var(--black);
    --dark-bg-2:   #122022;
    --dark-text:   var(--white);
    --dark-muted:  rgb(255 255 255 / .62);
    --dark-border: rgb(255 255 255 / .10);

    /* ---------- Typography ---------- */
    --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
    --font-body:    "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono:    "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;

    --fs-xs:   .75rem;
    --fs-sm:   .875rem;
    --fs-base: 1rem;
    --fs-md:   1.125rem;
    --fs-lg:   clamp(1.15rem, 1rem + .5vw, 1.35rem);
    --fs-xl:   clamp(1.5rem, 1.2rem + 1.2vw, 2rem);
    --fs-2xl:  clamp(2rem, 1.4rem + 2.6vw, 3.4rem);
    --fs-hero: clamp(2.6rem, 1.6rem + 5vw, 6rem);

    /* ---------- Spacing / layout ---------- */
    --container: 1240px;
    --gutter:    clamp(16px, 4vw, 40px);
    --section-y: clamp(72px, 8.25vw, 124px);   /* vertical space inside each section (top & bottom) */
    --radius-sm: 10px;
    --radius:    18px;
    --radius-lg: 28px;
    --header-h:  76px;

    /* ---------- Motion ---------- */
    --ease-out:    cubic-bezier(.16, 1, .3, 1);
    --ease-in-out: cubic-bezier(.65, 0, .35, 1);
    --dur:         .6s;
}

/* ---------- DARK theme (explicit choice or OS preference in "auto") ---------- */
:root[data-theme="dark"] {
    --bg:          var(--black);
    --bg-alt:      #101718;
    --surface:     #152022;
    --surface-2:   #1c2a2c;
    --text:        var(--white);
    --text-muted:  rgb(255 255 255 / .64);
    --border:      rgb(255 255 255 / .09);
    --border-strong: rgb(255 255 255 / .18);
    --brand-text:  var(--brand-300);
    --glass:       rgb(11 15 16 / .70);
    --shadow-md:   0 10px 30px -10px rgb(0 0 0 / .6);
    --shadow-lg:   0 30px 60px -20px rgb(0 0 0 / .7);
    color-scheme: dark;
}

/* Precise tints, only where color-mix is supported. srgb, not oklab. */
@supports (color: color-mix(in srgb, black, white)) {
    :root {
        --brand-50:  color-mix(in srgb, var(--brand) 8%,  var(--white));
        --brand-100: color-mix(in srgb, var(--brand) 18%, var(--white));
        --brand-200: color-mix(in srgb, var(--brand) 40%, var(--white));
        --brand-300: color-mix(in srgb, var(--brand) 70%, var(--white));
        --brand-500: color-mix(in srgb, var(--brand) 85%, var(--black));
        --brand-600: color-mix(in srgb, var(--brand) 68%, var(--black));
        --brand-700: color-mix(in srgb, var(--brand) 50%, var(--black));
        --brand-800: color-mix(in srgb, var(--brand) 30%, var(--black));
        --brand-900: color-mix(in srgb, var(--brand) 14%, var(--black));
        --brand-glow: color-mix(in srgb, var(--brand) 35%, transparent);
        --accent-soft: color-mix(in srgb, var(--accent) 16%, transparent);
        --accent-glow: color-mix(in srgb, var(--accent) 40%, transparent);
        --grey-50:  color-mix(in srgb, var(--grey) 5%,  var(--white));
        --grey-100: color-mix(in srgb, var(--grey) 10%, var(--white));
        --grey-200: color-mix(in srgb, var(--grey) 20%, var(--white));
        --grey-400: color-mix(in srgb, var(--grey) 60%, var(--white));
        --grey-700: color-mix(in srgb, var(--grey) 60%, var(--black));
        --grey-800: color-mix(in srgb, var(--grey) 25%, var(--black));
        --grey-900: color-mix(in srgb, var(--grey) 12%, var(--black));
        --border:      color-mix(in srgb, var(--black) 9%, transparent);
        --border-strong: color-mix(in srgb, var(--black) 16%, transparent);
        --glass:       color-mix(in srgb, var(--white) 72%, transparent);
        --dark-bg-2:   color-mix(in srgb, var(--black) 92%, var(--brand));
        --dark-muted:  color-mix(in srgb, var(--white) 62%, transparent);
        --dark-border: color-mix(in srgb, var(--white) 10%, transparent);
    }
    :root[data-theme="dark"] {
        --bg-alt:      color-mix(in srgb, var(--black) 94%, var(--brand));
        --surface:     color-mix(in srgb, var(--black) 90%, var(--brand));
        --surface-2:   color-mix(in srgb, var(--black) 84%, var(--brand));
        --text-muted:  color-mix(in srgb, var(--white) 64%, transparent);
        --border:      color-mix(in srgb, var(--white) 9%, transparent);
        --border-strong: color-mix(in srgb, var(--white) 18%, transparent);
        --glass:       color-mix(in srgb, var(--black) 70%, transparent);
    }
}
