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

:root {
  --bg: #0a1628;
  --bg-card: #111d35;
  --bg-card-hover: #162545;
  --accent-blue: #2196F3;
  --accent-cyan: #00BCD4;
  --accent-orange: #FF9800;
  --accent-red: #f44336;
  --accent-green: #4CAF50;
  --text: #e8edf5;
  --text-muted: #8899b3;
  --text-dim: #556b8a;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* === Loading === */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.5s, visibility 0.5s;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader {
  text-align: center;
}

.loader-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader p {
  color: var(--text-muted);
  font-size: 14px;
}

/* === Error Banner === */
#error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(244, 67, 54, 0.9);
  color: #fff;
  padding: 12px 48px 12px 24px;
  font-size: 14px;
  z-index: 999;
  backdrop-filter: blur(8px);
}

#error-banner.hidden { display: none; }

#error-banner button {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

/* === Main === */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 20px 80px;
}

/* === Hero === */
.hero {
  text-align: center;
  padding: 60px 0 40px;
}

.hero-badge {
  display: inline-block;
  background: rgba(0, 188, 212, 0.15);
  color: var(--accent-cyan);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 20px;
}

.hero h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(2.2rem, 6vw, 3.5rem);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 8px;
}

.hero-subtitle {
  color: var(--accent-cyan);
  font-size: clamp(1.2rem, 3.5vw, 1.8rem);
  font-weight: 500;
}

.hero-location {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 32px;
}

/* === Countdown === */
.countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 40px;
}

.countdown-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
}

.countdown-value {
  font-family: 'Space Grotesk', monospace;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.countdown-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

.countdown-sep {
  font-family: 'Space Grotesk', monospace;
  font-size: 1.8rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}

/* === Gauge === */
.gauge-container {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 0 auto 32px;
}

.gauge-container canvas {
  display: block;
}

.gauge-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.gauge-percent {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3.2rem;
  font-weight: 700;
  line-height: 1;
}

.gauge-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

/* === Scenario Cards === */
.scenario-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.scenario-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  transition: background 0.2s;
}

.scenario-card:hover {
  background: var(--bg-card-hover);
}

.scenario-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.scenario-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.scenario-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.scenario-prob {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
}

.scenario-card.wetsuit .scenario-prob { color: var(--accent-blue); }
.scenario-card.borderline .scenario-prob { color: var(--accent-orange); }
.scenario-card.no-wetsuit .scenario-prob { color: var(--accent-red); }

.pro-note {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* === Sections === */
.section {
  margin-top: 56px;
}

.section h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

/* === Predicted Temp === */
.predicted-temp-display {
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.predicted-temp-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.predicted-temp-range {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* === Charts === */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
}

.chart-container-sm {
  max-height: 350px;
}

.chart-container canvas {
  width: 100% !important;
}

/* === Ensemble Summary === */
.ensemble-summary {
  text-align: center;
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 500;
}

.ensemble-summary strong {
  color: var(--accent-blue);
}

/* === History Grid === */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: background 0.2s;
}

.history-card:hover {
  background: var(--bg-card-hover);
}

.history-year {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.history-temp {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.history-temp.wetsuit { color: var(--accent-blue); }
.history-temp.no-wetsuit { color: var(--accent-orange); }

.history-status {
  font-size: 13px;
  font-weight: 500;
}

.history-status.wetsuit { color: var(--accent-blue); }
.history-status.no-wetsuit { color: var(--accent-orange); }

.history-air {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* === Methodology === */
.methodology {
  border-top: 1px solid var(--border);
  padding-top: 40px;
}

.method-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
}

.method-content strong {
  color: var(--text);
}

.method-content ol {
  padding-left: 20px;
  margin: 12px 0;
}

.method-content li {
  margin-bottom: 8px;
}

.attribution {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-dim);
}

.attribution a {
  color: var(--accent-cyan);
  text-decoration: none;
}

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

/* === Responsive === */
@media (max-width: 640px) {
  .hero { padding: 40px 0 24px; }
  .countdown-value { font-size: 1.5rem; }
  .countdown-unit { min-width: 50px; }
  .countdown-sep { font-size: 1.3rem; }

  .gauge-container {
    width: 220px;
    height: 220px;
  }

  .gauge-percent { font-size: 2.5rem; }

  .scenario-cards {
    grid-template-columns: 1fr;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
  }

  .scenario-prob { font-size: 1.4rem; }
  .predicted-temp-value { font-size: 2.2rem; }

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