/* ---------- Tokens ---------- */
:root {
  --paper:   #E9EDF1;   /* page: registration-paper grey */
  --surface: #FFFFFF;
  --ink:     #14213D;   /* deep navy text */
  --steel:   #56657A;   /* secondary text */
  --line:    #C9D1DB;
  --amber:   #E0A21E;   /* salvage / branded title */
  --amber-bg:#FCEFCF;
  --green:   #1E7F55;
  --green-bg:#E1F1E8;
  --red:     #B3261E;

  --font: "Overpass", system-ui, sans-serif;
  --mono: "Overpass Mono", ui-monospace, monospace;

  --cell: clamp(17px, 4.3vw, 44px);
  --gap-group: clamp(6px, 1.4vw, 14px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #0E1522;
    --surface: #16202F;
    --ink:     #E7ECF3;
    --steel:   #98A6BA;
    --line:    #2A3647;
    --amber:   #D9A23A;
    --amber-bg:#3A2E12;
    --green:   #4CB685;
    --green-bg:#12301F;
    --red:     #F07067;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
}
a { color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Header ---------- */
.top {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  max-width: 1040px; margin: 0 auto; padding: 22px 16px 0;
}
.brand {
  font-weight: 800; font-size: 20px; text-decoration: none; letter-spacing: -0.01em;
}
.top-note { color: var(--steel); font-size: 15px; }

/* ---------- Hero ---------- */
main { max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.hero { padding: clamp(40px, 9vw, 96px) 0 40px; }
.hero h1 {
  font-size: clamp(32px, 5.6vw, 58px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.025em;
  max-width: 16ch;
  margin: 0 0 18px;
}
.lede { color: var(--steel); font-size: clamp(17px, 2vw, 20px); max-width: 52ch; margin: 0 0 36px; }

/* ---------- VIN plate (the one bold element) ---------- */
.vin-form { display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }

.plate {
  position: relative;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: clamp(14px, 2.6vw, 26px) clamp(14px, 3vw, 34px) clamp(12px, 2vw, 18px);
  max-width: 100%;
  cursor: text;
}
/* rivets */
.plate::before, .plate::after {
  content: ""; position: absolute; top: 50%; width: 7px; height: 7px; margin-top: -3.5px;
  border-radius: 50%; background: var(--line); box-shadow: inset 0 0 0 1px var(--steel);
}
.plate::before { left: 5px; }
.plate::after  { right: 5px; }

.plate input {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; font-size: 16px; /* 16px stops iOS zoom */
  cursor: text; border: 0; padding: 0;
}
.plate:focus-within { box-shadow: 0 0 0 4px var(--amber-bg); }
.plate:has(input:focus-visible) { outline: 3px solid var(--amber); outline-offset: 3px; }

.groups { display: flex; gap: var(--gap-group); pointer-events: none; }
.group { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cells { display: flex; gap: 2px; }
.cell {
  width: var(--cell);
  height: calc(var(--cell) * 1.45);
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700;
  font-size: calc(var(--cell) * 0.72);
  border-bottom: 2px solid var(--line);
  color: var(--ink);
}
.cell.is-filled { border-bottom-color: var(--ink); }
.plate:focus-within .cell.is-active { border-bottom-color: var(--amber); background: var(--amber-bg); }
.group-label { font-size: 12px; color: var(--steel); white-space: nowrap; }

.plate.is-complete { border-color: var(--green); }
.plate.is-loading .cell { animation: scan 1.2s ease-in-out infinite; animation-delay: calc(var(--i) * 55ms); }
@keyframes scan {
  0%, 60%, 100% { background: transparent; }
  20% { background: var(--amber-bg); }
}

.btn-check {
  font: inherit; font-weight: 800; font-size: 18px;
  background: var(--ink); color: var(--paper);
  border: 0; border-radius: 999px;
  padding: 14px 30px; cursor: pointer;
}
.btn-check:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-check:not(:disabled):hover { background: var(--steel); }

.hint { color: var(--steel); font-size: 15px; max-width: 60ch; margin: 18px 0 0; }
.error { color: var(--red); font-weight: 600; margin: 12px 0 0; min-height: 1.5em; }

.recent { margin-top: 28px; }
.recent-title { font-size: 14px; font-weight: 600; color: var(--steel); margin: 0 0 8px; }
.recent-list { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-list button {
  font-family: var(--mono); font-size: 14px; color: var(--ink);
  background: transparent; border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 10px; cursor: pointer;
}
.recent-list button:hover { border-color: var(--ink); }

@media (max-width: 560px) {
  .group-label { display: none; }
  .plate { padding: 12px 10px; width: 100%; }
  .plate::before, .plate::after { display: none; }
  .groups { --gap-group: 4px; justify-content: center; }
  .cells { gap: 1px; }
  /* 17 cells fill the width: viewport − gutters − plate padding − borders − gaps */
  :root { --cell: min(28px, calc((100vw - 32px - 20px - 4px - 16px - 16px) / 17)); }
}

/* ---------- Results ---------- */
.results { padding: 8px 0 56px; }

.verdict {
  border-left: 8px solid var(--steel);
  background: var(--surface);
  border-radius: 4px 12px 12px 4px;
  padding: 22px 24px;
  margin-bottom: 36px;
}
.verdict h2 { font-size: clamp(24px, 3.4vw, 34px); line-height: 1.15; margin: 0 0 6px; letter-spacing: -0.015em; }
.verdict p { margin: 0; max-width: 62ch; }
.verdict--warn  { border-left-color: var(--amber); background: var(--amber-bg); }
.verdict--clean { border-left-color: var(--green); background: var(--green-bg); }

.vehicle { margin-bottom: 28px; }
.vehicle h3 { font-size: clamp(22px, 3vw, 30px); margin: 0; letter-spacing: -0.01em; }
.vehicle .vin { font-family: var(--mono); color: var(--steel); font-size: 15px; letter-spacing: 0.08em; }

.columns { display: grid; grid-template-columns: 1fr 1.4fr; gap: 40px; align-items: start; }
@media (max-width: 820px) { .columns { grid-template-columns: 1fr; gap: 32px; } }

.block-title { font-size: 18px; font-weight: 800; margin: 0 0 12px; }

.specs { margin: 0; }
.specs div { display: grid; grid-template-columns: 7.5em 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.specs dt { color: var(--steel); }
.specs dd { margin: 0; font-weight: 600; }

.lots { list-style: none; margin: 0; padding: 0; }
.lot {
  display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 10px;
}
.badge {
  font-weight: 800; font-size: 13px; padding: 4px 8px; border-radius: 4px;
  background: var(--ink); color: var(--paper); min-width: 64px; text-align: center;
}
.badge--IAAI   { background: #C8102E; color: #fff; }
.badge--Copart { background: #1E4FA3; color: #fff; }
.lot-title { font-weight: 600; line-height: 1.3; }
.lot-meta { color: var(--steel); font-size: 14px; }
.lot a {
  font-weight: 800; font-size: 15px; text-decoration: none; white-space: nowrap;
  border: 2px solid var(--ink); border-radius: 999px; padding: 7px 14px;
}
.lot a:hover { background: var(--ink); color: var(--paper); }
@media (max-width: 480px) {
  .lot { grid-template-columns: 1fr; gap: 8px; }
  .lot a, .lot .badge { justify-self: start; }
}

.keywords { margin-top: 22px; }
.keywords p { margin: 0 0 8px; color: var(--steel); font-size: 15px; }
.chip {
  display: inline-block; margin: 0 6px 6px 0; padding: 3px 10px; border-radius: 999px;
  background: var(--amber-bg); border: 1px solid var(--amber); font-size: 14px; font-weight: 600;
}

.empty { color: var(--steel); margin: 0; }

.mentions { margin-top: 36px; }
.mentions ul { margin: 0; padding: 0; list-style: none; }
.mentions li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.mentions a { font-weight: 600; text-underline-offset: 3px; }
.mentions span { display: block; color: var(--steel); font-size: 14px; }

.checked { color: var(--steel); font-size: 14px; margin-top: 28px; }

/* ---------- Auction record + gallery ---------- */
.record { margin-bottom: 44px; }
.record-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 32px; align-items: start; }
.record .specs div { grid-template-columns: 7em 1fr; }
/* grid children must be allowed to shrink, or the scrolling photo strip widens the page */
.record-grid > *, .columns > * { min-width: 0; }
.lot > div { min-width: 0; overflow-wrap: anywhere; }
.specs dd, .mentions a { overflow-wrap: anywhere; }
@media (max-width: 820px) { .record-grid { grid-template-columns: 1fr; gap: 24px; } }

.gallery-main {
  position: relative; display: block; width: 100%; padding: 0; border: 0; cursor: zoom-in;
  aspect-ratio: 4 / 3; background: var(--surface); border-radius: 12px; overflow: hidden;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-count {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(20, 33, 61, 0.82); color: #fff; font-size: 14px; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
}
.gallery-credit { margin: 6px 0 0; font-size: 13px; color: var(--steel); }
.gallery-credit a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }
.record-note { margin: -4px 0 14px; color: var(--steel); font-size: 15px; max-width: 60ch; }
@media (max-width: 560px) { .gallery-credit { padding: 0 16px; } }
.gallery-strip {
  display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin;
}
.gallery-thumb {
  flex: 0 0 auto; width: 84px; aspect-ratio: 4 / 3; padding: 0; cursor: pointer;
  border: 2px solid transparent; border-radius: 6px; overflow: hidden; background: var(--surface);
}
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-thumb.is-current { border-color: var(--ink); }

.gallery-main, .lightbox img { touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.gallery-strip { scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.gallery-thumb { scroll-snap-align: start; }

.lightbox {
  border: 0; padding: 0; margin: 0;
  width: 100vw; height: 100vh; height: 100dvh; max-width: 100vw; max-height: 100dvh;
  background: #000; color: #fff; overflow: hidden;
}
.lightbox::backdrop { background: #000; }
.lightbox[open] { display: flex; flex-direction: column; }
.lb-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 8px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.lb-close {
  position: absolute; top: max(10px, env(safe-area-inset-top)); right: 10px; z-index: 2;
  font: inherit; font-weight: 600; font-size: 16px; color: #fff;
  background: rgba(255, 255, 255, 0.16); border: 0; border-radius: 999px;
  height: 44px; padding: 0 18px; cursor: pointer;
}
.lb-bar {
  display: flex; align-items: center; justify-content: center; gap: 18px;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom)); font-weight: 600;
}
.lb-bar button {
  font: inherit; font-size: 26px; line-height: 1; color: #fff; background: rgba(255, 255, 255, 0.16);
  border: 0; border-radius: 999px; width: 52px; height: 52px; cursor: pointer;
}
.lb-close:hover, .lb-bar button:hover { background: rgba(255, 255, 255, 0.28); }
.lb-hint { display: none; }

@media (max-width: 560px) {
  /* photo goes edge to edge on phones */
  .gallery { margin: 0 -16px; }
  .gallery-main { border-radius: 0; }
  .gallery-strip { padding: 0 16px 4px; }
  .gallery-thumb { width: 68px; }
  .lb-hint { display: block; text-align: center; color: rgba(255,255,255,0.6); font-size: 13px; margin-top: -4px; padding-bottom: 6px; }
}

/* ---------- Footer ---------- */
.foot { max-width: 1040px; margin: 0 auto; padding: 24px 16px 40px; border-top: 1px solid var(--line); }
.foot p { color: var(--steel); font-size: 14px; max-width: 70ch; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .plate.is-loading .cell { animation: none; }
}