/* ═══════════════════════════════════════════════════════════════════
   Averionics Theme — canonical tokens
   ───────────────────────────────────────────────────────────────────
   Source of truth: payment processing/averionics_theme_pack.md
   Style: technical-instrument-panel-hud-aerospace-cockpit
   Mode default: Midnight Command (dark). Companion: Precision White.
   Accent ratio: 80 neutrals / 15 cyan emphasis / 5 orange action.
   Do not edit per-application. Override via [data-theme] only.

   2026-07-07 — color/font/radius/shadow VALUES ported from Iliad
   (axis-iliad's theme.css, the sibling AXIS product) for brand
   consistency; token NAMES unchanged so every existing --av-* consumer
   across the codebase keeps working untouched. Iliad's own light-mode
   accent/amber/success/warning values are themselves AA-corrected over
   their raw generated palette (see Iliad's theme.css header) — carried
   through here as-is. Spacing scale (--av-space-*) is intentionally
   NOT remapped to Iliad's rem-based scale: hundreds of existing layout
   rules depend on Foundry's own px scale, and spacing is structural,
   not a brand-visual property. --av-accent-purple has no Iliad
   equivalent (Iliad has no purple token) — kept as Foundry's own value.
   ═══════════════════════════════════════════════════════════════════ */

:root,
:root[data-theme="averionics-dark"] {
  /* Surfaces — Iliad dark (axis-iliad theme.css [data-theme="dark"]) */
  --av-bg-canvas:    #070B11;
  --av-bg-surface-1: #0D141D;
  --av-bg-surface-2: #141E29;
  --av-bg-surface-3: #1B2733;
  --av-bg-elevated:  #29384A;

  /* Foreground */
  --av-fg-primary:   #D6E2EE;
  --av-fg-secondary: #AEBCCD;
  --av-fg-tertiary:  #8B9BB0;

  /* Lines */
  --av-line-soft:    #1B2733;
  --av-line-strong:  #29384A;

  /* Accents */
  --av-accent-cyan:        #22D3EE;
  --av-accent-cyan-soft:   #67E8F9;
  --av-accent-orange:      #FFB020;
  --av-accent-orange-soft: #FFC53D;
  --av-accent-purple:      #996FF7;  /* multi-stage visualizations — no Iliad equivalent; lightened 2026-07-07 from #8B5CF6, hue-preserving, to clear WCAG AA 3:1 against the new --av-bg-elevated (was 2.82:1) */

  /* State */
  --av-state-success: #2EE6A6;
  --av-state-warning: #FFC53D;
  --av-state-danger:  #FF5D6C;

  /* Geometry — Iliad radius scale (rem values converted to px) */
  --av-radius-sm:   4px;
  --av-radius-md:   6px;
  --av-radius-lg:   8px;
  --av-radius-xl:   12px;
  --av-radius-pill: 9999px;

  /* Spacing scale — Foundry's own; not part of the Iliad port (see header) */
  --av-space-1: 4px;
  --av-space-2: 8px;
  --av-space-3: 12px;
  --av-space-4: 16px;
  --av-space-5: 20px;
  --av-space-6: 24px;
  --av-space-7: 32px;
  --av-space-8: 40px;
  --av-space-9: 48px;

  /* Elevation — Iliad dark shadow scale */
  --av-shadow-low:  0 1px 2px rgba(0,0,0,0.4);
  --av-shadow-mid:  0 1px 2px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.35);
  --av-shadow-high: 0 10px 18px rgba(0,0,0,0.55);

  /* Glow — used only for active / focused / armed states (Iliad's --glow formula) */
  --av-glow-cyan:   0 0 0 1px rgba(34,211,238,0.55), 0 0 18px rgba(34,211,238,0.28);
  --av-glow-orange: 0 0 0 1px rgba(255,176,32,0.55), 0 0 18px rgba(255,176,32,0.28);

  /* Motion — measured, mechanical, never bouncy */
  --av-duration-control: 150ms;
  --av-duration-panel:   220ms;
  --av-duration-dock:    180ms;
  --av-easing-out:       cubic-bezier(0.16, 1, 0.3, 1);
  --av-easing-in-out:    cubic-bezier(0.4, 0, 0.2, 1);

  /* Type — Iliad's fonts (self-hosted; see css/fonts.css) */
  --av-font-ui:   "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --av-font-mono: "JetBrains Mono", "Fira Code", "Consolas", monospace;
}

:root[data-theme="averionics-light"] {
  /* Surfaces — Iliad light (axis-iliad theme.css :root default block) */
  --av-bg-canvas:    #ECEFF3;
  --av-bg-surface-1: #FFFFFF;
  --av-bg-surface-2: #F4F6F9;
  --av-bg-surface-3: #E8EDF3;
  --av-bg-elevated:  #FFFFFF;

  --av-fg-primary:   #0D141D;
  --av-fg-secondary: #324153;
  --av-fg-tertiary:  #44566B;

  --av-line-soft:    #CFD9E4;
  --av-line-strong:  #AEBCCD;

  /* AA-corrected values per Iliad's own theme.css (their raw generated
     palette failed AA on light tints; these are the app's shipped fix). */
  --av-accent-cyan:        #0A5A6B;
  --av-accent-cyan-soft:   #22D3EE;
  --av-accent-orange:      #7A4900;
  --av-accent-orange-soft: #A85C00;
  --av-accent-purple:      #7C3AED;  /* multi-stage visualizations — no Iliad equivalent */

  /* State — light mode (Iliad's AA-corrected values) */
  --av-state-success: #0A6638;
  --av-state-warning: #7A4900;
  --av-state-danger:  #B01F1F;

  --av-shadow-low:  0 1px 2px rgba(0,0,0,0.05);
  --av-shadow-mid:  0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.1);
  --av-shadow-high: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.1);

  --av-glow-cyan:   0 0 0 3px rgba(10,90,107,0.22);
  --av-glow-orange: 0 0 0 3px rgba(122,73,0,0.22);
}

/* ─── Auto-detect system mode (only when no explicit theme set) ─── */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --av-bg-canvas:    #ECEFF3;
    --av-bg-surface-1: #FFFFFF;
    --av-bg-surface-2: #F4F6F9;
    --av-bg-surface-3: #E8EDF3;
    --av-bg-elevated:  #FFFFFF;
    --av-fg-primary:   #0D141D;
    --av-fg-secondary: #324153;
    --av-fg-tertiary:  #44566B;
    --av-line-soft:    #CFD9E4;
    --av-line-strong:  #AEBCCD;
    --av-accent-cyan:  #0A5A6B;
    --av-accent-orange:#7A4900;
    --av-shadow-low:  0 1px 2px rgba(0,0,0,0.05);
    --av-shadow-mid:  0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.1);
    --av-shadow-high: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.1);
  }
}

/* ─── Reusable Averionics primitives ─── */
.av-panel {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
    var(--av-bg-surface-2);
  border: 1px solid var(--av-line-soft);
  border-radius: var(--av-radius-lg);
  box-shadow: var(--av-shadow-mid), inset 0 1px 0 rgba(255,255,255,0.04);
  padding: var(--av-space-5);
}

.av-button {
  display: inline-flex;
  align-items: center;
  gap: var(--av-space-2);
  padding: var(--av-space-2) var(--av-space-4);
  border-radius: var(--av-radius-md);
  border: 1px solid var(--av-line-strong);
  background: var(--av-bg-surface-3);
  color: var(--av-fg-primary);
  font-family: var(--av-font-ui);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color  var(--av-duration-control) var(--av-easing-out),
    box-shadow    var(--av-duration-control) var(--av-easing-out),
    background    var(--av-duration-control) var(--av-easing-out);
}
.av-button:hover { border-color: var(--av-accent-cyan-soft); }
.av-button:focus-visible,
.av-button.is-active {
  outline: none;
  border-color: var(--av-accent-cyan);
  box-shadow: var(--av-glow-cyan);
}
.av-button.is-armed,
.av-button[data-variant="critical"] {
  border-color: var(--av-accent-orange);
}
.av-button.is-armed:focus-visible,
.av-button[data-variant="critical"]:focus-visible {
  box-shadow: var(--av-glow-orange);
}

/* Instrument-grade input wells */
.av-input {
  background: var(--av-bg-surface-1);
  border: 1px solid var(--av-line-soft);
  border-radius: var(--av-radius-sm);
  padding: var(--av-space-2) var(--av-space-3);
  color: var(--av-fg-primary);
  font-family: var(--av-font-ui);
  font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(0,0,0,0.18);
  transition: border-color var(--av-duration-control) var(--av-easing-out),
              box-shadow   var(--av-duration-control) var(--av-easing-out);
}
.av-input:focus {
  outline: none;
  border-color: var(--av-accent-cyan);
  box-shadow:
    inset 0 1px 0 rgba(0,0,0,0.18),
    0 0 0 1px rgba(24,210,255,0.45);
}

/* Micro-label — uppercase tracking ONLY for tiny labels */
.av-label {
  display: block;
  font-family: var(--av-font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--av-fg-tertiary);
  margin-bottom: var(--av-space-1);
}

/* Numeric / telemetry cells */
.av-mono {
  font-family: var(--av-font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  letter-spacing: 0;
}

/* Cyan = active/live, Orange = action/armed/anomaly */
.av-state-active   { color: var(--av-accent-cyan); }
.av-state-armed    { color: var(--av-accent-orange); }
.av-state-success  { color: var(--av-state-success); }
.av-state-warning  { color: var(--av-state-warning); }
.av-state-danger   { color: var(--av-state-danger); }

/* Docking sockets — receiving plate, not generic highlight */
.av-dock-socket {
  position: relative;
  border-radius: 14px;
  border: 1px solid var(--av-line-soft);
  background: color-mix(in srgb, var(--av-bg-surface-1) 92%, black);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.05),
    inset 0 -8px 16px rgba(0,0,0,0.12);
  transition: border-color var(--av-duration-dock) var(--av-easing-out),
              box-shadow   var(--av-duration-dock) var(--av-easing-out);
}
.av-dock-socket.is-target {
  border-color: rgba(24,210,255,0.55);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -8px 16px rgba(0,0,0,0.12),
    0 0 0 1px rgba(24,210,255,0.28);
}

/* Reduced motion respect — averionics is restrained, but never punishes */
@media (prefers-reduced-motion: reduce) {
  :root {
    --av-duration-control: 0ms;
    --av-duration-panel:   0ms;
    --av-duration-dock:    0ms;
  }
}
