/* Design tokens (--bg, --panel, --accent, ...) live in theme.css, loaded first. */

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

body {
  margin: 0;
  background: radial-gradient(1200px 700px at 75% -10%, #16203a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
}

/* ---------------- masthead ---------------- */
.masthead {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.9);
  backdrop-filter: blur(8px);
}
.masthead .title { font-size: 15px; letter-spacing: .3px; color: var(--muted); }
.masthead .title b { color: var(--text); font-weight: 600; }
.masthead-controls { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.mode-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
#render-mode {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px; font-size: 13px;
}
#render-mode:hover { border-color: var(--accent); }
.back-link {
  color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border); padding: 7px 13px; border-radius: 7px; background: var(--panel);
  white-space: nowrap;
}
.back-link:hover { border-color: var(--accent); }
/* The "Back to Learn" link is the primary way out of the tour, so it carries
   the accent fill; the simulator link stays the quiet secondary action. */
.back-link--primary { background: var(--accent); color: #06101f; border-color: transparent; }
.back-link--primary:hover { filter: brightness(1.1); border-color: transparent; }

/* ---------------- layout ---------------- */
.explore { max-width: 1040px; margin: 0 auto; padding: 12px 26px 100px; }

.intro { padding: 28px 0 8px; }
.intro h1 { font-size: 30px; line-height: 1.2; margin: 0 0 12px; letter-spacing: .2px; max-width: 760px; }
.intro .lead { font-size: 18px; color: #cdd7f5; margin: 0 0 12px; max-width: 760px; }
.intro .note { font-size: 14px; color: var(--muted); max-width: 760px; }

/* contents / table of sections */
.contents {
  margin-top: 22px; padding: 16px 20px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
}
.contents-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 0 0 10px; }
.contents ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 24px; }
.contents .grp { font-weight: 600; color: var(--accent-2); margin-top: 6px; font-size: 13px; }
.contents a { color: var(--accent); text-decoration: none; font-size: 13.5px; }
.contents a:hover { text-decoration: underline; }

/* themed parts */
.part { margin-top: 50px; }
.part-title {
  font-size: 13px; text-transform: uppercase; letter-spacing: 2.5px; color: var(--accent);
  margin: 0 0 4px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}

/* a topic block */
.module { margin-top: 30px; scroll-margin-top: 70px; }
.module > h3 { font-size: 21px; margin: 0 0 14px; }

.module-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.prose p { margin: 0 0 12px; }
.prose strong { color: #fff; }
.prose em { color: var(--accent); font-style: italic; }
.prose.wide { max-width: 820px; }

/* image figures and galleries */
.fig { margin: 0; }
.fig img { width: 100%; display: block; border-radius: 10px; border: 1px solid var(--border); background: #060a14; }
.fig figcaption { font-size: 12.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }
.fig.wide { max-width: 720px; margin: 22px 0 0; }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 0 0 16px; }
.gallery.two { grid-template-columns: repeat(2, 1fr); }
.gallery .fig img { aspect-ratio: 1 / 1; object-fit: cover; }

/* ---------------- visualization box ---------------- */
.viz {
  position: relative;
  aspect-ratio: 4 / 3;
  width: 100%;
  border: 1px solid var(--border); border-radius: 12px;
  background: linear-gradient(160deg, #0c1426, #060a14);
  overflow: hidden;
}
.viz canvas { display: block; width: 100%; height: 100%; }
.viz-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 18px; color: var(--muted); font-size: 14px;
}
.viz.scene-live .viz-fallback { display: none; }
.viz.scene-image {
  background:
    radial-gradient(140px 140px at 50% 45%, rgba(124,156,255,0.18), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 26px),
    linear-gradient(160deg, #0c1426, #060a14);
}

/* ---------------- audio / video ---------------- */
.audio {
  margin: 22px 0 0; padding: 16px 18px;
  background: var(--panel); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px;
}
.audio figcaption { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.audio-intro { font-size: 14px; color: #cdd7f5; margin: 0 0 12px; }
.audio audio { width: 100%; }
.audio video { width: 100%; display: block; border-radius: 8px; background: #000; }
.audio-source { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }
.audio-source a { color: var(--accent); }
.transcript { margin-top: 8px; font-size: 13.5px; color: var(--muted); }
.transcript summary { cursor: pointer; color: var(--accent-2); }
.transcript p { margin: 8px 0 0; }
.audio.audio-missing audio,
.audio.audio-missing video { display: none; }

/* ---------------- credits ---------------- */
.credits { margin-top: 50px; padding-top: 20px; border-top: 1px solid var(--rule); color: var(--muted); font-size: 13.5px; }
.credits h2 { font-size: 16px; color: var(--text); }
.credits code { font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; color: #ffd9a0; }

/* ======================================================================
   Knowledge layer: search, sidebar, cards, timeline, glossary, tooltips
   ====================================================================== */

/* Search trigger, overlay, and inline glossary tooltip moved to search.css
   (a shared component loaded on every page with search). */

/* ---------------- two-column shell with sidebar ---------------- */
.explore-shell { display: block; }
.catnav {
  position: sticky; top: 64px;
  align-self: start;
  width: 230px; flex-shrink: 0;
  max-height: calc(100vh - 80px); overflow-y: auto;
  padding: 18px 6px 18px 0;
}
.catnav-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 0 0 10px 14px; }
.catnav ul { list-style: none; margin: 0 0 14px; padding: 0; }
.catnav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent-2); font-weight: 600; margin: 14px 0 5px 14px; }
.catnav a {
  display: block; padding: 6px 14px; margin: 1px 0;
  color: var(--muted); text-decoration: none; font-size: 13.5px;
  border-left: 2px solid transparent;
}
.catnav a:hover { color: var(--text); }
.catnav a.active { color: var(--text); border-left-color: var(--accent); background: var(--panel); }

@media (min-width: 1100px) {
  .explore-shell { display: flex; gap: 8px; max-width: 1320px; margin: 0 auto; padding: 0 26px; }
  .explore-shell .explore { margin: 0; padding-left: 18px; }
}
@media (max-width: 1099px) {
  .catnav { display: none; }
}

/* ---------------- planet card grid ---------------- */
.astro-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.astro-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; transition: border-color 0.18s ease, transform 0.18s ease;
}
.astro-card:hover { border-color: var(--accent-2); }
.astro-card.open { border-color: var(--accent); }
.astro-card-head {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: left;
  background: transparent; border: 0; cursor: pointer; color: var(--text);
  padding: 14px 14px; font-family: inherit;
}
.planet-dot {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 32% 30%, #fff5, transparent 45%), var(--dot);
  box-shadow: 0 0 14px -2px var(--dot);
}
.astro-card-titles { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.astro-card-title { font-size: 16px; font-weight: 600; }
.astro-card-kind { font-size: 12px; color: var(--muted); }
.astro-card-chevron { color: var(--muted); transition: transform 0.18s ease; }
.astro-card.open .astro-card-chevron { transform: rotate(180deg); }
.astro-card-body { padding: 0 14px 14px; }
.astro-card-summary { font-size: 13.5px; color: #cdd7f5; margin: 0 0 12px; }
.astro-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 0 0 12px; }
.astro-facts .fact { display: flex; flex-direction: column; }
.astro-facts dt { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.astro-facts dd { margin: 1px 0 0; font-size: 13.5px; color: var(--text); font-weight: 600; }
.astro-fact { font-size: 13px; color: var(--accent); margin: 0; padding: 9px 11px; background: var(--panel-2); border-radius: 8px; }

/* ---------------- missions timeline ---------------- */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 13px; top: 4px; bottom: 4px; width: 2px; background: var(--rule); }
.tl-item { position: relative; padding: 0 0 22px 44px; }
.tl-marker { position: absolute; left: 6px; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 3px solid var(--accent); box-shadow: 0 0 10px -1px var(--accent); }
.tl-card { background: var(--panel); border: 1px solid var(--border); border-radius: 11px; padding: 13px 16px; }
.tl-card:hover { border-color: var(--accent-2); }
.tl-year { font-size: 12px; font-weight: 700; letter-spacing: 1px; color: var(--accent); }
.tl-title { font-size: 16px; margin: 3px 0 2px; }
.tl-agency { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.tl-summary { font-size: 13.5px; color: #cdd7f5; margin: 0 0 8px; }
.tl-fact { font-size: 12.5px; color: var(--accent); margin: 0; }

/* ---------------- glossary ---------------- */
.glossary-tools { margin: 6px 0 16px; }
.glossary-filter {
  width: 100%; max-width: 360px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 14px; font-family: inherit;
}
.glossary-filter:focus { outline: none; border-color: var(--accent); }
.glossary-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin: 0; }
.glossary-entry { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 15px; scroll-margin-top: 80px; }
.glossary-entry:target { border-color: var(--accent); }
.glossary-entry dt { font-size: 14.5px; font-weight: 600; color: var(--text); }
.glossary-entry dd { margin: 5px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

@media (max-width: 820px) {
  .module-grid { grid-template-columns: 1fr; }
  .gallery, .contents ul { grid-template-columns: 1fr; }
  .masthead { flex-wrap: wrap; }
  .masthead-controls { flex-wrap: wrap; width: 100%; }
}

@media (max-width: 560px) {
  .masthead { padding: 10px 14px; gap: 8px 10px; }
  .explore { padding: 12px 16px 80px; }
  .intro { padding: 20px 0 6px; }
  .intro h1 { font-size: 24px; }
  .intro .lead { font-size: 16px; }
  .gallery.two { grid-template-columns: 1fr; }
  .module > h3 { font-size: 18px; }
  .contents { padding: 14px 16px; }
  /* 16px controls avoid iOS focus auto-zoom. */
  #render-mode, .lang-select, .glossary-filter { font-size: 16px; }
}

/* Comfortable 44px targets on touch devices (WCAG 2.5.5 / pointer: coarse),
   matching the portal-wide convention in theme.css/portal.css/styles.css. */
@media (pointer: coarse) {
  .back-link { min-height: 44px; display: inline-flex; align-items: center; }
  #render-mode { min-height: 44px; }
  .glossary-filter { min-height: 44px; }
  .transcript summary { min-height: 44px; display: flex; align-items: center; }
  .contents a { min-height: 44px; display: flex; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .search-box { animation: none; }
  .astro-card, .astro-card-chevron { transition: none; }
}

/* ---------------- premium polish (elevation + motion) ---------------- */
.astro-card, .tl-card {
  box-shadow: var(--elev-1);
  transition: transform var(--t-med) var(--ease-out), box-shadow var(--t-med) var(--ease-out), border-color var(--t-med) ease;
}
.astro-card:hover, .tl-card:hover { transform: translateY(-3px); box-shadow: var(--elev-2); }
.astro-card-body { overflow: hidden; }
.fig img { transition: transform var(--t-slow) var(--ease-out); }
.fig:hover img { transform: scale(1.02); }

@media (prefers-reduced-motion: reduce) {
  .astro-card, .tl-card { transition: none; }
  .astro-card:hover, .tl-card:hover { transform: none; }
  .fig:hover img { transform: none; }
}
