/* KSA Auto theme tokens — "Showroom garage": concrete greys, one signal red, square-ish corners, thin rules, italic display type.
   One system for every page: radius --r-*, type --fs-*, spacing --sp-* / --gap / --pad-card, borders 1 px (2 px focus, 3 px accent stripe). */
html { scrollbar-gutter: stable; }
:root, [data-theme] {
  --r-xs: 2px; --r-sm: 4px; --r-md: 6px; --r-lg: 10px; --r-pill: var(--r-sm);
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 10px;
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 28px; --fs-2xl: 40px; --fs-3xl: clamp(40px, 5.4vw, 72px);
  --sp-section: clamp(40px, 7vw, 88px); --gap: 16px; --pad-card: 24px; --h-btn: 48px; --h-btn-sm: 44px;
  --container: 1320px; --side: clamp(16px, 2.4vw, 32px);
  --as-graphite: #232427; --as-on-graphite: #f1efeb; --as-graphite-line: rgba(241, 239, 235, .14); --as-graphite-accent: #ff8a85;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --as-red: #e5484d; --as-green: #30a46c;
  --as-red-badge: #c62f2f; /* white badge text on red passes contrast (5.4:1) */
  --as-brand: #2563eb; /* default brand colour — the dealer's own comes from dealers.json → brand.colors (Worker) */
  --as-brand-btn: #1d4ed8; /* one step darker: white button text must pass WCAG AA (4.5:1) */
}
:root, [data-theme="light"] {
  --color-bg: #eceae6; --color-surface: #ffffff; --as-surface-2: #e1ded9;
  --color-text: #17181a; --as-muted: #55565b;
  --color-divider: rgba(23, 24, 26, .14); --as-line-strong: rgba(23, 24, 26, .28);
  /* Brand colour: buttons, selected filters, checkboxes, active page — the "action" colour. */
  --as-ink: var(--as-brand-btn); --as-on-ink: #ffffff; --as-logo-plate: transparent;
  --color-accent: var(--as-brand); --color-accent-100: #fbe4e3; --color-accent-800: #8e1b19;
  --as-stripe: rgba(23, 24, 26, .05);
  --shadow-sm: 0 1px 0 rgba(23, 24, 26, .08);
  --shadow-md: 0 6px 18px rgba(23, 24, 26, .10);
  --shadow-lg: 0 18px 40px rgba(23, 24, 26, .16);
}
[data-theme="dark"] {
  --color-bg: #141517; --color-surface: #1d1e21; --as-surface-2: #28292d;
  --color-text: #f1efeb; --as-muted: #a8a9ae;
  --color-divider: rgba(241, 239, 235, .12); --as-line-strong: rgba(241, 239, 235, .24);
  /* Same brand colour as day mode for buttons / selected items, so both themes match. */
  --as-ink: var(--as-brand-btn); --as-on-ink: #ffffff; --as-logo-plate: #ffffff;
  --color-accent: var(--as-brand-btn); --color-accent-100: #3a1615; --color-accent-800: #ff8a85;
  --as-stripe: rgba(241, 239, 235, .04);
  --as-graphite: #0e0f11;
  --shadow-sm: 0 1px 0 rgba(0, 0, 0, .4);
  --shadow-md: 0 8px 22px rgba(0, 0, 0, .40);
  --shadow-lg: 0 0 0 1px rgba(241, 239, 235, .06), 0 22px 48px rgba(0, 0, 0, .55);
}

html, body { margin: 0; background: var(--color-bg); }

/* Display type: heavy italic like the KSA AUTO lettering, on every page. */
h1, h2, [data-hero-h1] { font-family: var(--font-heading, "Archivo", system-ui, sans-serif); font-style: italic; font-weight: 800; letter-spacing: -0.02em !important; text-wrap: balance; }
h1, [data-hero-h1] { text-transform: uppercase; letter-spacing: -0.015em !important; }
/* Section kicker: numbered label "01 — …" above a heading (data-kicker="01"). */
[data-kicker] { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--as-muted); }
[data-kicker]::before { content: attr(data-kicker) " —"; color: var(--as-brand-btn); letter-spacing: .06em; }
[data-theme="dark"] [data-kicker]::before { color: var(--color-accent-800); }
/* On the graphite bands (footer, finance cluster, panels) the red accents use the light red, readable on the dark surface. */
footer [data-kicker]::before, [style*="background: var(--as-graphite)"] [data-kicker]::before { color: var(--as-graphite-accent); }
/* Signal rule: the short red line under a display heading. */
[data-rule] { display: block; width: 56px; height: 3px; background: var(--as-brand); border-radius: 0; }
/* Cards lift by 2 px and their rule turns red on hover (one hover language everywhere). */
@media (hover: hover) { [data-card]:hover { border-color: var(--as-brand) !important; transform: translateY(-2px); } }
[data-card] { transition: transform .35s var(--ease), border-color .25s var(--ease), box-shadow .35s var(--ease); }
:focus-visible { outline: 2px solid var(--as-brand-btn); outline-offset: 2px; }
/* One container for every page: content is 1320 px wide, the side padding sits outside it (header bar, sections, footer start on one line). */
[data-site] [style*="max-width: var(--container)"] { box-sizing: content-box !important; }

[data-skip-link] { position: fixed; left: 12px; top: 12px; z-index: 4000; transform: translateY(-160%); padding: 12px 16px; border-radius: var(--r-sm); background: var(--as-ink); color: var(--as-on-ink); font: 700 14px/1 var(--font-body); text-decoration: none; transition: transform .18s var(--ease); }
[data-skip-link]:focus { transform: translateY(0); outline: 3px solid var(--color-text); outline-offset: 3px; }

/* Smooth page-to-page transitions (cross-document View Transitions — Chrome/Edge/Safari 18+; others navigate normally) */
/* cross-document view transitions disabled — page fade is handled in theme.js + the server shell (prevents multiple flashes) */
::view-transition-old(root) { animation: as-vt-out .28s cubic-bezier(.4,0,1,1) both; }
::view-transition-new(root) { animation: as-vt-in .42s cubic-bezier(.16,1,.3,1) both; }
@keyframes as-vt-out { to { opacity: 0; transform: translateY(-10px) scale(.995); } }
@keyframes as-vt-in { from { opacity: 0; transform: translateY(16px); } }
header, [data-site-header] { view-transition-name: as-header; }
::view-transition-group(as-header) { animation-duration: 0s; }
@media (prefers-reduced-motion: reduce) { ::view-transition-old(root), ::view-transition-new(root) { animation: none; } }
html { background: var(--color-bg); }

/* Native selects: themed dropdown lists (dark mode was white-on-white) */
:root { color-scheme: light; }
[data-theme="dark"] { color-scheme: dark; }
select option, select optgroup { background-color: var(--color-surface); color: var(--color-text); }
/* Inventory and vehicle pages sit in the shared container; their own blocks carry no side padding of their own. */
[data-page-container] > :not([data-keep]):not(.lp-below) { padding-left: 0 !important; padding-right: 0 !important; }
/* Similar vehicles on desktop: the 4 closest matches as a grid, like the latest arrivals on Home; phones keep the swipe row. */
@media (min-width: 1024px) {
  [data-related-row] { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: visible !important; }
  [data-related-row] > :nth-child(n+5) { display: none !important; }
  [data-related-row] > * { flex: none !important; }
  [data-related-arrows] button { display: none !important; }
}
