/* ═══════════════════════════════════════════════════════════════════
   FluideUI Core — Universal Reset & Base Variables
   ASGARD Design System — CDN: dash.asgard/themes/

   This file is design-agnostic. It provides:
   - CSS reset
   - Semantic variable slots (--p3x-*) that each design fills
   - Base typography and scrollbar
   - Status color system (universal across all designs)

   Usage: Always loaded first, before layout + design CSS.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset ── */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: var(--p3x-bg);
    color: var(--p3x-text);
    font-family: var(--p3x-font);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--p3x-accent); text-decoration: none; }
a:hover { color: var(--p3x-accent-light); }

/* ── Semantic Variable Slots ──
   These are filled by each design CSS (standard, lcars, weyland-yutani, protostar).
   Layouts and components use ONLY --p3x-* variables. */

:root {
    /* ── Backgrounds (filled by design) ── */
    --p3x-bg:              #0a0e14;
    --p3x-bg-panel:        #141923;
    --p3x-bg-surface:      #1a1f2e;
    --p3x-bg-elevated:     #2a2f3e;
    --p3x-bg-border:       rgba(255, 255, 255, 0.06);
    --p3x-bg-glass:        rgba(10, 10, 10, 0.85);
    --p3x-bg-glass-blur:   blur(12px);

    /* ── Accent Colors — sémantique → alias vers DECOR ──
       Les layouts et composants utilisent ces noms sémantiques.
       Les thèmes remplissent les DECOR, les alias suivent automatiquement. */
    --p3x-accent:          var(--p3x-decor-1);
    --p3x-accent-light:    var(--p3x-decor-2);
    --p3x-accent-glow:     var(--p3x-decor-3);
    --p3x-accent-dim:      var(--p3x-hover-1);
    --p3x-secondary:       var(--p3x-decor-4);

    /* ══ PALETTE DÉCORS byGP — 27 couleurs switchables en temps réel ══
       Structure Palette normalisée : chaque thème (Station) peut avoir
       N palettes différentes. Le switch = mise à jour de ces 27 variables.
       Source de vérité : API /api/v1/decors/palettes
       Valeurs par défaut ci-dessous = thème Standard. ══ */

    /* ── DECOR1-12 : Couleurs décoratives / accents (remplies par palette) ── */
    --p3x-decor-1:         #3498db;
    --p3x-decor-2:         #5dade2;
    --p3x-decor-3:         #00d4ff;
    --p3x-decor-4:         #2980b9;
    --p3x-decor-5:         #1a5276;
    --p3x-decor-6:         #154360;
    --p3x-decor-7:         transparent;
    --p3x-decor-8:         transparent;
    --p3x-decor-9:         transparent;
    --p3x-decor-10:        transparent;
    --p3x-decor-11:        transparent;
    --p3x-decor-12:        transparent;

    /* ── TEXT1-3 : Texte (rempli par palette) ── */
    --p3x-text:            #ecf0f1;       /* TEXT1 */
    --p3x-text-secondary:  #bdc3c7;       /* TEXT2 */
    --p3x-text-muted:      #7f8c8d;       /* TEXT3 */

    /* ── TEXTHOVER1-2, TEXTACCENT, TEXTWARNING ── */
    --p3x-text-hover:      #ffffff;       /* TEXTHOVER1 */
    --p3x-text-hover-2:    #ecf0f1;       /* TEXTHOVER2 */
    --p3x-text-accent:     #0a0e14;       /* TEXTACCENT — texte sur fond accent */
    --p3x-text-warning:    #ffaa00;       /* TEXTWARNING */

    /* ── BG1-3 : Fonds (remplis par palette) ── */
    /* Note : --p3x-bg, --p3x-bg-panel, --p3x-bg-surface ci-dessus = BG1, BG2, BG3 */

    /* ── HOVER1-2 : États hover (remplis par palette) ── */
    --p3x-hover-1:         rgba(52, 152, 219, 0.15);   /* HOVER1 */
    --p3x-hover-2:         rgba(52, 152, 219, 0.08);   /* HOVER2 */

    /* ── ALERT1, OK1, NEUTRAL1 : États système (remplis par palette) ── */
    /* Note : mappés vers --p3x-status-critical, --p3x-status-ok, --p3x-status-offline */

    /* ── Status (universal — same across all designs) ── */
    --p3x-status-ok:       #00ff88;
    --p3x-status-warn:     #ffaa00;
    --p3x-status-critical: #ff3344;
    --p3x-status-offline:  #555555;
    --p3x-status-info:     #3498db;

    /* ── Typography (filled by design) ── */
    --p3x-font:            -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --p3x-font-mono:       'SF Mono', 'Cascadia Code', 'Consolas', 'Liberation Mono', monospace;
    --p3x-font-display:    var(--p3x-font);

    /* ── Spacing ── */
    --p3x-gap-xs:          2px;
    --p3x-gap-sm:          4px;
    --p3x-gap-md:          8px;
    --p3x-gap-lg:          16px;
    --p3x-gap-xl:          24px;

    /* ── Borders (filled by design — WY uses 0, LCARS uses rounded) ── */
    --p3x-border:          var(--p3x-bg-border);
    --p3x-border-bright:   rgba(255, 255, 255, 0.15);

    /* ── Radius ── */
    --p3x-radius-sm:       4px;
    --p3x-radius-md:       6px;
    --p3x-radius-lg:       8px;
    --p3x-radius-round:    40px;

    /* ── Glow (filled by design — used for status emphasis, hover effects) ── */
    --p3x-glow-accent:     0 0 8px var(--p3x-accent-dim);
    --p3x-glow-ok:         0 0 8px rgba(0, 255, 136, 0.3);
    --p3x-glow-warn:       0 0 8px rgba(255, 170, 0, 0.3);
    --p3x-glow-critical:   0 0 8px rgba(255, 51, 68, 0.3);
    --p3x-glow-info:       0 0 8px rgba(52, 152, 219, 0.3);

    /* ── Transitions ── */
    --p3x-transition:      0.2s ease;
    --p3x-transition-slow: 0.5s ease;

    /* ── Z-Index Layers ── */
    --p3x-z-panel:         10;
    --p3x-z-dropdown:      100;
    --p3x-z-modal:         1000;
    --p3x-z-toast:         2000;
    --p3x-z-overlay:       5000;
    --p3x-z-sector-float:  9000;

    /* ── Sector Sizes — Origin: FluideUI layout ── */
    --p3x-header-h:        48px;
    --p3x-footer-h:        32px;
    --p3x-nav-w:           280px;
    --p3x-ctx-w:           320px;
    --p3x-resizer-w:       4px;
    --p3x-stage-console-h: 50%;
    --p3x-stage-console-min: 100px;
    --p3x-stage-console-max: 80%;

    /* ── Sector Sizes — Origin: 10Foot layout ── */
    --p3x-topbar-h:        56px;
    --p3x-dock-h:          72px;
    --p3x-drawer-w:        320px;
    --p3x-drawer-right-w:  400px;
    --p3x-safe-h:          48px;      /* TV safe area horizontal */
    --p3x-safe-v:          27px;      /* TV safe area vertical */
    --p3x-poster-w:        200px;
    --p3x-poster-h:        300px;
    --p3x-poster-ratio:    2 / 3;
    --p3x-focus-scale:     1.05;
    --p3x-focus-ring:      3px solid var(--p3x-accent);
    --p3x-focus-glow:      0 0 12px var(--p3x-accent-dim);
    --p3x-font-hero:       48px;
    --p3x-font-title:      32px;
    --p3x-font-body-lg:    18px;
    --p3x-font-caption:    14px;
    --p3x-target-min:      56px;      /* minimum touch/focus target */
}

/* ── Scrollbar (WebKit) ── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--p3x-bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--p3x-accent); }

/* ── Selection ── */

::selection {
    background: var(--p3x-accent-dim);
    color: var(--p3x-text);
}

/* ── Focus visible ── */

:focus-visible {
    outline: 2px solid var(--p3x-accent);
    outline-offset: 2px;
}

/* ── Universal component helpers ── */

.p3x-glass {
    background: var(--p3x-bg-glass);
    backdrop-filter: var(--p3x-bg-glass-blur);
    border: 1px solid var(--p3x-bg-border);
}

.p3x-mono { font-family: var(--p3x-font-mono); }
.p3x-uppercase { text-transform: uppercase; letter-spacing: 1px; }
.p3x-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Status dots (universal across all designs) ── */

.p3x-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    transition: background var(--p3x-transition);
}
.p3x-status-dot.ok       { background: var(--p3x-status-ok); box-shadow: 0 0 6px var(--p3x-status-ok); }
.p3x-status-dot.warn     { background: var(--p3x-status-warn); box-shadow: 0 0 6px var(--p3x-status-warn); }
.p3x-status-dot.critical { background: var(--p3x-status-critical); box-shadow: 0 0 6px var(--p3x-status-critical); animation: p3x-pulse 1.5s ease-in-out infinite; }
.p3x-status-dot.offline  { background: var(--p3x-status-offline); }

@keyframes p3x-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
