/*
  Design system - tokens
  ------------------------------------------------------------------
  Fonte única de verdade para cor, tipografia, espaço, raio, sombra e
  movimento. Os componentes (components.css) só consomem estas
  variáveis; mudar o tema = editar este ficheiro.

  Documentação visual: /design-system.html
*/

/* Tipografia self-hosted (subset latin, cobre os acentos do português).
   Ficheiros variáveis: um ficheiro serve todos os pesos. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../assets/fonts/inter-latin-variable.woff2") format("woff2");
}

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

:root {
  color-scheme: light dark;

  /* ---------- Cor: primitivas ---------- */
  --stone-50: #f6f5f1;
  --stone-100: #eeece6;
  --stone-200: #e2dfd6;
  --stone-300: #cdc9bd;
  --graphite-400: #8a909b;
  --graphite-500: #646975;
  --graphite-600: #474c57;
  --graphite-800: #1d2129;
  --graphite-850: #171a21;
  --graphite-900: #111318;
  --graphite-950: #0c0e12;

  --cobalt-200: #c9d2ff;
  --cobalt-300: #9fb0ff;
  --cobalt-400: #7c93ff;
  --cobalt-500: #3651e8;
  --cobalt-600: #2a40c4;
  --cobalt-900: #1a2150;

  --green-500: #1f9d55;
  --green-400: #3fcf7f;

  /* ---------- Cor: semântica (tema claro) ---------- */
  --color-bg: var(--stone-50);
  --color-surface: #ffffff;
  --color-surface-2: var(--stone-100);
  --color-text: var(--graphite-900);
  --color-text-muted: var(--graphite-600);
  --color-text-subtle: var(--graphite-500);
  --color-border: var(--stone-200);
  --color-border-strong: var(--stone-300);

  --color-accent: var(--cobalt-500);
  --color-accent-hover: var(--cobalt-600);
  --color-accent-contrast: #ffffff;   /* texto sobre --color-accent */
  --color-accent-soft: #e6eaff;       /* fundos de realce */
  --color-success: var(--green-500);

  --color-inverse-bg: var(--graphite-900);
  --color-inverse-text: var(--stone-50);
  --color-inverse-muted: var(--graphite-400);

  /* Sintaxe (bloco de código do hero) */
  --code-key: var(--cobalt-500);
  --code-string: #a3462a;
  --code-punct: var(--graphite-500);

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

  --fs-xs: 0.8125rem;                                    /* 13 */
  --fs-sm: 0.9375rem;                                    /* 15 */
  --fs-base: 1.0625rem;                                  /* 17 */
  --fs-lg: 1.25rem;                                      /* 20 */
  --fs-xl: clamp(1.375rem, 1.2rem + 0.6vw, 1.625rem);    /* 22-26 */
  --fs-2xl: clamp(1.75rem, 1.4rem + 1.4vw, 2.5rem);      /* 28-40 */
  --fs-3xl: clamp(2.25rem, 1.6rem + 2.6vw, 3.75rem);     /* 36-60 */
  --fs-display: clamp(2.75rem, 1.5rem + 5vw, 5.75rem);   /* 44-92 */

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  --lh-tight: 1.04;
  --lh-snug: 1.2;
  --lh-normal: 1.6;

  --tracking-tight: -0.035em;
  --tracking-snug: -0.02em;
  --tracking-wide: 0.08em;

  /* ---------- Espaço (base 4px) ---------- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --space-10: 8rem;

  --section-y: clamp(var(--space-8), 6vw + 2rem, var(--space-10));
  --container: 72rem;      /* 1152px */
  --container-narrow: 46rem;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);

  /* ---------- Raio ---------- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* ---------- Sombra ---------- */
  --shadow-sm: 0 1px 2px rgb(17 19 24 / 0.06);
  --shadow-md: 0 1px 2px rgb(17 19 24 / 0.05), 0 8px 24px -8px rgb(17 19 24 / 0.12);
  --shadow-lg: 0 2px 4px rgb(17 19 24 / 0.04), 0 24px 56px -16px rgb(17 19 24 / 0.22);

  /* ---------- Movimento ---------- */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --duration-fast: 140ms;
  --duration-base: 240ms;
  --duration-slow: 600ms;

  /* ---------- Foco ---------- */
  --focus-ring: 0 0 0 3px var(--color-bg), 0 0 0 5px var(--color-accent);

  /* ---------- Camadas ---------- */
  --z-header: 50;
  --z-skip: 100;
}

/* ---------- Tema escuro ----------
   Segue o sistema operativo, a menos que o visitante escolha no botão sol/lua
   (main.js grava a escolha e põe data-theme="light|dark" no <html>).
   As duas regras abaixo têm de ter as mesmas declarações. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: var(--graphite-950);
    --color-surface: var(--graphite-850);
    --color-surface-2: var(--graphite-800);
    --color-text: #eceef2;
    --color-text-muted: #b1b6c0;
    --color-text-subtle: var(--graphite-400);
    --color-border: #262a33;
    --color-border-strong: #353a45;

    --color-accent: var(--cobalt-400);
    --color-accent-hover: var(--cobalt-300);
    --color-accent-contrast: var(--graphite-950);
    --color-accent-soft: var(--cobalt-900);
    --color-success: var(--green-400);

    --color-inverse-bg: #eceef2;
    --color-inverse-text: var(--graphite-950);
    --color-inverse-muted: var(--graphite-600);

    --code-key: var(--cobalt-300);
    --code-string: #f0a07a;
    --code-punct: var(--graphite-400);

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -8px rgb(0 0 0 / 0.6);
    --shadow-lg: 0 2px 4px rgb(0 0 0 / 0.4), 0 24px 56px -16px rgb(0 0 0 / 0.7);
  }
}

:root[data-theme="dark"] {
  --color-bg: var(--graphite-950);
  --color-surface: var(--graphite-850);
  --color-surface-2: var(--graphite-800);
  --color-text: #eceef2;
  --color-text-muted: #b1b6c0;
  --color-text-subtle: var(--graphite-400);
  --color-border: #262a33;
  --color-border-strong: #353a45;

  --color-accent: var(--cobalt-400);
  --color-accent-hover: var(--cobalt-300);
  --color-accent-contrast: var(--graphite-950);
  --color-accent-soft: var(--cobalt-900);
  --color-success: var(--green-400);

  --color-inverse-bg: #eceef2;
  --color-inverse-text: var(--graphite-950);
  --color-inverse-muted: var(--graphite-600);

  --code-key: var(--cobalt-300);
  --code-string: #f0a07a;
  --code-punct: var(--graphite-400);

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 1px 2px rgb(0 0 0 / 0.4), 0 8px 24px -8px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 2px 4px rgb(0 0 0 / 0.4), 0 24px 56px -16px rgb(0 0 0 / 0.7);
}
