/* ==========================================================================
   MY GARAGE — NFS Most Wanted inspired styling
   ========================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* highlight colour — black, with a hairline + light ink so it still reads
     against the dark chrome of the UI */
  --accent: #000000;
  --accent-2: #17191d;
  --accent-ink: #ffffff;
  --accent-edge: rgba(255, 255, 255, .30);
  --panel: #22262b;
  --panel-2: #1a1d21;
  --line: #3a4048;
  --ink: #e8eaed;
  --muted: #9aa1ab;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

html, body {
  height: 100%;
  background: #101216;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font-family: inherit; }

.hidden { display: none !important; }

/* ======================= LOADER ======================= */

.loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, #23272e 0%, #0e1013 55%, #050607 100%);
  transition: opacity .5s ease, visibility .5s ease;
}
.loader.done { opacity: 0; visibility: hidden; }

.loader-slash {
  position: absolute;
  top: -10%; left: -20%;
  width: 90%;
  height: 42px;
  background: linear-gradient(90deg, #f2f3f5, rgba(201, 204, 210, 0));
  transform: skewX(-32deg) rotate(-8deg);
  opacity: .10;
}

.loader-inner {
  width: min(560px, calc(100vw - 44px));
  padding: 0 4px;
}

.loader-kicker {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .34em;
}
.loader-title {
  color: var(--accent);
  -webkit-text-stroke: 1.5px rgba(255, 255, 255, .62);
  text-shadow: 0 4px 30px rgba(0, 0, 0, .9);
  font-size: clamp(40px, 9vw, 62px);
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  letter-spacing: .02em;
  margin: 2px 0 22px;
}

/* --- per-car rows --- */
.loader-list { margin-bottom: 20px; }
.load-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  padding: 9px 2px;
  font-size: 12px;
  font-weight: 700;
  font-style: italic;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #6d747e;
  transition: color .25s ease;
}
.load-row.active { color: var(--ink); }
.load-row.ready  { color: var(--ink); }
.load-state { font-style: normal; letter-spacing: .1em; font-size: 11px; color: var(--muted); }
.load-row.ready .load-state { color: #fff; }
.load-row.ready .load-state::before { content: '✓ '; }
.load-row.failed .load-state { color: #d98b8b; }

/* --- master bar --- */
.loader-bar {
  height: 14px;
  background: linear-gradient(#8d949e, #666d77);
  border: 1px solid #9aa1ab;
  transform: skewX(-24deg);
  overflow: hidden;
}
.loader-fill {
  display: block;
  height: 100%;
  width: 0%;
  background:
    repeating-linear-gradient(115deg,
      var(--accent) 0 14px,
      var(--accent-2) 14px 28px);
  background-size: 56px 100%;
  animation: loader-stripes 1s linear infinite;
  transition: width .28s ease-out;
}
@keyframes loader-stripes {
  from { background-position: 0 0; }
  to   { background-position: 56px 0; }
}

.loader-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2em;
}
#loader-pct { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .loader-fill { animation: none; }
}

/* ======================= GARAGE ======================= */

#garage {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(160deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0) 34%),
    linear-gradient(#15181c, #0d0f12);
  padding-bottom: 84px;
}

/* --- top bar --- */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 16px 10px;
}
.topbar-slash {
  position: absolute;
  top: 0; left: -40px;
  width: 46%;
  height: 30px;
  background: linear-gradient(90deg, #f2f3f5, #c9ccd2);
  transform: skewX(-32deg);
  opacity: .92;
}
.topbar-chip, .topbar-money {
  background: linear-gradient(#3a3f46, #23272d);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  padding: 7px 16px;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}
.topbar-money {
  background: linear-gradient(#f2f3f5, #cfd3d9);
  color: #16181c;
}

/* --- title --- */
.title-block { padding: 10px 20px 6px; }
.title-block h1 {
  color: var(--accent);
  -webkit-text-stroke: 1.5px rgba(255, 255, 255, .62);
  text-shadow: 0 4px 26px rgba(0, 0, 0, .9);
  font-size: clamp(38px, 8vw, 56px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: .02em;
  line-height: .95;
  text-transform: uppercase;
}
.subtitle {
  color: #cfd3d9;
  font-size: clamp(18px, 4vw, 26px);
  font-weight: 300;
  letter-spacing: .22em;
}

/* --- card grid --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
  gap: 14px;
  padding: 14px 16px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

.card {
  position: relative;
  display: block;
  border: 1px solid var(--line);
  outline: 1px solid #0a0b0d;
  background:
    radial-gradient(120% 90% at 50% 20%, #2e3238 0%, #1c1f24 60%, #131519 100%);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card:hover, .card:focus-visible {
  transform: translateY(-3px);
  border-color: #6b7280;
  box-shadow: 0 10px 30px rgba(0,0,0,.5), 0 0 0 1px var(--accent-edge);
}
.card:active { transform: translateY(-1px) scale(.99); }

.card-img {
  display: block;
  width: 100%;
  aspect-ratio: 8 / 5;
  object-fit: cover;
}

.card-name {
  position: absolute;
  top: 10px; left: 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  font-style: italic;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-shadow: 0 1px 3px rgba(0,0,0,.8);
}
.card-name em { color: var(--muted); font-style: italic; }

.card-plate {
  position: absolute;
  left: 0; bottom: 10px;
  background: linear-gradient(#41464e, #26292f);
  border-top: 1px solid #565c66;
  color: #f2f3f5;
  font-size: 15px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: .06em;
  padding: 6px 26px 6px 14px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
}

.card-badge {
  position: absolute;
  top: 0; right: 0;
  z-index: 2;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-edge);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
  padding: 5px 12px 5px 18px;
  clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%);
}

/* --- drag & drop a .glb onto a card --- */
.card-drop {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .72);
  border: 2px dashed var(--accent-edge);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .2em;
  z-index: 3;
}
.card.dropping .card-drop { display: flex; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(680px, calc(100vw - 32px));
  background: var(--accent);
  border: 1px solid var(--accent-edge);
  color: var(--accent-ink);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 10px 18px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .7);
}

/* --- bottom nav (decorative) --- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 64px;
  display: flex;
  background: linear-gradient(#f4f5f7, #d4d7dc);
  box-shadow: 0 -6px 24px rgba(0,0,0,.55);
}
.nav-seg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(0,0,0,.15);
  transform: skewX(-18deg);
  margin: 0 -6px;
}
.nav-seg svg { width: 26px; height: 26px; fill: #3c4149; transform: skewX(18deg); }
.nav-seg.active { background: var(--accent); }
.nav-seg.active svg { fill: var(--accent-ink); }

/* ======================= 3D SHOWROOM ======================= */

#detail {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, #262a30 0%, #101216 55%, #07080a 100%);
  overflow: hidden;
}

#stage-wrap { position: absolute; inset: 0; touch-action: none; cursor: grab; }
#stage-wrap:active { cursor: grabbing; }
#stage { width: 100%; height: 100%; display: block; }

#back-btn {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
  background: linear-gradient(#3a3f46, #23272d);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .14em;
  padding: 10px 22px;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  cursor: pointer;
}
#back-btn:hover { background: var(--accent); border-color: var(--accent-edge); color: var(--accent-ink); }

/* --- previous / next car --- */
.car-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 18px 14px;
  cursor: pointer;
  color: var(--muted);
  opacity: .45;
  transition: opacity .2s ease, color .2s ease;
}
.car-nav-prev { left: 2px; }
.car-nav-next { right: 2px; }
.car-nav:hover, .car-nav:focus-visible { opacity: 1; color: #fff; }

.car-nav-arrow {
  font-size: 24px;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .9);
}
.car-nav-label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: .16em;
  text-transform: uppercase;
  text-shadow: 0 2px 10px rgba(0, 0, 0, .9);
  transition: max-width .3s ease;
}
.car-nav:hover .car-nav-label,
.car-nav:focus-visible .car-nav-label { max-width: 220px; }

.detail-title {
  position: absolute;
  left: 20px;
  bottom: max(56px, calc(env(safe-area-inset-bottom) + 46px));
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0,0,0,.8);
}
.d-make {
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .3em;
}
.detail-title h2 {
  color: #fff;
  font-size: clamp(34px, 7vw, 58px);
  font-weight: 900;
  font-style: italic;
  line-height: 1;
  text-transform: uppercase;
}
.d-tagline {
  display: inline-block;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent-edge);
  color: var(--accent-ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .22em;
  padding: 4px 12px;
  margin-top: 8px;
}
.d-owned {
  display: inline-block;
  margin-top: 10px;
  background: linear-gradient(#f2f3f5, #cfd3d9);
  color: #16181c;
  font-size: 14px;
  font-weight: 800;
  font-style: italic;
  padding: 5px 20px 5px 12px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
}

/* --- spec sheet --- */
.spec-sheet {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 56px;              /* leaves the right edge free for the next-car arrow */
  width: min(320px, calc(100vw - 70px));
  max-height: calc(100dvh - 130px);
  overflow-y: auto;
  background: linear-gradient(rgba(26,29,33,.92), rgba(16,18,21,.92));
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.spec-head {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-bottom: 1px solid var(--accent-edge);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .22em;
  padding: 8px 14px;
}

.bars { padding: 12px 14px 4px; }
.bar-row {
  display: grid;
  grid-template-columns: 108px 1fr;
  align-items: center;
  gap: 10px;
  margin-bottom: 9px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--muted);
}
/* track is light so the black fill reads against it */
.bar {
  height: 7px;
  background: linear-gradient(#8d949e, #666d77);
  border: 1px solid #9aa1ab;
  transform: skewX(-24deg);
  overflow: hidden;
  display: block;
}
.bar-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
}

.facts { padding: 6px 14px 10px; }
.fact {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: 13px;
}
.fact:last-child { border-bottom: none; }
/* ownership rows sit slightly apart from the technical specs */
.fact-split { border-top: 1px solid rgba(255,255,255,.16); margin-top: 8px; padding-top: 11px; }
.fact span { color: var(--muted); }
.fact strong { font-weight: 700; text-align: right; }

/* --- collapsed extra specs --- */
.facts-extra {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  transition: max-height .3s ease, padding-bottom .3s ease;
}
.spec-sheet.expanded .facts-extra {
  max-height: 460px;
  padding-bottom: 8px;
}

.facts-toggle {
  display: block;
  width: calc(100% - 28px);
  margin: 2px 14px 12px;
  background: linear-gradient(#31353c, #21252a);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .2em;
  padding: 7px 10px;
  clip-path: polygon(7px 0, 100% 0, calc(100% - 7px) 100%, 0 100%);
  cursor: pointer;
  transition: color .18s ease, background .18s ease;
}
.facts-toggle:hover, .facts-toggle:focus-visible {
  background: var(--accent);
  color: var(--accent-ink);
}

.story {
  padding: 4px 14px 14px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.drag-hint {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  text-align: center;
  color: #6b727c;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .18em;
  pointer-events: none;
}

/* --- mobile: spec sheet becomes a compact bottom-right panel --- */
@media (max-width: 700px) {
  .spec-sheet {
    top: auto;
    bottom: max(40px, calc(env(safe-area-inset-bottom) + 30px));
    right: 10px;
    width: min(230px, 58vw);
    max-height: 53dvh;      /* the collapsed sheet fits without scrolling */
    font-size: 12px;
  }
  .bar-row { grid-template-columns: 86px 1fr; font-size: 9.5px; }
  .fact { font-size: 11.5px; }
  .detail-title { left: 12px; bottom: max(44px, calc(env(safe-area-inset-bottom) + 34px)); max-width: 35vw; }
  .facts-toggle { padding: 11px 10px; }        /* comfortable tap target */
  /* long names ("A3 Sportback") have to fit beside the spec sheet */
  .detail-title h2 { font-size: clamp(22px, 6vw, 34px); overflow-wrap: anywhere; }
  .d-make { font-size: 11px; letter-spacing: .22em; }
  .d-tagline { font-size: 11px; letter-spacing: .14em; padding: 3px 8px; }
  .d-owned { font-size: 12px; }
  .story { font-size: 11px; }
  .drag-hint .hint-drop { display: none; }
  /* sit above the spec sheet, and drop the name — there's no hover to reveal it */
  .car-nav { top: 30%; padding: 14px 10px; opacity: .55; }
  .car-nav-label { display: none; }
}
