/* ==========================================================================
   Car choice (E1): the plate lookup form and the site-wide car dialog.
   Markup: partials/_vehicle_lookup.php, partials/_car_picker.php.
   Behaviour: assets/js/sp/car-picker.js. The home hero layout of the form
   lives in sp/pages/home.css.
   ========================================================================== */

/* --- Plate lookup form, shared by both placements ---------------------- */
.sp-lookup { min-width: 0; }
.sp-lookup-plate { position: relative; }
.sp-lookup-plate input { width: 100%; }
/* The plate clips the global focus outline into a stripe beside the badge; the plate's own ring marks focus */
body.sp .sp-lookup-plate input:focus-visible { outline: none; }
/* The visible placeholder is a span so it can fade between reg and VIN */
.sp-lookup-plate input::placeholder { color: transparent; }
.sp-lookup-ph {
    position: absolute; left: 50px; right: 0; top: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center;
    pointer-events: none; color: var(--sp-ink-faint); white-space: nowrap; overflow: hidden;
    font: 600 clamp(26px, 5.6vw, 36px) var(--sp-font-plate); letter-spacing: .04em; text-transform: uppercase;
}
.sp-lookup-plate:has(input:not(:placeholder-shown)) .sp-lookup-ph { display: none; }
.sp-lookup-reg { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.sp-lookup-vin { width: 27px; height: 27px; }
.sp-lookup-plate .sp-plate-eu { transition: background-color 420ms ease; }
.sp-lookup-plate.is-vin .sp-plate-eu { background: var(--sp-t3); }
.sp-lookup-plate.has-vin input { font-size: clamp(18px, 3vw, 26px); letter-spacing: .015em; }
.sp-lookup-plate.is-static .sp-lookup-ph { font-size: clamp(18px, 4.8vw, 30px); letter-spacing: .01em; text-transform: none; }
.sp-lookup-go .sp-spinner { width: 20px; height: 20px; }
.sp-lookup-go-icon { display: inline-flex; }
.sp-lookup-msg { margin: 10px 0 0; font-size: var(--sp-fs-ui); line-height: 1.45; color: var(--sp-bad); }
.sp-lookup-msg p { margin: 0; }
.sp-lookup-msg.is-not-found { color: var(--sp-ink); overflow-wrap: anywhere; }
.sp-lookup-msg.is-not-found > p:first-child { font-weight: 600; }
.sp-lookup-msg .sp-lookup-help { margin-top: 6px; color: var(--sp-ink-soft); }
.sp-lookup-brands { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.sp-lookup-brands .sp-pill { min-height: var(--sp-hit); gap: 8px; }
.sp-car-picker-find:has(.sp-lookup[data-not-found]) > :is(.sp-car-picker-or, .sp-btn) { display: none; }

/* Dialog placement: compact plate, full-width button */
.sp-lookup--dialog .sp-lookup-box { display: grid; gap: 14px; }
.sp-lookup--dialog .sp-plate { height: 62px; border-radius: var(--sp-r-sm); box-shadow: inset 0 0 0 1px var(--sp-line-strong); background: var(--sp-surface); }
.sp-lookup--dialog .sp-plate:focus-within { box-shadow: inset 0 0 0 2px var(--sp-t3); }
.sp-lookup--dialog .sp-plate-eu { width: 40px; }
.sp-lookup--dialog .sp-plate-eu svg { width: 15px; height: 15px; }
.sp-lookup--dialog .sp-lookup-ph { left: 40px; justify-content: flex-start; padding-left: 14px; font-size: 25px; letter-spacing: .025em; }
.sp-lookup--dialog .sp-plate input { text-align: left; padding: 0 14px; font-size: 25px; letter-spacing: .025em; }
.sp-lookup--dialog .sp-lookup-plate.has-vin input { font-size: 20px; }
.sp-lookup--dialog .sp-lookup-go { width: 100%; min-height: 52px; font-size: var(--sp-fs-body); }

/* --- Car dialog --------------------------------------------------------- */
.sp-car-picker { color: var(--sp-ink); }
.sp-car-picker { flex-direction: column; }
.sp-car-picker[open] { display: flex; }
.sp-car-picker[data-view="manual"] { height: min(740px, calc(100dvh - 32px)); overflow: hidden; }
/* Mid-slide (car-picker.js move()): the leaving pane is a still copy laid over its old place */
.sp-car-picker.is-moving { overflow: hidden; }
/* Two classes: must beat .sp-car-picker-scroll's position: relative when the list is the ghost. */
.sp-car-picker > .sp-car-picker-ghost { position: absolute; margin: 0; pointer-events: none; }
.sp-car-picker .sp-dialog-head { flex: none; margin-bottom: 18px; }
.sp-car-picker .sp-dialog-x { flex: none; }

/* "Mina bilar": one row per remembered car, the active one marked */
.sp-car-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.sp-car-row { border-radius: var(--sp-r-sm); background: var(--sp-surface); }
.sp-car-row.is-active { background: var(--sp-paper); box-shadow: inset 0 0 0 1px var(--sp-t3); }
.sp-car-row-pick {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 12px 14px 4px;
    border: 0; border-radius: var(--sp-r-sm) var(--sp-r-sm) 0 0; background: none; color: var(--sp-ink);
    font: inherit; text-align: left; cursor: pointer;
}
/* "Ingen bil" and the car on screen have no tools row under them: centre the content */
.sp-car-row-pick:last-child { padding-bottom: 12px; border-radius: var(--sp-r-sm); }
.sp-car-row-media { display: grid; justify-items: center; align-content: center; gap: 4px; flex: none; width: 112px; }
.sp-car-row-photo { display: grid; place-items: center; width: 100%; height: 56px; }
.sp-car-row-photo img { display: block; width: 100%; height: auto; -webkit-mask-image: linear-gradient(#000 94%, transparent); mask-image: linear-gradient(#000 94%, transparent); }
.sp-car-row-photo [hidden] { display: none; }
.sp-car-row-name { display: grid; justify-items: start; gap: 3px; flex: 1; min-width: 0; }
.sp-car-row-media + .sp-car-row-name { align-self: flex-start; padding-top: 8px; }
.sp-car-row-media .sp-plate-badge { font-size: 15px; line-height: 24px; }
@media (max-width: 600px) {
    .sp-car-row-media { width: 80px; }
    .sp-car-row-photo { height: 40px; }
    .sp-car-row-pick:has(.sp-car-row-photo) { gap: 10px; }
}
.sp-car-row-name strong { font-weight: 600; overflow-wrap: anywhere; }
.sp-car-row-name small { font-size: var(--sp-fs-xs); color: var(--sp-ink-soft); }
.sp-car-row-name small:empty { display: none; }
.sp-car-row-check { width: 20px; height: 20px; flex: none; color: var(--sp-t3); }
.sp-car-row-tools { display: flex; justify-content: flex-end; gap: 4px 18px; padding: 0 14px 4px; }
.sp-car-row-tools .sp-link { display: inline-flex; align-items: center; min-height: 36px; font-size: var(--sp-fs-sm); }
.sp-car-row-remove { color: var(--sp-ink-soft); }
/* Stays at the bottom of the dialog however long the list is. The negative margins reach
   the dialog's padding so rows scroll away under a solid edge. */
.sp-car-picker-add-bar {
    position: sticky; bottom: -28px; z-index: 1;
    margin: 0 -28px -28px; padding: 16px 28px 28px; background: var(--sp-paper);
}
@media (max-width: 700px) {
    .sp-car-picker-add-bar { bottom: -20px; margin: 0 -20px -20px; padding: 12px 20px 20px; }
}
.sp-car-picker-add { min-height: 52px; font-size: var(--sp-fs-body); gap: 8px; }
.sp-car-picker-add svg { width: 18px; height: 18px; }
.sp-car-picker-account { display: flex; justify-content: center; align-items: center; min-height: var(--sp-hit); margin-top: 6px; font-size: var(--sp-fs-ui); }

.sp-car-picker-or { display: flex; align-items: center; gap: 15px; margin: 20px 0; color: var(--sp-ink-soft); font-size: var(--sp-fs-sm); }
.sp-car-picker-or::before, .sp-car-picker-or::after { content: ""; flex: 1; height: 1px; background: var(--sp-line); }
.sp-car-picker-find .sp-btn--soft { font-size: var(--sp-fs-body); min-height: 52px; }

/* Manual steps: header block, scrolling choices, sticky footer */
.sp-car-picker-manual { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sp-car-picker-content { flex: none; outline: none; }
.sp-car-picker-progress { margin: 0 0 4px; font-size: var(--sp-fs-xs); color: var(--sp-ink-soft); }
.sp-car-picker-step { margin: 0 0 14px; font-size: 23px; line-height: 1.2; font-weight: 600; letter-spacing: -.02em; }
.sp-car-picker-pills { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 12px; }
/* Not x-show: Alpine shows on a timeout, after move() has measured where the list sits. */
.sp-car-picker-pills:not(:has(.sp-pill)) { display: none; }
.sp-car-picker-pills .sp-pill { min-height: 36px; font-size: var(--sp-fs-sm); }
.sp-car-picker-pills .sp-pill svg { width: 14px; height: 14px; color: var(--sp-ink-soft); }

.sp-car-picker-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; margin: 14px -3px 0; padding: 3px; }
.sp-car-picker-filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sp-car-picker-filters .sp-segment > button { min-height: 40px; padding: 0 16px; font-size: var(--sp-fs-body); }
.sp-car-picker-reg { font-size: var(--sp-fs-sm); min-height: var(--sp-hit); text-align: right; }

.sp-car-picker-older { display: inline-flex; align-items: center; gap: 8px; min-height: var(--sp-hit); margin-bottom: 8px; }
.sp-car-picker-older svg { width: 18px; height: 18px; }
.sp-car-picker-years { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.sp-car-picker-list { display: grid; gap: 8px; }
.sp-car-picker-choice {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 12px 14px;
    border: 0; border-radius: var(--sp-r-sm); background: var(--sp-surface); color: var(--sp-ink);
    font: 500 var(--sp-fs-body)/1.35 var(--sp-font); text-align: left; cursor: pointer;
    transition: background var(--sp-fast);
}
.sp-car-picker-choice:hover { background: var(--sp-t1); }
.sp-car-picker-choice[aria-pressed="true"] { background: var(--sp-paper); box-shadow: inset 0 0 0 1px var(--sp-t3); }
.sp-car-picker-choice:disabled { cursor: progress; }
.sp-car-picker-choice-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sp-car-picker-choice small { flex: none; font-size: var(--sp-fs-xs); color: var(--sp-ink-soft); white-space: nowrap; }
.sp-car-picker-chev { width: 18px; height: 18px; flex: none; color: var(--sp-ink-soft); }
.sp-car-picker-years .sp-car-picker-choice { justify-content: center; min-height: 46px; padding: 10px 6px; text-align: center; font-variant-numeric: tabular-nums; }
.sp-car-picker-years .sp-car-picker-choice-name { flex: none; }
.sp-car-picker-years .sp-car-picker-chev { display: none; }
.sp-car-picker-empty { margin: 8px 0; font-size: var(--sp-fs-sm); color: var(--sp-ink-soft); }
.sp-car-picker-scroll .sp-notice { margin-top: 8px; }
.sp-car-picker-loading {
    position: absolute; inset: 0; display: grid; place-items: start center; padding-top: 48px;
    background: color-mix(in srgb, var(--sp-paper) 65%, transparent); color: var(--sp-t3);
}

.sp-car-picker-foot { flex: none; display: grid; gap: 4px; padding-top: 14px; }
.sp-car-picker-foot .sp-btn--quiet { min-height: 46px; color: var(--sp-action); }
.sp-car-picker-finish { justify-self: center; min-height: 40px; font-size: var(--sp-fs-ui); }
.sp-car-picker-hint { margin: 4px 0 0; font-size: var(--sp-fs-sm); color: var(--sp-ink-soft); text-align: center; }

@media (max-width: 700px) {
    .sp-car-picker[data-view="manual"] { height: calc(100dvh - 24px); }
    .sp-car-picker-years { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sp-car-picker-step { font-size: 20px; }
    .sp-lookup--dialog .sp-plate input, .sp-lookup--dialog .sp-lookup-ph { font-size: 21px; }
}
@media (max-width: 359px) {
    .sp-car-picker-filters { flex-wrap: wrap; }
    .sp-car-picker-years .sp-car-picker-choice { font-size: var(--sp-fs-ui); }
}
@media (prefers-reduced-motion: reduce) {
    .sp-lookup-plate .sp-plate-eu { transition: none; }
}

/* --- Vehicle bar: the page shows another car than the active one, or no car is active ---- */
.sp-vehicle-bar.is-mismatch, .sp-vehicle-bar.is-unsaved { background: var(--sp-t1); }
.sp-vehicle-shown { display: flex; align-items: center; gap: 10px 14px; min-width: 0; }
.sp-vehicle-shown > svg { width: 18px; height: 18px; flex: none; color: var(--sp-t3); }
.sp-vehicle-shown p { margin: 0; line-height: 1.3; overflow-wrap: anywhere; }
.sp-vehicle-shown strong { font-weight: 600; }
.sp-vehicle-shown small { display: block; font-size: var(--sp-fs-xs); color: var(--sp-ink-soft); }
.sp-vehicle-save { flex: none; min-height: 38px; padding: 0 14px; font-size: 13.5px; }
.is-mismatch .sp-vehicle-mine { padding-left: 20px; border-left: 1px solid var(--sp-line-strong); }
.is-mismatch .sp-vehicle-name strong { font-weight: 500; color: var(--sp-ink-soft); }
.is-mismatch .sp-vehicle-go, .is-mismatch .sp-car-glyph { background: var(--sp-paper); }
@media (max-width: 700px) {
    .sp-vehicle-bar.is-mismatch .sp-vehicle-inner { flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
    .is-mismatch .sp-vehicle-shown { flex: 1 1 100%; justify-content: space-between; }
    .is-mismatch .sp-vehicle-mine { padding-left: 0; border-left: 0; }
    .sp-vehicle-shown p { font-size: 13.5px; }
    .sp-vehicle-save { min-height: 40px; padding: 0 12px; }
}
