/* ==========================================================================
   DESIGN TOKENS — single source of truth
   Source: Figma "Portfolio-new" (BtKuOuc4qi0NVkzhPNI7xH)

   How to edit:
   - Change a primitive (e.g. --grey-450) to shift every place it is used.
   - Change a semantic token (e.g. --color-text) to re-point a role
     without touching the palette.
   - Components only reference semantic tokens, never raw hex.
   ========================================================================== */

:root {
  /* ---------- Color primitives (Figma: Neutral / Grey alpha) ---------- */
  --paper: #e3e1dd;       /* page background */
  --white: #ffffff;
  --black: #000000;
  --grey-5: #f9f9f9;
  --grey-25: #f5f5f5;
  --grey-50: #e8e8e8;
  --grey-100: #d1d1d1;
  --grey-150: #bababa;
  --grey-200: #a3a3a3;
  --grey-300: #767676;
  --grey-400: #484848;
  --grey-450: #333333;
  --grey-500: #1a1a1a;

  /* ---------- Color roles ---------- */
  --color-bg: var(--paper);
  --color-surface: var(--white);           /* media placeholders, active nav item */
  --color-surface-muted: var(--grey-100);  /* tags, active filter, active icon button */
  --color-surface-subtle: var(--grey-50);  /* subtle fills */
  --color-callout: #115ea3;                /* Figma Anatomy / Callout: numbered feature notes */

  --color-text-strong: var(--black);       /* display, logo, case study title */
  --color-text: var(--grey-450);           /* headings, body, list rows */
  --color-text-secondary: var(--grey-400); /* supporting paragraphs */
  --color-text-muted: var(--grey-300);     /* tags, inactive nav, long-form body */

  --color-border: var(--grey-100);         /* dividers, table rules */

  --color-inverse-bg: var(--grey-500);     /* dark buttons */
  --color-inverse-text: var(--grey-150);   /* text on dark buttons */
  --color-inverse-text-strong: var(--grey-25); /* menu links, menu button label */
  --color-inverse-text-muted: var(--grey-100); /* menu panel label */
  --color-glass-panel: rgb(34 34 34 / 0.5);   /* menu panel */
  --color-glass-button: rgb(26 26 26 / 0.75); /* menu button */
  /* Menu button: dark glass, light label + icon (dark mode: Figma 2:33) */
  --color-menu-btn: var(--color-glass-button);
  --color-menu-btn-text: var(--color-inverse-text-strong);
  --menu-icon-filter: none;
  --color-menu-btn-hover-text: var(--color-inverse-text-strong);
  --menu-icon-hover-filter: none;

  /* ---------- Typography ---------- */
  /* Geist (Vercel, SIL Open Font License) — self-hosted in assets/fonts/geist,
     loaded in base.css. One variable file covers every weight. */
  --font-sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "DM Mono", ui-monospace, Menlo, monospace;
  --weight-regular: 400;
  --weight-medium: 500;

  /* size / line-height pairs */
  --text-xs: 0.75rem;     /* 12 */
  --leading-xs: 1.125rem; /* 18 */
  --text-sm: 0.875rem;    /* 14 */
  --leading-sm: 1.25rem;  /* 20 */
  --text-md: 0.875rem;    /* 14 — was 16; all body/UI text is now 14 */
  --leading-md: 1.25rem;  /* 20 — pairs with 14px text */
  --text-lg: clamp(1.25rem, 1.1rem + 0.5vw, 1.5rem);  /* 20 → 24 */
  --leading-lg: 1.3333;   /* 24/32 */
  --text-xl: clamp(1.75rem, 1.3rem + 1.4vw, 2.5rem);  /* 28 → 40 */
  --leading-xl: 1.3;
  --leading-tight: 1.2;
  --text-display: clamp(3.5rem, 0.5rem + 11.95vw, 11.25rem); /* 56 → 180 at 1440 */
  --leading-display: 1;

  --tracking-logo: -0.02em; /* -0.32px @ 16px */
  --tracking-xl: -1px;      /* every 40px statement: -1px */

  /* ---------- Spacing (named by px value) ---------- */
  --space-4: 0.25rem;
  --space-8: 0.5rem;
  --space-10: 0.625rem;
  --space-12: 0.75rem;
  --space-16: 1rem;
  --space-20: 1.25rem;
  --space-24: 1.5rem;
  --space-32: 2rem;     /* Figma sp-1000 */
  --space-40: 2.5rem;   /* Figma sp-1100 */
  --space-60: 3.75rem;
  --space-80: 5rem;
  --space-90: 5.625rem;

  /* ---------- Grid (Figma: 12 columns, margin 60, gutter 20) ----------
     Fluid: margin and gutter stay fixed on wide screens, columns stretch.
     Text sizes cap at their 1440 values, so type never grows past Figma. */
  --grid-columns: 12;
  --grid-margin: clamp(1rem, -0.2rem + 5vw, 3.75rem);  /* 16 → 60 */
  --grid-gutter: 1.25rem;                              /* 20 */

  /* ---------- Layout ---------- */
  --page-gutter: var(--grid-margin);                   /* alias, kept for existing rules */
  --section-y: clamp(3rem, 1.5rem + 5vw, 5.625rem);    /* 48 → 90 */
  --header-y: var(--space-32);
  --header-h: calc(var(--header-y) * 2 + var(--leading-md)); /* 88 — fixed header height */

  --measure-narrow: 21rem;  /* 336 — side copy, captions */
  --measure-body: 26rem;    /* 416 */
  --measure-lead: 29.25rem; /* 466 — about intro */
  --measure-wide: 54.5rem;  /* 870 — big statements, experience table */

  /* ---------- Radius ---------- */
  --radius-xs: 4px;   /* tags, nav items */
  --radius-sm: 6px;   /* count chip */
  --radius-md: 8px;   /* buttons, filters, menu */
  --radius-lg: 16px;  /* image cards */
  --radius-xl: 20px;  /* case study media */
  --radius-full: 999px;

  /* ---------- Effects ---------- */
  --blur-glass: 5.6px;    /* Figma Glass/* styles: background blur 11.2 */
  --blur-heavy: 40px;     /* A.O.D LLM panel: fully blurs out whatever it covers */
  --grain-opacity: 0.25;  /* Figma Texture/Paper grain: black @ 25%; 0 to disable */
  --icon-filter: none;           /* dark mode inverts line icons */
  --icon-hover-filter: brightness(0.274); /* button arrow #BABABA → #333 on hover */
  --placeholder-filter: none;
  color-scheme: light;

  /* ---------- Motion (not specified in Figma — sensible defaults) ---------- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);   /* iOS sheets and page pushes */
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);  /* on-screen moves */
  --ease-camera: cubic-bezier(0.65, 0, 0.35, 1);   /* in-out cubic: a calm camera move, no lurch */
  --duration-fast: 150ms;
  --duration-base: 250ms;

  /* ---------- Icon sizes ---------- */
  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;
}

/* ---------- Dark theme ----------
   Follows the visitor's system setting; the Menu's theme switch overrides it
   (html[data-theme="dark" | "light"], remembered per visitor). Only roles change —
   components keep using the same tokens. Not in Figma: tune these values freely. */
:root[data-theme="dark"] {
  --color-bg: #161616;                    /* dark paper */
  --color-surface: #262626;               /* image placeholders, cards */
  --color-surface-muted: var(--grey-450); /* tags, active filter/tab pill, button hover */
  --color-surface-subtle: #1f1f1f;
  --color-text-strong: var(--grey-25);
  --color-text: var(--grey-50);
  --color-text-secondary: var(--grey-150);
  --color-text-muted: var(--grey-200);
  --color-border: #2e2e2e;
  --color-inverse-bg: var(--grey-50);     /* buttons flip to light */
  --color-inverse-text: var(--grey-400);
  --color-glass-panel: rgb(52 52 52 / 0.6);   /* glass lifts a little so it reads on dark paper */
  --color-glass-button: rgb(46 46 46 / 0.85);
  /* Menu button — Figma 2:33: solid white, #333 label + icon */
  --color-menu-btn: var(--white);
  --color-menu-btn-text: var(--grey-450);
  --menu-icon-filter: brightness(0.209);   /* #F5F5F5 add icon → #333 */
  --color-menu-btn-hover-text: var(--grey-400); /* hover flips to the light button */
  --menu-icon-hover-filter: brightness(0.209);
  --grain-opacity: 0.5;
  --icon-filter: invert(1);               /* dark line icons → light */
  --icon-hover-filter: none;              /* button arrow on hover is already light */
  --placeholder-filter: invert(0.86);     /* checker placeholder → dark checker */
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #161616;                    /* dark paper */
    --color-surface: #262626;               /* image placeholders, cards */
    --color-surface-muted: var(--grey-450); /* tags, active filter/tab pill, button hover */
    --color-surface-subtle: #1f1f1f;
    --color-text-strong: var(--grey-25);
    --color-text: var(--grey-50);
    --color-text-secondary: var(--grey-150);
    --color-text-muted: var(--grey-200);
    --color-border: #2e2e2e;
    --color-inverse-bg: var(--grey-50);     /* buttons flip to light */
    --color-inverse-text: var(--grey-400);
    --color-glass-panel: rgb(52 52 52 / 0.6);
    --color-glass-button: rgb(46 46 46 / 0.85);
    /* Menu button — Figma 2:33: solid white, #333 label + icon */
    --color-menu-btn: var(--white);
    --color-menu-btn-text: var(--grey-450);
    --menu-icon-filter: brightness(0.209);   /* #F5F5F5 add icon → #333 */
    --color-menu-btn-hover-text: var(--grey-400);
    --menu-icon-hover-filter: brightness(0.209);
    --grain-opacity: 0.5;
    --icon-filter: invert(1);               /* dark line icons → light */
    --icon-hover-filter: none;              /* button arrow on hover is already light */
    --placeholder-filter: invert(0.86);     /* checker placeholder → dark checker */
    color-scheme: dark;
  }
}

/* Fewer columns on smaller screens; margin and gutter stay the same tokens */
@media (max-width: 64rem) { :root { --grid-columns: 8; } }
@media (max-width: 40rem) { :root { --grid-columns: 4; } }

@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-fast: 0ms;
    --duration-base: 0ms;
  }
}
