/* ═══════════════════════════════════════════════════════════════════════════
   Aurora Forecast — Observatory / Planetarium aesthetic
   Deep blacks, aurora green-teal, subtle purple, monospace data readouts.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg:          #06080d;
  --bg-card:     #0c1017;
  --bg-card-alt: #101620;
  --border:      #1a2233;
  --border-glow: rgba(56, 239, 125, 0.12);

  --text:        #c8d6e5;
  --text-dim:    #5a6a80;
  --text-bright: #eaf0f6;

  --aurora-green: #38ef7d;
  --aurora-teal:  #11998e;
  --aurora-purple:#845ec2;
  --aurora-pink:  #d65db1;
  --danger:       #ff6b6b;
  --warn:         #ffc048;

  --font-display: 'Outfit', sans-serif;
  --font-mono:    'DM Mono', monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */

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

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
}

a { color: var(--aurora-teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Ambient background ─────────────────────────────────────────────────── */

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 30% 10%, rgba(56,239,125,0.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 70% 20%, rgba(132,94,194,0.05) 0%, transparent 50%),
    var(--bg);
  animation: ambient-shift 30s ease-in-out infinite alternate;
}
@keyframes ambient-shift {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(15deg); }
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(6,8,13,0.85);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.logo-icon {
  font-size: 1.6rem;
  color: var(--aurora-green);
  animation: logo-pulse 4s ease-in-out infinite;
}
@keyframes logo-pulse {
  0%, 100% { opacity: 0.6; }
  50%      { opacity: 1; text-shadow: 0 0 12px var(--aurora-green); }
}
.logo h1 {
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--text-bright);
  letter-spacing: -0.02em;
}
.logo .thin { font-weight: 200; opacity: 0.7; }

.header-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}
.tz-toggle {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  cursor: pointer;
  transition: all 0.2s;
}
.tz-toggle:hover {
  border-color: var(--text-dim);
  color: var(--text);
}
.kp-badge {
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-weight: 500;
  color: var(--aurora-green);
  transition: all 0.4s;
}
.kp-badge.elevated {
  border-color: var(--warn);
  color: var(--warn);
  box-shadow: 0 0 8px rgba(255,192,72,0.15);
}
.kp-badge.storm {
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: 0 0 10px rgba(255,107,107,0.2);
}

/* ── Dashboard grid ─────────────────────────────────────────────────────── */

.dashboard {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.25rem;
  padding: 1.25rem 2rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .dashboard {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
}

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  transition: border-color 0.3s;
}
.card:hover {
  border-color: var(--border-glow);
}
.card-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

/* ── Map ────────────────────────────────────────────────────────────────── */

.card-map {
  min-height: 520px;
  display: flex;
  flex-direction: column;
}
#cesium-container {
  flex: 0 0 clamp(400px, 75vh, 900px);
  border-radius: var(--radius-sm);
  z-index: 1;
  width: 100%;
  position: relative;
  overflow: hidden;
}

/* Cesium: force all internal elements to stay within container */
.cesium-viewer,
.cesium-viewer-cesiumWidgetContainer,
.cesium-cesiumWidget,
.cesium-widget,
.cesium-widget canvas {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
}
/* Hide Cesium default UI chrome */
.cesium-viewer-bottom,
.cesium-viewer .cesium-widget-credits {
  display: none !important;
}

/* Aurora info popup */
.aurora-info-popup {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  text-align: center;
  line-height: 1.5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  transform: translate(-50%, -100%);
  margin-top: -12px;
}
.aurora-popup-val {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--aurora-green);
}
.aurora-popup-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text);
}
.aurora-popup-coords {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-dim);
}

.map-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  gap: 1rem;
}
.map-legend {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
}
.layer-toggles {
  display: flex;
  gap: 0.4rem;
}
.layer-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}
.layer-toggle:hover {
  border-color: var(--text-dim);
  color: var(--text);
}
.layer-toggle.active {
  border-color: var(--aurora-teal);
  color: var(--aurora-teal);
  box-shadow: 0 0 8px rgba(17,153,142,0.15);
}
.toggle-icon {
  font-size: 0.85rem;
}
.legend-scale {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.legend-bar {
  width: 180px;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg,
    rgba(56,239,125,0.05) 0%,
    rgba(56,239,125,0.4) 30%,
    rgba(17,153,142,0.7) 60%,
    var(--aurora-purple) 80%,
    var(--aurora-pink) 100%
  );
}
.legend-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.55rem;
  color: var(--text-dim);
  width: 180px;
}
.legend-colors {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.58rem;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.legend-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-left: 0.4rem;
}
.legend-swatch:first-child {
  margin-left: 0;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* ── Kp Gauge ───────────────────────────────────────────────────────────── */

.kp-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.kp-gauge {
  width: 100%;
  max-width: 220px;
}
.kp-value-wrap {
  text-align: center;
  margin-top: -1rem;
}
.kp-number {
  font-family: var(--font-mono);
  font-size: 2.8rem;
  font-weight: 500;
  color: var(--aurora-green);
  line-height: 1;
}
.kp-trend {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}
.kp-description {
  font-size: 0.82rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.6rem;
  line-height: 1.5;
}

/* ── Moon Phase ────────────────────────────────────────────────────────── */

.moon-display {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.moon-emoji {
  font-size: 2.8rem;
  line-height: 1;
  filter: drop-shadow(0 0 8px rgba(200,214,229,0.25));
}
.moon-info {
  display: flex;
  flex-direction: column;
}
.moon-phase-name {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-bright);
}
.moon-illumination {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}
.moon-impact {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.6rem;
  line-height: 1.5;
}

/* ── Location Forecast ──────────────────────────────────────────────────── */

.forecast-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 2rem 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--aurora-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

.forecast-prob-wrap {
  text-align: center;
  padding: 0.8rem 0;
}
.forecast-prob {
  font-family: var(--font-mono);
  font-size: 3.4rem;
  font-weight: 500;
  color: var(--aurora-green);
  line-height: 1;
}
.forecast-prob-unit {
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--aurora-teal);
  vertical-align: super;
}
.forecast-prob-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-top: 0.3rem;
}
.forecast-level {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  margin-top: 0.4rem;
}

.forecast-meta {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.8rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.meta-row {
  display: flex;
  justify-content: space-between;
}
.meta-key {
  font-size: 0.78rem;
  color: var(--text-dim);
}
.meta-val {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-bright);
}
.forecast-desc {
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text);
  margin-top: 0.75rem;
}

/* Manual location input */
.forecast-denied p {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.manual-loc {
  display: flex;
  gap: 0.5rem;
}
.manual-loc input {
  flex: 1;
  padding: 0.5rem 0.65rem;
  background: var(--bg-card-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}
.manual-loc input:focus {
  border-color: var(--aurora-teal);
}
.btn-go {
  padding: 0.5rem 1rem;
  background: linear-gradient(135deg, var(--aurora-teal), var(--aurora-green));
  border: none;
  border-radius: var(--radius-sm);
  color: var(--bg);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.78rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-go:hover { opacity: 0.85; }

/* ── 3-Day Timeline ─────────────────────────────────────────────────────── */

.kp-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.kp-day-row {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
}
.kp-day-label {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 38px;
  flex-shrink: 0;
  padding-bottom: 10px;
  font-family: var(--font-mono);
  line-height: 1.3;
}
.kp-day-name {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text);
}
.kp-day-name.today {
  color: var(--aurora-green);
}
.kp-day-date {
  font-size: 0.52rem;
  color: var(--text-dim);
}
.kp-day-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  flex: 1;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1px;
}
.kp-day-bars .kp-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 0;
}
.kp-day-bars .kp-bar {
  width: 100%;
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: height 0.6s ease;
}
.kp-day-bars .kp-bar-wrap.observed {
  opacity: 0.35;
}
.kp-day-bars .kp-bar-time {
  font-family: var(--font-mono);
  font-size: 0.48rem;
  color: var(--text-dim);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  text-align: center;
}

/* ── Tips ────────────────────────────────────────────────────────────────── */

.tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.tips-list li {
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text);
  padding-left: 1.1rem;
  position: relative;
}
.tips-list li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--aurora-green);
  font-weight: 600;
}

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

.site-footer {
  text-align: center;
  padding: 1.5rem 2rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

/* ── Animations ─────────────────────────────────────────────────────────── */

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.card {
  animation: fade-in 0.5s ease backwards;
}
.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.2s; }
.card:nth-child(5) { animation-delay: 0.25s; }

/* ── Mobile (< 768px) ──────────────────────────────────────────────────── */

@media (max-width: 768px) {
  html { font-size: 14px; }

  /* Prevent anything from overflowing */
  .site-header, .dashboard, .card, .card-map, .sidebar {
    max-width: 100vw;
    box-sizing: border-box;
  }

  /* Header: stack into rows */
  .site-header {
    flex-wrap: wrap;
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }
  .logo h1 { font-size: 1.1rem; }
  .logo-icon { font-size: 1.3rem; }
  .logo { gap: 0.4rem; }
  .header-meta {
    width: 100%;
    justify-content: space-between;
    font-size: 0.68rem;
    gap: 0.5rem;
  }

  /* Dashboard: single column, tight padding */
  .dashboard {
    padding: 0.5rem;
    gap: 0.75rem;
  }

  /* Globe: fit to screen width, shorter */
  .card-map {
    min-height: auto;
    padding: 0.75rem;
  }
  #cesium-container {
    flex: 0 0 clamp(250px, 50vh, 400px);
    max-width: 100%;
  }
  /* Cards: less padding */
  .card { padding: 0.75rem; }
  .card-label {
    font-size: 0.6rem;
    margin-bottom: 0.5rem;
    word-break: break-word;
  }

  /* Map controls: stack vertically */
  .map-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .layer-toggles {
    flex-wrap: wrap;
    gap: 0.3rem;
  }
  .layer-toggle {
    font-size: 0.6rem;
    padding: 0.2rem 0.5rem;
  }

  /* Legend: hide gradient, keep swatches */
  .legend-scale { display: none; }
  .legend-colors {
    font-size: 0.52rem;
    gap: 0.2rem;
  }

  /* Kp gauge: smaller */
  .kp-gauge { max-width: 150px; }
  .kp-number { font-size: 2rem; }
  .kp-description { font-size: 0.75rem; }

  /* Forecast */
  .forecast-prob { font-size: 2.4rem; }
  .forecast-prob-unit { font-size: 1rem; }
  .forecast-level { font-size: 0.62rem; }

  /* Moon */
  .moon-display { gap: 0.7rem; }
  .moon-emoji { font-size: 2rem; }
  .moon-phase-name { font-size: 0.8rem; }

  /* Timeline */
  .kp-day-row { gap: 0.4rem; }
  .kp-day-label { min-width: 28px; }
  .kp-day-name { font-size: 0.6rem; }
  .kp-day-date { font-size: 0.45rem; }

  /* Manual location inputs */
  .manual-loc { flex-wrap: wrap; }
  .manual-loc input { min-width: 0; }

  /* Footer */
  .site-footer { padding: 0.75rem; font-size: 0.6rem; }
}

/* ── Small phones (< 400px) ────────────────────────────────────────────── */

@media (max-width: 400px) {
  .site-header { padding: 0.5rem; }
  .dashboard { padding: 0.35rem; gap: 0.5rem; }
  .logo h1 { font-size: 0.95rem; }
  #cesium-container { flex: 0 0 clamp(200px, 45vh, 300px); }
  .forecast-prob { font-size: 1.8rem; }
  .kp-gauge { max-width: 120px; }
  .header-meta { font-size: 0.6rem; }
}
