/* ============================================================================
   SpaceMineralAtlas -- Authentic Barker Lab COSE Theme
   Identical design system tokens, typography, and section architecture
   as Plant_response_to_radiation and the COSE ecosystem.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --fg: #1a2230;
  --ink: #1a2230;
  --muted: #5a6473;
  --slate: #5a6473;
  --line: #e5e9f0;
  --border: #e5e9f0;
  --card: #f7f9fc;
  --panel: #f7f9fc;
  --soft: #f7f9fc;
  --code: #f1f5f9;
  --accent: #3B6EA5;
  --accent2: #3FB6A8;
  --coral: #c2412b;
  --gold: #b38600;
  --grey: #8A8A8A;
  --navy: var(--accent);
  --teal: var(--accent2);
  --teal-graphic: var(--accent2);
  --coral-graphic: var(--coral);
  --gold-graphic: var(--gold);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --maxw: 1040px;
  --rail: 288px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --fg: #e6ebf2;
    --ink: #e6ebf2;
    --muted: #9aa6b6;
    --slate: #9aa6b6;
    --line: #232c39;
    --border: #232c39;
    --card: #161d27;
    --panel: #161d27;
    --soft: #161d27;
    --code: #0f1a2e;
    --accent: #6ea3d8;
    --accent2: #54c9ba;
    --coral: #f08e74;
    --gold: #e8c547;
    --navy: var(--accent);
    --teal: var(--accent2);
    --teal-graphic: var(--accent2);
    --coral-graphic: var(--coral);
    --gold-graphic: var(--gold);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    color-scheme: dark;
  }
}

html[data-theme="light"] {
  --bg: #ffffff;
  --fg: #1a2230;
  --ink: #1a2230;
  --muted: #5a6473;
  --slate: #5a6473;
  --line: #e5e9f0;
  --border: #e5e9f0;
  --card: #f7f9fc;
  --panel: #f7f9fc;
  --soft: #f7f9fc;
  --code: #f1f5f9;
  --accent: #3B6EA5;
  --accent2: #3FB6A8;
  --coral: #c2412b;
  --gold: #b38600;
  --navy: var(--accent);
  --teal: var(--accent2);
  --teal-graphic: var(--accent2);
  --coral-graphic: var(--coral);
  --gold-graphic: var(--gold);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0f141b;
  --fg: #e6ebf2;
  --ink: #e6ebf2;
  --muted: #9aa6b6;
  --slate: #9aa6b6;
  --line: #232c39;
  --border: #232c39;
  --card: #161d27;
  --panel: #161d27;
  --soft: #161d27;
  --code: #0f1a2e;
  --accent: #6ea3d8;
  --accent2: #54c9ba;
  --coral: #f08e74;
  --gold: #e8c547;
  --navy: var(--accent);
  --teal: var(--accent2);
  --teal-graphic: var(--accent2);
  --coral-graphic: var(--coral);
  --gold-graphic: var(--gold);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---- Content Design System (COSE Authentic) ---- */
header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(59, 110, 165, 0.10), transparent);
}

header .wrap { padding: 56px 20px 40px; }

.eyebrow {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin: 0 0 10px;
}

h1 {
  font-size: 2.15rem;
  line-height: 1.2;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
  color: var(--fg);
}

h1 span { color: var(--accent2); font-weight: 300; }

.lede {
  font-size: 1.12rem;
  color: var(--muted);
  margin: 0 0 22px;
  max-width: 72ch;
  line-height: 1.55;
}

.meta { color: var(--muted); font-size: 0.92rem; margin: 0 0 20px; }

.btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn:hover { text-decoration: none; filter: brightness(1.04); border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.btn.primary:hover { text-decoration: none; filter: brightness(1.08); }

section { padding: 48px 0; border-bottom: 1px solid var(--line); }

h2 {
  font-size: 1.55rem;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
  scroll-margin-top: 30px;
  color: var(--fg);
}

h2 .n { color: var(--accent); font-weight: 700; margin-right: 0.5rem; }

.sub { color: var(--muted); margin: 0 0 24px; font-size: 1rem; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 20px 18px;
  transition: border-color 0.15s ease;
}

.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--fg); }
.card p { margin: 0; color: var(--muted); font-size: 0.93rem; line-height: 1.55; }
.stat { font-size: 2rem; font-weight: 700; line-height: 1; margin: 2px 0 8px; color: var(--accent); }

/* Alerts & Callouts in COSE Style */
.callout {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent2);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 20px 0;
}

.callout h4 { margin: 0 0 6px; color: var(--fg); font-size: 1rem; }
.callout p { margin: 0; color: var(--muted); font-size: 0.92rem; }

.alert-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--coral);
  border-radius: 8px;
  padding: 16px 18px;
  margin: 20px 0;
}

.alert-box h4 { margin: 0 0 6px; color: var(--coral); font-size: 1rem; }
.alert-box p { margin: 0; color: var(--fg); font-size: 0.92rem; }

/* Interactive Controls Bar */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.btn-group {
  display: inline-flex;
  background: var(--line);
  padding: 2px;
  border-radius: 6px;
  gap: 2px;
}

.btn-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-toggle:hover { color: var(--fg); }
.btn-toggle.active { background: var(--bg); color: var(--accent); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }

.control-label { font-size: 0.82rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }

select.select-custom, input.input-custom {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 6px;
  font-size: 0.88rem;
  outline: none;
}

select.select-custom:focus, input.input-custom:focus {
  border-color: var(--accent);
}

/* Slider Controls */
.slider-container {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 240px;
}

input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }

.slider-val-badge {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--card);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 6px;
  min-width: 65px;
  text-align: center;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

th, td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: var(--card);
  color: var(--fg);
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--line);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(59, 110, 165, 0.04); }

.text-right { text-align: right; }
.text-center { text-align: center; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-survives { background: rgba(63, 182, 168, 0.15); color: var(--accent2); }
.badge-artefact { background: rgba(194, 65, 43, 0.15); color: var(--coral); }
.badge-decreased { background: rgba(179, 134, 0, 0.15); color: var(--gold); }
.badge-nochange { background: var(--line); color: var(--muted); }
.badge-flight { background: rgba(59, 110, 165, 0.15); color: var(--accent); }
.badge-ground { background: var(--line); color: var(--muted); }

.badge-open { background: rgba(34, 197, 94, 0.15); color: #16a34a; }
html[data-theme="dark"] .badge-open { color: #4ade80; }

.badge-gated { background: rgba(234, 179, 8, 0.15); color: #ca8a04; }
html[data-theme="dark"] .badge-gated { color: #facc15; }

.badge-unsubmitted { background: rgba(239, 68, 68, 0.15); color: #dc2626; }
html[data-theme="dark"] .badge-unsubmitted { color: #f87171; }

/* Progress Bars */
.progress-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar-track {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.fill-teal { background: var(--accent2); }
.fill-blue { background: var(--accent); }
.fill-coral { background: var(--coral); }
.fill-gold { background: var(--gold); }
.fill-slate { background: var(--muted); }

.progress-val-text {
  font-size: 0.85rem;
  font-weight: 700;
  min-width: 48px;
  text-align: right;
  color: var(--fg);
}

/* Figures in COSE theme */
figure {
  margin: 26px 0 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  background: #ffffff;
  cursor: zoom-in;
}

figcaption {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.45;
  text-align: left;
}

/* Grid helper */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin: 20px 0;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

/* Crew cards */
.crew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.crew-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.crew-card:hover { border-color: var(--accent); }
.crew-card.active { border-color: var(--accent); background: rgba(59, 110, 165, 0.08); }
.crew-name { font-weight: 700; font-size: 0.98rem; color: var(--fg); }
.crew-role { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; }
.crew-details { font-size: 0.82rem; color: var(--muted); }

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0; top: 0; width: 100%; height: 100%;
  background: rgba(15, 20, 27, 0.85);
  backdrop-filter: blur(6px);
  padding: 24px;
  overflow-y: auto;
  align-items: center;
  justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 1000px;
  width: 100%;
  padding: 20px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 1.4rem;
  background: var(--card);
  border: 1px solid var(--line);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
}

.modal-img { width: 100%; height: auto; border-radius: 8px; background: #fff; }

/* Download Links */
.download-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.btn-download {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  text-decoration: none;
  color: var(--fg);
  transition: all 0.15s ease;
}

.btn-download:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.btn-download-icon { font-size: 1.3rem; }
.btn-download-title { font-weight: 700; font-size: 0.9rem; display: block; color: var(--fg); }
.btn-download-sub { font-size: 0.78rem; color: var(--muted); display: block; }

code {
  background: var(--code);
  color: var(--fg);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Footer */
footer { padding: 40px 0 60px; font-size: 0.88rem; color: var(--muted); border-top: 1px solid var(--line); }
footer p { margin: 0 0 6px; }

@media (max-width: 640px) {
  header .wrap { padding: 40px 16px 28px; }
  h1 { font-size: 1.75rem; }
  .lede { font-size: 1rem; }
  section { padding: 32px 0; }
  .cards { grid-template-columns: 1fr; }
}
