/* ==========================================================================
   CTRL Studio — Design tokens
   Fonte de verdade: branding/BRAND_GUIDELINES.md
   ========================================================================== */

:root {
  /* ---- Cores principais ---- */
  --c-ink: #171612;          /* Grafite: primária */
  --c-ink-2: #24221d;        /* Grafite 2: cards sobre escuro */
  --c-ink-3: #34312a;        /* Grafite 3: bordas sobre escuro */
  --c-signal: #8c7bff;       /* Sinal: destaque / ação */
  --c-signal-deep: #5942f0;  /* Sinal profundo: texto violeta sobre claro */
  --c-signal-soft: #dbd6ff;  /* Sinal suave: fundos de destaque */
  --c-stone: #5e594f;        /* Pedra: secundária / texto de apoio */
  --c-mist: #a8a192;         /* Névoa: apoio sobre escuro */
  --c-paper: #f4f1ea;        /* Papel: fundo principal */
  --c-surface: #fbfaf6;      /* Folha: superfícies */
  --c-surface-2: #eae6dc;    /* Cartão: áreas recuadas */
  --c-line: #d8d2c4;         /* Traço: bordas */

  /* ---- Estados ---- */
  --c-success: #2a7248;
  --c-success-soft: #e3f1e7;
  --c-warning: #9a6206;
  --c-warning-soft: #fbefd5;
  --c-error: #c0362c;
  --c-error-soft: #fbe4e1;
  --c-info: #2f5e8a;
  --c-info-soft: #e2ecf5;

  /* ---- Papéis semânticos (tema claro) ---- */
  --bg: var(--c-paper);
  --surface: var(--c-surface);
  --surface-2: var(--c-surface-2);
  --text: var(--c-ink);
  --text-muted: var(--c-stone);
  --line: var(--c-line);
  --accent: var(--c-signal);
  --focus: var(--c-signal);

  /* ---- Tipografia ---- */
  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --fs-display: clamp(2.75rem, 1.2rem + 5vw, 6rem);
  --fs-h2: clamp(2rem, 1.45rem + 2.5vw, 3.5rem);
  --fs-h3: clamp(1.25rem, 1.15rem + 0.45vw, 1.5rem);
  --fs-lead: clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);
  --fs-body: clamp(1rem, 0.97rem + 0.12vw, 1.0625rem);
  --fs-small: 0.875rem;
  --fs-mono: 0.78125rem;

  --lh-tight: 0.95;
  --lh-heading: 1.04;
  --lh-body: 1.6;

  /* ---- Espaçamento (base 4px) ---- */
  --space-1: 0.25rem;   /* 4 */
  --space-2: 0.5rem;    /* 8 */
  --space-3: 0.75rem;   /* 12 */
  --space-4: 1rem;      /* 16 */
  --space-5: 1.5rem;    /* 24 */
  --space-6: 2rem;      /* 32 */
  --space-7: 3rem;      /* 48 */
  --space-8: 4rem;      /* 64 */
  --space-9: 6rem;      /* 96 */
  --space-10: 8rem;     /* 128 */
  --space-11: 10rem;    /* 160 */

  --container: 1320px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --section-y: clamp(4rem, 2.75rem + 3.5vw, 7rem);
  --section-head-gap: clamp(2.5rem, 2rem + 2vw, 3.5rem);
  --header-h: 72px;

  /* ---- Raios ---- */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-key: 25%;

  /* ---- Sombras ---- */
  --shadow-key: 0 3px 0 0 var(--c-ink);
  --shadow-key-hover: 0 5px 0 0 var(--c-ink);
  --shadow-soft: 0 1px 2px rgb(23 22 18 / 0.06), 0 12px 32px -12px rgb(23 22 18 / 0.18);
  --shadow-float: 0 30px 80px -30px rgb(23 22 18 / 0.35);

  /* ---- Movimento ---- */
  --dur-1: 120ms;
  --dur-2: 220ms;
  --dur-3: 420ms;
  --dur-4: 700ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-snap: cubic-bezier(0.3, 1.4, 0.5, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* ---- Constantes (nunca mudam com o tema) ---- */
  --k-ink: #171612;          /* texto sobre o Sinal: sempre escuro */
  --k-paper: #f4f1ea;

  /* ---- Tema ---- */
  --header-bg: rgb(244 241 234 / 0.9);
  --hover-tint: rgb(23 22 18 / 0.05);

  /* ---- Texturas ---- */
  --dot-grid: radial-gradient(circle at 1px 1px, rgb(23 22 18 / 0.13) 1px, transparent 0);
  --dot-grid-size: 24px 24px;
}

/* ==========================================================================
   Paleta fixa da marca
   .theme-fixed  → elementos que mantêm a aparência original em qualquer tema
                   (painel violeta do CTA, card "Por que CTRL?", peças do guia).
   .theme-dark   → seções escuras por natureza (Diferenciais, rodapé): usam as
                   cores constantes da marca, independentemente do tema.
   ========================================================================== */
.theme-fixed,
.theme-dark {
  --c-ink: #171612;
  --c-ink-2: #24221d;
  --c-ink-3: #34312a;
  --c-signal-deep: #5942f0;
  --c-signal-soft: #dbd6ff;
  --c-stone: #5e594f;
  --c-mist: #a8a192;
  --c-paper: #f4f1ea;
  --c-surface: #fbfaf6;
  --c-surface-2: #eae6dc;
  --c-line: #d8d2c4;
  --c-success: #2a7248;
  --c-success-soft: #e3f1e7;
  --c-warning: #9a6206;
  --c-warning-soft: #fbefd5;
  --c-error: #c0362c;
  --c-error-soft: #fbe4e1;
  --c-info: #2f5e8a;
  --c-info-soft: #e2ecf5;
}

.theme-fixed {
  --bg: var(--c-paper);
  --surface: var(--c-surface);
  --surface-2: var(--c-surface-2);
  --text: var(--c-ink);
  --text-muted: var(--c-stone);
  --line: var(--c-line);
  --dot-grid: radial-gradient(circle at 1px 1px, rgb(23 22 18 / 0.13) 1px, transparent 0);
  color-scheme: light;
}

/* Seções escuras redefinem os papéis semânticos */
.theme-dark {
  --bg: var(--c-ink);
  --surface: var(--c-ink-2);
  --surface-2: var(--c-ink-3);
  --text: var(--c-paper);
  --text-muted: var(--c-mist);
  --line: var(--c-ink-3);
  --dot-grid: radial-gradient(circle at 1px 1px, rgb(244 241 234 / 0.08) 1px, transparent 0);
}

/* ==========================================================================
   MODO ESCURO
   Ativado por data-theme="dark" no <html> (definido antes da renderização
   pelo script inline do <head>, com base na escolha salva ou no sistema).
   A paleta é remapeada: "Papel" vira o fundo escuro e "Grafite" vira o texto
   claro. O Sinal permanece idêntico. Contrastes verificados (AA ou superior).
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --c-paper: #1b1a16;        /* fundo          (texto 14,9:1) */
  --c-surface: #22201b;      /* superfícies */
  --c-surface-2: #282621;    /* seções alternadas */
  --c-line: #3a372f;         /* bordas */
  --c-ink: #f1ede4;          /* texto, bordas e sombras de tecla */
  --c-ink-2: #2e2b25;
  --c-ink-3: #3a372f;
  --c-stone: #aba495;        /* texto de apoio (7,0:1) */
  --c-signal-deep: #a699ff;  /* violeta para texto (7,1:1) */
  --c-signal-soft: #1d1839;  /* fundo de selos */

  --c-success: #5cc08a;
  --c-success-soft: #17301f;
  --c-warning: #e3a63b;
  --c-warning-soft: #33270f;
  --c-error: #ff7468;
  --c-error-soft: #3a1a17;
  --c-info: #74a9de;
  --c-info-soft: #172636;

  --header-bg: rgb(27 26 22 / 0.88);
  --hover-tint: rgb(244 241 234 / 0.07);
  --dot-grid: radial-gradient(circle at 1px 1px, rgb(244 241 234 / 0.08) 1px, transparent 0);
  --shadow-soft: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px -12px rgb(0 0 0 / 0.6);
  --shadow-float: 0 30px 80px -30px rgb(0 0 0 / 0.75);
}

/* No modo escuro, as seções escuras ficam um tom mais profundas que a página */
:root[data-theme="dark"] .theme-dark {
  --bg: #100f0c;
  --surface: #1a1915;
  --line: #2c2924;
}
