/* ============================================================
   Mission Debrief — the crew sheets at /mission-debrief/sheets.html.
   Serviceware Horizon Design System 25.12, graded dark, the same
   palette as assets/theme.css: Mechanical Grey carries the page,
   Summer Orange is the single accent, blue is secondary. Chart hues
   are Horizon's own and were checked for CVD separation and contrast
   against the sheet (#16242b).
   ============================================================ */
:root {
  color-scheme: dark;

  /* ---- Horizon primaries ---- */
  --mech-grey: #2c424c;
  --mech-80: #566870;
  --mech-60: #808e94;
  --mech-40: #abb3b7;
  --orange: #f7941d;
  --yellow: #ffcc32;
  --classical-blue: #006baa;
  --blue-60: #66a6cc;

  /* ---- surfaces ---- */
  --ground: #2c424c;                 /* Faded Charcoal, top stop */
  --ground-2: #4a5d65;               /* Faded Charcoal, bottom stop */
  --sheet: #16242b;                  /* Mechanical Grey, deepened for a dense data sheet */
  --sheet-2: #1d2f37;
  --rail: #121e24;

  --ink: #ffffff;
  --ink-soft: rgba(255, 255, 255, .82);
  --ink-muted: var(--mech-40);
  --ink-dim: var(--mech-60);
  --line: rgba(171, 179, 183, .24);
  --line-soft: rgba(171, 179, 183, .13);

  --accent: var(--orange);
  --sunrise: linear-gradient(90deg, #f7941d 0%, #ffcc32 100%);

  /* ---- the three Phases, in the order they are stacked ----
     Six separable hues do not exist in this palette on this ground
     (Sugar Plum and Classical Blue sit 1.5 ΔE apart under deuteranopia),
     so the two figures are faceted: the mission bar carries the hues,
     the Phase-1 breakdown carries two Mechanical Grey steps and the
     accent. Both sets pass CVD and normal-vision separation on all pairs. */
  --s-p1: #66b649;      /* Green Apple — Phase 1, Challenges and Side Quests */
  --s-p2: #a589cc;      /* Sugar Plum — Phase 2 Challenges */
  --s-bonus: #ffcc32;   /* Electric Yellow — the lead and winner bonuses */

  /* ---- Phase-1 decomposition ---- */
  --r-base: #566870;      /* Mechanical Grey 80% — what the ship paid anyway */
  --r-alliance: #abb3b7;  /* Mechanical Grey 40% — what the alliances added */
  --r-cards: #f7941d;     /* Summer Orange — what the crew played */

  --font-text: "Open Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-ui: "Open Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --font-code: "Open Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}


body {
  margin: 0;
  background:
    radial-gradient(rgba(255, 255, 255, .055) 1px, transparent 1.4px) 0 0 / 18px 18px,
    linear-gradient(180deg, var(--ground) 0%, var(--ground-2) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---- command bar ---------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 12px 28px;
  background: rgba(29, 44, 52, .90);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar__mark {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: auto;
}
.bar__mark span { color: var(--ink-dim); }
.bar label {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
select {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: var(--sheet-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  min-width: 230px;
}
.step {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  background: var(--sheet-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 12px;
  cursor: pointer;
}
.step:hover { border-color: var(--accent); color: var(--ink); }
.step:disabled { opacity: .35; cursor: default; }
.bar__hint {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--ink-dim);
  letter-spacing: .04em;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- the sheet ------------------------------------------------------ */

.sheet {
  max-width: 1060px;
  margin: 26px auto 60px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-top: none;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .34);
  padding: 30px 34px 34px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.sheet::before { content: ""; display: block; height: 4px; margin: -30px -34px 0; background: var(--sunrise); }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 20px; }
.head__id { flex: 1 1 320px; display: flex; flex-direction: column; gap: 6px; }
.eyebrow {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.eyebrow b { color: var(--orange); font-weight: 700; }
.head h1 {
  margin: 0;
  font-size: 40px;
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -.015em;
  text-wrap: balance;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
}
.chip--code { font-family: var(--font-code); font-weight: 700; letter-spacing: .09em; color: var(--ink-muted); }

.placement { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.placement__rank {
  font-family: var(--font-ui);
  font-size: 56px;
  font-weight: 800;
  line-height: .9;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.placement--podium .placement__rank { color: var(--orange); }
.placement__of { font-family: var(--font-ui); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); }

/* ---- body grid ------------------------------------------------------ */

.body { display: grid; grid-template-columns: 286px minmax(0, 1fr); gap: 26px; align-items: start; }
.rail { display: flex; flex-direction: column; gap: 18px; }
.main { display: flex; flex-direction: column; gap: 26px; min-width: 0; }

/* the crew's ship, as chosen by scanning its card in the Aufbau */
.ship { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.ship__plate {
  background:
    radial-gradient(120% 90% at 50% 18%, rgba(247, 148, 29, .13), transparent 62%),
    var(--rail);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  padding: 10px 12px 6px;
}
.ship img { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .55)); }
.ship figcaption { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.ship__name { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.ship__code { font-family: var(--font-code); font-size: 11px; font-weight: 700; letter-spacing: .1em; color: var(--ink-dim); }
.stats { display: flex; flex-direction: column; gap: 5px; }
.stat { display: grid; grid-template-columns: 56px minmax(0, 1fr) 18px; align-items: center; gap: 9px; font-size: 11.5px; color: var(--ink-muted); }
.stat__track { height: 6px; border-radius: 3px; background: rgba(171, 179, 183, .16); overflow: hidden; }
.stat__bar { display: block; height: 100%; border-radius: 3px; }
.stat__val { text-align: right; font-weight: 700; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* the crew's own photo from the Mission Control Channel */
.photo { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.photo__frame {
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: var(--rail);
}
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.photo figcaption { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.photo__label {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--orange);
}
.photo__note { font-size: 10.5px; color: var(--ink-dim); line-height: 1.4; text-align: right; }

.panel { display: flex; flex-direction: column; gap: 9px; }
.panel__title {
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--ink-dim);
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
}
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.kv dt { color: var(--ink-muted); }
.kv dd { margin: 0; font-family: var(--font-ui); font-weight: 600; font-variant-numeric: tabular-nums; }

.check { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.check li { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 9px; align-items: baseline; font-size: 13px; }
.check .mark { font-family: var(--font-ui); font-weight: 700; font-size: 12px; }
.check .got .mark { color: var(--s-p1); }
.check .missed .mark { color: var(--ink-dim); }
.check .missed { color: var(--ink-dim); }
.check .pts { font-family: var(--font-ui); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-muted); }
.check .missed .pts { color: var(--ink-dim); }

/* stat tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }
.tile { background: var(--sheet-2); padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; }
.tile__label { font-family: var(--font-ui); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-dim); }
.tile__value { font-family: var(--font-ui); font-size: 27px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tile__sub { font-size: 11.5px; color: var(--ink-muted); line-height: 1.35; }

/* figures */
figure { margin: 0; display: flex; flex-direction: column; gap: 12px; }
figcaption { display: flex; flex-direction: column; gap: 3px; }
.fig__title { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.fig__sub { font-size: 12.5px; color: var(--ink-muted); max-width: 62ch; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--font-ui); font-size: 12px; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.swatch { width: 11px; height: 11px; border-radius: 2px; flex: none; }
.swatch--tick { height: 0; border-top: 1.5px dashed var(--ink-dim); border-radius: 0; width: 14px; }
.legend b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }

/* data table under the Phase 1 chart */
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-family: var(--font-ui); font-size: 12.5px; }
caption { text-align: left; font-family: var(--font-ui); font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); padding-bottom: 8px; }
th, td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
th { font-weight: 600; color: var(--ink-dim); font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; }
td { color: var(--ink-soft); }
td.total { font-weight: 700; color: var(--ink); }
tbody tr:last-child td { border-bottom: none; }
td.cards-cell { text-align: left; white-space: normal; min-width: 208px; padding-top: 6px; padding-bottom: 6px; }
.cards { display: flex; flex-direction: column; gap: 3px; }
.card { display: flex; align-items: baseline; gap: 7px; color: var(--ink-soft); }
.card em { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .07em; color: var(--ink-dim); }
.card b { margin-left: auto; color: var(--r-cards); font-variant-numeric: tabular-nums; }
.card--dud, .card--empty { color: var(--ink-dim); }
.card--dud b { color: var(--ink-dim); }
.card--empty { font-style: italic; }
.card--sum { color: var(--ink-dim); }
.code { font-weight: 700; letter-spacing: .08em; color: var(--ink-dim); }

/* flight notes */
.notes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding-top: 22px; border-top: 1px solid var(--line); }
.note { display: flex; flex-direction: column; gap: 7px; }
.note__title { font-family: var(--font-ui); font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.note--good .note__title { color: var(--s-p1); }
.note--gap .note__title { color: var(--s-bonus); }
.note--call .note__title { color: var(--yellow); }
.note p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--ink-soft); }
.note p b { color: var(--ink); font-weight: 700; }

.foot { font-family: var(--font-ui); font-size: 11px; color: var(--ink-dim); display: flex; flex-wrap: wrap; gap: 6px 16px; border-top: 1px solid var(--line-soft); padding-top: 14px; }

/* tooltip */
#tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity .1s;
  background: #060d12;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink);
  max-width: 240px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .55);
}
#tip b { font-variant-numeric: tabular-nums; }

@media (max-width: 860px) {
  .body { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .notes { grid-template-columns: minmax(0, 1fr); }
  .sheet { padding: 22px 18px 26px; margin: 16px 10px 40px; }
  .sheet::before { margin: -22px -18px 0; }  /* the top rule follows the tighter padding */
  .head h1 { font-size: 30px; }
  .photo { max-width: 340px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

@media print {
  .bar, .bar__hint { display: none; }
  body { background: var(--ground); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet { margin: 0; max-width: none; border: none; page-break-after: always; }
  @page { size: A4; margin: 12mm; }
}

/* ---- the crew question, asked first ---------------------------------- */

.ask {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  background:
    radial-gradient(rgba(255, 255, 255, .055) 1px, transparent 1.4px) 0 0 / 18px 18px,
    linear-gradient(180deg, var(--ground) 0%, var(--ground-2) 100%);
  padding: 36px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.ask[hidden] { display: none; }
.ask__head { display: flex; flex-direction: column; gap: 8px; text-align: center; max-width: 560px; }
.ask h1 { margin: 0; font-size: 32px; line-height: 1.1; font-weight: 700; letter-spacing: -.015em; }
.ask__note { margin: 0; color: var(--ink-muted); font-size: 14px; }
.ask__grid {
  width: 100%;
  max-width: 760px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 8px;
}
.ask__crew {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--sheet-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 10px;
  min-height: 56px;
  cursor: pointer;
  text-align: left;
}
.ask__crew img { width: 64px; height: auto; flex: none; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, .5)); }
.ask__name { display: block; min-width: 0; }
.ask__crew small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--ink-dim); }
.ask__crew:hover, .ask__crew:focus-visible { border-color: var(--accent); }

/* the crew indicator, top right of the bar */
.bar__crew { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.bar__mark { margin-right: 0; }
.bar__crew select { min-width: 0; max-width: 60vw; }
.bar__crew .step { padding: 7px 10px; }

@media (max-width: 600px) {
  .bar { padding: 10px 14px; gap: 8px; }
  .bar label { display: none; }
  .bar__mark span { display: none; }
  .ask h1 { font-size: 26px; }
  .ask__grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
  .ask__crew { font-size: 14px; padding: 8px; min-height: 50px; gap: 8px; }
  .ask__crew img { width: 52px; }
}
