/* ============================================================
   RETRODEX — terminal.css — Design System (Layer 1)
   ============================================================
   Based on DOCTRINE.md §V — Terminal Diégétique
   "Bloomberg Terminal meets Game Boy Color"

   This file is the SOLE design system — replaces core.css.
   Contains: global base styles, legacy variable aliases,
   --rdx- prefixed tokens, and opt-in utility classes.

   Import order (when migrated):
   terminal.css → components.css → zones.css → codec.css
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500&display=swap');

/* ── Design Tokens ────────────────────────────────────────── */

:root {
  /* Palette CRT — 10 couleurs (DOCTRINE §V) */
  --rdx-phosphor:        #00FF41;
  --rdx-phosphor-dim:    rgba(0, 255, 65, 0.7);
  --rdx-phosphor-off:    rgba(0, 255, 65, 0.15);
  --rdx-gold:            #FFD700;
  --rdx-danger:          #FF4444;
  --rdx-positive:        #44FF44;
  --rdx-text:            #D4D0C8;
  --rdx-bg:              #060806;
  --rdx-bg-panel:        #0C0E0C;
  --rdx-border:          #1A1A1A;

  /* Typography — 2 families */
  --rdx-font-system:     'IBM Plex Mono', 'Courier New', monospace;
  --rdx-font-reading:    'IBM Plex Sans', system-ui, sans-serif;

  /* Type scale — 6 levels (DOCTRINE §V) */
  --rdx-h1:              28px;
  --rdx-h2:              20px;
  --rdx-h3:              16px;
  --rdx-body:            15px;
  --rdx-small:           12px;
  --rdx-badge:           10px;

  /* Font weights */
  --rdx-weight-regular:  400;
  --rdx-weight-medium:   500;
  --rdx-weight-bold:     600;

  /* Spacing */
  --rdx-space-xs:        4px;
  --rdx-space-sm:        8px;
  --rdx-space-md:        16px;
  --rdx-space-lg:        24px;
  --rdx-space-xl:        32px;
  --rdx-space-2xl:       48px;

  /* Layout */
  --rdx-content-max:     1180px;
  --rdx-gutter:          24px;
  --rdx-radius:          4px;

  /* CRT effects */
  --rdx-scanline-opacity:    0.06;
  --rdx-scanline-header:     0.12;
  --rdx-grain-opacity:       0.03;
  --rdx-vignette-opacity:    0.4;
  --rdx-glow-color:          rgba(0, 255, 65, 0.3);
  --rdx-glow-spread:         8px;

  /* Transitions */
  --rdx-transition-fast:     150ms ease;
  --rdx-transition-normal:   250ms ease;
  --rdx-transition-slow:     400ms ease;

  /* ── Legacy variable aliases (consumed by components.css, zones.css, codec.css) ── */
  --bg:              #000000;
  --bg-surface:      #050805;
  --bg-card:         #0a0f0a;
  --border:          #1a2a1a;
  --text-primary:    #00ff66;
  --text-secondary:  #00994c;
  --text-muted:      #4a8a54;
  --text-value:      #33ff99;
  --text-alert:      #ffcc00;
  --text-danger:     #FF4444;
  --text-disabled:   #486648;
  --accent:          #00ff66;
  --accent-dim:      #005c22;
  --condition-loose: #888888;
  --condition-cib:   #4ecdc4;
  --condition-mint:  #ffd700;
  --confidence-low:  #e05252;
  --confidence-mid:  #e0b352;
  --confidence-high: #52e052;
  --rarity-epic:     #c48be8;
  --rarity-uncommon: #44aadd;
  --nav-label:       #b8d658;
  --status-negative: #e05252;
  --status-info:     #38bdf8;
  --font-ui:         'IBM Plex Mono', 'Courier New', monospace;
  --font-display:    'IBM Plex Mono', 'Courier New', monospace;
  --font-mono:       var(--font-ui);
  --font-size-base:  13px;
  --line-height:     1.4;
  --radius:          0px;
  --space-xs:        4px;
  --space-sm:        8px;
  --space-md:        16px;
  --space-lg:        24px;
  --space-xl:        32px;
  --space-section:   24px;
  --content-max:     1180px;
  --content-gutter:  24px;
}

/* ── Global Base Styles (from core.css) ──────────────────── */

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

html {
  background-color: var(--bg);
  min-height: 100vh;
}

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  background: var(--bg);
  color: var(--text-primary);
  padding: 20px 16px;
  padding-bottom: 60px;
  overflow-wrap: break-word;
  word-break: break-word;
}

a { color: var(--text-primary); }

.btn,
button,
input,
select,
textarea,
label {
  font-family: var(--font-ui);
}

img { max-width: 100%; }

/* ── Accessibility ───────────────────────────────────────── */

.skip-link { position: absolute; top: -60px; left: 0; background: var(--accent); color: var(--bg); padding: 8px 16px; z-index: 9999; font-family: var(--font-ui); font-size: 12px; text-decoration: none; }
.skip-link:focus { top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible,
.terminal-filter-btn:focus-visible, .cockpit-signal-card:focus-visible,
.tab-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Layout Containers ───────────────────────────────────── */

.rdx-container {
  width: min(var(--content-max), calc(100% - var(--content-gutter) * 2));
  margin-left: auto;
  margin-right: auto;
}
@media (max-width: 768px) {
  .rdx-container {
    width: min(var(--content-max), calc(100% - 24px));
  }
}

/* ── Display Fonts ───────────────────────────────────────── */

.wordmark,
.page-title,
.page-title-display,
.hub-page-title,
.hub-universe-title,
.product-universe-title,
.universe-hero {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.12;
  letter-spacing: 0.08em;
}

/* ── Footer ──────────────────────────────────────────────── */

.footer-attribution {
  max-width: var(--content-max, 1180px);
  margin: 24px auto 0;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.footer-attribution a {
  color: var(--text-alert);
  text-decoration: none;
}

.footer-attribution a:hover {
  text-decoration: underline;
}

/* ── Typography Classes ───────────────────────────────────── */

/* System titles — IBM Plex Mono 500 */
.rdx-title {
  font-family: var(--rdx-font-system);
  font-size: var(--rdx-h1);
  font-weight: var(--rdx-weight-medium);
  color: var(--rdx-phosphor);
  line-height: 1.15;
  letter-spacing: 0.04em;
}

.rdx-h2 {
  font-family: var(--rdx-font-system);
  font-size: var(--rdx-h2);
  font-weight: var(--rdx-weight-medium);
  color: var(--rdx-phosphor);
  line-height: 1.2;
  letter-spacing: 0.03em;
}

.rdx-h3 {
  font-family: var(--rdx-font-system);
  font-size: var(--rdx-h3);
  font-weight: var(--rdx-weight-medium);
  color: var(--rdx-text);
  line-height: 1.3;
}

/* HUD labels — IBM Plex Mono 400, uppercase */
.rdx-label {
  font-family: var(--rdx-font-system);
  font-size: var(--rdx-small);
  font-weight: var(--rdx-weight-regular);
  color: var(--rdx-phosphor-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.4;
}

/* Body reading — IBM Plex Sans 400 */
.rdx-reading {
  font-family: var(--rdx-font-reading);
  font-size: var(--rdx-body);
  font-weight: var(--rdx-weight-regular);
  color: var(--rdx-text);
  line-height: 1.55;
}

/* Data / numbers — IBM Plex Mono 500 */
.rdx-data {
  font-family: var(--rdx-font-system);
  font-size: var(--rdx-h3);
  font-weight: var(--rdx-weight-medium);
  color: var(--rdx-text);
  letter-spacing: 0.02em;
}

.rdx-data-lg {
  font-family: var(--rdx-font-system);
  font-size: var(--rdx-h2);
  font-weight: var(--rdx-weight-medium);
  letter-spacing: 0.02em;
}

/* Codec voice — IBM Plex Mono 400 13px */
.rdx-codec-voice {
  font-family: var(--rdx-font-system);
  font-size: 13px;
  font-weight: var(--rdx-weight-regular);
  color: var(--rdx-phosphor);
  line-height: 1.5;
}

/* ── Color Utility Classes ────────────────────────────────── */

.rdx-phosphor    { color: var(--rdx-phosphor); }
.rdx-phosphor-dim { color: var(--rdx-phosphor-dim); }
.rdx-gold        { color: var(--rdx-gold); }
.rdx-danger      { color: var(--rdx-danger); }
.rdx-positive    { color: var(--rdx-positive); }
.rdx-dim         { color: var(--rdx-phosphor-off); }
.rdx-muted       { color: var(--rdx-phosphor-dim); }

/* Glow — ONLY for titles and badges, NEVER for body text */
.rdx-glow {
  text-shadow: 0 0 var(--rdx-glow-spread) var(--rdx-glow-color);
}

/* ── Structural Classes ───────────────────────────────────── */

/* Panel — full-width section background */
.rdx-panel {
  background: var(--rdx-bg-panel);
  border: 1px solid var(--rdx-border);
  padding: var(--rdx-space-lg);
}

/* Card — interactive content block */
.rdx-card {
  background: var(--rdx-bg-panel);
  border: 1px solid var(--rdx-border);
  border-radius: var(--rdx-radius);
  padding: var(--rdx-space-md) var(--rdx-space-lg);
  transition: border-color var(--rdx-transition-fast);
}

.rdx-card:hover {
  border-color: var(--rdx-phosphor-off);
}

/* Container — centered max-width */
.rdx-shell {
  width: min(var(--rdx-content-max), calc(100% - var(--rdx-gutter) * 2));
  margin-left: auto;
  margin-right: auto;
}

/* ── Badge Classes ────────────────────────────────────────── */

.rdx-badge {
  display: inline-block;
  font-family: var(--rdx-font-system);
  font-size: var(--rdx-badge);
  font-weight: var(--rdx-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  border-radius: 2px;
  line-height: 1.4;
}

.rdx-badge-legendary {
  color: var(--rdx-gold);
  border: 1px solid var(--rdx-gold);
  background: rgba(255, 215, 0, 0.08);
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.3);
}

.rdx-badge-epic {
  color: #c48be8;
  border: 1px solid #c48be8;
  background: rgba(196, 139, 232, 0.08);
  text-shadow: 0 0 6px rgba(196, 139, 232, 0.3);
}

.rdx-badge-rare {
  color: #38bdf8;
  border: 1px solid #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.rdx-badge-common {
  color: var(--rdx-phosphor-dim);
  border: 1px solid var(--rdx-border);
  background: transparent;
}

/* ── Navigation HUD ───────────────────────────────────────── */

.rdx-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--rdx-space-sm);
  width: min(var(--rdx-content-max), calc(100% - var(--rdx-gutter) * 2));
  margin: 0 auto var(--rdx-space-lg);
  align-items: stretch;
}

.rdx-nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--rdx-space-sm) var(--rdx-space-md);
  font-family: var(--rdx-font-system);
  font-size: var(--rdx-small);
  font-weight: var(--rdx-weight-regular);
  color: var(--rdx-phosphor-dim);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--rdx-border);
  background: transparent;
  transition: color var(--rdx-transition-fast),
              border-color var(--rdx-transition-fast),
              background var(--rdx-transition-fast);
  cursor: pointer;
}

.rdx-nav-tab:hover {
  color: var(--rdx-phosphor);
  border-color: var(--rdx-phosphor-off);
  background: rgba(0, 255, 65, 0.03);
}

.rdx-nav-tab.active {
  color: var(--rdx-phosphor);
  border-color: var(--rdx-phosphor-dim);
  background: rgba(0, 255, 65, 0.06);
  text-shadow: 0 0 6px var(--rdx-glow-color);
}

.rdx-nav-tab-label {
  font-weight: var(--rdx-weight-medium);
  font-size: var(--rdx-small);
}

.rdx-nav-tab-sub {
  font-size: 9px;
  color: var(--rdx-phosphor-dim);
  opacity: 0.7;
}

/* ── Price Display ────────────────────────────────────────── */

.rdx-price {
  font-family: var(--rdx-font-system);
  font-weight: var(--rdx-weight-medium);
  color: var(--rdx-gold);
}

.rdx-price-lg {
  font-size: var(--rdx-h2);
}

.rdx-price-sm {
  font-size: var(--rdx-h3);
}

.rdx-delta-up {
  color: var(--rdx-positive);
}

.rdx-delta-down {
  color: var(--rdx-danger);
}

/* ── CRT Effects — Opt-in via body.rdx-crt-enabled ────────── */

/* Scanlines overlay */
body.rdx-crt-enabled::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1px,
    rgba(0, 0, 0, var(--rdx-scanline-opacity)) 1px,
    rgba(0, 0, 0, var(--rdx-scanline-opacity)) 2px
  );
  pointer-events: none;
  z-index: 9998;
}

/* Vignette overlay */
body.rdx-crt-enabled::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    ellipse at center,
    transparent 60%,
    rgba(0, 0, 0, var(--rdx-vignette-opacity)) 100%
  );
  pointer-events: none;
  z-index: 9997;
}

/* ── Blink Cursor (search bar) ────────────────────────────── */

@keyframes rdx-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.rdx-cursor-blink::after {
  content: '_';
  animation: rdx-blink 1s step-end infinite;
  color: var(--rdx-phosphor);
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 980px) {
  .rdx-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--rdx-space-xs);
  }

  .rdx-nav-tab {
    padding: var(--rdx-space-xs) var(--rdx-space-sm);
    font-size: 10px;
  }

  .rdx-nav-tab-sub {
    display: none;
  }

  .rdx-shell {
    width: min(100%, calc(100% - var(--rdx-space-md)));
  }
}

@media (max-width: 640px) {
  :root {
    --rdx-h1:    22px;
    --rdx-h2:    18px;
    --rdx-h3:    15px;
    --rdx-body:  14px;
  }

  .rdx-nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .rdx-panel {
    padding: var(--rdx-space-md);
  }

  .rdx-card {
    padding: var(--rdx-space-sm) var(--rdx-space-md);
  }
}

/* ── Reduced Motion ───────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .rdx-cursor-blink::after {
    animation: none;
  }

  body.rdx-crt-enabled::before,
  body.rdx-crt-enabled::after {
    display: none;
  }

  .rdx-card {
    transition: none;
  }

  .rdx-nav-tab {
    transition: none;
  }
}

/* ── Hub Hero & Proof Cards (migrated from effects.css) ──── */

.landing-hero {
  text-align: center;
  padding: 32px 24px 16px;
  max-width: var(--content-max);
  margin: 0 auto;
}

.landing-title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  color: var(--accent);
  margin-bottom: 8px;
  letter-spacing: 0.12em;
  font-weight: 400;
}

.landing-tagline {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.landing-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.landing-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.landing-cta-primary {
  display: inline-block;
  padding: 10px 24px;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  text-decoration: none;
  letter-spacing: 0.06em;
  transition: background 0.2s, color 0.2s;
}

.landing-cta-primary:hover {
  background: var(--accent);
  color: var(--bg);
}

.landing-cta-secondary {
  display: inline-block;
  padding: 10px 24px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  text-decoration: none;
  letter-spacing: 0.06em;
  transition: border-color 0.2s;
}

.landing-cta-secondary:hover {
  border-color: var(--text-secondary);
}

@media (max-width: 480px) {
  .landing-title { font-size: 1.6rem; }
  .landing-tagline { font-size: 0.8rem; }
  .landing-hero { padding: 32px 16px 24px; }
}

.landing-proof {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 24px;
}

.proof-card {
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.proof-label {
  font-size: 0.62rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.proof-example {
  font-size: 0.7rem;
  color: var(--text-primary);
}

.proof-value {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: bold;
}

.proof-verdict {
  font-size: 0.6rem;
  color: var(--text-secondary);
  font-style: italic;
}

@media (max-width: 640px) {
  .landing-proof { grid-template-columns: 1fr; padding: 0 16px; }
}
