/*
 * Design tokens. The single source of truth for color, type, space, radius and motion.
 * Components must reference these custom properties, never raw values.
 * See docs/design-system.md before adding or renaming a token.
 */

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

@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-var-latin.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-var-latin.woff2") format("woff2");
}

@layer tokens {
  :root {
    color-scheme: light;

    /* Color: light theme (default) */
    --color-bg: #ebebea;
    --color-bg-raised: #f5f5f3;
    --color-ink: #121212;
    --color-ink-muted: #545452;
    --color-ink-subtle: #8c8c89;
    --color-line: #d2d2cf;
    --color-line-strong: #b4b4b0;
    --color-accent: #e5402a;
    --color-accent-ink: #b52a17;
    --color-success: #19a058;
    --color-focus: #1f6feb;
    --color-card-bg: #161616;
    --color-card-ink: #f2f2f0;
    --color-card-ink-muted: #a3a3a0;
    --color-card-line: #2e2e2d;
    --color-giant: #c4c4c1;
    --color-selection: #121212;
    --color-selection-ink: #ebebea;

    /* Typography */
    --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

    /* Fluid type scale (360px to 1440px viewport) */
    --step--2: clamp(0.6875rem, 0.67rem + 0.08vw, 0.75rem);
    --step--1: clamp(0.8125rem, 0.79rem + 0.1vw, 0.875rem);
    --step-0: clamp(1rem, 0.96rem + 0.19vw, 1.125rem);
    --step-1: clamp(1.25rem, 1.15rem + 0.46vw, 1.5rem);
    --step-2: clamp(1.5rem, 1.29rem + 0.93vw, 2.125rem);
    --step-3: clamp(2rem, 1.58rem + 1.85vw, 3.25rem);
    --step-4: clamp(2.5rem, 1.83rem + 2.96vw, 4.5rem);
    --step-display: clamp(3.25rem, 1.7rem + 6.9vw, 8rem);
    --step-giant: clamp(5rem, 0.5rem + 20vw, 19rem);

    --leading-tight: 1;
    --leading-snug: 1.15;
    --leading-normal: 1.55;
    --tracking-display: -0.045em;
    --tracking-tight: -0.025em;
    --tracking-wide: 0.08em;

    /* Space (fluid) */
    --space-3xs: clamp(0.25rem, 0.24rem + 0.05vw, 0.3125rem);
    --space-2xs: clamp(0.5rem, 0.48rem + 0.09vw, 0.5625rem);
    --space-xs: clamp(0.75rem, 0.73rem + 0.09vw, 0.8125rem);
    --space-s: clamp(1rem, 0.96rem + 0.19vw, 1.125rem);
    --space-m: clamp(1.5rem, 1.44rem + 0.28vw, 1.6875rem);
    --space-l: clamp(2rem, 1.92rem + 0.37vw, 2.25rem);
    --space-xl: clamp(3rem, 2.79rem + 0.93vw, 3.625rem);
    --space-2xl: clamp(4rem, 3.58rem + 1.85vw, 5.25rem);
    --space-3xl: clamp(6rem, 5.17rem + 3.7vw, 8.5rem);

    /* Layout */
    --container-max: 82rem;
    --container-narrow: 46rem;
    --gutter: clamp(1rem, 0.5rem + 2.2vw, 2.5rem);
    --header-height: 4rem;

    /* Shape */
    --radius-s: 0.375rem;
    --radius-m: 0.75rem;
    --radius-l: 1.25rem;
    --radius-pill: 999px;
    --border-width: 1px;

    /* Motion */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration-fast: 150ms;
    --duration-base: 300ms;
    --duration-slow: 700ms;
  }

  /* Dark theme: follows the OS unless the visitor picked light explicitly. */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      color-scheme: dark;

      --color-bg: #0f0f0f;
      --color-bg-raised: #181818;
      --color-ink: #ededeb;
      --color-ink-muted: #a6a6a3;
      --color-ink-subtle: #73736f;
      --color-line: #262626;
      --color-line-strong: #3a3a39;
      --color-accent: #ff5a3c;
      --color-accent-ink: #ff7a61;
      --color-success: #2fcf78;
      --color-focus: #6ea8ff;
      --color-card-bg: #181818;
      --color-card-ink: #ededeb;
      --color-card-ink-muted: #9a9a97;
      --color-card-line: #2c2c2b;
      --color-giant: #262625;
      --color-selection: #ededeb;
      --color-selection-ink: #0f0f0f;
    }
  }

  /* Dark theme: explicit choice from the theme toggle. Keep in sync with the block above. */
  :root[data-theme="dark"] {
    color-scheme: dark;

    --color-bg: #0f0f0f;
    --color-bg-raised: #181818;
    --color-ink: #ededeb;
    --color-ink-muted: #a6a6a3;
    --color-ink-subtle: #73736f;
    --color-line: #262626;
    --color-line-strong: #3a3a39;
    --color-accent: #ff5a3c;
    --color-accent-ink: #ff7a61;
    --color-success: #2fcf78;
    --color-focus: #6ea8ff;
    --color-card-bg: #181818;
    --color-card-ink: #ededeb;
    --color-card-ink-muted: #9a9a97;
    --color-card-line: #2c2c2b;
    --color-giant: #262625;
    --color-selection: #ededeb;
    --color-selection-ink: #0f0f0f;
  }
}
