/* styles.css — OWNED BY THE UI AGENT (wave 2).
 *
 * Loads AFTER index.html's inline <style> (engine-critical chrome), so rules here win —
 * that's how the engine's placeholder loading screen / #hint line get restyled or retired below.
 *
 * Two rules this file must never break:
 *   1. #notice stays visible at all times (contract §1, legal) — not touched here.
 *   2. #scene keeps `touch-action: none` (set inline by the engine) — not touched here.
 *
 * Design language: dusk gradient (deep navy -> warm amber), glass panels, Inter/system-ui,
 * rounded-xl, restrained. One accent color for every interactive state.
 */

:root {
  --navy-deep: #0a121b;
  --navy: #101d2b;
  --accent: #f0a84e;
  --accent-strong: #ffbf6b;
  --glass-bg: rgba(9, 16, 24, 0.74);
  --glass-border: rgba(255, 255, 255, 0.14);
  --text: #eef4f8;
  --text-dim: rgba(238, 244, 248, 0.72);
  --text-faint: rgba(238, 244, 248, 0.5);
  --radius: 16px;
  --radius-sm: 10px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --tap: 44px;
}

*, *::before, *::after { box-sizing: border-box; }

/* ------------------------------------------------------------ base / a11y */

body { font-family: var(--font); }

button, input, select {
  font-family: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Superseded by the landing footer + touch-hints ghost overlay (deliverables 1 + 3) — the
   engine's own always-on text hint would otherwise sit redundantly in the same lower band. */
#hint { display: none; }

/* ------------------------------------------------------- loading (restyle only, engine HTML) */

#loading {
  background: radial-gradient(120% 90% at 50% 18%, #17293c 0%, #080e15 72%);
}
#loading h1 {
  font-family: var(--font);
  letter-spacing: 0.22em;
  font-weight: 700;
  background: linear-gradient(100deg, #cfe3f2 0%, var(--accent-strong) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
#loading h1 small {
  background: none;
  -webkit-text-fill-color: var(--text-faint);
  color: var(--text-faint);
  letter-spacing: 0.24em;
}
#loading-track { background: rgba(255, 255, 255, 0.1); }
#loading-bar { background: linear-gradient(90deg, var(--accent) 0%, var(--accent-strong) 100%); }
#loading-status { color: var(--text-faint); }

/* ------------------------------------------------------------------ glass */

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* ---------------------------------------------------------------- overlay (landing) */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(130% 100% at 50% 28%, rgba(16, 29, 43, 0.55) 0%, rgba(6, 10, 15, 0.92) 78%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.overlay-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
}

.landing-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  padding: 8px 4px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-strong);
  font-weight: 600;
}
.wordmark {
  margin: 0 0 10px;
  font-size: clamp(34px, 11vw, 52px);
  font-weight: 800;
  letter-spacing: 0.12em;
  background: linear-gradient(100deg, #eaf2f8 0%, var(--accent-strong) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tagline {
  margin: 0 0 26px;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-dim);
}
.question {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 600;
}

.choice-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}
.choice-btn {
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.choice-btn:hover { background: rgba(240, 168, 78, 0.14); border-color: rgba(240, 168, 78, 0.4); }
.choice-btn:active { transform: scale(0.98); }

.landing-footer {
  margin: 0 0 6px;
  font-size: 11px;
  color: var(--text-faint);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.move-hint {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.03em;
  color: var(--text-faint);
}

/* ---------------------------------------------------------------------- top bar */

.hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 46;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  pointer-events: none;
}
.hud-top-left, .hud-top-right { flex: 0 0 auto; display: flex; flex-direction: column; gap: 4px; pointer-events: auto; }
.hud-top-right { align-items: flex-end; }
.hud-top-center { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; pointer-events: auto; }

.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pill-btn:hover { background: rgba(240, 168, 78, 0.14); border-color: rgba(240, 168, 78, 0.4); }
.pill-btn:active { transform: scale(0.97); }
.pill-icon { font-size: 15px; line-height: 1; opacity: 0.9; }

.text-link {
  background: none;
  border: none;
  padding: 4px 6px;
  min-height: 28px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  align-self: flex-start;
}
.text-link:hover { color: var(--text); }

.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.35;
  max-width: min(240px, 40vw);
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 102, 0.35);
  background: rgba(9, 16, 24, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text);
  cursor: pointer;
  min-height: 34px;
  justify-content: center;
}
.badge-main {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #ffd666;
}
.badge-sub {
  font-size: 9px;
  color: var(--text-faint);
  white-space: nowrap;
}

/* ------------------------------------------------------------------- unit chip */
/*
 * Positioned as a child of #hud-dock (see index.html), anchored to the dock's own top edge
 * via bottom:100% + a small margin. This is deliberate: a fixed px offset guessed against the
 * dock's rendered height (font metrics, line-height) is fragile and was WRONG in an earlier
 * pass (158px landed inside the dock's own box, overlapping the sliders instead of clearing
 * them). bottom:100% is exact regardless of how tall the dock actually renders.
 */
.unit-chip {
  position: absolute;
  left: 50%;
  bottom: 100%;
  margin-bottom: 12px;
  transform: translateX(-50%) translateY(6px);
  z-index: 44;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12px;
  max-width: min(360px, 90vw);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.unit-chip.open { opacity: 1; visibility: visible; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.unit-chip .text-link { align-self: center; }

/* ------------------------------------------------------------------- slider dock */
/*
 * Deliberately kept OFF the very bottom edge and width-capped (not edge-to-edge): the
 * engine's touch input treats the whole left/right half of the screen as the joystick /
 * look-drag origin (controller.js `half()` split), and real thumbs rest at the bottom
 * corners. This dock is the one exception allowed to sit in that lower band (per brief),
 * so it's centered and compact rather than full-bleed, and every OTHER persistent control
 * lives in the top bar instead. Sheets/backdrops are modal (expected to capture input while
 * open) and the unit-chip only shows while walking is already disabled (unit view).
 *
 * `--notice-h` is set by hud.js from #notice's real measured height (its text wraps to 3-4
 * lines on a narrow phone, so a guessed constant undershoots and the dock would sit on top of
 * the legally-required notice text). The 44px fallback only applies before JS has run once.
 */
.hud-dock {
  position: fixed;
  left: 50%;
  bottom: calc(var(--notice-h, 44px) + 10px);
  transform: translateX(-50%);
  z-index: 45;
  width: min(400px, 78vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px 16px 10px;
  border-radius: var(--radius);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.slider-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}
.slider-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
#year-value { font-size: 16px; color: var(--accent-strong); }

.slider-track-wrap { position: relative; padding-bottom: 14px; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  margin: 0;
  display: block;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right,
    var(--accent) 0%, var(--accent) var(--fill, 0%),
    rgba(255, 255, 255, 0.16) var(--fill, 0%), rgba(255, 255, 255, 0.16) 100%);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}
input[type="range"]::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.ticks { position: absolute; left: 9px; right: 9px; top: 20px; height: 0; pointer-events: none; }
.tick { position: absolute; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.tick-mark { width: 2px; height: 5px; border-radius: 1px; background: rgba(255, 255, 255, 0.45); }
.tick-label { margin-top: 3px; font-size: 8.5px; white-space: nowrap; color: var(--text-faint); }
.time-tick .tick-mark { background: #ffd666; height: 7px; }

/* -------------------------------------------------------------------- sheets / modals */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 54;
  background: rgba(4, 8, 12, 0.55);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.sheet-backdrop.open { opacity: 1; visibility: visible; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 56;
  margin: 0 auto;
  width: min(480px, 100%);
  max-height: min(78vh, 620px);
  overflow-y: auto;
  padding: 16px 20px calc(20px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0;
  background: linear-gradient(180deg, #101d2b 0%, #0a1119 100%);
  border: 1px solid var(--glass-border);
  border-bottom: none;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.45);
  transform: translateY(100%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}
.sheet.open { transform: translateY(0); opacity: 1; visibility: visible; pointer-events: auto; }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 700; }

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }

.field-label {
  display: block;
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.field {
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 15px;
}

.stepper { display: flex; align-items: stretch; gap: 8px; }
.stepper-btn {
  width: var(--tap);
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
}
.stepper-btn:hover { background: rgba(255, 255, 255, 0.14); }
.stepper-input { flex: 1; text-align: center; -moz-appearance: textfield; }
.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.primary-btn {
  width: 100%;
  min-height: var(--tap);
  margin-top: 20px;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(100deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #1a1206;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: scale(0.99); }

.field-error {
  min-height: 16px;
  margin: 8px 2px 0;
  font-size: 12px;
  color: #ff9b86;
}

.info-body { font-size: 14px; line-height: 1.55; color: var(--text-dim); }
.info-body h3 {
  margin: 18px 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-strong);
}
.info-body h3:first-of-type { margin-top: 6px; }
.info-body p { margin: 0 0 4px; }
.info-body .made-for { margin-top: 18px; font-size: 12px; color: var(--text-faint); font-style: italic; }

.legend-list, .attrib-list { list-style: none; margin: 0; padding: 0; }
.legend-list li { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.attrib-list li {
  padding-left: 14px;
  position: relative;
  margin-bottom: 4px;
  font-size: 12.5px;
  color: var(--text-faint);
}
.attrib-list li::before { content: "—"; position: absolute; left: 0; opacity: 0.6; }

.swatch {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--glass-border);
}
.swatch-ghost { background: rgba(255, 255, 255, 0.18); }
.swatch-unknown {
  background: repeating-linear-gradient(45deg, rgba(207, 201, 182, 0.5) 0 4px, rgba(207, 201, 182, 0.15) 4px 8px);
  color: #fff5d6;
}

/* -------------------------------------------------------------------- touch hints */

.touch-hints {
  position: fixed;
  inset: 0;
  z-index: 42;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease;
}
.touch-hints.open { opacity: 1; visibility: visible; }

.thumb-hint {
  position: absolute;
  bottom: max(64px, calc(10vh + env(safe-area-inset-bottom)));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: thumb-pulse 1.8s ease-in-out infinite;
}
.thumb-hint-left { left: 14vw; }
.thumb-hint-right { right: 14vw; }
.thumb-dot {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 0 10px rgba(255, 255, 255, 0.05);
}
.thumb-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
@keyframes thumb-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.12); opacity: 1; }
}

/* -------------------------------------------------------------------- responsive */

@media (min-width: 720px) {
  .hud-dock { width: min(460px, 42vw); }
  .badge { max-width: 320px; }
  .badge-main, .badge-sub { display: inline; }
  .badge-sub { margin-left: 5px; }
  .sheet { left: 50%; right: auto; bottom: 24px; transform: translate(-50%, 12px); border-radius: 20px; border-bottom: 1px solid var(--glass-border); }
  .sheet.open { transform: translate(-50%, 0); }
}

@media (max-width: 380px) {
  .wordmark { letter-spacing: 0.08em; }
  .hud-dock { width: 84vw; }
}
