/*
 * x99 design tokens — Opção B (Warmer + balanced)
 * Fonte canonical: docs/theme/conventions.md + ADR 0002 (copy conventions)
 *
 * Estratégia: :root contém tokens dark (default) + compartilhados (spacing,
 * radius, font, animation). :root[data-theme="light"] sobrescreve só cores
 * + shadows + glass.
 *
 * Consumo: zero hardcoded color/sp/radius/fs/shadow em CSS x99. Sempre
 * var(--c-*) / var(--sp-*) / var(--r-*) / var(--fs-*) / var(--sh-*).
 */

/* ==========================================================================
 * DEFAULTS (dark) + tokens compartilhados
 * ========================================================================== */
:root {
  /* ---- Cores base (dark) — sidebar/footer/headers e cards usam o
     mesmo cinza-escuro elevado (#1f2021) "flutuando" sobre o body
     mais escuro (#0e1013). Borders quase nulos, contraste vem da
     diferença de bg. Edgar 2026-04-29. */
  --c-bg-sunken: #1f2021;                     /* sidebar/footer/header chrome */
  --c-bg-base: #0e1013;                       /* body principal (mais escuro) */
  --c-bg-elevated: #1f2021;                   /* cards/widgets */
  --c-surface: rgba(255, 255, 255, 0.035);
  --c-surface-hover: rgba(255, 255, 255, 0.07);
  --c-border: rgba(255, 255, 255, 0.02);      /* praticamente nula: contraste vem do bg */
  --c-border-strong: rgba(255, 255, 255, 0.06);

  /* ---- Texto (dark) ---- */
  --c-text-primary: #f5f5f7;
  --c-text-secondary: rgba(245, 245, 247, 0.78);
  --c-text-muted: rgba(245, 245, 247, 0.50);
  --c-text-inverse: #0d0e11;

  /* ---- Accent + semantic (dark) — rose-400 punchier que rose-300 (Edgar 2026-04-28) ---- */
  --c-accent: #fb7185;                        /* rose-400, mais quente */
  --c-accent-soft: rgba(251, 113, 133, 0.14);
  --c-accent-warm: #fda4af;                   /* rose-300 */
  --c-success: #4ade80;
  --c-success-soft: rgba(74, 222, 128, 0.16);
  --c-warning: #fbbf24;
  --c-warning-soft: rgba(251, 191, 36, 0.16);
  --c-danger: #ef4444;
  --c-danger-soft: rgba(239, 68, 68, 0.16);
  --c-info: #60a5fa;
  --c-info-soft: rgba(96, 165, 250, 0.18);

  /* ---- Glass effects (dark) ---- */
  --glass-blur: blur(20px) saturate(160%);
  --glass-tint: rgba(15, 15, 17, 0.55);
  --glass-border: rgba(255, 255, 255, 0.08);

  /* ---- RGB channels (pra rgba() com alpha variável) ---- */
  /* Dark: texto branco sobre fundo escuro */
  --text-rgb: 255, 255, 255;
  --bg-rgb: 13, 14, 17;
  --accent-rgb: 251, 113, 133;                /* rose-400 */
  --accent-warm-rgb: 253, 164, 175;           /* rose-300 */
  --success-rgb: 74, 222, 128;
  --warning-rgb: 251, 191, 36;
  --danger-rgb: 239, 68, 68;
  --info-rgb: 96, 165, 250;

  /* ---- Shimmer skeleton tokens (loading state) ----
     Dark: branco sutil pulsando sobre fundo escuro.
     Light: cinza-warm sutil pulsando sobre cream (override abaixo). */
  --sh-shimmer-base: rgba(255, 255, 255, 0.04);
  --sh-shimmer-peak: rgba(255, 255, 255, 0.10);

  /* ---- Shadows (dark) ---- */
  --sh-card: 0 2px 8px rgba(0, 0, 0, 0.35);
  --sh-card-hover: 0 4px 14px rgba(0, 0, 0, 0.45);
  --sh-sticky: 0 0 32px rgba(251, 113, 133, 0.22);
  --sh-modal: 0 10px 40px rgba(0, 0, 0, 0.60);
  --sh-focus: 0 0 0 3px rgba(251, 113, 133, 0.40);

  /* ==========================================================================
   * COMPARTILHADOS (dark + light) — spacing, radius, font, animation
   * ========================================================================== */

  /* ---- Tipografia ---- */
  --font-ui: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
  --font-code: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* Scale (px declarado pra clareza; em produção consumir via var) */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-3xl: 36px;

  /* Line-heights (multipliers) */
  --lh-tight: 1.2;
  --lh-base: 1.4;
  --lh-loose: 1.5;
  --lh-looser: 1.55;

  /* Weights */
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semi: 600;
  --fw-bold: 700;
  --fw-extra: 800;

  /* Letter-spacing */
  --ls-tight: -0.01em;
  --ls-normal: 0;
  --ls-kicker: 0.08em;

  /* ---- Spacing scale ---- */
  --sp-0: 0;
  --sp-1: 4px;
  --sp-2: 6px;
  --sp-3: 8px;
  --sp-4: 10px;
  --sp-5: 12px;
  --sp-6: 16px;
  --sp-7: 20px;
  --sp-8: 24px;
  --sp-9: 32px;
  --sp-10: 48px;

  /* ---- Border radius ---- */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-xl: 14px;
  --r-2xl: 16px;
  --r-full: 999px;

  /* ---- Animation tokens ---- */
  --dur-fast: 150ms;
  --dur-base: 200ms;
  --dur-med: 300ms;
  --dur-slow: 600ms;
  --dur-enter: 400ms;

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --ease-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-linear: linear;
}

/* ==========================================================================
 * LIGHT MODE — override colors + shadows + glass (ADR 0002)
 * ========================================================================== */
:root[data-theme="light"] {
  /* ---- Cores base — paleta creme 3 níveis (Edgar 2026-04-29 v5) ----
     Hierarquia visual: sidebar/footer mais saturados (sunken) >
     body principal (base) > cards (elevated). Delta sutil pra evitar cards muito brancos. */
  --c-bg-sunken: #e8e1d1;                     /* warm beige neutral, sidebar/footer/header chrome */
  --c-bg-base: #f4eedf;                       /* cream warm luminoso (93% L) body */
  --c-bg-elevated: #faeedf;                   /* cream elevado, warm off-white */
  --c-surface: rgba(9, 9, 11, 0.055);
  --c-surface-hover: rgba(9, 9, 11, 0.10);
  --c-border: rgba(9, 9, 11, 0.16);           /* cards/dividers — finas mas presentes */
  --c-border-strong: rgba(9, 9, 11, 0.30);

  /* ---- Texto (alto contraste sobre creme) ---- */
  --c-text-primary: #09090b;                  /* near-black (zinc-950) — títulos bem densos */
  --c-text-secondary: rgba(9, 9, 11, 0.78);
  --c-text-muted: rgba(9, 9, 11, 0.58);
  --c-text-inverse: #fafaf9;                  /* stone-50 */

  /* ---- Accent + semantic (mid-saturação) ---- */
  --c-accent: #ef4444;                        /* red-500 — meio termo (Edgar) */
  --c-accent-soft: rgba(239, 68, 68, 0.12);
  --c-accent-warm: #f87171;                   /* matches dark */
  --c-success: #16a34a;
  --c-success-soft: rgba(22, 163, 74, 0.14);
  --c-warning: #d97706;
  --c-warning-soft: rgba(217, 119, 6, 0.14);
  --c-danger: #dc2626;
  --c-danger-soft: rgba(220, 38, 38, 0.12);
  --c-info: #2563eb;
  --c-info-soft: rgba(37, 99, 235, 0.14);

  /* ---- Glass effects ---- */
  --glass-blur: blur(20px) saturate(130%);
  --glass-tint: rgba(250, 238, 223, 0.88);
  --glass-border: rgba(9, 9, 11, 0.20);

  /* ---- RGB channels (light: near-black sobre creme) ---- */
  --text-rgb: 9, 9, 11;                       /* zinc-950 */
  --bg-rgb: 244, 238, 223;                    /* matches bg-base */
  --accent-rgb: 239, 68, 68;
  --accent-warm-rgb: 248, 113, 113;
  --success-rgb: 22, 163, 74;
  --warning-rgb: 217, 119, 6;
  --danger-rgb: 220, 38, 38;
  --info-rgb: 37, 99, 235;

  /* ---- Shimmer (light: near-black sutil sobre creme) ---- */
  --sh-shimmer-base: rgba(9, 9, 11, 0.03);
  --sh-shimmer-peak: rgba(9, 9, 11, 0.07);

  /* ---- Shadows (folha em branco — sombras MUITO sutis,
         acento vai nas linhas/bordas, não em glow) ---- */
  --sh-card: 0 1px 2px rgba(9, 9, 11, 0.04);
  --sh-card-hover: 0 1px 2px rgba(9, 9, 11, 0.05);
  --sh-sticky: 0 0 24px rgba(239, 68, 68, 0.18);
  --sh-modal: 0 24px 48px rgba(9, 9, 11, 0.24);
  --sh-focus: 0 0 0 3px rgba(239, 68, 68, 0.30);
}

/* ==========================================================================
 * prefers-reduced-motion — respeita user setting
 * ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0.01ms;
    --dur-base: 0.01ms;
    --dur-med: 0.01ms;
    --dur-slow: 0.01ms;
    --dur-enter: 0.01ms;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
