/* ==========================================================================
   Lunar Site Planner — NASA Space Apps 2026
   Visual system from the Figma "Nasa" design: near-black surfaces, 3px grey
   outlines, 40px radii, white pill buttons, Dela Gothic One display type.
   ========================================================================== */

:root {
  --bg: #0e0e0e;
  --bg-deep: #010101;
  --bg-panel: #060606;
  --line: #666668;
  --line-soft: rgba(102, 102, 104, .45);
  --text: #ffffff;
  --muted: #8d8d91;
  --accent: #ffffff;
  --sun: #ffd24a;
  --earth: #7fb4ff;
  --go: #3ddc97;
  --nogo: #fc3d21;

  --radius: 40px;
  --radius-sm: 16px;
  --border: 3px solid var(--line);

  --font-display: "Dela Gothic One", "Arial Black", system-ui, sans-serif;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
}

/* starfield (static, CSS only) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff9, transparent),
    radial-gradient(1px 1px at 120px 80px, #fff7, transparent),
    radial-gradient(1.5px 1.5px at 220px 150px, #fffc, transparent),
    radial-gradient(1px 1px at 320px 40px, #fff6, transparent),
    radial-gradient(1px 1px at 60px 190px, #fff5, transparent);
  background-size: 360px 220px;
  opacity: .55;
}

h1, h2, h3 { margin: 0; line-height: 1.2; font-family: var(--font-display); font-weight: 400; }
h2 { font-size: 1.25rem; margin-bottom: .6rem; letter-spacing: .02em; }
h3 { font-size: 1rem; letter-spacing: .03em; text-transform: uppercase; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: #fff; color: #000; padding: .5rem 1rem; border-radius: 999px; z-index: 20; }

/* ---------- navbar ---------- */
.topbar {
  position: relative;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  min-height: 110px;
  padding: 0 clamp(1rem, 5.6vw, 5rem);
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
}
.topbar-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: .9rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.nasa-mark { display: inline-grid; place-items: center; width: 102px; height: 102px; }
.nasa-mark.small { width: 64px; height: 64px; }
.nasa-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.nasa-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #0b3d91;
  font-family: var(--font-display);
  font-size: .85rem;
  letter-spacing: .08em;
}

.mode-switch {
  justify-self: end;
  display: inline-flex;
  border: 3px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  margin: 0;
  min-inline-size: 0;
  background: transparent;
}
.mode-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mode-switch label {
  margin: 0;
  padding: .5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.mode-switch input:checked + label { background: #fff; color: #000; }
.mode-switch input:focus-visible + label { outline: 2px solid #fff; outline-offset: 3px; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  min-height: 560px;
  padding: 3rem clamp(1rem, 5.6vw, 5rem) 4rem;
  overflow: hidden;
  background:
    radial-gradient(900px 500px at 78% 40%, #1b1b1d, transparent 65%),
    var(--bg);
}
.hero-copy { position: relative; z-index: 1; max-width: 600px; }
.hero h1 {
  font-size: clamp(2rem, 4.6vw, 3.25rem);
  line-height: 1.15;
  text-transform: uppercase;
}
.hero h1 .dim { color: var(--line); }
.tagline { margin: 1.25rem 0 0; color: var(--muted); font-size: .95rem; }

/* crescent moon drawn in CSS (swap for the exported Figma photo if desired) */
.hero-moon {
  position: relative;
  justify-self: end;
  width: min(380px, 38vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 70% 40%, #f2f2f2 0%, #bdbdbd 35%, #6b6b6e 70%, #2a2a2c 100%);
  box-shadow: 0 0 80px rgba(255, 255, 255, .12);
}
.hero-moon::after {
  content: "";
  position: absolute;
  inset: -4% 14% -4% -22%;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 0 40px 10px var(--bg);
}

/* ---------- layout ---------- */
.layout {
  display: block;
  padding: 2.5rem clamp(1rem, 5.6vw, 5rem) 3rem;
  max-width: 1440px;
  margin: 0 auto;
}
.results { display: grid; gap: 1.5rem; min-width: 0; }

.panel {
  background: var(--bg);
  border: var(--border);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 2.4vw, 1.9rem);
}

.hint { color: var(--muted); font-size: .8rem; margin: .35rem 0 0; }
.eyebrow {
  margin: .5rem 0 0;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- KPI cards ---------- */
.cards { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .25rem;
  padding: 1.5rem 1.25rem 1.75rem;
  background: var(--bg);
  border: var(--border);
  border-radius: var(--radius);
}
.card:first-child { background: var(--bg-deep); }
.card-icon { width: 64px; height: 64px; margin-bottom: .6rem; color: #fff; }
.card h3 {
  order: 1;
  font-family: var(--font-body);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--muted);
}
.card .big {
  order: 2;
  margin: .6rem 0 .1rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
  line-height: 1.2;
}
.card .hint { order: 3; }
.card .checks { order: 4; text-align: left; }
.card .card-icon { order: 0; }

.verdict[data-state="GO"],
.verdict[data-state="go"] { border-color: var(--go); }
.verdict[data-state="GO"] .big,
.verdict[data-state="go"] .big { color: var(--go); }

.verdict[data-state="NO-GO"],
.verdict[data-state="nogo"] { border-color: var(--nogo); }
.verdict[data-state="NO-GO"] .big,
.verdict[data-state="nogo"] .big { color: var(--nogo); }

.verdict[data-state="idle"] .big { color: #fff; }

.checks { list-style: none; margin: .75rem 0 0; padding: 0; font-size: .78rem; }
.checks li { margin: .25rem 0; }
.checks .ok::before { content: "✔ "; color: var(--go); }
.checks .bad::before { content: "✖ "; color: var(--nogo); }

.explainer {
  margin: 0;
  padding: 1.1rem 1.5rem;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 1rem;
  line-height: 1.5;
}

/* ---------- simulation panel ---------- */
.sim { padding: clamp(1.25rem, 2.6vw, 1.875rem); }
.sim-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.sim-head h3 { font-size: clamp(1.1rem, 2.2vw, 1.75rem); color: var(--muted); }

.sim-grid {
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
}

.controls {
  padding: 1.5rem 1.5rem 1.75rem;
  border: var(--border);
  border-radius: var(--radius);
  background: transparent;
}
.controls h2 { font-size: 1.1rem; text-transform: uppercase; margin-bottom: .25rem; }

label {
  display: block;
  margin: .9rem 0 .3rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.check-label { text-transform: none; letter-spacing: 0; font-size: .8rem; font-weight: 600; color: #ddd; }

input:not([type="range"]):not([type="radio"]):not([type="checkbox"]),
select {
  width: 100%;
  padding: .65rem 1rem;
  border-radius: 999px;
  border: 3px solid var(--line);
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: .85rem;
}
select option { background: #0e0e0e; color: #fff; }
input[type="range"] { width: 100%; accent-color: #fff; cursor: pointer; margin: 0; }
input[type="checkbox"] { accent-color: #fff; }
input:focus-visible,
select:focus-visible,
.btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.actions { display: grid; gap: .75rem; margin-top: 1.5rem; }

.btn {
  padding: .8rem 1.25rem;
  border-radius: 999px;
  border: 3px solid var(--line);
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  cursor: pointer;
}
.btn:hover { border-color: #fff; }
.btn.primary { background: #fff; color: #000; border-color: var(--line); font-family: var(--font-display); font-weight: 400; }
.btn.primary:hover { border-color: #fff; background: #ececec; }
.btn.small { padding: .55rem 1.5rem; font-size: .8rem; }
.btn.light { background: #fff; color: #000; border-color: #fff; font-weight: 400; }
.btn.light:hover { background: #e6e6e6; }
.btn[disabled] { opacity: .5; cursor: progress; }

.status { min-height: 1.2em; font-size: .8rem; color: var(--muted); margin: .9rem 0 0; }
.status.error { color: var(--nogo); }

/* ---------- 3D viewport (React + Three.js) ---------- */
.viewport {
  position: relative;
  min-width: 0;
  border: var(--border);
  border-radius: var(--radius);
  background:
    radial-gradient(1px 1px at 20px 30px, #fff9, transparent),
    radial-gradient(1px 1px at 120px 80px, #fff7, transparent),
    radial-gradient(1.5px 1.5px at 220px 150px, #fffc, transparent),
    #000;
  background-size: 260px 180px, 260px 180px, 260px 180px, auto;
  overflow: hidden;
}
#react-3d-root {
  position: relative;
  min-height: 518px;
  margin: 0;
  padding: .75rem;
}
#react-3d-root canvas {
  display: block;
  width: 100% !important;
  border-radius: calc(var(--radius) - 14px);
}
#react-3d-root label {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  color: #ddd;
}

.hud-3d {
  position: absolute;
  top: 18px;
  left: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  padding: .45rem .9rem;
  border-radius: 999px;
  background: rgba(6, 6, 6, .8);
  border: 2px solid var(--line);
  backdrop-filter: blur(6px);
  font-size: .75rem;
  pointer-events: none;
}
.hud-3d > div { display: flex; align-items: center; gap: .35rem; }
.hud-3d span { color: var(--muted); font-weight: 600; }
.hud-3d em { font-style: normal; font-weight: 700; }
.hud-3d em.ok { color: var(--go); }
.hud-3d em.bad { color: var(--nogo); }

.slider-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .5rem .25rem;
}

/* ---------- charts (Plotly) ---------- */
.charts { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.chart-panel { background: var(--bg-deep); }
.chart-panel h3 { font-size: 1.1rem; color: #fff; }
.chart-panel .hint { font-family: var(--font-body); text-transform: uppercase; letter-spacing: .02em; font-size: .72rem; }
.chart { width: 100%; height: 340px; margin-top: 1rem; }
.chart.short { height: 260px; }
.chart[hidden] { display: none !important; }
.chart:empty {
  display: grid;
  place-items: center;
  border: 2px dashed var(--line-soft);
  border-radius: var(--radius-sm);
}
.chart:empty::after {
  content: "Run a simulation";
  color: var(--muted);
  font-family: var(--font-display);
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ---------- scenario comparator ---------- */
.comparator { background: var(--bg-deep); }
.comp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.comp-head h3 { font-size: 1.1rem; }
.comp-head .hint { text-transform: uppercase; letter-spacing: .02em; font-size: .72rem; }

.compare-stage {
  position: relative;
  min-height: 320px;
  margin-top: 1.25rem;
  padding: 1.25rem;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
}
/* idle state: table still hidden → show the empty-state label from the design */
.compare-stage:has(#comp-table[hidden])::after {
  content: "Run a simulation";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  pointer-events: none;
}
.compare-stage:has(#comp-table[hidden]) .chart { display: none; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
table[hidden] { display: none; }
th, td {
  text-align: left;
  padding: .7rem .75rem;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
th { color: var(--muted); font-weight: 700; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.tag { padding: .2rem .7rem; border-radius: 999px; font-weight: 700; font-size: .72rem; border: 2px solid currentColor; }
.tag.GO { color: var(--go); background: rgba(61, 220, 151, .12); }
.tag.NO-GO { color: var(--nogo); background: rgba(252, 61, 33, .12); }
.x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; }
.x:hover { color: #fff; }
ul.plain { margin: .75rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: .85rem; line-height: 1.55; }

/* ---------- footer ---------- */
.footer {
  padding: 2.5rem clamp(1rem, 5.6vw, 5rem) 3rem;
  background: var(--bg);
  border-top: 1px solid var(--line-soft);
}
.footer-brand { display: flex; align-items: center; gap: 1.25rem; }
.footer-brand p {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.footer-data { margin: 1.5rem 0 0; color: var(--muted); font-size: .78rem; }

/* ---------- profile modes ---------- */
body[data-mode="explorer"] .only-engineer { display: none !important; }
body[data-mode="engineer"] .only-explorer { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .sim-grid { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-moon { justify-self: center; margin-top: 2rem; width: min(280px, 60vw); }
}
@media (max-width: 720px) {
  .topbar { grid-template-columns: 1fr auto; min-height: 0; padding-top: .75rem; padding-bottom: .75rem; }
  .topbar-title { display: none; }
  .nasa-mark { width: 64px; height: 64px; }
  .mode-switch label { padding: .45rem .75rem; font-size: .72rem; }
  :root { --radius: 28px; }
}
@media (max-width: 480px) {
  .charts { grid-template-columns: 1fr; }
  .chart { height: 300px; }
  #react-3d-root { min-height: 360px; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn, .card { transition: border-color .2s, transform .2s, background .2s; }
  .card:hover { transform: translateY(-2px); }
}
