/* ============================================================== *
 *  components.css — shared building blocks reused across views:
 *  SVG car silhouettes, photo+fallback media, the modal, specs, stats.
 * ============================================================== */

/* ---- hand-drawn car silhouettes (js/svg.js) ---- */
.car-svg { width: 100%; height: auto; overflow: visible; color: var(--accent); }
.car-body {
  fill: color-mix(in srgb, var(--accent) 16%, transparent);
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-linejoin: round;
}
.car-line { stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; opacity: 0.55; fill: none; }
.car-tyre { fill: #0b0b0f; stroke: var(--accent); stroke-width: 2.4; }
.car-rim { fill: none; stroke: var(--accent); stroke-width: 1.4; opacity: 0.5; }
.car-hub { fill: var(--accent); }
.car-spoke { stroke: var(--accent); stroke-width: 1.2; opacity: 0.6; }
.car-shadow ellipse { fill: #000; opacity: 0.32; }

/* ---- per-brand emblem badges (svg.js) ---- */
.brand-badge { width: 100%; height: auto; color: var(--accent); }
.bdg-shape { fill: color-mix(in srgb, var(--accent) 12%, transparent); stroke: var(--accent); stroke-width: 2.4; }
.bdg-ring { fill: none; stroke: var(--accent); stroke-width: 1.4; opacity: 0.45; }
.bdg-mono { fill: var(--accent); font-family: var(--font-display); font-weight: 700; }

/* ---- photo with silhouette fallback (svg.js) ---- */
.media {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--ink-800), var(--ink-900));
}
.media__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media--fallback {
  display: grid;
  place-items: center;
  padding: 12% 8%;
  background:
    radial-gradient(120% 90% at 50% 18%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    linear-gradient(160deg, var(--ink-800), var(--ink-950));
}
.media--fallback::after {
  content: 'illustration';
  position: absolute;
  bottom: 0.7rem; right: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-lo);
}
.media__svg { width: min(82%, 360px); }

/* ============================================================== *
 *  Modal
 * ============================================================== */

html.is-modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 4vw, 2.5rem);
  background: rgba(4, 4, 7, 0.66);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease-out);
}
.modal-overlay.is-open { opacity: 1; }

.modal {
  position: relative;
  width: min(680px, 100%);
  max-height: min(90dvh, 880px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--ink-850);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, 0.9);
  transform: translateY(18px) scale(0.985);
  transition: transform var(--t-med) var(--ease-out);
}
.modal-overlay.is-open .modal { transform: none; }

.modal__close {
  position: absolute;
  top: 0.9rem; right: 0.9rem;
  z-index: 3;
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--text-hi);
  background: rgba(8, 8, 12, 0.55);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  transition: background var(--t-fast), transform var(--t-fast);
}
.modal__close svg { width: 20px; height: 20px; }
.modal__close:hover { background: var(--accent); color: #07080a; transform: rotate(90deg); }

.modal__media {
  width: 100%;
  aspect-ratio: 16 / 9;
  flex: none;
  background: radial-gradient(120% 100% at 50% 30%, var(--ink-800), var(--ink-950));
}
/* show the whole car rather than cropping it */
.modal__media .media__img { aspect-ratio: auto; object-fit: contain; }

.modal__body { display: contents; }

.modal__info {
  flex: 1;
  padding: clamp(1.4rem, 3vw, 2.4rem);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.modal__year {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 0.1em;
}
.modal__name { font-size: clamp(1.8rem, 4vw, 2.5rem); color: var(--text-hi); }
.modal__blurb { color: var(--text-mid); font-size: 1.02rem; }

.spec-grid {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.spec { background: var(--ink-850); padding: 0.85rem 1rem; }
.spec dt { font-family: var(--font-mono); font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-lo); }
.spec dd { font-family: var(--font-mono); font-weight: 700; font-size: 1.05rem; color: var(--text-hi); margin-top: 0.25rem; }

.modal__trivia {
  margin-top: 0.4rem;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.95rem;
  color: var(--text-mid);
}
.modal__trivia span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.35rem;
}


/* ============================================================== *
 *  Stat number (count-up)
 * ============================================================== */

.stat { display: flex; flex-direction: column; gap: 0.2rem; }
.stat__num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(1.4rem, 3.4vw, 2rem);
  color: var(--text-hi);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat__label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-lo);
}
