/* ==========================================================================
   PROTOCOL 212 // SURVIVAL OS & SYSTEM CODEX THEME
   Visual Identity & Gamified HUD Engine
   ========================================================================== */

:root {
  --bg-primary: #070a0e;
  --bg-secondary: #0e131b;
  --bg-card: rgba(18, 26, 38, 0.85);
  --bg-card-hover: rgba(26, 38, 56, 0.95);
  --border-dim: #1e293b;
  --border-glow: #22c55e;
  --border-hazard: #f59e0b;
  --border-necro: #a855f7;
  --border-danger: #ef4444;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-green: #10b981;
  --accent-neon: #00ff66;
  --accent-amber: #f59e0b;
  --accent-necro: #c084fc;
  --accent-cyan: #06b6d4;
  --accent-red: #f43f5e;

  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', 'Fira Code', Menlo, monospace;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --glow-green: 0 0 15px rgba(16, 185, 129, 0.4);
  --glow-amber: 0 0 15px rgba(245, 158, 11, 0.4);
  --glow-necro: 0 0 15px rgba(192, 132, 252, 0.4);
}

/* Base resets & typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-mono);
  line-height: 1.6;
}

body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background: 
    radial-gradient(circle at 15% 15%, rgba(16, 185, 129, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 85% 75%, rgba(168, 85, 247, 0.05) 0%, transparent 40%),
    linear-gradient(180deg, #070a0e 0%, #0b0f16 50%, #070a0e 100%);
  background-attachment: fixed;
}

/* CRT Scanline Overlay */
body.crt-active::after {
  content: " ";
  display: block;
  position: fixed;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.03), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.03));
  z-index: 999;
  background-size: 100% 3px, 6px 100%;
  pointer-events: none;
  opacity: 0.85;
}

a {
  color: var(--accent-neon);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  color: #fff;
  text-shadow: var(--glow-green);
}

/* ==========================================================================
   HUD TELEMETRY BAR
   ========================================================================== */
.hud-telemetry {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 10, 14, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-dim);
  padding: 0.5rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--text-main);
  text-transform: uppercase;
}

.hud-pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-neon);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-neon);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 102, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 255, 102, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 255, 102, 0); }
}

.hud-metric {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
}

.hud-metric strong {
  color: var(--accent-neon);
}

.hud-metric.necro strong {
  color: var(--accent-necro);
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hud-btn {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.hud-btn:hover, .hud-btn.active {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-neon);
  color: var(--accent-neon);
}

/* ==========================================================================
   NAVIGATION
   ========================================================================== */
.site-header {
  border-bottom: 1px solid var(--border-dim);
  background: rgba(11, 15, 22, 0.85);
  backdrop-filter: blur(8px);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.logo-badge {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #000;
  font-weight: 900;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.1em;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.5rem;
  position: relative;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--accent-neon);
}

.nav-links a.active::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0.5rem;
  right: 0.5rem;
  height: 2px;
  background: var(--accent-neon);
  box-shadow: 0 0 6px var(--accent-neon);
}

.nav-cta {
  background: rgba(16, 185, 129, 0.15) !important;
  border: 1px solid var(--accent-neon) !important;
  color: var(--accent-neon) !important;
  border-radius: 3px;
  padding: 0.4rem 0.85rem !important;
  box-shadow: var(--glow-green);
}

.nav-cta:hover {
  background: var(--accent-neon) !important;
  color: #000 !important;
}

/* ==========================================================================
   LAYOUT & CONTAINERS
   ========================================================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.hero-section {
  padding: 4rem 1.5rem 3rem;
  text-align: center;
  position: relative;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid var(--accent-amber);
  color: var(--accent-amber);
  padding: 0.35rem 0.9rem;
  border-radius: 20px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1.5rem;
}

.hero-title {
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.hero-title span.glitch {
  color: var(--accent-neon);
  text-shadow: var(--glow-green);
}

.hero-title span.necro {
  color: var(--accent-necro);
  text-shadow: var(--glow-necro);
}

.hero-lead {
  max-width: 780px;
  margin: 0 auto 2.5rem;
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1.7;
}

.cta-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--accent-neon);
  color: #000;
  border: 1px solid var(--accent-neon);
  box-shadow: var(--glow-green);
}

.btn-primary:hover {
  background: #fff;
  color: #000;
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(0, 255, 102, 0.7);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.5);
  color: var(--text-main);
  border: 1px solid var(--border-dim);
}

.btn-secondary:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: translateY(-2px);
}

.btn-hazard {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--accent-amber);
  color: var(--accent-amber);
  box-shadow: var(--glow-amber);
}

.btn-hazard:hover {
  background: var(--accent-amber);
  color: #000;
}

.btn-necro {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid var(--accent-necro);
  color: var(--accent-necro);
  box-shadow: var(--glow-necro);
}

.btn-necro:hover {
  background: var(--accent-necro);
  color: #000;
}

/* ==========================================================================
   CARDS & GRIDS
   ========================================================================== */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin: 2.5rem 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 2rem;
  margin: 2.5rem 0;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 1.75rem;
  position: relative;
  transition: all 0.3s ease;
}

.card:hover {
  border-color: var(--border-glow);
  background: var(--bg-card-hover);
  transform: translateY(-3px);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
}

.card.hazard:hover {
  border-color: var(--accent-amber);
}

.card.necro:hover {
  border-color: var(--accent-necro);
}

.card-tag {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-dim);
  color: var(--text-muted);
}

.card-tag.green { color: var(--accent-neon); border-color: rgba(16, 185, 129, 0.3); }
.card-tag.amber { color: var(--accent-amber); border-color: rgba(245, 158, 11, 0.3); }
.card-tag.necro { color: var(--accent-necro); border-color: rgba(168, 85, 247, 0.3); }

.card h3 {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.card p {
  color: var(--text-muted);
  font-size: 0.925rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

/* Corner clip embellishment for sci-fi look */
.cyber-panel {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-dim);
  padding: 2rem;
  border-radius: 4px;
}

.cyber-panel::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  width: 12px;
  height: 12px;
  border-top: 2px solid var(--accent-neon);
  border-left: 2px solid var(--accent-neon);
}

.cyber-panel::after {
  content: "";
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 12px;
  height: 12px;
  border-bottom: 2px solid var(--accent-neon);
  border-right: 2px solid var(--accent-neon);
}

/* ==========================================================================
   TERMINAL SIMULATOR
   ========================================================================== */
.terminal-window {
  background: #05070a;
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  margin: 2rem 0;
}

.terminal-header {
  background: #0d121a;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-dim);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot-red { background: #ef4444; }
.dot-amber { background: #f59e0b; }
.dot-green { background: #10b981; }

.terminal-body {
  padding: 1.25rem;
  color: #a7f3d0;
  font-size: 0.875rem;
  line-height: 1.6;
  max-height: 380px;
  overflow-y: auto;
}

.prompt-line {
  color: var(--accent-cyan);
  margin-bottom: 0.5rem;
}

.prompt-line strong {
  color: var(--accent-neon);
}

.error-trace {
  color: #f87171;
  background: rgba(239, 68, 68, 0.1);
  padding: 0.5rem;
  border-left: 2px solid #ef4444;
  margin: 0.5rem 0;
}

.success-trace {
  color: #34d399;
  background: rgba(52, 211, 153, 0.1);
  padding: 0.5rem;
  border-left: 2px solid #34d399;
  margin: 0.5rem 0;
}

/* ==========================================================================
   INTERACTIVE SIMULATOR (AUTOPSY & TRIAGE)
   ========================================================================== */
.interactive-bench {
  background: #090e15;
  border: 1px solid var(--border-dim);
  border-radius: 6px;
  padding: 1.5rem;
  margin: 2rem 0;
}

.bench-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-dim);
}

.bench-title {
  font-size: 1.1rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-editor-sim {
  background: #030508;
  border: 1px solid var(--border-dim);
  border-radius: 4px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #e2e8f0;
  position: relative;
  margin-bottom: 1rem;
}

.code-line {
  display: flex;
  gap: 1rem;
  padding: 0.15rem 0;
}

.code-line.error-target {
  background: rgba(239, 68, 68, 0.15);
  border-left: 3px solid var(--accent-red);
}

.line-num {
  color: var(--text-dim);
  user-select: none;
  min-width: 25px;
  text-align: right;
}

/* Footers */
.site-footer {
  border-top: 1px solid var(--border-dim);
  background: #06090d;
  padding: 3rem 1.5rem;
  margin-top: 5rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-col h4 {
  color: var(--text-main);
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.footer-col ul {
  list-style: none;
}

.footer-col li {
  margin-bottom: 0.5rem;
}

.footer-col a {
  color: var(--text-dim);
}

.footer-col a:hover {
  color: var(--accent-neon);
}

.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
  .hud-telemetry {
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
  }
  .hud-right {
    width: 100%;
    justify-content: space-between;
  }
  .nav-container {
    flex-direction: column;
    gap: 1rem;
  }
  .nav-links {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
  }
}

/* AI Terminal additions */
.quick-prompt-btn:hover {
  background: rgba(16, 185, 129, 0.2) !important;
  color: var(--accent-neon) !important;
  border-color: var(--accent-neon) !important;
}

#ai-user-input:focus {
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

/* ==========================================================================
   MOBILE & RESPONSIVE UX ENHANCEMENTS
   Touch-friendly targets, viewport scaling, mobile navigation drawer
   ========================================================================== */

/* Mobile Hamburger Toggle */
.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 1.1rem;
}

.mobile-menu-toggle:hover {
  border-color: var(--accent-neon);
  color: var(--accent-neon);
}

@media (max-width: 900px) {
  .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    background: #090e15;
    border: 1px solid var(--border-dim);
    border-radius: 6px;
    padding: 1rem;
    margin-top: 1rem;
    gap: 0.5rem;
  }

  .nav-links.mobile-open {
    display: flex;
    animation: fadeInDown 0.25s ease-out;
  }

  @keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem !important;
    border-radius: 4px;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.02);
  }

  .nav-links a:hover {
    background: rgba(16, 185, 129, 0.1);
  }

  /* HUD Mobile wrapping */
  .hud-telemetry {
    padding: 0.6rem 1rem;
    font-size: 0.75rem;
  }

  .hud-left {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .hud-brand {
    grid-column: 1 / -1;
    font-size: 0.8rem;
  }

  .hud-right {
    width: 100%;
    margin-top: 0.4rem;
    padding-top: 0.4rem;
    border-top: 1px solid rgba(255,255,255,0.05);
    justify-content: flex-end;
  }

  /* Mobile Inputs: Prevent Safari Auto-Zoom */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Grid adjustments */
  .grid-2, .grid-3 {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }

  .hero-title {
    font-size: 2rem !important;
    line-height: 1.2 !important;
  }

  .hero-lead {
    font-size: 1rem !important;
  }

  .card {
    padding: 1.25rem !important;
  }

  .cyber-panel {
    padding: 1.25rem !important;
  }

  .btn {
    width: 100%;
    min-height: 48px;
  }
}

/* Touch optimization */
button, .btn, a {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ==========================================================================
   NATIVE MOBILE APP SHELL & PWA STYLES (iOS / Android Look & Feel)
   ========================================================================== */

/* Native App Base Adjustments */
html {
  -webkit-text-size-adjust: 100%;
}

body {
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 840px) {
  body {
    padding-bottom: calc(env(safe-area-inset-bottom) + 72px) !important;
  }
}

/* Native Mobile Bottom Tab Bar */
.mobile-tab-bar {
  display: none;
}

@media (max-width: 840px) {
  .mobile-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 62px;
    background: rgba(6, 10, 18, 0.94);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 9999;
    justify-content: space-around;
    align-items: center;
    padding-bottom: max(0.2rem, env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.7);
    user-select: none;
    -webkit-user-select: none;
  }

  .tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: var(--text-dim);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.02em;
    transition: color 0.15s ease, transform 0.1s ease;
    gap: 2px;
  }

  .tab-item:active {
    transform: scale(0.92);
  }

  .tab-item.active {
    color: var(--accent-neon);
  }

  .tab-icon {
    font-size: 1.25rem;
    line-height: 1.1;
  }

  .tab-label {
    font-weight: 600;
  }
}

/* Terminal Dock Breathing Space */
.terminal-dock {
  width: 100%;
  box-sizing: border-box;
}

.prompt-input-row {
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .prompt-input-row {
    flex-direction: column;
    align-items: stretch !important;
  }

  .prompt-input-row button {
    width: 100%;
  }
}

/* Executive Audit Score Telemetry Elements */
.audit-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--accent-neon);
}
