/* =====================================================
   ARTEMIS II MISSION TRACKER — STYLES
   Dark space theme with NASA blue/cyan accents
   ===================================================== */

:root {
  --bg:         #030810;
  --bg-card:    #08111f;
  --bg-panel:   #0b1a30;
  --bg-header:  rgba(6, 14, 28, 0.92);
  --blue:       #4fc3f7;
  --cyan:       #00e5ff;
  --cyan-dim:   #0097a7;
  --green:      #69f0ae;
  --gold:       #ffd54f;
  --red:        #ff5252;
  --text:       #d6eaf8;
  --text-dim:   #6a9bb8;
  --text-muted: #2e5272;
  --border:     #0f2540;
  --border-dim: #071525;
  --nasa-blue:  #0b3d91;
  --nasa-red:   #fc3d21;
  --glow-blue:  rgba(79, 195, 247, 0.18);
  --glow-cyan:  rgba(0, 229, 255, 0.15);
  --radius:     8px;
  --radius-lg:  14px;
}

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

html { scroll-behavior: smooth; }

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

.mono { font-family: 'Space Mono', 'Courier New', monospace; }

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

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}

/* =====================
   HEADER
   ===================== */
header {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.7rem 1.5rem;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nasa-worm {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.35rem;
  letter-spacing: 0.15em;
  color: #fff;
  background: var(--nasa-blue);
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
}

.brand-divider {
  color: var(--text-muted);
  font-size: 1.4rem;
  font-weight: 300;
}

.mission-id {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.mission-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
}

.mission-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 50, 50, 0.15);
  border: 1px solid rgba(255, 82, 82, 0.4);
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
  animation: live-pulse 1.4s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

.unit-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.2rem;
  transition: border-color 0.2s;
}
.unit-toggle:hover { border-color: var(--cyan); }
.unit-sep { color: var(--border); }
.unit-opt { transition: color 0.2s; }
.unit-opt.active { color: var(--cyan); font-weight: 700; }

.met-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.05rem;
}

.met-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.met-value {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px var(--glow-cyan);
}

/* =====================
   TELEMETRY BAR
   ===================== */
.telem-bar {
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.telem-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.65rem 1.4rem;
  gap: 0.1rem;
  flex: 1;
  min-width: 120px;
}

.telem-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.telem-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--blue);
  line-height: 1;
  letter-spacing: 0.02em;
}

.telem-unit {
  font-size: 0.65rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.phase-val {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--green);
  text-align: center;
}

.telem-sep {
  width: 1px;
  background: var(--border);
  margin: 0.5rem 0;
  align-self: stretch;
}

/* =====================
   MAP SECTION
   ===================== */
.map-section {
  background: var(--bg);
}

.map-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.map-header h2 {
  font-size: 0.85rem;
  color: var(--text-dim);
}

.map-controls {
  display: flex;
  gap: 0.4rem;
  margin-left: auto;
}

.map-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.72rem;
  font-family: 'Space Grotesk', sans-serif;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}

.map-btn:hover {
  background: var(--bg-panel);
  border-color: var(--blue);
  color: var(--blue);
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

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

.leg-line {
  width: 16px;
  height: 2px;
  display: inline-block;
  border-top: 2px solid;
}

.leg-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-right: 0.5rem;
}

#map-container {
  position: relative;
  width: 100%;
  height: 520px;
  background: #030810;
  overflow: hidden;
}

#map-resize-handle {
  width: 100%;
  height: 10px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  user-select: none;
}

#map-resize-handle:hover,
#map-resize-handle.dragging {
  background: var(--bg-panel);
  border-color: var(--blue);
}

.resize-grip {
  width: 36px;
  height: 3px;
  border-radius: 2px;
  background: var(--text-muted);
  transition: background 0.15s, width 0.15s;
}

#map-resize-handle:hover .resize-grip,
#map-resize-handle.dragging .resize-grip {
  background: var(--blue);
  width: 56px;
}

#three-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.map-overlay-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0.6rem 1rem;
  background: linear-gradient(0deg, rgba(3,8,16,0.8) 0%, transparent 100%);
  pointer-events: none;
}

.api-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: 'Space Mono', monospace;
  pointer-events: auto;
}

.api-status.ok { color: var(--green); }
.api-status.err { color: var(--red); }
.api-status.warn { color: var(--gold); }

.drag-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(3,8,16,0.85);
  color: var(--text-dim);
  font-size: 0.85rem;
  z-index: 10;
  transition: opacity 0.5s;
}

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

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

/* =====================
   CONTENT GRID
   ===================== */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 0;
  border-top: 1px solid var(--border);
}

/* =====================
   STREAM
   ===================== */
.stream-section {
  padding: 1.4rem;
  border-right: 1px solid var(--border);
}

.section-head {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.section-tag {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.25);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}

.youtube-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.youtube-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stream-note {
  margin-top: 0.6rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* =====================
   SIDEBAR
   ===================== */
.sidebar {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
}

.card {
  padding: 1.2rem;
  border-bottom: 1px solid var(--border);
}

.status-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.8rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--border-dim);
}

.sl {
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.sv {
  color: var(--text);
  text-align: right;
  font-size: 0.8rem;
}

/* =====================
   TIMELINE
   ===================== */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tl-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.55rem 0;
  position: relative;
  opacity: 0.45;
  transition: opacity 0.4s;
}

.tl-item::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 1.3rem;
  bottom: -0.55rem;
  width: 1px;
  background: var(--border);
}

.tl-item:last-child::before { display: none; }

.tl-item.completed { opacity: 0.7; }
.tl-item.active    { opacity: 1; }

.tl-marker {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  background: var(--bg-card);
  flex-shrink: 0;
  margin-top: 0.2rem;
  transition: all 0.4s;
  z-index: 1;
}

.tl-item.completed .tl-marker {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 8px rgba(105, 240, 174, 0.5);
}

.tl-item.active .tl-marker {
  border-color: var(--cyan);
  background: var(--bg-card);
  box-shadow: 0 0 10px var(--glow-cyan);
  animation: tl-pulse 2s ease-in-out infinite;
}

@keyframes tl-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(0, 229, 255, 0.4); }
  50%       { box-shadow: 0 0 14px rgba(0, 229, 255, 0.8); }
}

.tl-content { flex: 1; min-width: 0; }

.tl-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.tl-item.active .tl-label { color: var(--cyan); }

.tl-time {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: 'Space Mono', monospace;
  margin-top: 0.1rem;
}

.tl-detail {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

/* =====================
   CREW
   ===================== */
.crew-section {
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.crew-section h2 {
  margin-bottom: 0.4rem;
}

.crew-intro {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  max-width: 600px;
}

.crew-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.crew-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  transition: border-color 0.25s, transform 0.2s;
}

.crew-card:hover {
  border-color: var(--blue);
  transform: translateY(-3px);
}

.crew-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
  box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.av-blue  { background: linear-gradient(135deg, #0b3d91, #1565c0); }
.av-teal  { background: linear-gradient(135deg, #004d5a, #00838f); }
.av-red   { background: linear-gradient(135deg, #6a1a1a, #c62828); }

.crew-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.crew-role {
  font-size: 0.72rem;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.crew-agency {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}

.agency-nasa { background: rgba(11,61,145,0.3); color: var(--blue); border: 1px solid rgba(11,61,145,0.5); }
.agency-csa  { background: rgba(220,38,38,0.15); color: #ff8a80; border: 1px solid rgba(220,38,38,0.3); }

.crew-milestone {
  font-size: 0.7rem;
  color: var(--gold);
  font-style: italic;
  margin-top: 0.2rem;
  line-height: 1.3;
}

.crew-card { cursor: pointer; }
.crew-more {
  font-size: 0.68rem;
  color: var(--cyan);
  margin-top: 0.4rem;
  opacity: 0;
  transition: opacity 0.2s;
}
.crew-card:hover .crew-more { opacity: 1; }

/* =====================
   CREW MODAL
   ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(12px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal-box { transform: translateY(0); }
.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.2s, color 0.2s;
}
.modal-close:hover { border-color: var(--cyan); color: var(--cyan); }
.modal-header {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  margin-bottom: 1.5rem;
}
.modal-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 24px rgba(0,0,0,0.5);
}
.modal-name { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.modal-role { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin: 0.2rem 0; }
.modal-agency { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; }
.modal-body { font-size: 0.88rem; color: var(--text-dim); line-height: 1.7; }
.modal-body h4 {
  color: var(--cyan);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin: 1.2rem 0 0.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}
.modal-body h4:first-child { margin-top: 0; }
.modal-body ul {
  list-style: none;
  padding: 0; margin: 0;
}
.modal-body ul li {
  padding: 0.25rem 0;
  padding-left: 1rem;
  position: relative;
}
.modal-body ul li::before {
  content: '—';
  position: absolute; left: 0;
  color: var(--border);
}
.modal-body .milestone-tag {
  display: inline-block;
  background: rgba(0,255,200,0.08);
  border: 1px solid rgba(0,255,200,0.25);
  color: var(--cyan);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  margin-top: 0.5rem;
}

/* =====================
   FOOTER
   ===================== */
footer {
  border-top: 1px solid var(--border);
  padding: 1.2rem 1.5rem;
  background: var(--bg-card);
}

.footer-inner {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: center;
  text-align: center;
}

footer p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 1100px) {
  .content-grid { grid-template-columns: 1fr; }
  .sidebar { border-left: none; border-top: 1px solid var(--border); }
  .stream-section { border-right: none; }
  .crew-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .header-inner { padding: 0.5rem 1rem; }
  .met-block { display: none; }
  .telem-bar { flex-wrap: wrap; }
  .telem-item { min-width: 45%; padding: 0.5rem 0.8rem; }
  .telem-sep { display: none; }
  .map-header { gap: 0.5rem; }
  .map-legend { display: none; }
  #map-container { height: 360px; }
  .crew-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .brand-divider, .mission-sub { display: none; }
}

@media (max-width: 480px) {
  .crew-grid { grid-template-columns: 1fr 1fr; }
}
