/* =========================================
   Driving simulator page (/cars/drive/)
   Builds on the quiz card / finder styles in site.css.
   ========================================= */

.drive-hero { padding-bottom: 1rem; }
.drive-section { padding-top: 1rem; }
.drive-layout { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 1.25rem; align-items: start; }
.drive-side { display: grid; gap: 1rem; position: sticky; top: 5rem; }
.drive-main { min-width: 0; }

/* Car search */
.drive-pick { position: relative; padding: 1.1rem; }
.drive-pick .quiz-kind { display: block; margin-bottom: 0.5rem; }
.drive-search { margin: 0; max-width: none; }
.drive-list {
  position: absolute; left: 1.1rem; right: 1.1rem; top: calc(100% - 0.6rem); z-index: 30;
  list-style: none; margin: 0; padding: 0.35rem 0; max-height: 320px; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}
.drive-list li { padding: 0.5rem 0.85rem; cursor: pointer; display: flex; flex-direction: column; gap: 0.1rem; }
.drive-list li small { color: var(--text-muted); font-size: 0.78rem; }
.drive-list li:hover, .drive-list li.is-active { background: var(--accent-dim); }
.drive-trim { margin-top: 0.8rem; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; font-size: 0.82rem; color: var(--text-muted); }
.drive-trim > span { width: 100%; }
.drive-trim button {
  flex: 1; padding: 0.45rem 0.6rem; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg-raised); color: var(--text); font: inherit; font-size: 0.85rem; cursor: pointer; text-align: left;
}
.drive-trim button small { display: block; color: var(--text-muted); font-size: 0.75rem; }
.drive-trim button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-dim); }

/* How it drives */
.drive-profile { padding: 1.1rem; }
.drive-name { font-family: 'Space Grotesk', sans-serif; font-size: 1.25rem; line-height: 1.25; margin: 0.2rem 0 0.8rem; }
.drive-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.9rem; margin: 0 0 0.9rem; }
.drive-stats div { min-width: 0; }
.drive-stats dt { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.drive-stats dd { margin: 0; font-weight: 600; font-size: 0.95rem; }
.drive-est { font-weight: 500; color: var(--text-muted); font-size: 0.72rem; }
.drive-notes { list-style: none; margin: 0 0 0.7rem; padding: 0; display: grid; gap: 0.55rem; font-size: 0.86rem; line-height: 1.5; color: var(--text); }
.drive-notes b { color: var(--accent); }
.drive-est-note { font-size: 0.76rem; color: var(--text-muted); margin: 0 0 0.4rem; line-height: 1.5; }
.drive-specs { display: inline-block; margin-top: 0.2rem; text-decoration: none; }

/* Simulator */
.drive-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 320px; max-height: 78vh;
  border-radius: 16px; overflow: hidden; background: #9fc4e8; border: 1px solid var(--border);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.drive-stage canvas { display: block; width: 100%; height: 100%; outline: none; }

.drive-hud { position: absolute; inset: 0; pointer-events: none; font-family: 'Space Grotesk', sans-serif; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.drive-gauge {
  position: absolute; right: 14px; bottom: 14px; padding: 0.6rem 0.85rem; min-width: 150px;
  background: rgba(8, 6, 16, 0.62); border-radius: 12px; backdrop-filter: blur(6px);
}
.drive-speed { display: flex; align-items: baseline; gap: 0.3rem; }
.drive-speed b { font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }
.drive-speed span { font-size: 0.8rem; opacity: 0.8; }
.drive-gear { display: flex; justify-content: space-between; align-items: baseline; margin-top: 0.15rem; }
.drive-gear span { font-size: 1.2rem; font-weight: 700; color: #c4b5fd; }
.drive-gear small { font-size: 0.72rem; opacity: 0.8; font-variant-numeric: tabular-nums; }
.drive-rpm { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.2); margin-top: 0.35rem; overflow: hidden; }
.drive-rpm span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #a78bfa, #60a5fa); transition: width 0.06s linear; }
.drive-rpm span.is-red { background: #ef4444; }

.drive-times {
  position: absolute; left: 14px; top: 14px; display: grid; grid-template-columns: auto auto; gap: 0.15rem 0.9rem;
  padding: 0.55rem 0.8rem; background: rgba(8, 6, 16, 0.55); border-radius: 12px; font-size: 0.8rem; backdrop-filter: blur(6px);
}
.drive-times div { display: contents; }
.drive-times span { opacity: 0.75; }
.drive-times b { font-variant-numeric: tabular-nums; text-align: right; }

.drive-flags { position: absolute; right: 14px; top: 14px; display: flex; gap: 0.4rem; }
.drive-flags span { padding: 0.2rem 0.55rem; border-radius: 6px; font-size: 0.75rem; font-weight: 600; background: rgba(8, 6, 16, 0.55); }
.drive-flags span:empty { display: none; }
#hudTc { color: #fca5a5; }
#hudTc.is-on { color: #86efac; }
#hudWarn { background: rgba(239, 68, 68, 0.8); }

.drive-start {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 1rem;
  background: rgba(8, 6, 16, 0.45); color: #fff; backdrop-filter: blur(2px);
}
.drive-start[hidden] { display: none; }
.drive-start-title { font-family: 'Space Grotesk', sans-serif; font-size: 1.35rem; font-weight: 600; margin: 0 0 0.9rem; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6); }
.drive-start-hint { font-size: 0.82rem; opacity: 0.85; margin: 0.8rem 0 0; }

/* Touch controls */
.drive-touch { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 12px; pointer-events: none; }
.drive-touch[hidden] { display: none; }
.drive-touch > div { display: flex; gap: 10px; pointer-events: auto; }
.drive-touch button {
  width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(8, 6, 16, 0.45); color: #fff; font: 600 0.85rem 'Space Grotesk', sans-serif; touch-action: none;
}
.drive-touch button.is-down { background: rgba(167, 139, 250, 0.7); }
.drive-touch-pedals button { border-radius: 14px; width: 72px; height: 80px; }
.drive-touch:not([hidden]) ~ .drive-hud .drive-gauge { bottom: 104px; }

.drive-controls { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem 1rem; flex-wrap: wrap; margin-top: 0.8rem; }
.drive-keys { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-size: 0.8rem; color: var(--text-muted); }
.drive-keys kbd {
  display: inline-block; min-width: 1.4rem; padding: 0.05rem 0.35rem; margin-right: 0.2rem; text-align: center;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; font: 600 0.72rem 'Inter', sans-serif; color: var(--text);
}
.drive-buttons { display: flex; gap: 1rem; }
.drive-buttons .pick-back { margin: 0; }
.drive-note { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; margin: 0.6rem 0 0; }

@media (max-width: 900px) {
  .drive-layout { grid-template-columns: 1fr; }
  .drive-side { position: static; order: 2; }
  .drive-main { order: 1; }
  .drive-stage { aspect-ratio: 4 / 3; }
}
@media (max-width: 520px) {
  .drive-stage { aspect-ratio: 3 / 4; max-height: 70vh; }
  .drive-speed b { font-size: 2rem; }
  .drive-gauge { min-width: 120px; }
}

/* Theme touches */
[data-theme="light"] .drive-stage { border: 1.5px solid #1c1917; border-radius: 4px; }
[data-theme="light"] .drive-name { font-family: 'Fraunces', Georgia, serif; }
[data-theme="light"] .drive-list { border: 1.5px solid #1c1917; border-radius: 2px; background: #fffdf8; box-shadow: 4px 4px 0 #1c1917; }
html:not([data-theme="light"]):not([data-theme="hud"]) .drive-stage { border-radius: 0; border: 0; border-top: 5px solid var(--livery); }
html:not([data-theme="light"]):not([data-theme="hud"]) .drive-name { font-family: 'Barlow Condensed', sans-serif; font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 1.5rem; }
[data-theme="hud"] .drive-stage { border-color: var(--hud-line); box-shadow: 0 0 24px rgba(166, 107, 255, 0.35); border-radius: 6px; }
[data-theme="hud"] .drive-name { font-family: var(--hud-font); letter-spacing: 0.03em; }
[data-theme="hud"] .drive-hud { font-family: var(--hud-font); }
[data-theme="hud"] .drive-stats dt { font-family: var(--hud-font); letter-spacing: 0.14em; }
