/* ==========================================================================
   Plate Scanner — instrument-cluster HUD
   Dark, sodium-amber at rest, acid-lime when armed. Everything readable at a
   glance and hittable without looking. Chrome floats over the camera as smoked
   glass so the road is never fully covered.
   ========================================================================== */

@font-face {
  font-family: 'Archivo';
  src: url('../vendor/fonts/archivo-latin.woff2') format('woff2');
  font-weight: 500 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Archivo';
  src: url('../vendor/fonts/archivo-latin-ext.woff2') format('woff2');
  font-weight: 500 700;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Martian Mono';
  src: url('../vendor/fonts/martianmono-latin.woff2') format('woff2');
  font-weight: 600 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Martian Mono';
  src: url('../vendor/fonts/martianmono-latin-ext.woff2') format('woff2');
  font-weight: 600 700;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --void: #08090b;
  --smoke: rgba(13, 15, 18, 0.82);
  --smoke-hi: rgba(24, 27, 32, 0.9);
  --edge: rgba(255, 255, 255, 0.11);
  --edge-hi: rgba(255, 255, 255, 0.2);
  --txt: #edeae4;
  --dim: #8d8a83;
  --amber: #ffa31a;
  --lime: #c6ff2e;
  --red: #ff4438;
  --eu-blue: #0b3ea8;
  --plate-face: #f4f2ec;

  --dock-h: 92px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);

  /* Fine noise, so the smoked panels read as glass rather than flat fill. */
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--void);
  color: var(--txt);
  font-family: 'Archivo', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ stage */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.cam {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 78% at 50% 46%, transparent 40%, rgba(4, 5, 7, 0.55) 100%);
}

/* White-out pulse on a confirmed read — visible in peripheral vision. */
.flashlayer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: var(--lime);
  opacity: 0;
}
.stage.flash .flashlayer { animation: flash 0.26s ease-out; }
@keyframes flash {
  0% { opacity: 0.34; }
  100% { opacity: 0; }
}

/* ------------------------------------------------------------------- rail */

.rail {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-t) + 12px) 16px 12px;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(6, 7, 9, 0.72), transparent);
  pointer-events: none;
}
.rail__mark { color: var(--txt); }
.rail__mark i { color: var(--amber); font-style: normal; margin: 0 2px; }
.rail__spacer { flex: 1; }
.rail__stat {
  font-family: 'Martian Mono', ui-monospace, monospace;
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 3px 7px;
  border: 1px solid var(--edge);
  border-radius: 5px;
  background: var(--smoke);
}
.rail__stat--dim { color: var(--dim); }

.debug {
  position: absolute;
  top: calc(var(--safe-t) + 46px);
  left: 16px;
  right: 16px;
  margin: 0;
  padding: 8px 10px;
  font-family: 'Martian Mono', ui-monospace, monospace;
  font-size: 10px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--lime);
  background: rgba(6, 7, 9, 0.78);
  border: 1px solid var(--edge);
  border-radius: 8px;
  pointer-events: none;
}

/* ------------------------------------------------------------------ toast */

.debugcrop {
  position: absolute;
  top: calc(var(--safe-t) + 118px);
  left: 16px;
  width: calc(100% - 32px);
  max-height: 84px;
  object-fit: contain;
  image-rendering: pixelated;
  border: 1px solid var(--lime);
  border-radius: 6px;
  background: #fff;
  pointer-events: none;
}

.toast {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translate(-50%, -50%) scale(0.9);
  padding: 14px 22px;
  font-family: 'Martian Mono', ui-monospace, monospace;
  font-weight: 700;
  font-size: clamp(22px, 7vw, 34px);
  letter-spacing: 0.02em;
  color: #10120f;
  background: var(--lime);
  border-radius: 10px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.3) inset;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { animation: toast 2.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.82); }
  8% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); }
  14% { transform: translate(-50%, -50%) scale(1); }
  82% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -56%) scale(0.98); }
}

/* ------------------------------------------------------------------- dock */

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--dock-h) + var(--safe-b));
  padding: 0 18px var(--safe-b);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  background: linear-gradient(0deg, rgba(6, 7, 9, 0.86) 30%, transparent);
  z-index: 6;
}

.dock__btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 56px;
  min-height: 56px;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 14px;
  color: var(--txt);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  background: var(--smoke);
  border: 1px solid var(--edge);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: color 0.18s, border-color 0.18s, transform 0.12s;
}
.dock__btn:active { transform: scale(0.94); }
.dock__btn.on { color: var(--amber); border-color: rgba(255, 163, 26, 0.5); }

.dock__pair { display: flex; gap: 10px; justify-content: flex-end; }
.dock > .dock__btn:first-child { justify-self: start; }

.badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 10px;
  background: var(--amber);
  color: #17130a;
  font-family: 'Martian Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
}

/* the scan switch — the one control you must be able to hit blind */
.scan {
  position: relative;
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  transition: transform 0.14s;
}
.scan:active { transform: scale(0.93); }

.scan__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--amber);
  opacity: 0.85;
}
.scan__core {
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 34%, rgba(255, 163, 26, 0.28), rgba(255, 163, 26, 0.06));
  border: 1px solid rgba(255, 163, 26, 0.4);
  transition: background 0.22s, border-color 0.22s;
}
.scan__label {
  position: relative;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

.scan.on .scan__ring { border-color: var(--lime); animation: pulse 1.7s ease-out infinite; }
.scan.on .scan__core {
  background: radial-gradient(circle at 50% 34%, rgba(198, 255, 46, 0.4), rgba(198, 255, 46, 0.1));
  border-color: rgba(198, 255, 46, 0.62);
}
.scan.on .scan__label { color: var(--lime); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(198, 255, 46, 0.4); }
  70% { box-shadow: 0 0 0 18px rgba(198, 255, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(198, 255, 46, 0); }
}

/* ------------------------------------------------------------------ sheet */

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-b);
  background: var(--smoke-hi);
  backdrop-filter: blur(26px) saturate(1.3);
  -webkit-backdrop-filter: blur(26px) saturate(1.3);
  border-top: 1px solid var(--edge-hi);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.6);
  transform: translateY(102%);
  transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}
.sheet.open { transform: translateY(0); }
.sheet::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--grain);
  opacity: 0.035;
  pointer-events: none;
  mix-blend-mode: overlay;
}

.sheet__grip {
  width: 38px;
  height: 4px;
  margin: 9px auto 2px;
  border-radius: 2px;
  background: var(--edge-hi);
}

.sheet__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 12px;
  border-bottom: 1px solid var(--edge);
}
.sheet__head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.sheet__count {
  margin-left: 8px;
  font-family: 'Martian Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--amber);
}

.iconbtn {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: var(--dim);
  border: 1px solid var(--edge);
}
.iconbtn:active { color: var(--txt); }

/* ------------------------------------------------------- the plate object */

.plate {
  display: inline-flex;
  align-items: stretch;
  height: 30px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--plate-face);
  border: 1.5px solid #1b1c1a;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset, 0 2px 6px rgba(0, 0, 0, 0.42);
  font-family: 'Martian Mono', ui-monospace, monospace;
}
.plate__eu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 21px;
  padding-bottom: 3px;
  background: linear-gradient(180deg, #124bc4, var(--eu-blue));
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}
/* the ring of EU stars, at this size honestly just a bright dot */
.plate__eu i {
  width: 7px;
  height: 7px;
  margin-bottom: 2px;
  border-radius: 50%;
  border: 1.2px dotted rgba(255, 255, 255, 0.9);
}
.plate__num {
  display: flex;
  align-items: center;
  padding: 0 9px;
  color: #101010;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.plate--hero { height: 52px; border-radius: 6px; }
.plate--hero .plate__eu { width: 34px; font-size: 12px; padding-bottom: 5px; }
.plate--hero .plate__eu i { width: 12px; height: 12px; }
.plate--hero .plate__num { font-size: 26px; padding: 0 16px; }

/* -------------------------------------------------------------- log rows */

.rows {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 6px 0;
  list-style: none;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  animation: rowin 0.34s cubic-bezier(0.16, 1, 0.3, 1);
}
.row:active { background: rgba(255, 255, 255, 0.04); }
@keyframes rowin {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.row__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  color: var(--dim);
  font-family: 'Martian Mono', ui-monospace, monospace;
}
.row__meta .c {
  flex: 0 0 46px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.row__meta .c i { display: block; height: 100%; background: var(--lime); }
.row__meta .pct { color: var(--dim); }

.row__thumb {
  width: 74px;
  height: 34px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--edge);
  background: #000;
}

.row__del {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  color: var(--dim);
  border: 1px solid transparent;
}
.row__del:active { color: var(--red); border-color: rgba(255, 68, 56, 0.4); }

.empty {
  padding: 34px 18px 40px;
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--txt);
}
.empty span { display: block; margin-top: 6px; font-size: 12px; color: var(--dim); }

.sheet__foot {
  display: flex;
  gap: 8px;
  padding: 12px 18px calc(14px + var(--safe-b));
  border-top: 1px solid var(--edge);
}
.ghost {
  flex: 1;
  padding: 12px 8px;
  border-radius: 11px;
  border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--txt);
}
.ghost:active { background: rgba(255, 255, 255, 0.09); }
.ghost--danger { color: var(--red); border-color: rgba(255, 68, 56, 0.3); }

/* --------------------------------------------------------------- settings */

.sheet--settings .fields {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 18px calc(26px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.field__label b {
  font-family: 'Martian Mono', ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--amber);
}
.field__hint { font-size: 11px; line-height: 1.5; color: var(--dim); }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 30px;
  background: none;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
}
input[type='range']::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.16);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  margin-top: -11.5px;
  border-radius: 50%;
  background: var(--amber);
  border: 4px solid #14150f;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
input[type='range']::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--amber);
  border: 4px solid #14150f;
}

.toggle { display: flex; align-items: flex-start; gap: 12px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle__box {
  flex: none;
  width: 46px;
  height: 27px;
  margin-top: 2px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--edge);
  position: relative;
  transition: background 0.2s;
}
.toggle__box::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--dim);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s;
}
.toggle input:checked + .toggle__box { background: rgba(198, 255, 46, 0.24); border-color: rgba(198, 255, 46, 0.5); }
.toggle input:checked + .toggle__box::after { transform: translateX(19px); background: var(--lime); }
.toggle input:focus-visible + .toggle__box { outline: 2px solid var(--lime); outline-offset: 3px; }

.toggle__text { font-size: 13px; line-height: 1.4; }
.toggle__text i {
  display: block;
  margin-top: 3px;
  font-style: normal;
  font-size: 11px;
  line-height: 1.5;
  color: var(--dim);
}

/* ------------------------------------------------------------------ boot */

.boot {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(255, 163, 26, 0.1), transparent 60%),
    #06070a;
  transition: opacity 0.5s, visibility 0.5s;
}
.boot.gone { opacity: 0; visibility: hidden; pointer-events: none; }

.boot__inner { max-width: 420px; }
.boot__plate { margin-bottom: 26px; animation: drop 0.7s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes drop {
  from { opacity: 0; transform: translateY(-14px) rotate(-2deg); }
  to { opacity: 1; transform: none; }
}

.boot__title {
  margin: 0 0 10px;
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 700;
  letter-spacing: -0.02em;
  animation: rise 0.6s 0.08s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.boot__sub {
  margin: 0 0 26px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--dim);
  animation: rise 0.6s 0.16s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.boot__btn {
  width: 100%;
  padding: 17px 24px;
  border-radius: 14px;
  background: var(--amber);
  color: #17130a;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  box-shadow: 0 10px 34px rgba(255, 163, 26, 0.26);
  animation: rise 0.6s 0.24s cubic-bezier(0.16, 1, 0.3, 1) both;
  transition: transform 0.12s;
}
.boot__btn:active { transform: scale(0.97); }
.boot__btn:disabled { opacity: 0.5; }

.boot__msg { margin: 16px 0 0; font-size: 12px; line-height: 1.6; color: var(--dim); }
.boot__msg strong { color: var(--red); }

.boot__track {
  height: 2px;
  margin-top: 14px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.boot__track i {
  display: block;
  width: 0;
  height: 100%;
  background: var(--lime);
  transition: width 0.3s;
}

.boot__warn {
  margin: 30px 0 0;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  opacity: 0.75;
}

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