/* ASTRA CARTO — Refined Dark Design System (Deep Navy + Gold & Blue Accents) */
:root {
  --bg: #070b14;
  --bg-elevated: #0b1220;
  --panel: #10192b;
  --panel2: #162238;
  --line: #233352;
  --line-soft: #19253d;
  --text: #e6edf7;
  --muted: #8da2c0;
  --sun: #f2c14e;
  --earth: #5aa9e6;
  --horizon: #e07a4f;
  --ok: #7ec850;
  --warn: #e07a4f;
  --accent: #5aa9e6;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
  scroll-padding-bottom: 104px;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  background: radial-gradient(1200px 600px at 50% -180px, rgba(90, 169, 230, 0.08), transparent 65%), var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

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

[hidden] { display: none !important; }

/* ---------------- Independent Landing Page (#splash) ---------------- */
#splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(620px 620px at 50% 48%, rgba(242, 193, 78, 0.10), transparent 60%),
    radial-gradient(960px 540px at 50% 100%, rgba(90, 169, 230, 0.16), transparent 65%),
    var(--bg);
  overflow: hidden;
}

#splashVideo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.76) saturate(1.06);
}

#splash[data-video-state="fallback"] #splashVideo {
  display: none;
}

#splash[data-video-state="fallback"]::after {
  content: "";
  position: absolute;
  width: min(58vw, 520px);
  height: min(58vw, 520px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 32%, rgba(230, 237, 247, 0.24) 0%, rgba(141, 162, 192, 0.14) 36%, rgba(16, 25, 43, 0.85) 70%, rgba(7, 11, 20, 0) 74%);
  box-shadow: 0 0 110px rgba(90, 169, 230, 0.18), inset -30px -24px 60px rgba(7, 11, 20, 0.85);
  pointer-events: none;
}

.splashScrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 48%, rgba(7, 11, 20, 0.34) 0%, rgba(7, 11, 20, 0.78) 68%, rgba(7, 11, 20, 0.92) 100%);
  pointer-events: none;
}

.splashContent {
  position: relative;
  z-index: 2;
  max-width: 660px;
  text-align: center;
  padding: 28px 24px;
}

.splashEyebrow {
  margin: 0 0 14px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--sun);
  text-transform: uppercase;
}

.splashTitle {
  margin: 0;
  font-size: clamp(38px, 6.5vw, 64px);
  font-weight: 700;
  letter-spacing: 0.14em;
  line-height: 1.08;
  color: #ffffff;
  text-shadow: 0 4px 28px rgba(0, 0, 0, 0.75);
}

.splashTagline {
  margin: 14px 0 0;
  font-size: clamp(17px, 2.3vw, 22px);
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--earth);
}

.splashDesc {
  margin: 18px auto 30px;
  max-width: 540px;
  font-size: 15px;
  line-height: 1.65;
  color: #cdd8ea;
}

.splashCta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 30px;
  border-radius: 999px;
  border: 1px solid rgba(242, 193, 78, 0.55);
  background: linear-gradient(135deg, rgba(242, 193, 78, 0.18), rgba(90, 169, 230, 0.24));
  color: #ffffff;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.45);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.splashCta:hover,
.splashCta:focus-visible {
  transform: translateY(-1px);
  border-color: var(--sun);
  background: linear-gradient(135deg, rgba(242, 193, 78, 0.30), rgba(90, 169, 230, 0.34));
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  #splashVideo { display: none; }
}

/* ---------------- Mission Planner Header ---------------- */
.app-header {
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.90);
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-home {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 4px 10px 4px 4px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.brand-home:hover,
.brand-home:focus-visible {
  border-color: var(--line);
  background: rgba(22, 34, 56, 0.7);
  outline: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(242, 193, 78, 0.25), rgba(90, 169, 230, 0.22));
  border: 1px solid rgba(90, 169, 230, 0.45);
  color: var(--sun);
  font-size: 16px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-text strong {
  font-size: 15px;
  letter-spacing: 0.12em;
  color: #ffffff;
}

.brand-text span {
  font-size: 11.5px;
  color: var(--muted);
}

.cache-pill {
  display: inline-block;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
}

/* ---------------- Workspace Containers & Headings ---------------- */
#gate,
main {
  max-width: 1220px;
  margin: 0 auto;
  padding-left: 20px;
  padding-right: 20px;
}

#gate { padding-top: 20px; }
main { padding-bottom: 48px; }

.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 8px;
}

.sec-kicker {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--earth);
  margin-bottom: 2px;
}

h1, h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  color: #ffffff;
}

h3 {
  font-size: 12.5px;
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.gatelabel,
.sec-sub,
.sub {
  color: var(--muted);
  font-size: 13px;
  margin: 2px 0 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 10px 0 14px;
}

/* ---------------- Part 1: Mission Setup Controls ---------------- */
#controls.controls-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 14px;
  align-items: flex-end;
}

.ctl {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ctl label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.ctl-label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.custom {
  display: flex;
  flex-direction: row;
  gap: 10px;
}

.custom > div {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

select,
input[type=number],
input[type=datetime-local] {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  font-size: 14px;
}

select:focus-visible,
input[type=number]:focus-visible,
input[type=datetime-local]:focus-visible {
  outline: 2px solid rgba(90, 169, 230, 0.5);
  border-color: var(--accent);
}

select { max-width: 330px; }

.ctl-actions {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

button {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid rgba(90, 169, 230, 0.6); outline-offset: 1px; }
button:disabled { opacity: 0.65; cursor: wait; }

button.primary {
  background: linear-gradient(135deg, rgba(90, 169, 230, 0.26), rgba(35, 76, 130, 0.7));
  border-color: rgba(90, 169, 230, 0.65);
  color: #ffffff;
}

button.primary:hover {
  border-color: var(--sun);
  background: linear-gradient(135deg, rgba(90, 169, 230, 0.36), rgba(242, 193, 78, 0.22));
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 2px 10px;
}

.status.err { color: var(--warn); }

/* ---------------- Part 2: Mission Overview Metric Cards ---------------- */
.overview-head {
  margin: 8px 0 10px;
}

#scenTitle {
  font-size: 22px;
  margin-top: 2px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(225px, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 2px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  font-variant-numeric: tabular-nums;
}

.card.sun { border-top-color: rgba(242, 193, 78, 0.75); }
.card.earth { border-top-color: rgba(90, 169, 230, 0.75); }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.card .k-text {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

.card .v {
  font-size: 21px;
  font-weight: 650;
  color: #ffffff;
}

.card .d {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
  min-height: 36px;
  line-height: 1.4;
}

.card.sun .v { color: var(--sun); }
.card.earth .v { color: var(--earth); }

/* ---------------- Interactive 3D Lunar Globe ---------------- */
.globebox {
  display: flex;
  flex-direction: column;
}

.chart-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.globe-fs-btn {
  padding: 4px 9px;
  font-size: 11.5px;
  font-weight: 550;
  border-radius: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
  white-space: nowrap;
}

.globe-fs-btn:hover {
  border-color: var(--earth);
  color: #ffffff;
}

.globe-stage {
  position: relative;
  width: 100%;
  height: 360px;
  flex: 1 1 auto;
  min-height: 320px;
  border-radius: 8px;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #0c1428 0%, #050811 72%, #03050b 100%);
  border: 1px solid var(--line-soft);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.globe-stage:active {
  cursor: grabbing;
}

#moonGlobeCard.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 180;
  width: 100vw;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  border: none;
  padding: 14px 18px;
  background: #040711;
}

#moonGlobeCard.is-fullscreen .globe-stage {
  height: calc(100vh - 74px);
  min-height: 0;
  cursor: grab;
}

#moonGlobeCard.is-fullscreen .globe-stage:active {
  cursor: grabbing;
}

#moonGlobeCard.is-fullscreen .globe-fs-btn {
  border-color: rgba(242, 193, 78, 0.6);
  color: var(--sun);
  background: rgba(242, 193, 78, 0.12);
}

.globe-fs-time,
.globe-play-btn {
  display: none;
}

#moonGlobeCard.is-fullscreen .globe-fs-time {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #e2e8f0;
  margin-right: 4px;
  white-space: nowrap;
}

#moonGlobeCard.is-fullscreen .globe-play-btn {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.65);
  color: #ffffff;
  cursor: pointer;
  white-space: nowrap;
}

#moonGlobeCard.is-fullscreen .globe-play-btn:hover {
  background: rgba(56, 189, 248, 0.28);
  border-color: #7dd3fc;
}

#moonGlobeCard.is-fullscreen .globe-play-btn.playing {
  background: rgba(242, 193, 78, 0.18);
  border-color: rgba(242, 193, 78, 0.72);
  color: var(--sun);
}

#moonGlobeCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.globe-overlay-btns {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}

.globe-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(7, 11, 20, 0.68);
  border: 1px solid rgba(51, 65, 85, 0.75);
  color: #e2e8f0;
  backdrop-filter: blur(8px);
}

.globe-icon-btn:hover,
.globe-icon-btn.active {
  border-color: rgba(34, 211, 238, 0.6);
  color: #67e8f9;
  background: rgba(8, 22, 38, 0.8);
}

.pin-label {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(2, 6, 23, 0.82);
  border: 1px solid rgba(34, 211, 238, 0.4);
  color: #a5f3fc;
  font: 600 10px ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  transition: opacity 0.25s ease;
  will-change: transform;
}

.globe-foot {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(51, 65, 85, 0.55);
  backdrop-filter: blur(8px);
  font-size: 10.5px;
  line-height: 1.35;
  color: var(--muted);
  pointer-events: none;
}

#moonGlobeCard.is-fullscreen .globe-foot {
  left: 14px;
  right: 14px;
  bottom: 14px;
  gap: 8px 16px;
  padding: 7px 12px;
  font-size: 12px;
}

.globe-legend {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}

.leg-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.leg-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.leg-dot.sun { background: #f59e0b; }
.leg-dot.earth { background: #38bdf8; }
.leg-dot.pin { background: #22d3ee; box-shadow: 0 0 6px #22d3ee; }
.leg-dot.site { background: #e2e8f0; }

/* ---------------- Part 3: Visual Analysis 2+1+1+1 Grid ---------------- */
.charts-heading { margin-top: 6px; margin-bottom: 10px; }

.charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
}

.chartbox {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

.chartbox.full {
  grid-column: 1 / -1;
}

.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.chart-sub {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
}

#elevChart { height: 360px; }
#horizonChart { height: 230px; }
#geomCanvas { height: 280px; }
#windowsChart { height: 200px; }
#compareChart { height: 320px; }

/* ---------------- Part 4: Compact Sticky Mission Timeline Bar ---------------- */
.analysis-workspace {
  position: relative;
}

.scrubber.panel {
  position: sticky;
  bottom: 0;
  z-index: 20;
  margin: 16px 0 12px;
  padding: 10px 14px;
  background: rgba(11, 18, 32, 0.96);
  backdrop-filter: blur(10px);
  border-color: rgba(90, 169, 230, 0.42);
  box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.55);
}

.scrubhead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.scrub-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--earth);
}

.scrubtime {
  font-weight: 650;
  font-size: 14.5px;
  font-variant-numeric: tabular-nums;
  min-width: 165px;
  color: #ffffff;
}

.scrub-btns {
  display: inline-flex;
  gap: 6px;
}

.scrub-btns button {
  padding: 5px 11px;
  font-size: 13px;
}

.scrub-slider-wrap {
  flex: 1 1 240px;
  display: flex;
  align-items: center;
}

input[type=range] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.scrubread {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 18px;
  font-size: 12.5px;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.scrubread > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.scrubread b { font-weight: 600; }
.sun-t { color: var(--sun); }
.earth-t { color: var(--earth); }
.warn-t { color: var(--warn); }
.ok-t { color: var(--ok); }
.scrub-info { margin-left: auto; }

/* ---------------- Active-Site Links & Part 5 Comparison ---------------- */
.links {
  display: flex;
  gap: 10px 18px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 13.5px;
}

.links span {
  color: var(--muted);
  font-weight: 500;
}

.links-collab {
  margin-left: auto;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.collab-btn {
  padding: 5px 11px;
  font-size: 12.5px;
  border-radius: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--text);
}

.collab-btn:hover {
  border-color: var(--earth);
  color: #ffffff;
}

#compareView {
  margin-top: 24px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.tablewrap {
  overflow-x: auto;
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  border-collapse: collapse;
  font-size: 13.5px;
  width: 100%;
  background: var(--panel);
}

th, td {
  border-bottom: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

th:last-child, td:last-child { border-right: none; }
tr:last-child td { border-bottom: none; }

th {
  background: var(--panel2);
  color: var(--muted);
  font-weight: 600;
}

td .rm {
  cursor: pointer;
  color: var(--warn);
  padding: 2px 6px;
  border-radius: 4px;
}
td .rm:hover { background: rgba(224, 122, 79, 0.16); }

/* ---------------- Scientific Accessibility Info Buttons & Popover ---------------- */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  min-width: 19px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  font-weight: 600;
  flex-shrink: 0;
}

.info-btn:hover,
.info-btn:focus-visible,
.info-btn[aria-expanded="true"] {
  border-color: var(--sun);
  color: var(--sun);
  background: rgba(242, 193, 78, 0.12);
}

.tooltip-popover {
  position: fixed;
  z-index: 200;
  max-width: 300px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0d1628;
  border: 1px solid rgba(90, 169, 230, 0.55);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.65);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
  pointer-events: auto;
}

.tooltip-popover strong {
  display: block;
  margin-bottom: 4px;
  color: var(--sun);
  font-size: 12.5px;
}

/* ---------------- Responsive Breakpoints ---------------- */
@media (max-width: 960px) {
  .charts-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .globe-stage { height: 320px; }
  .globe-legend { margin-left: 0; }
  #elevChart { height: 300px; }
}

@media (max-height: 620px), (max-width: 720px) {
  .scrubber.panel {
    position: static;
    box-shadow: none;
  }
  .scrubread {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .scrub-info { margin-left: 0; }
}

@media (max-width: 640px) {
  #gate, main, .header-inner { padding-left: 14px; padding-right: 14px; }
  .links-collab { margin-left: 0; width: 100%; }
  .globe-stage { height: 280px; min-height: 260px; }
  #elevChart { height: 260px; }
  #horizonChart { height: 210px; }
  #geomCanvas { height: 230px; }
  #windowsChart { height: 185px; }
}
