/* Super Offroad garage — the baked mockup is the base layer; interactive
   elements are positioned overlays that crop the same image (so they are
   invisible until their state changes) plus live LED canvases and hotspots. */

html, body { margin: 0; height: 100%; overflow: hidden; background: #060504; }

#wrap { position: fixed; inset: 0; }

#stage {
  position: absolute; left: 50%; top: 50%;
  width: 1821px; height: 864px;
  transform-origin: 0 0;
  background: url('images/ui/src/garage-mockup.jpg') 0 0 / 1821px 864px no-repeat;
  user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; /* phones: no save-image sheet on long press */
  touch-action: manipulation;
  font-family: 'Bahnschrift', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
}
#stage * { -webkit-touch-callout: none; }
#stage img { -webkit-user-drag: none; }

/* sprites cropped from the delivered toggle art sheets */
.art-img { position: absolute; pointer-events: none; }

/* ---- generic positioned nodes ---- */
.hs { position: absolute; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.hs:focus-visible { outline: 2px solid #ffb400; outline-offset: -2px; }

/* crops the mockup at the element's own coordinates (set inline by JS) */
.crop {
  position: absolute;
  background-image: url('images/ui/src/garage-mockup.jpg');
  background-size: 1821px 864px;
  background-repeat: no-repeat;
  pointer-events: none;
}

/* ---- selection / state treatments ---- */
.dimmer {
  position: absolute; inset: 0; border-radius: 8px;
  background: rgba(5, 4, 3, 0.62); pointer-events: none;
  transition: opacity 0.18s;
}
.sel-ring {
  position: absolute; inset: -3px; border-radius: 8px; pointer-events: none;
  border: 3px solid #ffb400;
  box-shadow: 0 0 14px rgba(255, 180, 0, 0.85), inset 0 0 10px rgba(255, 180, 0, 0.4);
  animation: selpulse 1.6s ease-in-out infinite;
}
@keyframes selpulse {
  0%, 100% { box-shadow: 0 0 14px rgba(255, 180, 0, 0.85), inset 0 0 10px rgba(255, 180, 0, 0.4); }
  50% { box-shadow: 0 0 22px rgba(255, 180, 0, 1), inset 0 0 14px rgba(255, 180, 0, 0.55); }
}
.sel-ring.teal {
  border-color: #35e0ff;
  box-shadow: 0 0 14px rgba(53, 224, 255, 0.85), inset 0 0 10px rgba(53, 224, 255, 0.4);
  animation: none;
}

.hs:hover .hoverglow, .hs:active .hoverglow { opacity: 1; }
.hoverglow {
  position: absolute; inset: 0; border-radius: 8px; opacity: 0; pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(255, 220, 140, 0.55), 0 0 12px rgba(255, 200, 90, 0.35);
  transition: opacity 0.12s;
}

/* lock badge crops the padlock from the mockup's unlock panel */
.lock-badge {
  position: absolute; right: 6px; top: 6px; width: 26px; height: 28px;
  background-image: url('images/ui/src/garage-mockup.jpg');
  background-repeat: no-repeat;
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* small text patches that repaint baked labels (ON/OFF, FUN/WILD/INSANE) */
.patch {
  position: absolute; display: flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: 1px; pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
}
.patch.on { color: #59e659; text-shadow: 0 0 6px rgba(60, 230, 60, 0.7), 0 1px 2px #000; }
.patch.off { color: #ff5040; text-shadow: 0 0 6px rgba(255, 70, 50, 0.6), 0 1px 2px #000; }
.patch.plate {
  background: #0a0a0a;
  border: 1px solid #262626;
  border-radius: 5px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.95), inset 0 -1px 1px rgba(255, 255, 255, 0.05);
}

/* lamp dim overlay for the top status toggles */
.lamp-dim {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(8, 8, 8, 0.88) 0%, rgba(8, 8, 8, 0.82) 60%, rgba(8, 8, 8, 0) 74%);
  transition: opacity 0.15s;
}

/* levers / knobs cut from the mockup that rotate or flip in place */
.lever { transition: transform 0.13s ease-out; }
.knob { border-radius: 50%; transition: transform 0.16s ease-out; cursor: pointer; pointer-events: auto; }
.knob:active { filter: brightness(1.15); }

/* procedural controls: canvas-drawn knobs / toggles over the baked art */
canvas.pctl { position: absolute; pointer-events: none; }
canvas.pknob:focus-visible { outline: 2px solid #ffb400; outline-offset: 2px; border-radius: 50%; }

/* per-pack venue tag on the LED bezels */
.venue-tag {
  position: absolute; pointer-events: none;
  font-size: 12px; font-weight: 700; letter-spacing: 1px;
  color: #e8a33c; text-shadow: 0 0 6px rgba(232, 163, 60, 0.55), 0 1px 2px #000;
  white-space: nowrap; overflow: hidden;
}

/* READY switch arms the RACE button */
#race-hs.armed #race-glow { animation: racearm 1.1s ease-in-out infinite; }
@keyframes racearm {
  0%, 100% { opacity: 0.12; }
  50% { opacity: 0.55; }
}

/* live 3D set replacing the whole center stage (src/garageStage.js) */
#stage-frame {
  position: absolute;
  overflow: hidden;
  border-radius: 14px;
}
/* mockup bezel strips — tuck the viewer under the cabinet frame.
   DOM order keeps them above #stage-frame and under knobs/stats. */
.stage-bezel { pointer-events: none; }
#stage3d {
  display: block;
  pointer-events: auto;
  -webkit-user-drag: none;
}

/* ---- RACE! hold-to-start ---- */
#race-hs .hoverglow { border-radius: 12px; }
#race-glow {
  position: absolute; inset: -18px; border-radius: 20px; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, rgba(255, 60, 20, 0.55) 0%, rgba(255, 40, 10, 0.22) 55%, rgba(255, 30, 0, 0) 75%);
  mix-blend-mode: screen;
}
#race-bar {
  position: absolute; left: 8%; right: 8%; bottom: 7px; height: 6px;
  background: rgba(20, 6, 2, 0.85); border: 1px solid rgba(255, 90, 40, 0.5);
  border-radius: 3px; opacity: 0; pointer-events: none; overflow: hidden;
}
#race-bar > div {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #ff3a10, #ffb400);
  box-shadow: 0 0 8px #ff5020;
}
.race-launch { animation: launchflash 0.35s ease-in forwards; }
@keyframes launchflash {
  0% { filter: brightness(1); }
  100% { filter: brightness(3) saturate(0.6); }
}

/* ---- LED canvases ---- */
canvas.led { position: absolute; pointer-events: none; }

/* ---- toast ---- */
#toast {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  padding: 10px 26px; border-radius: 6px;
  background: rgba(12, 9, 6, 0.94); border: 2px solid #8a5a20;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.7), inset 0 0 12px rgba(255, 170, 60, 0.12);
  color: #ffd056; font-size: 21px; font-weight: 700; letter-spacing: 2px;
  white-space: nowrap; opacity: 0; transition: opacity 0.22s; pointer-events: none;
  z-index: 40;
}

/* panel attention flash (nav tabs point at their panel) */
.flash { animation: panelflash 0.9s ease-out; }
@keyframes panelflash {
  0%, 45% { box-shadow: inset 0 0 0 3px rgba(255, 180, 0, 0.9), 0 0 24px rgba(255, 180, 0, 0.5); }
  100% { box-shadow: inset 0 0 0 3px rgba(255, 180, 0, 0), 0 0 24px rgba(255, 180, 0, 0); }
}

/* POWER switched off: the whole cabinet browns out except the switch itself */
#brownout {
  position: absolute; inset: 0; z-index: 30; pointer-events: none;
  background: rgba(2, 2, 3, 0.66); opacity: 0; transition: opacity 0.35s;
}

.exit-link {
  position: fixed; top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left)); z-index: 50;
  font-family: "Courier New", monospace; font-weight: bold; font-size: 15px;
  letter-spacing: 2px; color: #ffe08a; text-decoration: none; user-select: none;
  padding: 8px 14px; border: 2px solid #b8342a; border-radius: 4px;
  background: rgba(20, 16, 12, 0.92);
}
.exit-link:hover { color: #fff4c8; background: #2a1810; }

/* ---- OPTIONS popup (steer sens / lin / dead) ---- */
#so-opts-scrim {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(4, 3, 2, 0.72);
  display: none; align-items: center; justify-content: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
#so-opts-scrim.open { display: flex; }
#so-opts {
  width: min(420px, 100%);
  max-height: min(90vh, 560px);
  overflow: auto;
  background: linear-gradient(180deg, #1c1610 0%, #0c0a08 100%);
  border: 2px solid #8a5a20;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.75), inset 0 0 24px rgba(255, 170, 60, 0.08);
  color: #f4e3c2;
  font-family: 'Bahnschrift', 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
  padding: 18px 18px 16px;
}
#so-opts .opts-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid rgba(138, 90, 32, 0.55);
}
#so-opts .opts-title {
  font-size: 18px; font-weight: 700; letter-spacing: 3px; color: #ffd056;
  text-shadow: 0 0 10px rgba(255, 180, 0, 0.35);
}
#so-opts .opts-close {
  appearance: none; border: 2px solid #b8342a; background: rgba(20, 16, 12, 0.92);
  color: #ffe08a; font: inherit; font-weight: 700; letter-spacing: 2px;
  padding: 6px 12px; border-radius: 4px; cursor: pointer;
}
#so-opts .opts-close:hover { color: #fff4c8; background: #2a1810; }
#so-opts .opts-blurb {
  margin: 0 0 14px; font-size: 12px; letter-spacing: 1px; color: #9a8060; line-height: 1.45;
}
#so-opts .sens { margin: 0 0 16px; }
#so-opts .sens label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; letter-spacing: 2px; color: #c8a060; margin-bottom: 8px;
}
#so-opts .sens label b { color: #ffe08a; font-size: 14px; letter-spacing: 1px; }
#so-opts .notch-row { display: flex; align-items: center; gap: 8px; }
#so-opts .notch-step {
  width: 40px; height: 40px; padding: 0; flex: none;
  font-size: 22px; line-height: 1; font-weight: 700;
  border-radius: 6px; border: 2px solid #8a5a20;
  background: rgba(20, 14, 10, 0.9); color: #ffe08a;
  cursor: pointer; touch-action: manipulation;
}
#so-opts .notch-step:hover { border-color: #ffb400; background: #2a1810; }
#so-opts .notch-step:active { transform: scale(0.96); }
#so-opts .notch-track { flex: 1; min-width: 0; position: relative; padding: 0 2px 14px; }
#so-opts .notch-track input[type="range"] {
  width: 100%; height: 28px; margin: 0; accent-color: #e8781c; cursor: pointer;
  touch-action: manipulation;
}
#so-opts .notch-ticks {
  display: flex; justify-content: space-between; pointer-events: none; margin-top: -4px;
}
#so-opts .notch-ticks i {
  width: 2px; height: 8px; background: #3a3228; border-radius: 1px;
}
#so-opts .notch-ticks i.on {
  background: #ffb400; box-shadow: 0 0 6px rgba(255, 180, 0, 0.55);
}
#so-opts .notch-scale {
  display: flex; justify-content: space-between; font-size: 9px; color: #6a5840;
  letter-spacing: 1px; margin-top: 2px;
}
#so-opts .opts-foot {
  margin-top: 4px; font-size: 11px; letter-spacing: 1px; color: #7a6848; line-height: 1.4;
}
