/**
 * NASA/JPL-Caliber Dark Astronomical Design System
 * Tailored for Eclipse-Lapse interactive solar astrophysics experience.
 * Fully responsive across all devices, mobile phones, tablets, high-DPI screens, and aspect ratios.
 */

:root {
  --bg-primary: #07080c;
  --bg-surface: #0e1017;
  --bg-card: #131622;
  --bg-card-hover: #1b2030;
  --border-dim: #1c2132;
  --border-bright: #2d354d;
  
  --text-main: #f0f3fa;
  --text-muted: #8b95a8;
  --text-dim: #5a6478;

  --accent-gold: #f59e0b;
  --sun-core: #ffd27d;
  --sun-limb: #ea580c;
  --moon-cyan: #38bdf8;
  --calib-emerald: #10b981;
  --alert-crimson: #ef4444;

  --font-heading: 'Space Grotesk', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --glow-sun: 0 0 24px rgba(245, 158, 11, 0.25);
  --glow-moon: 0 0 20px rgba(56, 189, 248, 0.25);
  --glow-emerald: 0 0 16px rgba(16, 185, 129, 0.2);
}

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

html {
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-dim); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.025em;
}

code, pre, .font-mono {
  font-family: var(--font-mono);
}

/* Cosmic Nav */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(7, 8, 12, 0.88);
  border-bottom: 1px solid var(--border-dim);
  padding: 0.75rem clamp(1rem, 3vw, 2rem);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff;
  flex-shrink: 0;
}

.logo-orb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff4cc, #f59e0b 60%, #b45309);
  box-shadow: var(--glow-sun);
  position: relative;
  flex-shrink: 0;
}

.logo-orb::after {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-primary);
  top: -2px;
  left: 6px;
}

.logo-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.nav-menu {
  display: flex;
  gap: clamp(0.75rem, 1.5vw, 1.5rem);
  list-style: none;
  align-items: center;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: color 0.2s;
  white-space: nowrap;
}

.nav-link:hover, .nav-link.active {
  color: var(--accent-gold);
}

/* Trilingual Switcher */
.lang-switcher {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 34px;
  min-height: 32px;
}

.lang-btn.active {
  background: var(--border-bright);
  color: var(--accent-gold);
}

/* Layout */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
}

/* Hero Section */
.hero {
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(2rem, 4vw, 3.5rem);
  text-align: center;
  position: relative;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 1.1rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 9999px;
  color: var(--accent-gold);
  font-size: clamp(0.75rem, 2vw, 0.82rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  max-width: 90vw;
}

.hero-title {
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  line-height: 1.15;
  margin-bottom: 1.25rem;
  background: linear-gradient(135deg, #ffffff 30%, #ffd27d 75%, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: clamp(0.95rem, 2.2vw, 1.15rem);
  color: var(--text-muted);
  max-width: 800px;
  margin: 0 auto 1.5rem;
  line-height: 1.6;
}

.hero-meta {
  font-family: var(--font-mono);
  font-size: clamp(0.78rem, 1.8vw, 0.85rem);
  color: var(--text-dim);
  margin-bottom: 2.5rem;
}

/* Metrics Grid */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: clamp(0.75rem, 1.5vw, 1rem);
  margin-bottom: 3.5rem;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: clamp(1rem, 2vw, 1.25rem);
  text-align: left;
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-gold);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.stat-value {
  font-size: clamp(1.35rem, 3.5vw, 1.65rem);
  font-weight: 700;
  font-family: var(--font-mono);
  color: #fff;
  white-space: nowrap;
}

.stat-sub {
  font-size: 0.76rem;
  color: var(--calib-emerald);
  margin-top: 0.3rem;
  line-height: 1.3;
}

/* Section Headers */
.section-head {
  margin-bottom: 1.75rem;
}

.section-head h2 {
  font-size: clamp(1.5rem, 3.5vw, 2rem);
  color: #fff;
  margin-bottom: 0.35rem;
}

.section-head p {
  color: var(--text-muted);
  font-size: clamp(0.88rem, 1.8vw, 0.95rem);
}

/* Panels */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: clamp(12px, 2vw, 16px);
  padding: clamp(1.15rem, 2.5vw, 1.75rem);
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.grid-2col {
  display: grid;
  grid-template-columns: 1.7fr 1.3fr;
  gap: clamp(1.25rem, 2.5vw, 1.75rem);
  align-items: start;
}

/* Sliders & Controls */
.slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.range-slider {
  flex: 1;
  accent-color: var(--accent-gold);
  height: 6px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  color: var(--text-main);
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 40px;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
}

.btn-primary {
  background: var(--accent-gold);
  color: #000;
  font-weight: 600;
  border: none;
}

.btn-primary:hover {
  background: #e09f1f;
  box-shadow: var(--glow-sun);
}

/* Telemetry HUD Box */
.telemetry-box {
  background: #090a0f;
  border: 1px solid var(--border-dim);
  border-radius: 10px;
  padding: clamp(1rem, 2vw, 1.25rem);
}

.tel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid #141722;
  font-size: 0.84rem;
  gap: 0.5rem;
}

.tel-row:last-child { border-bottom: none; }
.tel-key { color: var(--text-muted); font-size: 0.82rem; }
.tel-val { font-family: var(--font-mono); font-weight: 600; color: #fff; text-align: right; }

/* Tabs */
.tab-row {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-dim);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tab-row::-webkit-scrollbar { display: none; }

.tab-button {
  padding: 0.55rem 1.15rem;
  background: transparent;
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-height: 40px;
}

.tab-button.active {
  background: rgba(245, 158, 11, 0.2) !important;
  border-color: var(--accent-gold) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25) !important;
}

/* Pills & Selectors */
.pill-select {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
}

.pill-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  user-select: none;
}

.pill-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.pill-btn.active {
  background: var(--accent-gold) !important;
  color: #000000 !important;
  font-weight: 700 !important;
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.45) !important;
}

/* Pipeline Step Cards */
.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.pipeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.2s, transform 0.2s;
}

.pipeline-card:hover {
  border-color: var(--accent-gold);
  transform: translateY(-2px);
}

.pipeline-step-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-gold);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pipeline-img-wrap {
  width: 100%;
  aspect-ratio: 1/1;
  background: #000;
  border: 1px solid var(--border-dim);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pipeline-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Math Equation Container */
.math-box {
  background: #090a0f;
  border: 1px solid #191e2b;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
  text-align: center;
  -webkit-overflow-scrolling: touch;
  font-size: clamp(0.85rem, 2vw, 1rem);
}

/* =========================================================================
   RESPONSIVE BREAKPOINTS & ADAPTIVE RATIOS
   ========================================================================= */

/* Tablet & Smaller Desktops (<= 1024px) */
@media (max-width: 1024px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

/* Mobile & Portrait Screens (<= 768px) */
@media (max-width: 768px) {
  .nav-menu {
    display: none;
  }
  
  nav {
    padding: 0.65rem 1rem;
  }

  .logo-title {
    font-size: 1.05rem;
  }

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

  .metrics-row > :last-child {
    grid-column: span 2;
  }

  .panel {
    padding: 1.15rem;
  }

  .tel-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
  }

  .tel-val {
    text-align: left;
  }
}

/* Small Phones (<= 480px) */
@media (max-width: 480px) {
  .metrics-row {
    grid-template-columns: 1fr;
  }

  .metrics-row > :last-child {
    grid-column: span 1;
  }

  .lang-btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.72rem;
    min-width: 28px;
  }
}

/* Landscape Phones & Ultrawide Ratios */
@media (max-height: 550px) and (orientation: landscape) {
  .hero {
    padding: 2rem 0 1.5rem;
  }
  .grid-2col {
    grid-template-columns: 1fr 1fr;
  }
}
