/* Launch control simulator — xscript.net */

:root {
  --bg: #131517;
  --panel: #1a1d20;
  --panel-head: #22262a;
  --line: #30353b;
  --line-bright: #4b525a;
  --text: #f1f2f3;
  --muted: #8a9199;
  --dim: #5d646c;
  --red: #ff3b30;
  --red-bg: rgba(255, 59, 48, 0.16);
  --font-data: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-label: 'Barlow Condensed', 'Arial Narrow', var(--font-data);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { background: var(--bg); }

body {
  font-family: var(--font-data);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  min-height: 100vh;
  font-variant-numeric: tabular-nums;
}

button, select { font-family: inherit; }
[hidden] { display: none !important; }

/* ---------- App shell ---------- */
.console {
  height: 100vh;
  min-height: 680px;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}
.console:fullscreen { height: 100vh; width: 100vw; min-height: 0; }
.console:-webkit-full-screen { height: 100vh; width: 100vw; min-height: 0; }

/* ---------- Optional video view ----------
   Covers the console (so it also fills the screen in fullscreen); the
   simulation keeps counting underneath. Hidden panels leave the tab order. */
.console.video-mode > :not(.lc-video) { visibility: hidden; }
.lc-video {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  container-type: size;
  z-index: 50;
}
.lc-video iframe {
  width: min(100cqw, calc(100cqh * 16 / 9));
  aspect-ratio: 16 / 9;
  border: 0;
}
/* Small way back to the console; stays faint so it doesn't sit on the video */
.lc-video-close {
  position: absolute;
  bottom: 70px;
  right: 15px;
  z-index: 1;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0.3;
}
.lc-video-close:hover, .lc-video-close:focus-visible { opacity: 1; background: rgba(0, 0, 0, 0.8); }

/* ---------- Header ---------- */
.lh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  background: var(--panel-head);
  border-bottom: 2px solid var(--red);
  flex: 0 0 auto;
}
.lh-left, .lh-right { display: flex; align-items: center; gap: 12px; flex: 1 1 0; min-width: 0; }
.lh-right { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.lh-logo {
  width: 30px; height: 30px;
  flex: 0 0 auto;
  display: grid; place-items: center;
  background: var(--red);
  color: #fff;
  font-size: 0.9rem;
  border-radius: 50%;
}
.lh-name { display: flex; flex-direction: column; line-height: 1.05; }
.lh-title {
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 0.2em;
  color: var(--text);
}
.lh-sub { font-family: var(--font-label); font-size: 0.72rem; letter-spacing: 0.24em; color: var(--muted); white-space: nowrap; }

.lh-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-label);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--bg);
  background: var(--text);
  padding: 3px 10px;
  white-space: nowrap;
}
.lh-status .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.6s ease-in-out infinite; }
.lh-status.is-alert { background: var(--red); color: #fff; }
.lh-status.is-paused { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--muted); }
.lh-status.is-paused .dot { animation: none; }

.lh-sim {
  font-family: var(--font-label);
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  border: 1px dashed var(--line-bright);
  padding: 3px 7px;
  white-space: nowrap;
}

.lh-center { display: flex; flex-direction: column; align-items: center; line-height: 1; flex: 0 0 auto; }
.lh-clock {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  white-space: nowrap;
}
.lh-clock.is-alert { color: var(--red); animation: slowBlink 2s ease-in-out infinite; }
.lh-clock-sub { margin-top: 4px; font-family: var(--font-label); font-size: 0.74rem; letter-spacing: 0.2em; color: var(--muted); white-space: nowrap; }

.lh-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-label);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.lh-pick select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line-bright);
  padding: 5px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.lbtn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line-bright);
  padding: 6px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.lbtn:hover, .lbtn:focus-visible { background: rgba(255, 255, 255, 0.1); border-color: var(--text); }
.lbtn[aria-pressed="true"] { color: var(--red); border-color: var(--red); }
.lbtn:disabled { opacity: 0.35; cursor: default; background: transparent; border-color: var(--line-bright); }
.lbtn.is-red { border-color: var(--red); color: var(--red); }
.lbtn.is-red:hover, .lbtn.is-red:focus-visible { background: var(--red-bg); border-color: var(--red); }

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

/* ---------- Milestone strip ---------- */
.seq {
  flex: 0 0 auto;
  position: relative;
  padding: 9px 14px 7px;
  border-bottom: 1px solid var(--line);
  background: #0f1113;
  overflow-x: auto;
  scrollbar-width: none;
}
.seq::-webkit-scrollbar { display: none; }
.seq-inner { position: relative; min-width: 760px; }
.seq-line {
  position: absolute;
  left: 4.545%;
  right: 4.545%;
  top: 4px;
  height: 2px;
  background: var(--line-bright);
}
.seq-fill { display: block; height: 100%; width: 0; background: var(--text); }
.seq-nodes { position: relative; display: grid; grid-template-columns: repeat(11, 1fr); }
.sq { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; color: var(--dim); }
.sq-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #0f1113;
  border: 2px solid var(--line-bright);
}
.sq-l { font-family: var(--font-label); font-size: 0.84rem; font-weight: 600; letter-spacing: 0.14em; white-space: nowrap; margin-top: 2px; }
.sq-t { font-size: 0.6rem; letter-spacing: 0.04em; white-space: nowrap; }
.sq.is-done { color: var(--text); }
.sq.is-done .sq-dot { background: var(--text); border-color: var(--text); }
.sq.is-done .sq-t { color: var(--muted); }
.sq.is-next { color: var(--red); }
.sq.is-next .sq-dot { border-color: var(--red); animation: pulse 1.6s ease-in-out infinite; }

/* ---------- Main grid ---------- */
.lgrid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(236px, 0.6fr) minmax(0, 1.9fr) minmax(290px, 0.78fr);
  gap: 8px;
  padding: 8px 10px;
}
.col { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.ph {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 5px 10px 4px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-head);
  flex: 0 0 auto;
  white-space: nowrap;
  overflow: hidden;
}
.ph-title { font-family: var(--font-label); font-size: 0.92rem; font-weight: 700; letter-spacing: 0.18em; color: var(--text); }
.ph-note { margin-left: auto; font-family: var(--font-label); font-size: 0.74rem; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.pb { flex: 1 1 auto; min-height: 0; overflow: hidden; position: relative; }

.p-poll { flex: 0 0 auto; }
.p-wx { flex: 1 1 auto; }
.p-visual { flex: 1 1 auto; }
.p-charts { flex: 0 0 25%; min-height: 128px; }
.p-tlm { flex: 0 0 auto; }
.p-loop { flex: 1 1 auto; min-height: 96px; }

/* ---------- Go / no-go ---------- */
.poll { display: flex; flex-direction: column; padding: 3px 0; }
.st {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.66rem;
  min-width: 0;
}
.st:last-child { border-bottom: 0; border-top: 1px solid var(--line-bright); margin-top: 2px; padding-top: 5px; padding-bottom: 5px; }
.st-lamp { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--dim); }
.st-name { font-family: var(--font-label); font-size: 0.88rem; font-weight: 600; letter-spacing: 0.12em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-val { font-weight: 700; letter-spacing: 0.06em; color: var(--dim); }
.st.is-go .st-lamp { background: var(--text); border-color: var(--text); }
.st.is-go .st-name { color: var(--text); }
.st.is-go .st-val { color: var(--text); }
.st.is-nogo { background: var(--red); }
.st.is-nogo .st-lamp { background: #fff; border-color: #fff; animation: slowBlink 2s ease-in-out infinite; }
.st.is-nogo .st-name, .st.is-nogo .st-val { color: #fff; }

/* ---------- Range and weather ---------- */
.wx { display: flex; flex-direction: column; padding: 3px 0; }
.wx-row {
  flex: 1 1 0;
  min-height: 21px;
  max-height: 34px;
  display: grid;
  grid-template-columns: auto 1fr 46px;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.68rem;
}
.wx-row span:nth-child(1) { font-family: var(--font-label); font-size: 0.86rem; letter-spacing: 0.12em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-row span:nth-child(2) { color: var(--text); font-weight: 600; white-space: nowrap; text-align: right; overflow: hidden; }
.wx-row span:nth-child(3) { text-align: right; font-weight: 700; color: var(--text); letter-spacing: 0.04em; }
.wx-row.is-bad { background: var(--red-bg); }
.wx-row.is-bad span:nth-child(2), .wx-row.is-bad span:nth-child(3) { color: var(--red); }

/* ---------- Visual ---------- */
.vis canvas, .charts canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hold-banner {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 9px 14px;
  background: var(--red);
  color: #fff;
}
.hold-word {
  font-family: var(--font-label);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1;
  animation: slowBlink 2s ease-in-out infinite;
}
.hold-reason { flex: 1 1 auto; min-width: 0; font-size: 0.74rem; font-weight: 600; line-height: 1.35; letter-spacing: 0.02em; }
.hold-time { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; white-space: nowrap; }

.scrub {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 16, 18, 0.78);
}
.scrub-box {
  text-align: center;
  border: 2px solid var(--red);
  background: #101214;
  padding: 24px 36px;
  max-width: 92%;
}
.scrub-kicker { font-family: var(--font-label); font-size: 0.9rem; letter-spacing: 0.3em; color: var(--red); font-weight: 700; }
.scrub-title {
  font-family: var(--font-label);
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #fff;
  line-height: 1.1;
  margin: 6px 0 8px;
}
.scrub-reason { font-size: 0.74rem; color: var(--muted); letter-spacing: 0.04em; line-height: 1.5; max-width: 46ch; margin: 0 auto; }
.scrub-count { margin-top: 14px; font-size: 0.95rem; font-weight: 700; color: var(--red); letter-spacing: 0.1em; }
.scrub-reset { margin-top: 16px; font-size: 0.78rem; padding: 9px 16px; }

/* ---------- Telemetry ---------- */
.tlm { padding: 8px 10px 9px; display: flex; flex-direction: column; gap: 8px; overflow: visible; }
.big3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.rd { display: flex; flex-direction: column; min-width: 0; }
.rd-l { font-family: var(--font-label); font-size: 0.78rem; letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; }
.rd-v { display: flex; align-items: baseline; gap: 4px; white-space: nowrap; }
.rd-v b { font-size: 0.98rem; font-weight: 700; color: var(--text); }
.rd-v i { font-style: normal; font-family: var(--font-label); font-size: 0.7rem; letter-spacing: 0.1em; color: var(--dim); }
.big3 .rd { border-left: 2px solid var(--red); padding-left: 7px; }
.big3 .rd-v b { font-size: 1.32rem; }
.rd-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.rd-grid .rd { padding-left: 9px; }
.p-tlm.is-lost .rd-v b { color: var(--dim); }
.p-tlm.is-lost .ph-note { color: var(--red); font-weight: 700; }

.prop-row { display: grid; grid-template-columns: auto auto 1fr; gap: 12px; align-items: center; padding-top: 8px; border-top: 1px solid var(--line); }
.eng-block { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.eng-l { font-family: var(--font-label); font-size: 0.72rem; letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; }
.cluster { position: relative; width: 62px; height: 62px; border: 1px solid var(--line-bright); border-radius: 50%; }
.eng {
  position: absolute;
  width: 15px; height: 15px;
  margin: -7.5px 0 0 -7.5px;
  border-radius: 50%;
  border: 1.5px solid var(--dim);
  background: transparent;
}
.cluster .eng:nth-child(1) { left: 50%; top: 50%; }
.cluster .eng:nth-child(2) { left: 50%; top: 18%; }
.cluster .eng:nth-child(3) { left: 77.7%; top: 34%; }
.cluster .eng:nth-child(4) { left: 77.7%; top: 66%; }
.cluster .eng:nth-child(5) { left: 50%; top: 82%; }
.cluster .eng:nth-child(6) { left: 22.3%; top: 66%; }
.cluster .eng:nth-child(7) { left: 22.3%; top: 34%; }
.eng-vac { position: relative; width: 30px; height: 30px; margin: 16px; }
.eng.is-chill { border-style: dashed; border-color: var(--muted); }
.eng.is-run { background: var(--text); border-color: var(--text); }
.eng.is-fault { background: var(--red); border-color: var(--red); animation: slowBlink 2s ease-in-out infinite; }
.eng.is-out { border-color: var(--red); background: linear-gradient(45deg, transparent 43%, var(--red) 43%, var(--red) 57%, transparent 57%); }

.tanks { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 6px; align-items: center; font-size: 0.62rem; min-width: 0; }
.tanks .tk-l { font-family: var(--font-label); font-size: 0.74rem; letter-spacing: 0.1em; color: var(--muted); white-space: nowrap; }
.tanks .tk-b { height: 7px; background: #0f1113; border: 1px solid var(--line-bright); }
.tanks .tk-b span { display: block; height: 100%; background: var(--text); }
.tanks .tk-v { color: var(--text); font-weight: 600; text-align: right; min-width: 32px; }

/* ---------- Comm loop ---------- */
.loop { overflow: hidden; padding: 2px 0; }
.lp-row {
  display: grid;
  grid-template-columns: 44px 62px 1fr;
  gap: 7px;
  align-items: baseline;
  padding: 3px 10px;
  font-size: 0.68rem;
  line-height: 1.35;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
}
.lp-t { color: var(--dim); font-size: 0.62rem; white-space: nowrap; }
.lp-s { font-family: var(--font-label); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.1em; color: var(--text); white-space: nowrap; }
.lp-x { color: #c4c9ce; min-width: 0; }
.lp-row.is-alert .lp-s, .lp-row.is-alert .lp-x { color: var(--red); }
.lp-row:first-child { animation: rowIn 0.4s ease-out; }
@keyframes rowIn { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

/* ---------- Link / director bar ---------- */
.lb {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 14px;
  border-top: 1px solid var(--line-bright);
  background: var(--panel-head);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}
.lb-data { display: flex; align-items: center; gap: 18px; min-width: 0; overflow: hidden; }
.lb-item { display: inline-flex; align-items: center; gap: 6px; }
.lb-item b { color: var(--text); font-weight: 600; }
.lb-item.is-bad b { color: var(--red); }
.link-bar { display: inline-block; width: 70px; height: 7px; background: #0f1113; border: 1px solid var(--line-bright); }
.link-bar span { display: block; height: 100%; background: var(--text); transition: width 0.4s; }
.lb-item.is-bad .link-bar span { background: var(--red); }
.lb-dir { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.lb-dir .lbtn { padding: 4px 8px; font-size: 0.62rem; }
.lb-dir-l { font-family: var(--font-label); font-size: 0.76rem; letter-spacing: 0.16em; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes slowBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---------- Reference content ---------- */
.tool-info {
  max-width: 900px;
  margin: 44px auto 40px;
  padding: 0 24px;
  color: #a3aab2;
  line-height: 1.7;
  font-size: 0.92rem;
}
.tool-info h1 { color: var(--text); font-size: 1.3rem; letter-spacing: 0.03em; margin-bottom: 14px; line-height: 1.35; }
.tool-info h2 {
  color: var(--text);
  font-size: 1.02rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 32px 0 10px;
  padding-left: 10px;
  border-left: 3px solid var(--red);
}
.tool-info h3 { color: var(--text); font-size: 0.94rem; margin: 22px 0 6px; }
.tool-info p { margin-bottom: 12px; }
.tool-info ul { margin: 0 0 12px 22px; }
.tool-info li { margin-bottom: 6px; }
.tool-info a { color: #ff6f66; }
.tool-info strong { color: var(--text); }
.tool-info kbd {
  font-family: var(--font-data);
  font-size: 0.8em;
  border: 1px solid var(--line-bright);
  border-bottom-width: 2px;
  padding: 0 5px;
  border-radius: 3px;
  color: var(--text);
}
.glossary { margin: 0 0 12px; }
.glossary dt { color: var(--text); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; font-size: 0.84rem; margin-top: 16px; }
.glossary dd { margin: 4px 0 0; }

.table-wrap { overflow-x: auto; margin: 0 0 14px; }
.flight-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; min-width: 520px; }
.flight-table th, .flight-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.flight-table th { color: var(--text); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; border-bottom-color: var(--line-bright); }
.flight-table td:first-child { color: var(--text); font-weight: 600; white-space: nowrap; }

.site-foot {
  border-top: 1px solid var(--line-bright);
  background: var(--panel-head);
  padding: 15px;
  text-align: center;
  font-size: 0.8rem;
}
.site-foot-links { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.site-foot-links a { color: var(--text); text-decoration: none; }
.site-foot-links a:hover { text-decoration: underline; }
.site-foot-note { color: var(--muted); font-size: 0.72rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1700px) {
  .lh-pick span { display: none; }
}

@media (max-width: 1380px) {
  .lh-sub, .lh-sim { display: none; }
  .lh-clock { font-size: 1.6rem; }
  .lh .lbtn { padding: 6px 7px; letter-spacing: 0.06em; }
  .lh-right { gap: 6px; }
}

@media (max-width: 1100px) {
  .console { height: auto; min-height: 0; }
  .lh { flex-wrap: wrap; }
  .lh-left, .lh-right { flex: 1 1 auto; }
  .lh-center { order: -1; width: 100%; }
  .lgrid { grid-template-columns: 1fr 1fr; }
  .col-mid { grid-column: 1 / -1; order: -1; }
  .p-visual { flex: 0 0 auto; height: 440px; }
  .p-charts { flex: 0 0 auto; height: 170px; }
  .p-loop { flex: 0 0 auto; height: 240px; }
  .wx-row { flex: 0 0 auto; height: 28px; }
  .lb { flex-wrap: wrap; white-space: normal; justify-content: center; }
  .lb-data { flex-wrap: wrap; justify-content: center; gap: 6px 16px; }
  .lb-dir { flex: 1 1 100%; flex-wrap: wrap; justify-content: center; }
}

@media (max-width: 680px) {
  .lgrid { grid-template-columns: 1fr; padding: 6px; gap: 6px; }
  .col { gap: 6px; }
  .p-visual { height: 340px; }
  .lh-right { justify-content: center; }
  .lh-left { justify-content: center; flex-wrap: wrap; }
  .lh-clock { font-size: 1.45rem; }
  .hold-banner { flex-wrap: wrap; gap: 4px 12px; }
  .hold-word { font-size: 1.4rem; }
  .lb-dir { flex-wrap: wrap; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .lh-status .dot, .lh-clock.is-alert, .sq.is-next .sq-dot, .st.is-nogo .st-lamp,
  .hold-word, .eng.is-fault, .lp-row:first-child { animation: none; }
  .link-bar span { transition: none; }
}
