/* PowerTrain Field — assisted-reality prototype.
   Designed for a HUD read at arm's length in bad light with gloves on:
   heavy weights, high contrast, large hit targets, nothing subtle. */

:root {
  --bg: #07131c;
  --panel: rgba(9, 22, 31, 0.88);
  --panel-solid: #0b1a24;
  --edge: rgba(41, 199, 255, 0.28);
  --ink: #f2fbff;
  --ink-dim: #9db9c7;
  --accent: #29c7ff;
  --good: #34d17b;
  --warn: #ffb82e;
  --bad: #ff5757;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#cam {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  opacity: 0;
  transition: opacity 400ms ease;
}
#cam.live { opacity: 1; }

.hud {
  position: relative;
  z-index: 2;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 12px;
  padding: calc(var(--safe-top) + 14px) 14px calc(var(--safe-bottom) + 14px);
  max-width: 640px;
  margin: 0 auto;
}

/* ── Panels ───────────────────────────────────────────────────────────── */

.panel {
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--edge);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.kicker {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 6px;
}

h1 { font-size: 25px; line-height: 1.15; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 20px; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 22px; line-height: 1.2; margin: 0 0 10px; letter-spacing: -0.01em; }

.lede { color: var(--ink-dim); font-size: 14px; line-height: 1.5; margin: 0; }

/* ── Boot ─────────────────────────────────────────────────────────────── */

.boot { margin-top: auto; }
.boot-head { margin-bottom: 16px; }

.boot-modes { display: flex; flex-direction: column; gap: 9px; }

.boot-modes button {
  display: flex;
  flex-direction: column;
  gap: 3px;
  text-align: left;
  padding: 14px 16px;
  border-radius: 13px;
  border: 1px solid var(--edge);
  background: rgba(41, 199, 255, 0.07);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  min-height: 60px;
}
.boot-modes button b { font-size: 16px; font-weight: 750; }
.boot-modes button small { font-size: 12.5px; color: var(--ink-dim); line-height: 1.35; }
.boot-modes .mode-primary { background: var(--accent); border-color: var(--accent); color: #04202e; }
.boot-modes .mode-primary small { color: rgba(4, 32, 46, 0.78); }
.boot-modes .mode-secondary { background: rgba(162, 120, 255, 0.16); border-color: rgba(162, 120, 255, 0.45); }
.boot-modes .mode-tertiary { background: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.14); }

.boot-note { font-size: 12.5px; color: var(--warn); margin: 12px 0 0; min-height: 1em; line-height: 1.4; }

.xr-hint {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid rgba(162, 120, 255, 0.5);
  background: rgba(162, 120, 255, 0.14);
}
.xr-hint i { font-size: 20px; line-height: 1.2; color: #c4a6ff; flex: 0 0 auto; }
.xr-hint span { font-size: 13px; line-height: 1.5; color: #e7dcff; }
.xr-hint b { color: #fff; }

.xr-enter {
  width: 100%;
  margin-top: 10px;
  font: inherit;
  font-size: 16px;
  font-weight: 750;
  padding: 15px;
  border-radius: 12px;
  border: 1px solid rgba(162, 120, 255, 0.55);
  background: rgba(162, 120, 255, 0.2);
  color: #f0e9ff;
  cursor: pointer;
  min-height: 52px;
}
.xr-enter i { font-style: normal; margin-right: 4px; }

.boot-detail { margin-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.09); padding-top: 12px; }
.boot-detail summary { font-size: 13px; font-weight: 700; color: var(--ink-dim); cursor: pointer; }
.boot-detail ul { margin: 10px 0 0; padding-left: 18px; }
.boot-detail li { font-size: 13px; line-height: 1.55; color: var(--ink-dim); margin-bottom: 6px; }
.boot-detail li b { color: var(--ink); }

/* ── Identify ─────────────────────────────────────────────────────────── */

.panel-head { margin-bottom: 12px; }
.scan-status { font-size: 14px; color: var(--warn); margin: 0 0 14px; font-weight: 650; }
.scan-status.found { color: var(--good); }

.reticle {
  position: relative;
  height: 118px;
  margin-bottom: 14px;
  border-radius: 12px;
  background: rgba(41, 199, 255, 0.05);
}
.reticle i {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 3px solid var(--accent);
  animation: pulse 1.9s ease-in-out infinite;
}
.reticle i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.reticle i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.reticle i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.reticle i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.34; } }

.panel-actions { display: flex; gap: 9px; }

.manual-list { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.manual-list label { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; color: var(--ink-dim); }
.manual-list select {
  font: inherit;
  font-size: 16px;
  padding: 12px;
  border-radius: 11px;
  background: var(--panel-solid);
  color: var(--ink);
  border: 1px solid var(--edge);
}
.manual-list button {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 13px;
  border-radius: 11px;
  border: 0;
  background: var(--accent);
  color: #04202e;
  cursor: pointer;
}

/* ── Procedure chooser ────────────────────────────────────────────────── */

.proc-list { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.proc-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 14px 16px;
  border-radius: 13px;
  border: 1px solid var(--edge);
  background: rgba(41, 199, 255, 0.08);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.proc-card b { font-size: 16px; font-weight: 750; line-height: 1.25; }
.proc-card small { font-size: 12.5px; color: var(--ink-dim); }

/* ── Runner ───────────────────────────────────────────────────────────── */

.runner-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.step-count { text-align: right; white-space: nowrap; }
.step-count b { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1; }
.step-count span { font-size: 13px; color: var(--ink-dim); margin-left: 2px; }

.progress { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.11); overflow: hidden; margin-bottom: 16px; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 320ms ease; }

.step-say { font-size: 17px; line-height: 1.45; margin: 0 0 10px; font-weight: 600; }
.step-detail { font-size: 14px; line-height: 1.5; color: var(--ink-dim); margin: 0; }
.step-caution {
  margin: 12px 0 0;
  padding: 11px 13px;
  border-radius: 10px;
  border-left: 4px solid var(--warn);
  background: rgba(255, 184, 46, 0.12);
  font-size: 13.5px;
  line-height: 1.45;
  color: #ffe0a3;
}

/* ── Gate ─────────────────────────────────────────────────────────────── */

.gate {
  margin-top: 15px;
  padding: 14px;
  border-radius: 13px;
  border: 1px solid rgba(255, 184, 46, 0.42);
  background: rgba(255, 184, 46, 0.09);
}
.gate.satisfied { border-color: rgba(52, 209, 123, 0.5); background: rgba(52, 209, 123, 0.1); }
.gate-prompt { font-size: 15px; font-weight: 700; margin: 0 0 10px; color: var(--warn); line-height: 1.35; }
.gate.satisfied .gate-prompt { color: var(--good); }

.gate-parts { display: flex; flex-direction: column; gap: 7px; margin-bottom: 11px; }
.gate-part {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid transparent;
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}
.gate-part i {
  flex: 0 0 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--ink-dim);
  margin-top: 1px;
}
.gate-part.checked { border-color: rgba(52, 209, 123, 0.45); }
.gate-part.checked i { background: var(--good); border-color: var(--good); }
.gate-part.checked i::after { content: "✓"; display: block; text-align: center; font-size: 13px; line-height: 16px; color: #04202e; font-weight: 900; }

.gate-confirm {
  width: 100%;
  font: inherit;
  font-size: 16px;
  font-weight: 750;
  padding: 14px;
  border-radius: 11px;
  border: 0;
  background: var(--warn);
  color: #2a1c00;
  cursor: pointer;
}
.gate.satisfied .gate-confirm { background: var(--good); color: #03291a; }

/* ── Controls ─────────────────────────────────────────────────────────── */

.runner-controls { display: flex; gap: 9px; margin-top: 15px; }
.runner-controls button { flex: 1; font: inherit; font-size: 15px; font-weight: 700; padding: 15px 10px; border-radius: 12px; cursor: pointer; min-height: 52px; }

.primary { border: 0; background: var(--accent); color: #04202e; }
.primary:disabled { background: rgba(41, 199, 255, 0.24); color: rgba(4, 32, 46, 0.5); cursor: not-allowed; }
.ghost { border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.05); color: var(--ink); }
.ghost.small { flex: 0 0 auto; padding: 9px 14px; font-size: 13px; min-height: 0; border-radius: 9px; }

.runner-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding-top: 13px; border-top: 1px solid rgba(255, 255, 255, 0.09); }

.mic {
  display: flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  cursor: pointer;
}
.mic i { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-dim); }
.mic[aria-pressed="true"] { border-color: rgba(52, 209, 123, 0.5); background: rgba(52, 209, 123, 0.13); }
.mic[aria-pressed="true"] i { background: var(--good); animation: pulse 1.3s ease-in-out infinite; }

.heard { flex: 1; font-size: 12.5px; color: var(--ink-dim); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Lookup ───────────────────────────────────────────────────────────── */

.lookup h2 { font-size: 34px; font-weight: 850; color: var(--accent); letter-spacing: -0.02em; }
.lookup-name { font-size: 18px; font-weight: 700; margin: 2px 0 12px; }
.lookup-meaning { font-size: 15px; line-height: 1.5; margin: 0 0 12px; }
.lookup-cause { font-size: 13.5px; line-height: 1.5; color: var(--ink-dim); margin: 0 0 16px; }
.lookup-cause b { color: var(--warn); }
.lookup .primary { width: 100%; padding: 14px; font-size: 15px; font-weight: 700; border-radius: 11px; }

/* ── Legal ────────────────────────────────────────────────────────────── */

.legal {
  font-size: 10.5px;
  line-height: 1.45;
  color: rgba(157, 185, 199, 0.72);
  text-align: center;
  margin: 0;
  padding: 0 6px;
  text-wrap: balance;
}

/* ── Landscape / larger screens ───────────────────────────────────────── */

@media (min-height: 760px) { .hud { justify-content: center; } }

@media (orientation: landscape) and (max-height: 520px) {
  .hud { justify-content: flex-start; }
  .reticle { height: 70px; }
  h1 { font-size: 21px; }
  .boot-detail { display: none; }
}

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