/* ==========================================================================
   Tragwerkstatt — Design Tokens
   --------------------------------------------------------------------------
   Single source of truth for the visual identity. Values come from the
   approved static draft (version-3, `assets/css/site.css`).

   Three tiers:
     1. Primitives — raw values (colour ramps, scales).
     2. Semantic   — meaningful aliases (--color-bg, --color-accent, …).
     3. Brand      — the draft's own short names (--blue, --ink, --gutter …)
                     that the ported component CSS uses. They point at the
                     semantic tokens, so re-theming still happens up here.

   Light + dark: section 5 below swaps the semantic/brand tokens. Dark
   follows the OS (prefers-color-scheme) unless the visitor picked a theme
   in the switcher panel — then <html data-theme="light|dark"> (set on the
   server from the `tw-theme` cookie, App\Support\Theme) wins.
   ========================================================================== */

@layer reset, tokens, base, components, utilities;

@layer tokens {
  :root {
    /* ----------------------------------------------------------------
       1. PRIMITIVES — raw values
       ---------------------------------------------------------------- */

    /* Neutral ramp (draft greys) */
    --zinc-50:  #ffffff;
    --zinc-100: #f4f5f6;   /* --bg-2 */
    --zinc-200: #dfe2e5;   /* --line */
    --zinc-300: #c9ced3;
    --zinc-400: #8c9197;
    --zinc-500: #80858a;   /* --muted */
    --zinc-600: #474b4f;   /* --ink-2 */
    --zinc-700: #34383c;
    --zinc-800: #1b1d1f;   /* --ink */
    --zinc-900: #15181b;   /* --dark */
    --zinc-950: #0b0d0f;   /* hero ground */

    /* Accent ramp — tragwerkstatt blue (existing website) */
    --blue-50:  #e8f2fa;   /* --blue-tint */
    --blue-100: #d3e6f5;
    --blue-200: #a9cfec;
    --blue-300: #7cc0ef;   /* light blue on dark */
    --blue-400: #5fb0e8;
    --blue-500: #3a98d9;
    --blue-600: #1e83ca;   /* --blue */
    --blue-700: #166aa6;   /* --blue-dark */
    --blue-800: #125687;
    --blue-900: #0e4168;
    --blue-950: #0a2c47;

    --white: #ffffff;
    --black: #000000;

    /* Spacing — hybrid 4-then-doubling scale */
    --space-0:  0;
    --space-1:  0.25rem;   /*   4px */
    --space-2:  0.5rem;    /*   8px */
    --space-3:  0.75rem;   /*  12px */
    --space-4:  1rem;      /*  16px */
    --space-5:  1.5rem;    /*  24px */
    --space-6:  2rem;      /*  32px */
    --space-7:  3rem;      /*  48px */
    --space-8:  4rem;      /*  64px */
    --space-9:  6rem;      /*  96px */
    --space-10: 8rem;      /* 128px */
    --space-11: 12rem;     /* 192px */
    --space-12: 16rem;     /* 256px */

    /* Fluid type scale — clamp(min, fluid, max). */
    --text-xs:   clamp(0.75rem,  0.71rem + 0.18vw, 0.8125rem);  /* 12 → 13px */
    --text-sm:   clamp(0.875rem, 0.83rem + 0.21vw, 0.9375rem);  /* 14 → 15px */
    --text-base: 1rem;                                           /* 16px, as drafted */
    --text-lg:   clamp(1.0625rem, 1rem + 0.3vw, 1.1875rem);     /* 17 → 19px */
    --text-xl:   clamp(1.25rem,  1.14rem + 0.54vw, 1.5625rem);  /* 20 → 25px */
    --text-2xl:  clamp(1.5rem,   1.32rem + 0.89vw, 2rem);       /* 24 → 32px */
    --text-3xl:  clamp(1.875rem, 1.55rem + 1.61vw, 3rem);       /* 30 → 48px */
    --text-4xl:  clamp(2.125rem, 1.6rem + 2.6vw, 3.75rem);      /* 34 → 60px */
    --text-5xl:  clamp(2.75rem,  1.4rem + 6vw, 7.75rem);        /* 44 → 124px */

    /* Line heights */
    --leading-tight:   1.12;
    --leading-snug:    1.25;
    --leading-normal:  1.55;
    --leading-relaxed: 1.65;

    /* Letter spacing */
    --tracking-tighter: -0.035em;
    --tracking-tight:  -0.02em;
    --tracking-normal: 0;
    --tracking-wide:   0.1em;

    /* Font weights — Source Sans 3 is variable (200–900) */
    --font-light:    300;
    --font-normal:   400;
    --font-medium:   500;
    --font-semibold: 600;
    --font-bold:     700;

    /* Font families */
    --font-sans: "Source Sans 3", "Frutiger", "Segoe UI", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
                 "Liberation Mono", monospace;
    --font-display: var(--font-sans);

    /* Radii — the draft is square-edged throughout */
    --radius-none: 0;
    --radius-sm:   0;
    --radius-md:   0;
    --radius-lg:   0;
    --radius-xl:   0;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 6px 24px rgb(0 0 0 / 0.07);
    --shadow-lg: 0 30px 60px rgb(0 0 0 / 0.14);

    /* Motion */
    --duration-fast:   150ms;
    --duration-normal: 250ms;
    --duration-slow:   450ms;
    --ease-standard:   cubic-bezier(0.2, 0.7, 0.1, 1);
    --ease-emphasized: cubic-bezier(0.77, 0, 0.18, 1);

    /* Layout containers — .container caps at the draft's 1440px frame
       (content = frame − 2 × gutter, so every edge lines up with the draft). */
    --container-narrow:  42rem;
    --container-default: calc(1440px - 2 * clamp(16px, 3vw, 40px));
    --container-wide:    calc(1440px - 2 * clamp(16px, 3vw, 40px));
    --container-gutter:  clamp(16px, 3vw, 40px);

    /* ----------------------------------------------------------------
       2. SEMANTIC
       ---------------------------------------------------------------- */

    --color-bg:        var(--white);
    --color-bg-subtle: var(--zinc-100);
    --color-bg-muted:  var(--zinc-200);
    --color-bg-inset:  var(--white);

    --color-text:         var(--zinc-800);
    --color-text-muted:   var(--zinc-600);
    --color-text-subtle:  var(--zinc-500);
    --color-text-on-accent: var(--white);

    --color-border:        var(--zinc-200);
    --color-border-strong: var(--zinc-800);

    --color-accent:       var(--blue-600);
    --color-accent-hover: var(--blue-700);
    --color-accent-fg:    var(--white);

    --color-focus-ring:    var(--blue-600);
    --color-selection-bg:  var(--blue-600);
    --color-selection-fg:  var(--white);

    /* ----------------------------------------------------------------
       3. BRAND — the draft's names, used by the ported component CSS
       ---------------------------------------------------------------- */

    --blue:      var(--color-accent);
    --blue-dark: var(--color-accent-hover);
    --blue-tint: var(--blue-50);
    --blue-light: var(--blue-300);
    --bg:        var(--color-bg);
    --bg-2:      var(--color-bg-subtle);
    --ink:       var(--color-text);
    --ink-2:     var(--color-text-muted);
    --muted:     var(--color-text-subtle);
    --line:      var(--color-border);
    --dark:      var(--zinc-900);

    /* Theme-dependent extras (overridden in section 5) */
    --glass:       rgb(255 255 255 / .96);   /* sticky header / toolbar */
    --tag-fg:      var(--blue-dark);         /* text on --blue-tint */
    --logo-filter: brightness(0);            /* agency logo: flat black (white in dark) */
    --brand-ink:   #465056;                  /* tragwerkstatt logo: lettering */
    --brand-eagle: #a9aaac;                  /* tragwerkstatt logo: eagle */

    color-scheme: light;

    --f: var(--font-sans);

    --max: 1440px;
    --gutter: var(--container-gutter);
    --gap: clamp(12px, 1.4vw, 20px);
    --header-h: 84px;
    --topbar-h: 38px;
    --ease: var(--ease-standard);
  }

  @media (max-width: 760px) {
    :root { --header-h: 66px; }
  }

  /* ----------------------------------------------------------------
     5. DARK THEME — same structure, darker grounds, lighter ink.
        Two selectors: an explicit choice, or the OS setting when the
        visitor hasn't chosen. Keep both blocks identical.
     ---------------------------------------------------------------- */

  :root[data-theme="dark"] {
    --color-bg:        #121416;
    --color-bg-subtle: #1b1e21;
    --color-bg-muted:  #262a2e;
    --color-bg-inset:  #1b1e21;
    --color-text:        #e9ebed;
    --color-text-muted:  #b4b9be;
    --color-text-subtle: #8a9096;
    --color-border:        #2c3136;
    --color-border-strong: #e9ebed;
    --color-accent:       #2b8cd1;
    --color-accent-hover: var(--blue-700);
    --color-focus-ring:   var(--blue-400);
    --blue-tint: #13293b;
    --dark:      var(--zinc-950);
    --glass:       rgb(18 20 22 / .94);
    --tag-fg:      var(--blue-300);
    --logo-filter: brightness(0) invert(1);
    --brand-ink:   #e9ebed;
    --brand-eagle: #5f666c;
    --shadow-md: 0 6px 24px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 30px 60px rgb(0 0 0 / 0.5);
    color-scheme: dark;
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --color-bg:        #121416;
      --color-bg-subtle: #1b1e21;
      --color-bg-muted:  #262a2e;
      --color-bg-inset:  #1b1e21;
      --color-text:        #e9ebed;
      --color-text-muted:  #b4b9be;
      --color-text-subtle: #8a9096;
      --color-border:        #2c3136;
      --color-border-strong: #e9ebed;
      --color-accent:       #2b8cd1;
      --color-accent-hover: var(--blue-700);
      --color-focus-ring:   var(--blue-400);
      --blue-tint: #13293b;
      --dark:      var(--zinc-950);
      --glass:       rgb(18 20 22 / .94);
      --tag-fg:      var(--blue-300);
      --logo-filter: brightness(0) invert(1);
      --brand-ink:   #e9ebed;
      --brand-eagle: #5f666c;
      --shadow-md: 0 6px 24px rgb(0 0 0 / 0.35);
      --shadow-lg: 0 30px 60px rgb(0 0 0 / 0.5);
      color-scheme: dark;
    }
  }

  /* ----------------------------------------------------------------
     4. WEB FONTS — self-hosted Source Sans 3 (SIL OFL 1.1)
     ---------------------------------------------------------------- */

  @font-face {
    font-family: "Source Sans 3";
    font-style: normal;
    font-weight: 200 900;
    font-display: swap;
    src: url("/assets/fonts/SourceSans3-Variable-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                   U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                   U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }

  @font-face {
    font-family: "Source Sans 3";
    font-style: normal;
    font-weight: 200 900;
    font-display: swap;
    src: url("/assets/fonts/SourceSans3-Variable-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                   U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                   U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
                   U+2113, U+2C60-2C7F, U+A720-A7FF;
  }

  @font-face {
    font-family: "Source Sans 3";
    font-style: italic;
    font-weight: 200 900;
    font-display: swap;
    src: url("/assets/fonts/SourceSans3-Italic-Variable-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
                   U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F,
                   U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
  }

  @font-face {
    font-family: "Source Sans 3";
    font-style: italic;
    font-weight: 200 900;
    font-display: swap;
    src: url("/assets/fonts/SourceSans3-Italic-Variable-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                   U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                   U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
                   U+2113, U+2C60-2C7F, U+A720-A7FF;
  }
}
