/* Aurora base styles */
:root {
  --bg: #0b1020;
  --surface: #10172a;
  --text: #000000;
  --muted: #000000;
  --primary: #dbd8eb;
  --primary-600: #6d4dff;
  --primary-700: #5b3aff;
  --ring: rgba(124, 92, 255, 0.45);
  --card: rgba(255, 255, 255, 0.06);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #000000;
    --muted: #000000;
    --primary: #5b3aff;
    --primary-600: #4d33d9;
    --primary-700: #3f28b8;
    --ring: rgba(91, 58, 255, 0.3);
    --card: rgba(0, 0, 0, 0.04);
  }
}

/* Reset */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: hsla(162, 13%, 59%, 0.712);
  line-height: 1.6;
}

img, svg { display: block; max-width: 100%; height: auto; }

.container {
  width: min(1100px, 92%);
  margin-inline: auto;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(140%) blur(10px);
  background: silver;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
}
.brand {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.2px;
  text-decoration: none;
}

.nav-toggle {
  display: none;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px;
  border-radius: 8px;
}
.nav-toggle:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.nav ul { display: flex; gap: 20px; list-style: none; padding: 0; margin: 0; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover, .nav a:focus-visible { color: var(--text); }

/* Hero */
.hero {
  padding: 72px 0 56px;
}
.hero-inner {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  align-items: center;
  gap: 40px;
}
.hero-copy h1 {
  margin: 0 0 14px;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1.05;
}
.hero-copy p { color: var(--muted); margin: 0 0 22px; max-width: 60ch; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  --btn-bg: var(--primary);
  --btn-bg-h: var(--primary-600);
  color: white; background: var(--btn-bg);
  border: 1px solid transparent; border-radius: 10px;
  padding: 12px 16px; text-decoration: none; font-weight: 600; letter-spacing: 0.2px;
  display: inline-flex; align-items: center; gap: 10px; box-shadow: 0 10px 24px -8px rgba(124, 92, 255, 0.55);
  transition: transform .12s ease, background-color .12s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--btn-bg-h); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.btn-outline {
  --btn-bg: transparent; color: var(--text);
  border-color: rgba(255,255,255,0.25);
  box-shadow: none;
}
.btn-outline:hover { background: rgba(255,255,255,0.06); }

/* Segmented toggle (radio-based) */
.seg-toggle {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 2px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 2px;
}
.seg-toggle input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px; height: 1px;
  overflow: hidden;
  pointer-events: none;
}
.seg-toggle label {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.seg-toggle input[type="radio"]:checked + label {
  background: linear-gradient(180deg, rgba(124,92,255,0.22), rgba(124,92,255,0.12));
  color: var(--text);
  border-color: rgba(124,92,255,0.5);
}
.seg-toggle input[type="radio"]:focus-visible + label {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

.hero-media { display: grid; place-items: center; }
.glass-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.4);
  display: grid; gap: 14px;
}
.stat { display: grid; gap: 2px; }
.stat-value { font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }
.stat-label { color: var(--muted); font-size: 14px; }
.pulse { width: 8px; height: 8px; background: #22c55e; border-radius: 999px; box-shadow: 0 0 0 0 rgba(34,197,94, .7); animation: pulse 2s infinite; }
@keyframes pulse { 0%{ box-shadow: 0 0 0 0 rgba(34,197,94,.7);} 70%{ box-shadow: 0 0 0 10px rgba(34,197,94,0);} 100%{ box-shadow: 0 0 0 0 rgba(34,197,94,0);} }

/* Sections */
.section { padding: 56px 0; }
.section-header { text-align: center; margin-bottom: 28px; }
.section-header p { color: var(--muted); margin: 8px auto 0; max-width: 65ch; }

/* Section footer */
.section-footer { margin-top: 18px; text-align: center; }
.section-footer .to-top { color: var(--muted); text-decoration: none; font-size: 14px; }
.section-footer .to-top:hover, .section-footer .to-top:focus-visible { color: var(--text); text-decoration: underline; }
.section-footer .to-top:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

/* Dashboard */
.dashboard .metrics-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.metric {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 14px;
}
.metric .label { color: var(--muted); font-size: 12px; }
.metric .value { font-weight: 700; font-size: 20px; line-height: 1.2; }
.metric .value.kp-low { color: #eab308; }      /* Kp 0-2 (Yellow) */
.metric .value.kp-moderate { color: #22c55e; } /* Kp 2-4 (Green) */
.metric .value.kp-high { color: #f97316; }      /* Kp 4-5 (Orange) */
.metric .value.kp-severe { color: #ef4444; }    /* Kp 5+ (Red) */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.chart-card h3 { margin: 0 0 8px; }
/* Chart sizing controlled by box */
.chart-box { width: 100%; height: 320px; }
.chart-card canvas { width: 100% !important; height: 100% !important; display: block; }
@media (max-width: 720px) {
  .chart-box { height: 240px; }
}

/* Source badge */
.source-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

/* Mini Bz chart in features card */
.mini-chart-box { width: 100%; height: 120px; margin-top: 10px; }
.mini-chart-box canvas { width: 100% !important; height: 100% !important; display: block; }
/* Mini caption styling */
.mini-caption { margin-top: 6px; color: var(--muted); font-size: 12px; }
.mini-caption .sat { color: #3b82f6; font-weight: 600; }
.mini-caption strong { font-weight: 700; }

/* Radar map (Leaflet) */
.radar-map {
  width: 100%;
  height: 320px;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.radar-map .map-overlay {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  background: rgba(16, 23, 42, 0.75);
  color: var(--text);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 8px;
  display: none;
  z-index: 400;
}
.radar-map.error .map-overlay { display: block; }
@media (max-width: 720px) {
  .radar-map { height: 260px; }
}

/* Mini tables */
.mini-table-box { width: 100%; max-height: 160px; overflow: auto; margin-top: 10px; }
.mini-table-box:focus { outline: none; }
.mini-table-box:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 10px; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.mini-table thead th { position: sticky; top: 0; background: var(--surface); color: var(--muted); text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.12); }
.mini-table tbody td { padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.mini-table tbody tr:nth-child(odd) { background: rgba(255,255,255,0.03); }

/* VxBz card */
.vxbz-card .vxbz-value { font-size: 22px; font-weight: 700; display: flex; align-items: baseline; gap: 6px; }
.vxbz-card .vxbz-value .unit { color: var(--muted); font-size: 12px; font-weight: 600; }
.vxbz-card .mini-chart-box { display: flex; align-items: center; height: 120px; }
.vxbz-card .vxbz-scale { margin-top: 0; width: 100%; }
.vxbz-card .vxbz-bar { position: relative; height: 8px; background: rgba(255,255,255,0.12); border-radius: 999px; }
.vxbz-card .vxbz-bar .marker { position: absolute; top: 50%; transform: translate(-50%, -50%); width: 14px; height: 14px; background: #22c55e; border: 2px solid white; border-radius: 50%; box-shadow: 0 4px 10px rgba(0,0,0,.35); }
.vxbz-card .vxbz-bar .marker.neg { background: #ef4444; }
.vxbz-card .vxbz-bar .marker.pos { background: #22c55e; }
.vxbz-card .vxbz-scale-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; }
.vxbz-card .vxbz-time { color: var(--muted); font-size: 12px; margin-top: 8px; }

.rx { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.rx .label { color: var(--muted); }
.rx-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  text-transform: capitalize;
  border: 1px solid rgba(255,255,255,0.12);
}
.rx-badge.low { background: rgba(34,197,94,0.12); color: #22c55e; }
.rx-badge.moderate { background: rgba(234,179,8,0.15); color: #eab308; }
.rx-badge.high { background: rgba(239,68,68,0.15); color: #ef4444; }

/* Dst badge */
.dst-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  text-transform: none;
  border: 1px solid rgba(255,255,255,0.12);
}
.dst-badge.low { background: rgba(34,197,94,0.12); color: #22c55e; }
.dst-badge.moderate { background: rgba(234,179,8,0.15); color: #eab308; }
.dst-badge.high { background: rgba(239,68,68,0.15); color: #ef4444; }

.features .grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  justify-items: center; /* center cards when tracks are wider than card max */
}
.features .container { width: min(2200px, 95%); }
/* Feature cards width constraints */
.features .card { width: 100%; max-width: 720px; margin-inline: auto; }
@media (min-width: 500px) { .features .card { min-width: 500px; } }

/* Guide */
.guide .grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 1000px) {
  .guide .grid { grid-template-columns: 1fr; }
}

/* Learn (Aurora 101) */
.learn .grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
@media (max-width: 1000px) {
  .learn .grid { grid-template-columns: 1fr; }
}

/* Breakpoints for 3x2 -> 2x3 -> 1x6 */
@media (max-width: 1500px) {
  .features .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1000px) {
  .features .grid { grid-template-columns: 1fr; }
}
.card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 18px;
  transition: transform .15s ease, box-shadow .15s ease, background .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 16px 40px -24px rgba(0,0,0,.5); }
.card .icon { font-size: 22px; }
.card h3 { margin: 10px 0 6px; font-size: 18px; }
.card p { margin: 0; color: var(--muted); }

/* Solar & Lunar Panel */
#solarlunar-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 12px;
}

.solar-section, .lunar-section, .twilight-section {
  padding: 12px;
  border-radius: 8px;
  background: var(--card);
}

.solar-section h4, .lunar-section h4, .twilight-section h4 {
  margin: 0 0 8px 0;
  font-size: 16px;
  color: var(--primary);
}

.solar-data, .lunar-data, .twilight-data {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.data-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.data-item .label {
  color: var(--muted);
}

.data-item .value {
  font-weight: 500;
  text-align: right;
}

/* CTA */
.cta-inner {
  background: linear-gradient(180deg, rgba(124, 92, 255, 0.15), rgba(124, 92, 255, 0.08));
  border: 1px solid rgba(124, 92, 255, 0.25);
  border-radius: 16px;
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.cta-copy p { color: var(--muted); margin: 6px 0 0; }

/* Footer */
.site-footer { border-top: 1px solid rgba(255,255,255,0.08); }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px 0; }
.footer-inner p { margin: 0; color: var(--muted); }
.footer-inner .social { display: flex; gap: 14px; list-style: none; padding: 0; margin: 0; }
.footer-inner a { color: var(--muted); text-decoration: none; }
.footer-inner a:hover { color: var(--text); }

/* Responsive */
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; text-align: center; }
  .hero-media { order: -1; }
  .cta-inner { flex-direction: column; text-align: center; }
  .dashboard .metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .nav { position: absolute; inset: auto 0 0 0; top: 56px; background: var(--surface); border-top: 1px solid rgba(255,255,255,0.08); display: none; }
  .nav.open { display: block; }
  .nav ul { flex-direction: column; padding: 12px; }
  .features .grid { grid-template-columns: 1fr; }
  .dashboard .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Image Section */
.image-section {
  text-align: center;
  margin: 2rem 0;
}

.image-section img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  margin-inline: auto; /* Center the block-level image */
}

.image-section p {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: #666;
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
