/* ==========================================================================
   Orbit & Ground-Track Visualizer — prototype stylesheet
   Self-contained on purpose: the tool can be dropped into any folder of the
   EMXplore teaching site without depending on shared/css. Custom-property
   names and values mirror shared/css/base.css so it still looks native.

   1. Tokens and base
   2. Header and footer
   3. Workspace layout
   4. Panels
   5. Controls
   6. Views (3D stage, map)
   7. Readouts and guide
   8. Responsive
   9. Reduced motion
   ========================================================================== */

/* ---------- 1. Tokens and base ------------------------------------------ */

:root {
  --ink: #162033;
  --muted: #5d6878;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --line: #dce2ea;
  --blue: #155eef;
  --orbit: #087f8c;
  --orbit-dark: #075d68;
  --orbit-pale: #e9f7f6;
  --sand: #c77720;
  --red: #b42318;
  --radius: 14px;
  --shadow: 0 14px 34px rgba(31, 50, 81, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.6;
}

h1, h2, h3 { line-height: 1.2; letter-spacing: -.02em; margin: 0; }
p { margin: 0 0 .8em; }
button, input { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #7ab4ff; outline-offset: 2px; }

.skip-link {
  position: fixed; left: 1rem; top: -5rem; z-index: 100;
  background: #fff; padding: .7rem 1rem; border-radius: .5rem;
}
.skip-link:focus { top: 1rem; }

.eyebrow {
  text-transform: uppercase; letter-spacing: .14em;
  font-weight: 800; font-size: .7rem; color: var(--orbit-dark);
  margin: 0 0 .35rem;
}

/* ---------- 2. Header and footer ---------------------------------------- */

.tool-header {
  padding: clamp(1.4rem, 3vw, 2.4rem) clamp(1rem, 3vw, 2rem) 1.2rem;
  background: linear-gradient(120deg, #0b2441 0%, #174f69 100%);
  color: #eaf4f7;
}
.tool-header .eyebrow { color: #8fe2dc; }
.tool-header h1 { font-size: clamp(1.5rem, 3.4vw, 2.3rem); }
.tool-header__lede {
  max-width: 62ch; margin-top: .6rem; margin-bottom: 0;
  color: #c9dfe6; font-size: .95rem;
}

.tool-footer {
  padding: 1.2rem clamp(1rem, 3vw, 2rem) 2rem;
  color: var(--muted); font-size: .82rem;
}
.tool-footer p { max-width: 90ch; margin: 0; }

/* ---------- 3. Workspace layout ----------------------------------------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  align-items: start;
}

.views {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  min-width: 0;
}

/* ---------- 4. Panels ---------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

/* ---------- 5. Controls -------------------------------------------------- */

.controls { padding: 1rem 1.1rem 1.2rem; position: sticky; top: 1rem; }

.controls__group { padding-bottom: .9rem; margin-bottom: .9rem; border-bottom: 1px solid var(--line); }
.controls__group:last-of-type { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }

.controls__title {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); font-weight: 800; margin-bottom: .7rem;
}
.controls__group--collapsible > summary { cursor: pointer; list-style: none; }
.controls__group--collapsible > summary::-webkit-details-marker { display: none; }
.controls__group--collapsible > summary::after { content: " ▾"; }
.controls__group--collapsible[open] > summary::after { content: " ▴"; }

.controls__note { font-size: .76rem; color: var(--muted); margin: .5rem 0 0; }

.controls__status {
  margin: .9rem 0 0; min-height: 1.2em; font-size: .8rem;
  color: var(--sand); font-weight: 650;
}

.field { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; margin-bottom: .85rem; }
.field:last-child { margin-bottom: 0; }
.field label { grid-column: 1; font-size: .85rem; font-weight: 650; }
.field__hint { color: var(--muted); font-weight: 500; font-style: italic; }
.field__value {
  grid-column: 2; grid-row: 1; justify-self: end;
  font-variant-numeric: tabular-nums; font-weight: 800;
  color: var(--orbit-dark); font-size: .85rem;
}
.field input[type="range"] { grid-column: 1 / -1; width: 100%; margin: 0; accent-color: var(--orbit); }
.field--primary label { font-size: .92rem; }
.field--primary .field__value { font-size: .95rem; }
.field--primary input[type="range"] { height: 1.5rem; }

.preset-row, .button-row { display: flex; flex-wrap: wrap; gap: .4rem; }

.chip {
  border: 1px solid var(--line); background: #fff; color: var(--orbit-dark);
  font-size: .78rem; font-weight: 700; padding: .4rem .7rem; border-radius: 999px;
}
.chip:hover { border-color: var(--orbit); background: var(--orbit-pale); }
.chip[aria-pressed="true"] { background: var(--orbit-dark); border-color: var(--orbit-dark); color: #fff; }

.button {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: .85rem; font-weight: 700; padding: .5rem .9rem; border-radius: 9px;
}
.button:hover { border-color: var(--orbit); }
.button--primary { background: var(--orbit-dark); border-color: var(--orbit-dark); color: #fff; }
.button--primary:hover { background: var(--orbit); border-color: var(--orbit); }

/* ---------- 6. Views ----------------------------------------------------- */

.view { padding: .85rem 1rem 1rem; }

.view__header { display: flex; align-items: baseline; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: .6rem; }
.view__header h2 { font-size: .95rem; }
.view__hint { margin: 0; font-size: .74rem; color: var(--muted); }

.stage {
  width: 100%; height: clamp(320px, 46vh, 520px);
  border-radius: 10px; overflow: hidden; background: #f7fbfd;
  border: 1px solid var(--line);
}
.stage canvas { display: block; width: 100%; height: 100%; }
.view__fallback { margin: .6rem 0 0; font-size: .82rem; color: var(--red); }

.map-holder {
  position: relative; width: 100%; aspect-ratio: 2 / 1;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.map-holder canvas { display: block; width: 100%; height: 100%; }

/* ---------- 7. Readouts and guide ---------------------------------------- */

.readouts { padding: .9rem 1rem 1rem; }

.alert {
  margin: 0 0 .8rem; padding: .6rem .8rem; border-radius: 8px;
  background: #fff1f0; color: #8f2119; border-left: 3px solid var(--red);
  font-size: .85rem; font-weight: 650;
}

.readout-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; margin: 0; }
.readout-grid > div { padding: .5rem .6rem; border-top: 2px solid var(--orbit); background: #f8fcfc; border-radius: 0 0 6px 6px; }
.readout-grid > div.is-live { border-top-color: var(--sand); background: #fdfaf4; }
.readout-grid dt { font-size: .7rem; color: var(--muted); letter-spacing: .02em; }
.readout-grid dd { margin: .1rem 0 0; font-weight: 800; font-variant-numeric: tabular-nums; font-size: .92rem; color: var(--ink); }

.guide { padding: .9rem 1.1rem 1.1rem; }
.guide h2 { font-size: .95rem; margin-bottom: .5rem; }
.guide ol { margin: 0; padding-left: 1.1rem; font-size: .86rem; color: var(--muted); }
.guide li { margin-bottom: .25rem; }
.guide strong { color: var(--ink); }

/* ---------- 8. Responsive ------------------------------------------------ */

@media (min-width: 1400px) {
  .views { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .views > .readouts, .views > .guide { grid-column: 1 / -1; }
  .stage { height: clamp(340px, 42vh, 480px); }
}

@media (max-width: 900px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .controls { position: static; }
  .readout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 480px) {
  .stage { height: 300px; }
  .readout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
  .readout-grid dd { font-size: .85rem; }
}

/* ---------- 9. Reduced motion -------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
