/* ═══════════════════════════════════════════════════════════
   Pulse Chat UI — Design tokens
   Spatial Pulse + Kinetic Uncensored + Chat Materiality freeze
   (Sprint 3.4). Structural color changes = new design pass.
   ═══════════════════════════════════════════════════════════ */

:root,
html[data-theme="premium"] {
  /* Deep Space */
  --space-base: #0B0A08;
  --space-elevated: #16130E;
  --orb-blue: rgba(255, 158, 44, 0.07);
  --orb-cyan: rgba(255, 158, 44, 0.10);
  --orb-amber: rgba(255, 180, 40, 0.03); /* premium mesh only; transparent in HACK */
  --noise-opacity: 0.03;
  --vignette: rgba(0, 0, 0, 0.5);

  /* Sprint 6 — Brand vitality (bridge-linked motion) */
  --vitality-online: #3DFF88;
  --vitality-online-soft: rgba(61, 255, 136, 0.38);
  --vitality-warn: #f59e0b;
  --vitality-warn-soft: rgba(245, 158, 11, 0.4);
  --vitality-offline: #f87171;
  --vitality-offline-soft: rgba(248, 113, 113, 0.35);
  --vitality-sinus: 2.6s;
  --vitality-think: 1.4s;
  --vitality-tachy: 0.95s;
  --vitality-ring-slow: 48s;
  --vitality-ring-mid: 64s;

  /* Pulse Signal — motion tokens (semantic, not decorative) */
  --motion-ack: 140ms;
  --motion-enter: 180ms;
  --motion-transfer: 260ms;
  --motion-settle: 220ms;
  --motion-ambient: 2100ms;
  --motion-distance-sm: 4px;
  --motion-distance-md: 10px;
  --motion-glow-low: 0.2;
  --motion-glow-active: 0.72;
  --motion-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --motion-ease-flow: cubic-bezier(0.45, 0, 0.2, 1);

  /* Pulse Glass — Onda 0: scrim ≥85% para contraste AA em ambos os temas */
  --glass-bg: rgba(16, 18, 26, 0.88);
  --glass-bg-hover: rgba(20, 24, 36, 0.92);
  --glass-blur: 12px;
  --glass-saturate: saturate(160%);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-highlight: rgba(255, 255, 255, 0.06);
  --glass-shadow:
    0 8px 32px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 158, 44, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --glass-radius: var(--radius-lg);

  /* Surfaces */
  --bg: #16130E;
  --bg-deep: var(--space-base);
  --bg-elevated: rgba(22, 19, 14, 0.82);
  --bg-sidebar: var(--glass-bg);
  --bg-panel: rgba(22, 19, 14, 0.9);
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-user: rgba(255, 158, 44, 0.10);
  --bg-assistant: rgba(16, 14, 11, 0.82);
  --bubble-blur: 12px;
  --bubble-glass-window: 6; /* last N msgs get backdrop-filter */
  --bg-code: #000000;
  --bg-glass: rgba(18, 18, 22, 0.45);

  /* Elevação tonal L0–L3 (Onda 0) — camadas de profundidade sem sombra */
  --elevation-l0: #0B0A08;   /* canvas base */
  --elevation-l1: #16130E;   /* surface / cards */
  --elevation-l2: #211B13;   /* elevated / hover */
  --elevation-l3: #2B2318;   /* overlay / modals */
  --elevation-spotlight: rgba(255, 158, 44, 0.04); /* cyan highlight on L2+ */

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-soft: rgba(255, 255, 255, 0.04);
  --border-strong: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(255, 158, 44, 0.28);

  /* Text */
  --text: #D8D0C4;
  --text-strong: #F2EDE4;
  --muted: #A39A8B;
  --faint: #9B9284;

  /* Accents */
  --accent: #FF9E2C;
  --accent-cyan: #FF9E2C;
  --accent-2: #3DFF88;
  --accent-amber: #FF9E2C;
  --accent-dim: rgba(255, 158, 44, 0.12);
  --accent-glow: rgba(255, 158, 44, 0.22);
  --accent-glow-strong: rgba(255, 158, 44, 0.35);

  /* Semantic */
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.08);
  --success: #34d399;
  --warning: #fbbf24;

  /* Spacing Scale (8pt strict) */
  --space-2: 2px;
  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-24: 24px;
  --space-32: 32px;
  --space-48: 48px;
  --space-64: 64px;

  /* Geometry — Onda 0: escala completa 4→8→12→16→24→999 */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius: 8px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* Type */
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --font-scale: 1;
  --line: 1.5;

  /* Layout */
  --space: 1rem;
  --sidebar-w: 280px;
  --chat-max: 784px;
  --composer-max: 784px;
  --header-h: 56px;
  --msg-pad: 1rem 1.25rem;
  --msg-pad-user: 0.75rem 1rem;
  --density-gap: 2rem; /* 32px turn spacing (8pt snap) */

  /* Chat prose rhythm */
  --prose-size: calc(1rem * var(--font-scale));
  --prose-line: 1.5;
  --user-line: 1.5;
  --user-max: 75%;
  --ai-max: min(720px, 92%);

  /* Motion / depth */
  --transition: 0.3s ease;
  --transition-fast: 0.15s ease;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 4px 24px rgba(0, 0, 0, 0.35);
  --glow-cyan: 0 0 20px rgba(255, 158, 44, 0.15);
  --scanline: 0;

  /* Editorial & Ruptura Visual Tokens (Sprint P0) */
  --text-editorial: #f0ece4;
  --text-secondary-warm: #b8a99a;
  --surface-warm: #1c1a16;
  --surface-primary: #10141d;
  --surface-elevated: #1a1f2e;

  /* Ciano R9 — 3 níveis semânticos */
  --cyan-action: #FF9E2C;
  --cyan-structural: rgba(255, 158, 44, 0.20);
  --cyan-atmospheric: rgba(255, 158, 44, 0.06);

  /* Motion Tokens */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-instant: 100ms;
  --duration-fast: 200ms;
  --duration-medium: 350ms;
  --duration-slow: 600ms;
  --stagger-step: 80ms;
}

html[data-theme="hacker"] {
  /* Terminal verde — mesma família cromática da prova na landing */
  --space-base: #0A0C10;
  --space-elevated: #10131A;
  --orb-blue: rgba(0, 180, 220, 0.08);
  --orb-cyan: rgba(61, 255, 136, 0.09);
  --orb-amber: transparent;
  --noise-opacity: 0.025;
  --vignette: rgba(0, 0, 0, 0.58);

  --glass-bg: rgba(8, 12, 18, 0.88);
  --glass-bg-hover: rgba(12, 18, 24, 0.92);
  --glass-border: rgba(61, 255, 136, 0.1);
  --glass-highlight: rgba(61, 255, 136, 0.06);
  --glass-shadow:
    0 8px 32px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(61, 255, 136, 0.06),
    inset 0 1px 0 rgba(61, 255, 136, 0.05);

  --bg: #0A0C10;
  --bg-deep: var(--space-base);
  --bg-elevated: rgba(8, 10, 10, 0.78);
  --bg-sidebar: var(--glass-bg);
  --bg-panel: rgba(8, 12, 12, 0.9);
  --bg-hover: rgba(61, 255, 136, 0.04);
  --bg-user: rgba(0, 20, 24, 0.72);
  --bg-assistant: rgba(8, 12, 14, 0.78);
  --bubble-blur: 12px;
  --bubble-glass-window: 6;
  --bg-code: #000000;
  --bg-glass: rgba(0, 12, 14, 0.5);

  /* Elevação tonal L0–L3 (Onda 0) — hacker */
  --elevation-l0: #060A0E;
  --elevation-l1: #0C1016;
  --elevation-l2: #121820;
  --elevation-l3: #1A2028;
  --elevation-spotlight: rgba(61, 255, 136, 0.06);

  --border: rgba(61, 255, 136, 0.1);
  --border-soft: rgba(61, 255, 136, 0.06);
  --border-strong: rgba(61, 255, 136, 0.22);
  --border-glow: rgba(61, 255, 136, 0.35);

  --text: #c8d4d8;
  --text-strong: #e0f7fa;
  --muted: #7a9098;
  --faint: #8899A4;

  --accent: #3DFF88;
  --accent-cyan: #3DFF88;
  --accent-2: #3DFF88;
  --accent-amber: #3DFF88;
  --accent-dim: rgba(61, 255, 136, 0.1);
  --accent-glow: rgba(61, 255, 136, 0.28);
  --accent-glow-strong: rgba(61, 255, 136, 0.45);
  --warning: #3DFF88;

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --scanline: 1;
  --glow-cyan: 0 0 24px rgba(61, 255, 136, 0.2);
}

html[data-density="compact"] {
  --msg-pad: 0.75rem 1rem;
  --msg-pad-user: 0.5rem 0.75rem;
  --density-gap: 1.25rem;
  --space: 0.75rem;
  --prose-line: 1.5;
}

html[data-font="sm"] { --font-scale: 0.92; }
html[data-font="md"] { --font-scale: 1; }
html[data-font="lg"] { --font-scale: 1.12; }

html[data-width="wide"] {
  --chat-max: 980px;
  --composer-max: 980px;
}

html[data-hacker-fx="off"] {
  --scanline: 0;
}
