/* ORYX M6 interface.
   Lettering follows the rover's own stencil livery (DIN-style condensed
   grotesque, bone ink, one hazard-orange bar). Readouts sit directly on the
   image as drawing annotations: hairline rules, no boxed cards. */
:root {
  --ink: #f4ede1;
  --ink-dim: rgba(244, 237, 225, 0.66);
  --ink-faint: rgba(244, 237, 225, 0.36);
  --rule: rgba(244, 237, 225, 0.2);
  --plate: rgba(26, 14, 10, 0.56);
  --umber: #1b0f0a;
  --signal: #a6dbff;
  --hazard: #ff6a2a;
  --pad: clamp(14px, 2.2vw, 30px);
  --face: "DIN Alternate", "Bahnschrift", "D-DIN", "Ubuntu", "Roboto Condensed", "Barlow Semi Condensed", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #150c08; }
body {
  font-family: var(--face);
  font-stretch: 82%;
  font-size: 14px;
  line-height: 1.35;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; cursor: grab; }
#scene:active { cursor: grabbing; }

#hud { position: fixed; inset: 0; pointer-events: none; transition: opacity 0.4s ease; }
#hud::before {
  /* edge scrims keep the annotations legible over bright sky and sand */
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(22, 11, 7, 0.5), transparent 24%),
    linear-gradient(270deg, rgba(22, 11, 7, 0.58), transparent 23%),
    linear-gradient(0deg, rgba(22, 11, 7, 0.55), transparent 20%);
  transition: opacity 0.6s ease;
}
body.hud-hidden #hud { opacity: 0; }
p, h1, h2, dl, dd, dt, ol { margin: 0; padding: 0; }
small { font-size: 0.62em; font-weight: 400; color: var(--ink-dim); margin-left: 3px; }
.dim { color: var(--ink-dim); font-weight: 400; }

/* ---------------------------------------------------------------- identity */
.ident { position: absolute; z-index: 2; left: var(--pad); top: var(--pad); text-shadow: 0 1px 12px rgba(20, 8, 4, 0.55); transition: opacity 0.5s ease, top 0.6s ease; }
.wordmark { display: flex; align-items: center; gap: 11px; font-size: clamp(34px, 4.2vw, 54px); line-height: 0.92; letter-spacing: 0.01em; font-weight: 700; }
.wm-bar { width: 6px; height: 0.78em; background: var(--hazard); }
.wm-model { font-weight: 300; }
.ident-role { margin-top: 10px; font-size: 15px; color: var(--ink); }
.ident-mission { margin-top: 3px; font-size: 13px; color: var(--ink-dim); display: flex; gap: 14px; }
.ident-mission span + span { padding-left: 14px; border-left: 1px solid var(--rule); }

/* --------------------------------------------------------------- telemetry */
.telemetry {
  position: absolute; right: var(--pad); top: var(--pad); width: 226px;
  text-shadow: 0 1px 10px rgba(20, 8, 4, 0.6);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.status { display: flex; gap: 10px; align-items: flex-start; padding-bottom: 12px; border-bottom: 1px solid var(--ink-faint); }
.status-dot { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--ink-faint); flex: none; transition: background 0.3s; }
.status-dot.live { background: var(--signal); box-shadow: 0 0 0 4px rgba(166, 219, 255, 0.18); animation: pulse 1.8s ease-in-out infinite; }
.status-dot.work { background: var(--hazard); box-shadow: 0 0 0 4px rgba(255, 106, 42, 0.2); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(166, 219, 255, 0); } }
.status-text { font-size: 19px; font-weight: 600; line-height: 1.15; }
.status-sub { font-size: 13px; color: var(--ink-dim); margin-top: 2px; }

.row { position: relative; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; padding: 8px 0 8px; border-bottom: 1px solid var(--rule); }
.row dt { font-size: 12.5px; color: var(--ink-dim); }
.row dd { font-size: 17px; font-weight: 600; text-align: right; }
.row-big dd { font-size: 34px; line-height: 1; font-weight: 700; }
.row-split { gap: 0; justify-content: flex-start; align-items: center; }
.row-split > div:not(.horizon) { width: 74px; }
.row-split dd { text-align: left; }
.meter { flex: 0 0 100%; height: 3px; margin-top: 7px; background: var(--rule); }
.meter i { display: block; height: 100%; width: 0; background: var(--ink); transition: width 0.25s linear, background 0.3s; }
.meter i.low { background: var(--hazard); }

.tape { position: relative; flex: 0 0 100%; height: 20px; margin-top: 5px; overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); }
.tape-strip { position: absolute; left: 50%; top: 0; height: 100%; will-change: transform; }
.tape-strip i { position: absolute; bottom: 0; width: 1px; height: 5px; background: var(--ink-dim); }
.tape-strip i.major { height: 8px; background: var(--ink); }
.tape-strip span { position: absolute; top: -1px; transform: translateX(-50%); font-size: 10.5px; color: var(--ink-dim); font-style: normal; }
.tape-strip span.card { color: var(--ink); font-weight: 700; }
.tape-mark { position: absolute; left: 50%; bottom: 0; width: 0; height: 0; margin-left: -4px; border: 4px solid transparent; border-bottom: 6px solid var(--hazard); border-top: 0; }

.horizon { margin-left: auto; width: 38px; height: 38px; border: 1px solid var(--ink-faint); border-radius: 50%; overflow: hidden; position: relative; }
.horizon::after { content: ""; position: absolute; left: 50%; top: 50%; width: 12px; height: 1px; margin-left: -6px; background: var(--hazard); }
.horizon i { position: absolute; left: -20px; right: -20px; top: 50%; height: 60px; background: rgba(244, 237, 225, 0.22); border-top: 1px solid var(--ink); transform-origin: 50% 0; }

.susp { position: relative; flex: 0 0 100%; height: 76px; margin-top: 8px; }
.susp-body { position: absolute; left: 50%; top: 9px; width: 30px; height: 58px; margin-left: -15px; border: 1px solid var(--ink-faint); clip-path: polygon(22% 0, 78% 0, 100% 14%, 100% 86%, 78% 100%, 22% 100%, 0 86%, 0 14%); background: rgba(244, 237, 225, 0.08); }
.susp .w { position: absolute; width: 58px; height: 16px; }
.susp .w::before { content: ""; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: var(--rule); }
.susp .w b { position: absolute; top: 3px; width: 5px; height: 10px; background: var(--ink); transition: background 0.2s; }
.susp .w.hot b { background: var(--signal); }
.susp .w em { position: absolute; top: 1px; font-style: normal; font-size: 10.5px; color: var(--ink-dim); width: 34px; }
.susp .w.l { left: 32px; } .susp .w.r { right: 32px; }
.susp .w.l em { left: 0; text-align: left; } .susp .w.r em { right: 0; text-align: right; }

.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 12px; vertical-align: -1px; }
.bars i { width: 3px; background: var(--ink-faint); }
.bars i:nth-child(1) { height: 4px; } .bars i:nth-child(2) { height: 6px; } .bars i:nth-child(3) { height: 8px; }
.bars i:nth-child(4) { height: 10px; } .bars i:nth-child(5) { height: 12px; }
.bars i.on { background: var(--ink); }

/* --------------------------------------------------------------------- log */
.log { position: absolute; left: var(--pad); bottom: calc(var(--pad) + 70px); width: min(380px, 42vw); display: flex; flex-direction: column; gap: 3px; font-size: 13px; text-shadow: 0 1px 8px rgba(20, 8, 4, 0.7); transition: opacity 0.5s ease; }
.log p { display: flex; gap: 10px; color: var(--ink-dim); animation: logIn 0.4s ease both; }
.log p:last-child { color: var(--ink); }
.log time { flex: none; color: var(--ink-faint); }
.log p:nth-last-child(n+4) { opacity: 0.55; }
@keyframes logIn { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------ exploded view */
.parts { position: absolute; left: var(--pad); top: calc(var(--pad) + 132px); width: 236px; text-shadow: 0 1px 8px rgba(20, 8, 4, 0.7); opacity: 0; transform: translateX(-10px); transition: opacity 0.5s ease, transform 0.5s ease; }
.parts.show { opacity: 1; transform: none; }
.parts h2 { font-size: 15px; font-weight: 600; padding-bottom: 7px; border-bottom: 1px solid var(--ink-faint); }
.parts ol { list-style: none; }
.parts li { display: grid; grid-template-columns: 22px 1fr; padding: 4px 0; border-bottom: 1px solid var(--rule); font-size: 13px; line-height: 1.25; }
.parts li b { font-weight: 600; color: var(--hazard); }
.parts li span { display: block; }
.parts li i { display: block; font-style: normal; color: var(--ink-dim); font-size: 12px; }

#leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
#leaders line { stroke: var(--ink); stroke-width: 1; opacity: 0.75; }
#leaders circle { fill: var(--ink); }
#labels { position: absolute; inset: 0; }
.label { position: absolute; left: 0; top: 0; display: flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 13px; font-weight: 600; will-change: transform, opacity; text-shadow: 0 1px 8px rgba(20, 8, 4, 0.85); }
.label b { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--ink); border-radius: 50%; font-size: 11.5px; background: rgba(26, 14, 10, 0.72); text-shadow: none; }
.label.flip { flex-direction: row-reverse; }

/* -------------------------------------------------------------------- dock */
.dock {
  position: absolute; z-index: 2; left: 50%; bottom: var(--pad); transform: translateX(-50%);
  display: flex; align-items: stretch; max-width: calc(100vw - 2 * var(--pad));
  background: var(--plate); border: 1px solid var(--rule);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  pointer-events: auto; transition: opacity 0.4s ease, bottom 0.6s ease, background 0.4s ease;
}
.group { display: flex; align-items: center; padding: 6px; gap: 2px; }
.group + .group { border-left: 1px solid var(--rule); }
.seg { display: flex; border: 1px solid var(--rule); margin-right: 4px; }
button {
  appearance: none; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 600; letter-spacing: 0.01em;
  height: 36px; padding: 0 13px; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background 0.16s ease, color 0.16s ease;
}
button svg { width: 10px; height: 10px; fill: currentColor; flex: none; }
button:hover { background: rgba(244, 237, 225, 0.14); }
button:active { background: rgba(244, 237, 225, 0.26); }
button:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }
button[aria-pressed="true"], button[aria-checked="true"], button.on { background: var(--ink); color: var(--umber); }
button[disabled] { color: var(--ink-faint); cursor: default; background: transparent; }
.seg button { height: 32px; padding: 0 11px; }
button.primary.on svg { animation: nudge 1.2s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateX(2px); } }

.hint { position: absolute; left: 50%; bottom: calc(var(--pad) + 60px); transform: translateX(-50%); font-size: 13px; color: var(--ink-dim); text-shadow: 0 1px 8px rgba(20, 8, 4, 0.8); white-space: nowrap; transition: opacity 1s ease; }
.hint.gone { opacity: 0; }

/* ------------------------------------------------------------ studio credit */
.studio { position: absolute; z-index: 2; right: var(--pad); bottom: calc(var(--pad) + 15px); display: flex; align-items: flex-end; gap: 8px; color: var(--ink); text-decoration: none; pointer-events: auto; transition: opacity 0.4s ease; }
.studio-by { font-size: 12.5px; line-height: 1; color: var(--ink-dim); margin-bottom: 1.6px; }
.studio-mark { display: block; height: 19px; width: auto; opacity: 0.9; transition: opacity 0.16s ease; }
.studio-dot { fill: #e5322d; }
.studio:hover .studio-mark { opacity: 1; }
.studio:focus-visible { outline: 2px solid var(--signal); outline-offset: 4px; }

/* -------------------------------------------------------- cinematic framing */
.bars-cine { position: absolute; left: 0; right: 0; height: 0; z-index: 1; background: #0a0504; transition: height 0.7s cubic-bezier(0.6, 0, 0.2, 1); }
.bars-cine.top { top: 0; } .bars-cine.bottom { bottom: 0; }
body.cine .bars-cine { height: 9.5vh; }
body.cine #hud::before { opacity: 0; }
body.cine .telemetry, body.cine .log, body.cine .hint, body.cine .ident-role, body.cine .ident-mission { opacity: 0; }
body.cine .ident { opacity: 0.9; top: calc((9.5vh - 26px) / 2); }
body.cine .wordmark { font-size: 26px; }
body.cine .dock { opacity: 0.55; background: transparent; border-color: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; bottom: calc((9.5vh - 50px) / 2); }
body.cine .dock:hover, body.cine .dock:focus-within { opacity: 1; }
body.exploded .log { opacity: 0; }
body.cine .studio { opacity: 0.55; bottom: calc((9.5vh - 19px) / 2); }
body.cine .studio:hover { opacity: 1; }

#fade { position: fixed; inset: 0; background: #0a0504; opacity: 1; pointer-events: none; transition: opacity 1.4s ease; }
#fade.clear { opacity: 0; }
#fade.cut { transition: none; opacity: 0.9; }

#error { position: fixed; inset: 0; display: grid; place-items: center; padding: 40px; background: #150c08; color: var(--ink); font-size: 16px; text-align: center; line-height: 1.5; }
#error[hidden] { display: none; }

/* -------------------------------------------------------------- small views */
@media (max-width: 1180px) {
  .log { display: none; }
  .hint { display: none; }
}
@media (max-width: 1260px) {
  /* the dock reaches the corner: the credit moves under the name */
  .studio { left: var(--pad); right: auto; bottom: auto; top: calc(var(--pad) + clamp(34px, 4.2vw, 54px) + 60px); }
  body.cine .studio, body.exploded .studio { opacity: 0; pointer-events: none; }
}
@media (max-width: 960px) {
  .dock { flex-wrap: wrap; justify-content: center; left: var(--pad); right: var(--pad); transform: none; max-width: none; }
  .group + .group { border-left: 0; }
  .group { flex-wrap: wrap; justify-content: center; }
  body.cine .dock { background: var(--plate); border-color: var(--rule); bottom: var(--pad); }
}
@media (max-height: 620px) {
  .telemetry { width: 190px; }
  .tape, .susp, .horizon { display: none; }
  .row-big dd { font-size: 26px; }
  .parts { display: none; }
}
@media (max-height: 520px) and (min-width: 721px) {
  /* phones held sideways: status, speed and battery only */
  .ident-role { display: none; }
  .row { display: none; }
  .row.row-big, .row.keep { display: flex; }
  .meter { display: none; }
  .status { padding-bottom: 8px; }
}
@media (max-width: 720px) {
  /* phones: identity on top, one compact telemetry line above the controls */
  .ident-role { display: none; }
  .parts, #labels, #leaders { display: none; }
  .studio { left: auto; right: var(--pad); top: var(--pad); }
  .telemetry { left: var(--pad); right: var(--pad); top: calc(var(--pad) + 74px); width: auto; display: flex; align-items: flex-start; gap: 18px; padding-top: 10px; border-top: 1px solid var(--rule); }
  .status { flex: 1; border-bottom: 0; padding-bottom: 0; }
  .status-text { font-size: 17px; }
  .status-dot { margin-top: 5px; }
  .row dt { font-size: 11.5px; }
  .group { padding: 4px; }
  .readouts { display: flex; gap: 18px; }
  .row { display: none; }
  .row.row-big, .row.keep { display: block; border: 0; padding: 0; }
  .row.row-big dd, .row.keep dd { font-size: 20px; line-height: 1.1; text-align: left; white-space: nowrap; }
  .row.keep dd .dim { display: none; }
  .meter { display: none; }
  button { height: 34px; padding: 0 10px; font-size: 13px; }
  body.cine .telemetry { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
}
