/**
 * QuanterraOS Unified Design System Stylesheet
 *
 * Implements Phase 3 Task 3.2:
 * "Design tokens (Part 5) in one stylesheet."
 *
 * Requirements (QUANTERRAOS_ANTIGRAVITY_HANDOFF_V2.md Part 5):
 * 1. Public site (Tesla mode):
 *    - --bg: #000000, --fg: #FFFFFF, --muted: #8A8F98, --accent-gold: #C9A24A
 *    - One sans family (Inter or system), weights 400/600/700
 *    - Headlines: 56–72px desktop / 34–40px mobile
 *    - Full-viewport sections (100vh snap)
 *    - <=3 numbers per screen, <=2 buttons per panel
 * 2. Flight Deck (Celestial mode):
 *    - --space-900: #05060B, --space-700: #0D1120, --hud-cyan: #4FD1E8, --hud-gold: #C9A24A
 *    - --alert-red: #E5484D, --ok-green: #30A46C, --glass: rgba(255, 255, 255, 0.06) with 12px blur
 *    - Telemetry font: monospace (JetBrains Mono / IBM Plex Mono)
 *    - Scanline micro-texture at 2% opacity, HUD corner brackets
 * 3. Accessibility & Performance:
 *    - prefers-reduced-motion disables starfield & transitions
 *    - WCAG AA contrast compliance across all text
 */

/* ==========================================================================
   1. Root Design Tokens (Tesla Mode Default)
   ========================================================================== */
:root {
  /* Public Palette (Tesla Mode) */
  --bg: #000000;
  --bg-surface: #0A0A0C;
  --bg-card: rgba(18, 18, 20, 0.85);
  --fg: #FFFFFF;
  --fg-secondary: #E2E8F0;
  --muted: #8A8F98;
  --muted-dark: #4A4D54;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --border-gold: rgba(201, 162, 74, 0.35);

  /* Accents */
  --accent-gold: #C9A24A;
  --accent-gold-hover: #DFB843;
  --accent-gold-glow: rgba(201, 162, 74, 0.22);
  --accent-gold-bg: rgba(201, 162, 74, 0.1);

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Typography Scale */
  --text-xs: 0.75rem;     /* 12px */
  --text-sm: 0.875rem;    /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg: 1.125rem;    /* 18px */
  --text-xl: 1.25rem;     /* 20px */
  --text-2xl: 1.5rem;     /* 24px */
  --text-3xl: 2rem;       /* 32px */
  
  /* Tesla Hero Headline Scale (56-72px desktop / 34-40px mobile) */
  --headline-hero: clamp(2.125rem, 6vw, 4.5rem);
  --headline-panel: clamp(1.85rem, 4.5vw, 3.25rem);
  --headline-lead: clamp(1rem, 2vw, 1.25rem);

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --space-24: 96px;

  /* Layout */
  --max-width-site: 1280px;
  --max-width-readable: 840px;
  --header-height: 64px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-card: 0 16px 36px -10px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-gold: 0 4px 20px var(--accent-gold-glow);
}

/* ==========================================================================
   2. Flight Deck Tokens (Celestial Cockpit Mode)
   ========================================================================== */
[data-theme="celestial"],
.flight-deck-theme {
  --space-900: #05060B;
  --space-700: #0D1120;
  --hud-cyan: #4FD1E8;
  --hud-cyan-glow: rgba(79, 209, 232, 0.25);
  --hud-gold: #C9A24A;
  --alert-red: #E5484D;
  --alert-red-glow: rgba(229, 72, 77, 0.25);
  --ok-green: #30A46C;
  --ok-green-glow: rgba(48, 164, 108, 0.25);
  
  --bg: var(--space-900);
  --bg-surface: var(--space-700);
  --bg-card: rgba(13, 17, 32, 0.7);
  --glass: rgba(255, 255, 255, 0.06);
  --glass-blur: 12px;
  
  --scanline-opacity: 0.02;
  --border: rgba(79, 209, 232, 0.15);
  --border-strong: rgba(79, 209, 232, 0.35);
  
  font-feature-settings: "tnum" 1, "zero" 1;
}

/* ==========================================================================
   3. Global Reset & Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--fg);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--fg);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Monospace numerals & telemetry */
.mono, .telemetry-numeral {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ==========================================================================
   4. Tesla Full-Viewport Panels (Home Page)
   ========================================================================== */
.viewport-panel-container {
  scroll-snap-type: y mandatory;
  overflow-y: auto;
  height: 100vh;
  scroll-behavior: smooth;
}

.tesla-panel {
  min-height: 100vh;
  min-height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: calc(var(--header-height) + 24px) 24px 48px;
  position: relative;
  background: var(--bg);
}

.tesla-panel-inner {
  max-width: var(--max-width-readable);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tesla-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-gold);
  margin-bottom: var(--space-4);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.tesla-headline {
  font-size: var(--headline-hero);
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--fg);
  margin-bottom: var(--space-4);
}

.tesla-lead {
  font-size: var(--headline-lead);
  font-weight: var(--font-weight-regular);
  color: var(--muted);
  line-height: 1.6;
  max-width: 640px;
  margin-bottom: var(--space-8);
}

/* Constraint: <= 3 numbers per screen */
.tesla-metric-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-8);
  width: 100%;
  max-width: 760px;
  margin-bottom: var(--space-8);
}

.tesla-metric-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tesla-metric-val {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: var(--font-weight-bold);
  color: #FFFFFF;
  line-height: 1.1;
  margin-bottom: var(--space-1);
}

.tesla-metric-label {
  font-size: var(--text-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Constraint: <= 2 buttons per panel */
.tesla-button-group {
  display: flex;
  gap: var(--space-4);
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-tesla-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  color: #000000;
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
  padding: 14px 32px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 16px rgba(255, 255, 255, 0.15);
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-tesla-primary:hover {
  background: var(--accent-gold);
  color: #000000;
  box-shadow: 0 4px 24px var(--accent-gold-glow);
  transform: translateY(-1px);
}

.btn-tesla-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
  font-weight: var(--font-weight-medium);
  font-size: var(--text-sm);
  padding: 14px 28px;
  border-radius: var(--radius-pill);
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.btn-tesla-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

/* ==========================================================================
   5. HUD Glassmorphism & Corner Brackets (Celestial Mode)
   ========================================================================== */
.hud-panel {
  background: var(--glass);
  backdrop-filter: blur(var(--glass-blur, 12px));
  -webkit-backdrop-filter: blur(var(--glass-blur, 12px));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  position: relative;
  padding: var(--space-6);
  box-shadow: var(--shadow-card);
}

/* Corner bracket accents */
.hud-bracket-tl, .hud-bracket-tr, .hud-bracket-bl, .hud-bracket-br {
  position: absolute;
  width: 8px;
  height: 8px;
  border-color: var(--hud-cyan, var(--accent-gold));
  pointer-events: none;
}
.hud-bracket-tl { top: -1px; left: -1px; border-top: 2px solid; border-left: 2px solid; }
.hud-bracket-tr { top: -1px; right: -1px; border-top: 2px solid; border-right: 2px solid; }
.hud-bracket-bl { bottom: -1px; left: -1px; border-bottom: 2px solid; border-left: 2px solid; }
.hud-bracket-br { bottom: -1px; right: -1px; border-bottom: 2px solid; border-right: 2px solid; }

/* Micro-scanline texture */
.hud-scanlines::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
  background-size: 100% 4px;
  z-index: 2;
  pointer-events: none;
  opacity: var(--scanline-opacity, 0.02);
}

/* ==========================================================================
   6. Accessibility & Motion Preferences
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .viewport-panel-container {
    scroll-snap-type: none;
  }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .tesla-panel {
    min-height: auto;
    padding: 48px 16px;
    scroll-snap-align: none;
  }
  .viewport-panel-container {
    height: auto;
    scroll-snap-type: none;
  }
  .tesla-metric-grid-3 {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
}
