/* ============================================================
   DB CARS — shared styles
   Black / scarlet / brushed-silver system derived from the DB logo.
   Square geometry, hairline borders, no drop shadows on surfaces.
   ============================================================ */

html {
    scroll-behavior: smooth;
    scroll-padding-top: 96px;
    /* Belt and braces: overflow-x on body alone still lets the root scroll
       sideways when a full-bleed band overshoots by a pixel or two. */
    overflow-x: hidden;
}

body {
    background-color: #050505;
    color: #C4C5C7;
    overflow-x: hidden;
}

button,
[role="button"],
select,
summary,
label[for],
.cursor-pointer {
    cursor: pointer;
}

::selection {
    background: #C91600;
    color: #fff;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0A0A0A;
}

::-webkit-scrollbar-thumb {
    background: #2a2a2a;
    border: 2px solid #0A0A0A;
}

::-webkit-scrollbar-thumb:hover {
    background: #C91600;
}

:focus-visible {
    outline: 2px solid #FF4A33;
    outline-offset: 3px;
}

/* ---------- texture layers ---------- */

/* Film grain over everything — stops the large dark surfaces reading as flat black */
.grain::after {
    content: "";
    position: fixed;
    inset: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 90;
    opacity: 0.05;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Brushed-metal panel — the showroom counterpart to a workshop's carbon weave */
.brushed {
    background-color: #0C0C0C;
    background-image:
        repeating-linear-gradient(90deg,
            rgba(255, 255, 255, 0.022) 0px,
            rgba(255, 255, 255, 0.022) 1px,
            transparent 1px,
            transparent 3px),
        repeating-linear-gradient(90deg,
            rgba(255, 255, 255, 0.04) 0px,
            rgba(255, 255, 255, 0.04) 1px,
            transparent 1px,
            transparent 11px),
        linear-gradient(180deg, #121212 0%, #0A0A0A 55%, #101010 100%);
}

/* Asphalt — lane-marking diagonal for full-bleed bands */
.asphalt {
    background-color: #090909;
    background-image:
        repeating-linear-gradient(115deg,
            rgba(255, 255, 255, 0.014) 0 2px,
            transparent 2px 9px),
        radial-gradient(ellipse at 50% 0%, rgba(201, 22, 0, 0.10), transparent 62%);
}

/* Hairline used across the site instead of shadows */
.hairline {
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Viewfinder corner brackets */
.corner-frame {
    position: relative;
}

.corner-frame::before,
.corner-frame::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border-color: #C91600;
    border-style: solid;
    z-index: 2;
    pointer-events: none;
}

.corner-frame::before {
    top: -1px;
    left: -1px;
    border-width: 2px 0 0 2px;
}

.corner-frame::after {
    bottom: -1px;
    right: -1px;
    border-width: 0 2px 2px 0;
}

/* Outline / ghost display text */
.text-outline {
    -webkit-text-stroke: 1px rgba(255, 255, 255, 0.28);
    color: transparent;
}

.text-outline-red {
    -webkit-text-stroke: 1px rgba(255, 74, 51, 0.6);
    color: transparent;
}

.text-ghost {
    -webkit-text-stroke: 1px rgba(255, 255, 255, 0.07);
    color: transparent;
    user-select: none;
    pointer-events: none;
}

/* Polished-chrome display text — the DB showroom signature.
   background-clip needs a painted background, so the fallback colour
   below only shows on engines without it. */
.text-chrome {
    color: #E8E9EB;
    background: linear-gradient(176deg,
            #FFFFFF 0%,
            #C8CACD 22%,
            #6E7175 44%,
            #F2F3F5 52%,
            #9A9DA1 62%,
            #4A4D51 82%,
            #D6D8DB 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Diagonal scarlet hazard tape strip */
.hazard {
    background: repeating-linear-gradient(-45deg,
            #C91600 0 14px,
            #050505 14px 28px);
}

/* Number-plate badge — SA plates are white-on-blue at the tag end */
.plate {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #F3F4F5;
    color: #101114;
    font-family: "Chakra Petch", monospace;
    font-weight: 700;
    letter-spacing: 0.14em;
    padding: 5px 10px 5px 0;
    border: 2px solid #26282C;
}

.plate::before {
    content: "ZA";
    background: #1D4ED8;
    color: #fff;
    align-self: stretch;
    display: flex;
    align-items: center;
    padding: 0 6px;
    font-size: 10px;
    letter-spacing: 0.1em;
}

/* ---------- motion ---------- */

/* Scroll reveal — hidden states gated behind html.js so content stays
   visible if JavaScript never runs */
html.js [data-reveal] {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1), transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

html.js [data-reveal].is-visible {
    opacity: 1;
    transform: none;
}

html.js [data-reveal="left"] {
    transform: translateX(-36px);
}

html.js [data-reveal="right"] {
    transform: translateX(36px);
}

html.js [data-reveal="scale"] {
    transform: scale(0.94);
}

/* Staggered children — parent carries data-reveal-group */
html.js [data-reveal-group]>* {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

html.js [data-reveal-group].is-visible>* {
    opacity: 1;
    transform: none;
}

html.js [data-reveal-group].is-visible>*:nth-child(1) { transition-delay: 0s; }
html.js [data-reveal-group].is-visible>*:nth-child(2) { transition-delay: 0.07s; }
html.js [data-reveal-group].is-visible>*:nth-child(3) { transition-delay: 0.14s; }
html.js [data-reveal-group].is-visible>*:nth-child(4) { transition-delay: 0.21s; }
html.js [data-reveal-group].is-visible>*:nth-child(5) { transition-delay: 0.28s; }
html.js [data-reveal-group].is-visible>*:nth-child(6) { transition-delay: 0.35s; }

/* Hero headline line mask */
.line-mask {
    display: block;
    overflow: hidden;
    /* tight display line-heights clip glyph descenders without this compensation */
    padding-bottom: 0.08em;
    margin-bottom: -0.08em;
}

html.js .line-mask>span {
    display: block;
    transform: translateY(110%);
    transition: transform 1s cubic-bezier(0.16, 1, 0.3, 1);
}

html.js.loaded .line-mask>span {
    transform: none;
}

html.js.loaded .line-mask:nth-child(2)>span { transition-delay: 0.1s; }
html.js.loaded .line-mask:nth-child(3)>span { transition-delay: 0.2s; }

/* Marquee */
.marquee {
    overflow: hidden;
    white-space: nowrap;
    display: flex;
}

.marquee-track {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    min-width: 100%;
    animation: marquee 30s linear infinite;
}

.marquee:hover .marquee-track {
    animation-play-state: paused;
}

@keyframes marquee {
    from { transform: translateX(0); }
    to { transform: translateX(-100%); }
}

/* Slow spin (decor rings) */
@keyframes spin-slow {
    to { transform: rotate(360deg); }
}

.spin-slow {
    animation: spin-slow 14s linear infinite;
}

/* Scroll cue */
@keyframes cue {
    0%, 100% { transform: translateY(0); opacity: 1; }
    50% { transform: translateY(10px); opacity: 0.4; }
}

.scroll-cue {
    animation: cue 1.8s ease-in-out infinite;
}

/* Scarlet pulse dot (live-stock feel) */
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(201, 22, 0, 0.55); }
    60% { box-shadow: 0 0 0 9px rgba(201, 22, 0, 0); }
}

.pulse-dot {
    animation: pulse-dot 1.6s ease-out infinite;
}

/* Underline sweep for links */
.link-sweep {
    position: relative;
}

.link-sweep::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    height: 2px;
    width: 100%;
    background: #C91600;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.link-sweep:hover::after,
.link-sweep:focus-visible::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* ---------- buttons ---------- */

.btn-red {
    position: relative;
    overflow: hidden;
    background: #C91600;
    color: #fff;
    transition: color 0.3s;
    isolation: isolate;
}

.btn-red::before {
    content: "";
    position: absolute;
    inset: 0;
    background: #fff;
    transform: translateX(-101%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: -1;
}

.btn-red:hover,
.btn-red:focus-visible {
    color: #050505;
}

.btn-red:hover::before,
.btn-red:focus-visible::before {
    transform: translateX(0);
}

.btn-ghost {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    transition: color 0.3s, border-color 0.3s;
    isolation: isolate;
}

.btn-ghost::before {
    content: "";
    position: absolute;
    inset: 0;
    background: #C91600;
    transform: translateY(101%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: -1;
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
    border-color: #C91600;
}

.btn-ghost:hover::before,
.btn-ghost:focus-visible::before {
    transform: translateY(0);
}

/* WhatsApp is the default contact channel for SA motor trade — it gets its own token */
.btn-wa {
    background: #1EA55A;
    color: #fff;
    transition: background-color 0.3s;
}

.btn-wa:hover,
.btn-wa:focus-visible {
    background: #157A45;
}

/* ---------- header / nav ---------- */

#site-header {
    transition: background-color 0.4s, border-color 0.4s, transform 0.4s;
    background: transparent;
    border-bottom: 1px solid transparent;
}

#site-header.scrolled {
    background: rgba(5, 5, 5, 0.88);
    backdrop-filter: blur(14px);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* Mobile menu overlay */
#mobile-menu {
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

#mobile-menu.open {
    transform: translateX(0);
}

.menu-open {
    overflow: hidden;
}

/* ---------- forms ---------- */

.field {
    width: 100%;
    background: transparent;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 14px 0;
    transition: border-color 0.3s;
}

.field::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.field:focus {
    outline: none;
    box-shadow: none;
    border-bottom-color: #C91600;
}

select.field option {
    background: #101010;
    color: #fff;
}

/* Boxed variant used inside the filter bar and calculator */
.field-box {
    width: 100%;
    background: #0F0F0F;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 11px 13px;
    font-family: "Chakra Petch", monospace;
    letter-spacing: 0.06em;
    transition: border-color 0.25s, background-color 0.25s;
}

.field-box:hover {
    border-color: rgba(255, 255, 255, 0.22);
}

.field-box:focus {
    outline: none;
    border-color: #C91600;
}

/* Range sliders — the finance calculator's primary control */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 30px;
    background: transparent;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: linear-gradient(90deg, #C91600 var(--fill, 50%), rgba(255, 255, 255, 0.14) var(--fill, 50%));
}

input[type="range"]::-moz-range-track {
    height: 4px;
    background: linear-gradient(90deg, #C91600 var(--fill, 50%), rgba(255, 255, 255, 0.14) var(--fill, 50%));
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    margin-top: -9px;
    background: #F3F4F5;
    border: 3px solid #C91600;
    transition: transform 0.18s ease-out;
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 0;
    background: #F3F4F5;
    border: 3px solid #C91600;
    transition: transform 0.18s ease-out;
}

input[type="range"]:hover::-webkit-slider-thumb,
input[type="range"]:focus-visible::-webkit-slider-thumb {
    transform: scale(1.12);
}

input[type="range"]:hover::-moz-range-thumb,
input[type="range"]:focus-visible::-moz-range-thumb {
    transform: scale(1.12);
}

/* ---------- showroom ---------- */

/* Filter chips */
.chip {
    font-family: "Chakra Petch", monospace;
    font-size: 11px;
    letter-spacing: 0.18em;
    font-weight: 600;
    padding: 9px 15px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #C4C5C7;
    background: #0F0F0F;
    transition: color 0.25s, background-color 0.25s, border-color 0.25s;
    /* 44px hit target without inflating the visual pill */
    position: relative;
}

.chip::after {
    content: "";
    position: absolute;
    inset: -6px 0;
}

.chip:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.chip[aria-pressed="true"] {
    background: #C91600;
    border-color: #C91600;
    color: #fff;
}

/* Stock card enters/leaves as the filter changes */
.stock-card {
    transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.stock-card.is-hidden {
    display: none;
}

.stock-card.is-entering {
    opacity: 0;
    transform: translateY(14px);
}

/* Spec pill on a stock card */
.spec {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: "Chakra Petch", monospace;
    font-size: 11px;
    letter-spacing: 0.14em;
    font-weight: 600;
    color: #C4C5C7;
    background: #151515;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 10px;
}

/* ---------- lightbox ---------- */

#lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(3, 3, 3, 0.97);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

#lightbox.open {
    opacity: 1;
    visibility: visible;
}

#lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lb-thumb {
    width: 78px;
    height: 52px;
    object-fit: cover;
    opacity: 0.4;
    border: 2px solid transparent;
    transition: opacity 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.lb-thumb:hover {
    opacity: 0.8;
}

.lb-thumb[aria-current="true"] {
    opacity: 1;
    border-color: #C91600;
}

/* ---------- dialogs ---------- */

.sheet {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sheet.open {
    opacity: 1;
    visibility: visible;
}

.sheet-panel {
    transform: translateY(24px);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet.open .sheet-panel {
    transform: none;
}

@media (min-width: 768px) {
    .sheet {
        align-items: center;
    }
}

/* ---------- finance chart ---------- */

.chart-grid line {
    stroke: rgba(255, 255, 255, 0.07);
    stroke-width: 1;
}

.chart-axis text {
    fill: #8D8E90;
    font-family: "Chakra Petch", monospace;
    font-size: 11px;
    letter-spacing: 0.08em;
}

#chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: rgba(10, 10, 10, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 10px 14px;
    font-family: "Chakra Petch", monospace;
    font-size: 12px;
    color: #C4C5C7;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.15s;
    min-width: 168px;
}

/* ---------- responsive spec (mobile margins) ---------- */

@media (max-width: 767px) {
    .px-margin-edge {
        padding-left: 20px !important;
        padding-right: 20px !important;
    }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    [data-reveal],
    [data-reveal-group]>* {
        opacity: 1 !important;
        transform: none !important;
    }

    .line-mask>span {
        transform: none !important;
    }

    .marquee-track {
        animation: none !important;
    }
}

/* ---------- print ---------- */

@media print {
    #site-header,
    #mobile-menu,
    .marquee,
    .hazard,
    canvas,
    .grain::after {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }
}
