/* ═══════════════════════════════════════════════════════
   Speed Signal — Design Tokens
   Shared across all section files
   ═══════════════════════════════════════════════════════ */

:root {
    /* ── Backgrounds ──
       --ss-bg-surface unified to #0C1322 (was #0F172A, a slightly more
       violet/blue tint Mason didn't want). All cards now use the darker,
       cooler --ss-bg-surface-alt-equivalent. -alt and -surface are now equal;
       kept both names for code that already references them. */
    --ss-bg:              #080D19;
    --ss-bg-surface:      #0C1322;
    --ss-bg-surface-alt:  #0C1322;
    --ss-bg-elevated:     #162036;
    --ss-bg-hover:        #131C30;
    /* Used ONLY in the Ticker Detail panel cards (sipCard, dCard, sip-metric-
       item) so they contrast with the dark surface around the SIP panel. */
    --ss-detail-card:     #0F1A2D;

    /* ── Borders ── */
    --ss-border:          rgba(255, 255, 255, 0.06);
    --ss-border-hover:    rgba(255, 255, 255, 0.12);
    --ss-border-accent:   rgba(34, 197, 94, 0.25);
    --ss-border-danger:   rgba(239, 68, 68, 0.25);   /* borde de callouts danger/error (paralelo a -accent) */

    /* ── Accent palette ── */
    --ss-green:           #22C55E;
    --ss-green-light:     #4ADE80;
    --ss-green-dim:       rgba(34, 197, 94, 0.06);
    --ss-green-dim-hover: rgba(34, 197, 94, 0.16);
    --ss-teal:            #14B8A6;
    --ss-teal-light:      #2DD4BF;
    --ss-teal-dim:        rgba(20, 184, 166, 0.06);
    --ss-cyan:            #7FA0C8;
    --ss-cyan-dim:        rgba(127, 160, 200, 0.18);
    --ss-red:             #EF4444;
    --ss-red-light:       #F87171;
    --ss-red-dark:        #DC2626;
    --ss-red-dim:         rgba(239, 68, 68, 0.08);
    --ss-amber:           #F59E0B;
    --ss-amber-light:     #FBBF24;
    --ss-amber-dark:      #D97706;
    --ss-amber-dim:       rgba(245, 158, 11, 0.08);
    /* Estado "saved" del botón Save (amber soft): bg + borde un poco más fuertes
       que -dim, para que el botón activo lea claramente como toggle ON. */
    --ss-amber-soft-bg:     rgba(245, 158, 11, 0.10);
    --ss-amber-soft-border: rgba(245, 158, 11, 0.30);
    --ss-blue:            #60A5FA;
    --ss-blue-dim:        rgba(96, 165, 250, 0.08);
    --ss-purple:          #A78BFA;
    --ss-purple-dim:      rgba(167, 139, 250, 0.08);

    /* ── Semantic — Phase colors ──
       One token per phase. To recolor a phase across the entire app, change
       the hex here; STATUS_CONFIG / STATUS_BADGE / STATUS_GG / charts and
       inline pills read from these tokens. The `-bg` variant (15% opacity)
       is for pill backgrounds; the `-dim` variant (6% opacity) is for
       subtle card backgrounds. */
    --ss-phase-coiling:           #7FA0C8;
    --ss-phase-coiling-bg:        rgba(127, 160, 200, 0.15);
    --ss-phase-coiling-dim:       rgba(127, 160, 200, 0.06);
    --ss-phase-pre-ignition:      #60A5FA;
    --ss-phase-pre-ignition-bg:   rgba(96, 165, 250, 0.15);
    --ss-phase-pre-ignition-dim:  rgba(96, 165, 250, 0.06);
    --ss-phase-liftoff:           #F59E0B;
    --ss-phase-liftoff-bg:        rgba(245, 158, 11, 0.15);
    --ss-phase-liftoff-dim:       rgba(245, 158, 11, 0.06);
    --ss-phase-below:             #8B9DB0;
    --ss-phase-below-bg:          rgba(157, 170, 182, 0.12);
    --ss-phase-below-dim:         rgba(157, 170, 182, 0.06);

    /* ── Semantic — Conviction levels ──
       Independent of phase color. Low → muted, High → strongest signal.
       Mason can recolor conviction here without touching phase colors. */
    --ss-conviction-low:          var(--ss-text-muted);
    --ss-conviction-medium:       var(--ss-phase-pre-ignition);
    --ss-conviction-high:         var(--ss-phase-liftoff);
    /* Empty/unfilled dot color — overridden in light theme. */
    --ss-conf-dot-empty:          rgba(255, 255, 255, 0.14);

    /* ── Text ── */
    --ss-text:            #F1F5F9;
    --ss-text-body:       #8B9DB0;
    --ss-text-secondary:  #94A3B8;
    --ss-text-muted:      #64748B;
    --ss-text-light:      #CBD5E1;
    --ss-text-lighter:    #E2E8F0;
    --ss-text-faint:      #475569;

    /* ── Gradients ── */
    --ss-grad-accent:     linear-gradient(135deg, #14B8A6 0%, #22C55E 100%);
    --ss-grad-score:      linear-gradient(90deg, #0D9488 0%, #14B8A6 40%, #22C55E 100%);
    --ss-grad-glow:       radial-gradient(ellipse at 25% 40%, rgba(20, 184, 166, 0.06) 0%, transparent 55%);
    --ss-grad-glow-alt:   radial-gradient(ellipse at 75% 80%, rgba(34, 197, 94, 0.04) 0%, transparent 50%);

    /* ── Radii ── */
    --ss-r-sm:   0.375rem;
    --ss-r-md:   0.625rem;
    --ss-r-lg:   0.875rem;
    --ss-r-xl:   1.125rem;
    --ss-r-2xl:  1.5rem;
    --ss-r-pill: 9999px;

    /* ── Shadows ── */
    --ss-shadow-card:     0 4px 24px -4px rgba(0, 0, 0, 0.35);
    --ss-shadow-glow-sm:  0 0 24px rgba(34, 197, 94, 0.15);
    --ss-shadow-glow-md:  0 0 48px rgba(34, 197, 94, 0.10);
    --ss-shadow-glow-lg:  0 0 80px rgba(20, 184, 166, 0.08);

    /* ── Motion ── */
    --ss-ease:            cubic-bezier(0.16, 1, 0.3, 1);
    --ss-ease-out:        cubic-bezier(0.33, 1, 0.68, 1);
    --ss-dur-fast:        150ms;
    --ss-dur-normal:      280ms;
    --ss-dur-slow:        500ms;

    /* ── Typography scale ── */
    --ss-font:            'Inter', system-ui, -apple-system, sans-serif;
    --ss-text-xs:         0.75rem;
    --ss-text-sm:         0.875rem;
    --ss-text-base:       1rem;
    --ss-text-lg:         1.125rem;
    --ss-text-xl:         1.25rem;
    --ss-text-2xl:        1.5rem;
    --ss-text-3xl:        1.875rem;
    --ss-text-4xl:        2.25rem;
    --ss-text-5xl:        3rem;
    --ss-text-6xl:        3.75rem;

    /* ════════════════════════════════════════════════════════════
       Redesign clean/iOS — tokens ADITIVOS (Redesign/design-system/).
       No cambian valores existentes; inertes hasta que la capa .ss-*
       (redesign-components.css) los use. Detalle: Redesign/design-system/tokens.md
       ════════════════════════════════════════════════════════════ */

    /* ── Spacing (base 4) ── */
    --ss-space-0:   0;
    --ss-space-1:   0.25rem;   /*  4px */
    --ss-space-2:   0.5rem;    /*  8px */
    --ss-space-3:   0.75rem;   /* 12px */
    --ss-space-4:   1rem;      /* 16px */
    --ss-space-5:   1.25rem;   /* 20px */
    --ss-space-6:   1.5rem;    /* 24px */
    --ss-space-8:   2rem;      /* 32px */
    --ss-space-10:  2.5rem;    /* 40px */
    --ss-space-12:  3rem;      /* 48px */

    /* ── Radii por rol (aliasan a los de tamaño) ── */
    --ss-r-control: var(--ss-r-md);    /* 10px — botones, inputs, selects, steppers */
    --ss-r-chip:    var(--ss-r-pill);  /* pill — chips, tags, status pills */
    --ss-r-card:    var(--ss-r-xl);    /* 18px — grouped cards, paneles */
    --ss-r-card-in: var(--ss-r-lg);    /* 14px — items internos (concéntrico) */
    --ss-r-modal:   var(--ss-r-xl);    /* 18px — modales centrados */
    --ss-r-sheet:   1.25rem;           /* 20px — esquinas sup. del bottom sheet */
    --ss-r-field:   var(--ss-r-md);    /* 10px — campos de formulario */
    --ss-r-segment: var(--ss-r-md);    /* 10px — track del segmented control */

    /* ── Elevación por rol (dark; light se override abajo) ── */
    --ss-elev-card:     var(--ss-shadow-card);
    --ss-elev-dropdown: 0 8px 24px -8px rgba(0, 0, 0, 0.55), 0 2px 6px -2px rgba(0, 0, 0, 0.35);
    --ss-elev-modal:    0 24px 70px -12px rgba(0, 0, 0, 0.65);
    --ss-elev-sheet:    0 -12px 40px -8px rgba(0, 0, 0, 0.55);

    /* ── Foreground sobre el gradiente de acento (NO flipea con el tema:
       el texto siempre va sobre el verde/teal, en dark Y light).
       [C] 2026-07-07 pedido del dueño: blanco (antes navy #080D19). ── */
    --ss-on-accent: #FFFFFF;

    /* ── Primitivos de componente (tokenizados para la regla cero-hex) ── */
    --ss-focus-ring:   0 0 0 3px rgba(34, 197, 94, 0.45);  /* anillo de focus-visible */
    --ss-knob-bg:      #fff;                                /* knob del switch (blanco en ambos temas) */
    --ss-knob-shadow:  0 1px 3px rgba(0, 0, 0, 0.3);        /* sombra del knob */

    /* ── Glass (solo chrome: header/sheet/overlay; nunca sobre datos) ── */
    --ss-glass-bg:     rgba(12, 19, 34, 0.72);
    --ss-glass-blur:   blur(18px);
    --ss-glass-border: rgba(255, 255, 255, 0.08);
    --ss-overlay-bg:     rgba(8, 13, 25, 0.55);      /* backdrop de modal/sheet */
    --ss-skeleton-shine: rgba(255, 255, 255, 0.06);  /* brillo del shimmer del skeleton */

    /* ── Pesos + line-heights ── */
    --ss-weight-regular:  400;
    --ss-weight-medium:   500;
    --ss-weight-semibold: 600;
    --ss-weight-bold:     700;
    --ss-weight-heavy:    800;
    --ss-leading-tight:   1.1;
    --ss-leading-snug:    1.3;
    --ss-leading-normal:  1.5;

    /* ── Chart / velas (los charts leen estos via getComputedStyle) ── */
    --ss-chart-up:      var(--ss-green);
    --ss-chart-down:    var(--ss-red);
    --ss-chart-grid:    rgba(255, 255, 255, 0.06);
    --ss-chart-axis:    var(--ss-text-faint);
    --ss-chart-text:    var(--ss-text-secondary);
    --ss-chart-surface: var(--ss-bg-surface);
    --ss-candle-up:     var(--ss-green);
    --ss-candle-down:   var(--ss-red);
    --ss-candle-wick:   var(--ss-text-faint);

    /* ── Chart palette (CC) — leídos por getCC() en JS; equivalentes 1:1 a CC_DARK/CC_LIGHT ── */
    --ss-cc-bg:       #080D19;
    --ss-cc-surface:  #080D19;
    --ss-cc-elevated: #162036;
    --ss-cc-border:   rgba(255,255,255,0.06);
    --ss-cc-text:     #F1F5F9;
    --ss-cc-text2:    #94A3B8;
    --ss-cc-text3:    #64748B;
    --ss-cc-text4:    #475569;
    --ss-cc-green:    #22C55E;
    --ss-cc-greenD:   #16A34A;
    --ss-cc-teal:     #14B8A6;
    --ss-cc-slate:    #334155;
    --ss-cc-red:      #F87171;
    --ss-cc-redD:     #EF4444;
    --ss-cc-amber:    #FBBF24;
    --ss-cc-amberD:   #F59E0B;
    --ss-cc-cyan:     #06B6D4;
    --ss-cc-purple:   #A78BFA;
    --ss-cc-purpleD:  #8B5CF6;
    --ss-cc-accentH:  #4ADE80;
    --ss-cc-grid:     rgba(255,255,255,0.04);
    --ss-cc-zeroline: rgba(255,255,255,0.08);
    /* Velas (Lightweight + ECharts candlestick): TradingView-style teal/red,
       distintos del verde/rojo de score para que el chart lea como un chart. */
    --ss-cc-candleUp:  #089981;
    --ss-cc-candleDn:  #F23645;
    /* Barras de volumen = vela con alpha 0.4 (mismo hue, atenuado). */
    --ss-cc-volUp:     rgba(8,153,129,0.4);
    --ss-cc-volDn:     rgba(242,54,69,0.4);
    /* Serie "line" (precio en modo línea) + su área degradé. */
    --ss-cc-line:      #60A5FA;
    --ss-cc-lineArea:  rgba(96,165,250,0.22);
    /* Texto sobre un chip/badge de color saturado del chart (markLine labels,
       Trigger/Risk Stop pills). Blanco en AMBOS temas: el fondo es siempre un
       color saturado (verde/rojo/candle), donde el blanco lee bien. NO flipea. */
    --ss-cc-onChip:    #fff;

    /* ── Dimensiones de componente iOS ── */
    --ss-tap-min:         44px;
    --ss-switch-w:        51px;
    --ss-switch-h:        31px;
    --ss-switch-knob:     27px;
    --ss-switch-travel:   20px;
    --ss-sheet-grabber-w: 36px;
    --ss-sheet-grabber-h: 5px;
}

/* ── Light theme overrides ──
   Hallazgo #18: the light theme was previously implemented via CSS attribute
   selectors that matched Tailwind class strings literally (e.g.
   [class*="bg-[#0F172A]"]). That blocked migrating hex to var() tokens.
   Now the tokens themselves switch value when data-theme="light" is set,
   so the HTML can use bg-[var(--ss-bg-surface)] and it Just Works™ in both
   themes without any attribute selectors. */
html[data-theme="light"] {
    /* ── Backgrounds ── */
    --ss-bg:              #F8FAFC;
    --ss-bg-surface:      #FFFFFF;
    --ss-bg-surface-alt:  #F1F5F9;
    --ss-bg-elevated:     #E2E8F0;
    --ss-bg-hover:        #F1F5F9;
    /* Detail panel cards (sipCard, dCard, sip-metric-item) — slightly darker
       than --ss-bg to make a sutil contrast with the page background. */
    --ss-detail-card:     #F1F5F9;
    /* Light-mode shadow: subtler than the dark equivalent (the dark version
       uses heavy black shadow which would look harsh on a white background).
       Two-layer shadow gives the 3D feel without darkening the bg too much. */
    --ss-shadow-card:     0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    /* Empty dot color — visible on white background. */
    --ss-conf-dot-empty:  rgba(15, 23, 42, 0.18);

    /* ── Borders ── */
    --ss-border:          rgba(0, 0, 0, 0.08);
    --ss-border-hover:    rgba(0, 0, 0, 0.15);
    --ss-border-accent:   rgba(34, 197, 94, 0.2);
    --ss-border-danger:   rgba(220, 38, 38, 0.2);

    /* ── Text ── */
    --ss-text:            #0F172A;
    --ss-text-body:       #627484;
    --ss-text-secondary:  #566878;
    --ss-text-muted:      #475569;
    --ss-text-faint:      #94A3B8;

    /* ── Status colors — darker for contrast on light bg ── */
    --ss-amber-light:     #B45309;
    --ss-amber-dim:       rgba(180, 83, 9, 0.08);
    --ss-amber-soft-bg:     rgba(180, 83, 9, 0.10);
    --ss-amber-soft-border: rgba(180, 83, 9, 0.30);
    /* Hover del botón AI Analysis (accent-soft) en light. */
    --ss-green-dim-hover:   rgba(22, 163, 74, 0.16);
    --ss-cyan:            #4A6587;
    --ss-cyan-dim:        rgba(74, 101, 135, 0.15);
    --ss-blue:            #2563EB;
    --ss-blue-dim:        rgba(37, 99, 235, 0.08);
    --ss-purple:          #7C3AED;
    --ss-purple-dim:      rgba(124, 58, 237, 0.08);
    --ss-red-light:       #DC2626;
    --ss-red-dim:         rgba(220, 38, 38, 0.08);

    /* M16: greens más oscuros para texto/badges sobre superficies blancas — el #22C55E
       y #4ADE80 originales tienen contraste WCAG insuficiente en light mode. */
    --ss-green:           #16A34A;
    --ss-green-light:     #15803D;
    --ss-green-dim:       rgba(22, 163, 74, 0.10);
    --ss-teal:            #0D9488;
    --ss-teal-light:      #0F766E;
    --ss-teal-dim:        rgba(13, 148, 136, 0.10);

    /* ── Redesign clean/iOS — overrides light de los tokens aditivos ── */
    --ss-elev-dropdown: 0 4px 12px -2px rgba(15, 23, 42, 0.12);
    --ss-elev-modal:    0 12px 32px -8px rgba(15, 23, 42, 0.18);
    --ss-elev-sheet:    0 -12px 32px -8px rgba(15, 23, 42, 0.16);
    --ss-glass-bg:      rgba(255, 255, 255, 0.72);
    --ss-glass-border:  rgba(15, 23, 42, 0.08);
    --ss-chart-grid:    rgba(15, 23, 42, 0.06);
    --ss-overlay-bg:     rgba(15, 23, 42, 0.45);
    --ss-skeleton-shine: rgba(15, 23, 42, 0.05);

    /* Chart palette (CC) — overrides light (solo las keys que difieren de dark;
       text3/green/greenD/red/redD/amber/amberD/cyan/purple/purpleD/accentH son
       idénticas a dark y heredan del :root). */
    --ss-cc-bg:       #F8FAFC;
    --ss-cc-surface:  #F8FAFC;
    --ss-cc-elevated: #F1F5F9;
    --ss-cc-border:   rgba(0,0,0,0.08);
    --ss-cc-text:     #0F172A;
    --ss-cc-text2:    #475569;
    --ss-cc-text4:    #94A3B8;
    --ss-cc-grid:     rgba(0,0,0,0.04);
    --ss-cc-zeroline: rgba(0,0,0,0.08);
    /* Velas en light: teal/red ligeramente más oscuros para contraste sobre blanco. */
    --ss-cc-candleUp:  #0F9D7A;
    --ss-cc-candleDn:  #E5484D;
    --ss-cc-volUp:     rgba(15,157,122,0.4);
    --ss-cc-volDn:     rgba(229,72,77,0.4);
    /* Serie line: azul más oscuro (matchea --ss-blue light) para legibilidad. */
    --ss-cc-line:      #2563EB;
    --ss-cc-lineArea:  rgba(37,99,235,0.18);
}
