/* Strata KSP.
 *
 * Colour means one thing each. Cyan is the flight you are watching, grey an
 * attempt you already made, amber something wanting attention, red a flight
 * that ended badly. Nothing else is coloured.
 */
:root {
  --ground: #000000;
  --panel: #07090c;
  --raise: #0d1116;
  --grid: #16181c;
  --rule: #23262b;

  --ink: #ffffff;
  --ink-2: #9aa3ad;
  --ink-3: #5d646d;

  --live: #5bc8d6;
  --ghost: #49515b;
  --warn: #ffb03a;
  --fail: #ff6b6b;

  --sans: "Archivo", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
}

/* One screen at a time. */
.screen {
  display: none;
  min-height: 0;
}

body[data-screen='hangar'] #screen-hangar,
body[data-screen='flight'] #screen-flight {
  display: grid;
}

button {
  all: unset;
  cursor: pointer;
  padding: 8px 13px;
  font: 500 0.82rem/1 var(--sans);
  color: var(--ink-2);
  border: 1px solid var(--rule);
  white-space: nowrap;
}

button:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--ink-3);
}

button:focus-visible {
  outline: 2px solid var(--live);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* The one button that moves the loop forward. */
button.go {
  background: var(--ink);
  color: var(--ground);
  border-color: var(--ink);
  font-weight: 600;
}

button.go:hover:not(:disabled) {
  background: var(--live);
  border-color: var(--live);
  color: var(--ground);
}

button.toggle.active,
button.warp.active {
  background: var(--ink-2);
  border-color: var(--ink-2);
  color: var(--ground);
}

/* ── hangar ───────────────────────────────────────────────────── */

.hangar {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  background: var(--panel);
}

.screen-head {
  padding: 26px 32px 18px;
}

.screen-head h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.screen-head p {
  margin: 7px 0 0;
  color: var(--ink-2);
  font-size: 0.9rem;
}

/* ── hangar ───────────────────────────────────────────────────────
   A drawing office, not a cockpit. The flight screen is the instrument
   panel and shouts in mono capitals; this one is quiet, sentence case,
   and gives all of its contrast to the vehicle. */

.hangar {
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--panel);
}

.hangar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
  padding: 26px 34px 20px;
  border-bottom: 1px solid var(--grid);
}

.titling h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.6vw, 2.15rem);
  font-weight: 600;
  letter-spacing: -0.028em;
}

.titling p {
  margin: 8px 0 0;
  max-width: 62ch;
  color: var(--ink-2);
  font-size: 0.88rem;
  line-height: 1.55;
}

/* The launch site is a choice, not a page of cards: one control, four
   positions, and the consequences stated once underneath. */
.worlds {
  display: flex;
  border: 1px solid var(--rule);
}

.world {
  padding: 9px 16px;
  border: 0;
  border-right: 1px solid var(--rule);
  font-size: 0.82rem;
  color: var(--ink-3);
  background: transparent;
}

.world:last-child {
  border-right: 0;
}

.world:hover {
  color: var(--ink);
  background: var(--raise);
}

.world[data-active] {
  color: var(--ground);
  background: var(--ink);
}

.build {
  display: grid;
  grid-template-columns: 216px minmax(0, 660px);
  justify-content: start;
  gap: 48px;
  padding: 26px 34px 12px;
  min-height: 0;
  align-content: safe center;
  overflow-y: auto;
}

/* ── parts bin ─── */

.bin h2 {
  margin: 0 0 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-3);
}

.bin-list {
  display: grid;
  gap: 1px;
  background: var(--grid);
  border: 1px solid var(--grid);
}

.bin-part {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border: 0;
  background: var(--panel);
}

.bin-part:hover {
  background: var(--raise);
}

.bin-part:hover .figure-sm {
  --hull: #c9d2db;
}

.bin-part b {
  display: block;
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-2);
}

.bin-part:hover b {
  color: var(--ink);
}

.bin-part span span {
  font-family: var(--mono);
  font-size: 0.66rem;
  color: var(--ink-3);
}

.bin-fig {
  display: grid;
  place-items: center;
  height: 34px;
}

.bin-note {
  margin: 12px 0 0;
  font-size: 0.74rem;
  line-height: 1.5;
  color: var(--ink-3);
}

/* ── the elevation ───
   Three columns per part: the drawing, a leader, the controls. One grid row
   each, so the vehicle assembles itself and every callout is already level
   with the part it names. */

.elevation {
  position: relative;
  padding-bottom: 24px;
}

.stack {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0;
}

/* The row is as tall as the drawing, never as tall as the text beside it.
   Any other way round and the parts float apart and stop being a vehicle. */
.part {
  display: grid;
  grid-template-columns: 132px 44px minmax(0, 1fr);
  align-items: center;
}

.figure,
.figure-sm {
  display: block;
  width: 100%;
  overflow: visible;
  --hull: #aeb9c4;
  --hull-edge: #7d8794;
  --hull-shade: #79838f;
  --hull-lit: #e4ebf2;
}

.figure-sm {
  width: 30px;
  height: auto;
}

.part-fig {
  display: block;
  line-height: 0;
}

/* The leader is the datasheet's gesture: a hairline from the part out to the
   thing that describes it, with a node where it meets the drawing. */
.part-leader {
  position: relative;
  height: 1px;
  background: var(--rule);
}

.part-leader::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 3px;
  transform: translate(-1px, -50%);
  background: var(--ink-3);
}

.part-callout {
  display: flex;
  align-items: center;
  gap: 8px 24px;
  padding: 0 0 0 18px;
  border-left: 1px solid var(--rule);
  min-height: 100%;
}

.callout-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 13ch;
}

.callout-head b {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.callout-spec {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--ink-3);
  white-space: nowrap;
}

.callout-acts {
  display: flex;
  order: 3;
  gap: 2px;
  opacity: 0;
  transition: opacity 110ms ease;
}

.part:hover .callout-acts,
.part:focus-within .callout-acts {
  opacity: 1;
}

.act {
  padding: 3px 8px;
  border-color: transparent;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1;
  color: var(--ink-3);
}

.act:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--rule);
}

.act-remove:hover:not(:disabled) {
  color: var(--fail);
  border-color: var(--fail);
}

/* Tuning is visible at rest. Hiding a control behind a hover means nobody
   finds out it is there. */
.callout-tune {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 22px;
  margin-right: auto;
}

.knob {
  display: flex;
  align-items: center;
  gap: 8px;
}

.knob-label {
  font-size: 0.7rem;
  color: var(--ink-3);
  white-space: nowrap;
}

.knob input[type='range'] {
  width: 96px;
}

.knob b {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  min-width: 3.2em;
}

/* ── slots ─── */

.slot {
  position: relative;
  height: 0;
}

.slot-hit {
  all: unset;
  cursor: pointer;
  display: block;
  position: absolute;
  inset: -6px 0;
  width: 132px;
  z-index: 2;
}

.slot-hit::before {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 2px;
  transform: translateY(-50%);
  background: transparent;
}

.slot-hit:hover::before {
  background: var(--ink-3);
}

.slot[data-active] .slot-hit::before {
  background: var(--live);
}

.slot-hit:focus-visible::before {
  background: var(--live);
  outline: 2px solid var(--live);
  outline-offset: 2px;
}

.pad-empty {
  margin: 40px 0 0;
  max-width: 34ch;
  color: var(--ink-3);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ── the verdict ───
   Five readings and the button. Two of them can be wrong, and when they are
   they say so in words rather than leaving you to interpret a colour. */

.verdict {
  border-top: 1px solid var(--rule);
  padding: 18px 34px 22px;
  display: grid;
  gap: 16px;
}

.readings {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 46px;
  margin: 0;
}

.reading dt {
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-bottom: 7px;
}

.reading dd {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.reading b {
  font-family: var(--mono);
  font-size: 1.55rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.reading i {
  font-style: normal;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--ink-3);
}

.reading[data-state='bad'] b {
  color: var(--warn);
}

.warn {
  margin: 0;
  padding-left: 14px;
  border-left: 2px solid var(--warn);
  max-width: 76ch;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--ink-2);
}

.warn[hidden] {
  display: none;
}

.verdict .go {
  justify-self: start;
  padding: 13px 40px;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

/* ── flight ───────────────────────────────────────────────────── */

.flight {
  position: relative;
  grid-template-rows: minmax(0, 1fr) auto;
  background: var(--panel);
}

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

.outcome {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 9px 18px;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink);
}

.outcome[hidden] {
  display: none;
}

.outcome[data-state='fail'] {
  border-color: var(--fail);
  color: var(--fail);
}

.outcome[data-state='win'] {
  border-color: var(--live);
  color: var(--live);
}

.outcome[data-state='spent'] {
  border-color: var(--warn);
  color: var(--warn);
}

.hud {
  border-top: 1px solid var(--rule);
  background: var(--ground);
  display: grid;
  gap: 12px;
  padding: 14px 28px 16px;
}

.readouts {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px 40px;
}

.clock {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.clock .tplus {
  font-size: 0.7rem;
  color: var(--ink-3);
}

.clock b {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.dials {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 30px;
  margin: 0;
}

.dials dt {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 5px;
}

.dials dd {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.dials b {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.dials i {
  font-style: normal;
  font-size: 0.58rem;
  text-transform: uppercase;
  color: var(--ink-3);
}

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

.fuel-label {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.fuel-bar {
  display: block;
  width: 120px;
  height: 6px;
  background: var(--grid);
  overflow: hidden;
}

.fuel-bar span {
  display: block;
  height: 100%;
  background: var(--live);
  transition: width 120ms linear;
}

.fuel-bar span[data-state='low'] {
  background: var(--warn);
}

.fuel-bar span[data-state='empty'] {
  background: var(--fail);
}

.fuel b {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

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

.flight-controls .spacer {
  flex: 1;
}

.warps {
  display: flex;
  gap: 3px;
}

.warp {
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 0.72rem;
}

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

.slider span {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  height: 2px;
  width: 130px;
  background: var(--rule);
  cursor: pointer;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
}

input[type='range']::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
}

input[type='range']:focus-visible {
  outline: 2px solid var(--live);
  outline-offset: 5px;
}

/* ── attempts ─────────────────────────────────────────────────── */

.attempts {
  border-top: 1px solid var(--rule);
  background: var(--ground);
  padding: 11px 28px 13px;
  display: flex;
  align-items: center;
  gap: 18px;
  overflow-x: auto;
}

.attempts h2 {
  margin: 0;
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  white-space: nowrap;
}

.attempt-list {
  display: flex;
  gap: 7px;
}

.attempt {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 11px;
  border-color: var(--grid);
  font-family: var(--mono);
  font-size: 0.72rem;
}

.attempt b {
  font-weight: 500;
  color: var(--ink-2);
}

.attempt-peak {
  color: var(--ink-3);
  font-size: 0.68rem;
}

.attempt-glyph {
  color: var(--ink-3);
}

.attempt[data-state='fail'] .attempt-glyph {
  color: var(--fail);
}

.attempt[data-state='win'] .attempt-glyph {
  color: var(--live);
}

.attempt[data-state='spent'] .attempt-glyph {
  color: var(--warn);
}

/* The one you are watching, and the ones you asked to see behind it. */
.attempt[data-live] {
  border-color: var(--live);
}

.attempt[data-live] b {
  color: var(--live);
}

.attempt[data-shown] {
  border-color: var(--ink-3);
  background: #12171d;
}

.attempts-empty {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-3);
}

.attempts-empty[hidden] {
  display: none;
}

/* ── narrow ───────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .hangar-head {
    padding: 18px 18px 14px;
  }

  .worlds {
    width: 100%;
  }

  .world {
    flex: 1;
    text-align: center;
    padding: 9px 6px;
  }

  .build {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    padding: 18px 18px 8px;
  }

  .bin-list {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  /* No room for a leader, and none for a callout on one line either. The
     drawing gives up being continuous here and the parts become a list you
     can actually work with, which is the right trade on a phone. */
  .part {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .part-leader {
    display: none;
  }

  .part-callout {
    flex-wrap: wrap;
    align-content: center;
    gap: 4px 14px;
    padding: 10px 0 10px 14px;
  }

  .callout-head {
    min-width: 0;
  }

  .callout-acts {
    order: 0;
    margin-left: auto;
  }

  .callout-tune {
    flex-basis: 100%;
    margin-right: 0;
  }

  .knob input[type='range'] {
    width: 84px;
  }

  .slot-hit {
    width: 72px;
  }

  .verdict {
    padding: 16px 18px 20px;
  }

  .readings {
    gap: 12px 26px;
  }

  .reading b {
    font-size: 1.3rem;
  }

  .hud,
  .attempts {
    padding-left: 18px;
    padding-right: 18px;
  }

  .readouts {
    gap: 14px 22px;
  }

  .clock b {
    font-size: 1.6rem;
  }

  .flight-controls .spacer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
