/**
 * DealerPro Elite — Base Typography & Body
 *
 * Body, headings, paragraphs, links, selection.
 * Loaded after reset.css and tokens.css.
 *
 * @package DealerPro_Elite
 * @since 2.0.0
 */

html {
  /* Belt-and-suspenders against horizontal scrollbars caused by off-screen
     fixed/absolute elements (mobile drawer, decorative ::before glows, etc.).
     IMPORTANT: order matters. `hidden` establishes a containing block that
     breaks `position: sticky` on descendants; `clip` does not. So we set
     `hidden` first as a fallback for browsers without `clip` support, and
     let modern browsers override with `clip` (Chrome 90+, FF 81+, Safari 15.4+).
     Reversing this order silently breaks every sticky header on the site. */
  overflow-x: hidden;
  overflow-x: clip;
  /* Push anchor-link jumps below the sticky topbar+header (≈100px). Without
     this, clicking #dpInquiry or any in-page anchor lands the target
     underneath the sticky header. Modern browsers honour this on every
     scroll into view including form-error focus and tabbing to anchors. */
  scroll-padding-top: 100px;
  /* Smooth-scroll for in-page anchors. Wrapped in @supports + the
     reduced-motion guard below so users with motion sensitivity get the
     instant jump they expect. */
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* View Transitions API: cross-document smooth fade between same-origin
   navigations. The browser captures snapshots before/after navigation and
   crossfades them. Browsers without support ignore this entirely.
   Combined with Speculation Rules (inc/seo/meta-tags.php), this gives
   instant-feeling page transitions — prerender + cross-fade. Chrome 126+,
   Safari 18+, Firefox in progress (graceful no-op when unsupported). */
@view-transition {
  navigation: auto;
}

/* Reduced-motion users get an instant swap, no fade animation. We cannot
   wrap @view-transition in @media (spec disallows), so we neutralize the
   animation on the root snapshot pseudo-elements instead. */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0s;
    animation: none;
  }
}

/* Tune the default crossfade — 220ms is fast enough to feel instant but
   long enough that the eye registers the change. Default is 250ms which
   is just slightly noticeable as "wait". */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 220ms;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--t-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  overflow-x: clip;
}

/* Headings — display weights, tight letter-spacing, fluid sizing */
h1, h2, h3, h4 {
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
h5, h6 {
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

h1 { font-size: var(--t-page-hero); }
h2 { font-size: var(--t-section-title); }
h3 { font-size: var(--t-xl); letter-spacing: var(--ls-tight); }
h4 { font-size: var(--t-md); letter-spacing: 0; }
h5 { font-size: var(--t-base); }
h6 { font-size: var(--t-sm); text-transform: uppercase; letter-spacing: 0.06em; }

/* Paragraphs */
p {
  color: var(--text-soft);
  line-height: 1.6;
}

p + p {
  margin-top: var(--s-3);
}

/* Inline emphasis */
strong, b {
  font-weight: 700;
  color: var(--text);
}

em, i {
  font-style: italic;
}

/* Code */
code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

code {
  background: var(--bg-2);
  padding: 0.1em 0.4em;
  border-radius: var(--r-xs);
}

pre {
  background: var(--bg-2);
  padding: var(--s-4);
  border-radius: var(--r-md);
  overflow-x: auto;
}

/* Links — accent color underline on hover */
a {
  color: var(--accent);
  transition: opacity var(--transition);
}

a:hover {
  opacity: 0.85;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

/* Text selection */
::selection {
  background: var(--accent);
  color: var(--accent-fg);
}

/* Horizontal rule */
hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--s-8) 0;
}

/* Blockquote */
blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--s-4);
  color: var(--text-soft);
  font-style: italic;
}

/* iOS Safari: prevent auto-zoom on input focus by ensuring 16px+ font on
   touch devices. v2.0.62: bumped breakpoint from 720px to 1024px so iPad
   portrait (768px) + landscape (1024px) ALSO get 16px inputs. Previously
   iPad users saw the form bounce on every input focus because the OS
   thought the field was too small to read — frustrating mid-form on the
   buy-now wizard. The desktop breakpoint (>1024px) still gets the
   compact `var(--t-sm)` ≈ 14px since cursor precision is fine there. */
@media (max-width: 1024px) {
  input,
  textarea,
  select,
  .form-input,
  .form-textarea,
  .form-select {
    font-size: 16px !important;
  }
}

/* Brand the text-insertion caret on inputs so it matches the accent color
   instead of the OS default (white on dark = invisible on focus on some
   browsers; black on light = correct but unstyled). */
input,
textarea {
  caret-color: var(--accent);
}

/* Override Chrome / Safari autofill yellow/blue background that stomps the
   form field's brand colors. The `inset` trick paints over the autofill
   background using a tall box-shadow; `-webkit-text-fill-color` keeps the
   typed text in our brand text color. Animation delay keeps the value
   fast-painted (autofill triggers a style transition by default). */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-1) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--accent);
  transition: background-color 0s 600000s, color 0s 600000s;
}

/* Hide native number-input spinner arrows. They clash with our custom field
   chrome and rarely match the brand. Users still get the numeric keypad on
   mobile via inputmode="numeric" / "decimal". */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Image fade-in on lazy-load. Without this, lazy images "pop" into the
   layout when decode finishes — visible jank on a slow scroll. The
   `img:not([loading="eager"])` selector skips above-fold (LCP) images
   which we want painted instantly. JS in main.js adds `.is-loaded` once
   `complete=true` so cached images don't fade in twice. Wrapped in
   `prefers-reduced-motion: no-preference` so motion-sensitive users
   see the image instantly. */
@media (prefers-reduced-motion: no-preference) {
  img:not([loading="eager"]):not(.is-loaded) {
    opacity: 0;
    transition: opacity 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  img.is-loaded { opacity: 1; }
}

/* Honeypot spam-trap — visually + ARIA hidden, but still in DOM for bots */
.dpelite-form__honeypot,
.dpelite-honeypot,
[name="website"][type="text"]:not([data-real]) {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Specs table responsive wrapper (prevents horizontal overflow on small screens) */
.specs-table {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.specs-table table {
  min-width: 100%;
  width: max-content;
}
@media (max-width: 540px) {
  .specs-table table {
    width: 100%;
    min-width: 0;
  }
  .specs-table th,
  .specs-table td {
    word-break: break-word;
  }
}

/* Skip link (accessibility) — hidden until focused */
.skip-link {
  position: absolute;
  left: -9999px;
  z-index: var(--z-toast);
}

.skip-link:focus {
  left: var(--s-4);
  top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-sm);
  font-weight: 600;
}

/* Print: dealers do print listing pages and inquiry confirmations. The dark
   theme renders as huge black bars on paper, sticky CTAs cover content, and
   the topbar/header eats real estate. Strip chrome + invert to ink-on-paper. */
@media print {
  /* Page setup: 1.5cm margins keep content from running into printer
     edge-bleed; readable 11pt body for paper density. */
  @page {
    margin: 1.5cm;
  }
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt;
    line-height: 1.4;
  }

  /* Hide on print — extended list. The previous block hid only basic
     chrome; dealers reported ink-wasted prints with filter forms,
     pagination links, save/share buttons, and the entire inquiry form
     all printing alongside listing data. CRITICAL: also hide the
     buy-now Step 4 review block which leaks PII (name, email, phone,
     full address, ID document filename) to paper / cloud print queue. */
  .topbar,
  .header,
  .footer,
  .sticky-cta-bar,
  .mobile-drawer,
  .mobile-overlay,
  .skip-link,
  .breadcrumbs,
  .qv-modal,
  [data-dpelite-sticky],
  /* Listing chrome — interactive elements with no print value. */
  .icon-btn-group,
  .card__save,
  .card__qv-trigger,
  /* Archive chrome — filter form, pagination, results-header view-toggle. */
  .filters,
  .pagination,
  .results-header,
  .page-hero__live,
  /* Single-listing inquiry form — eats space, useless on paper. */
  .inquiry,
  #dpInquiry,
  /* Buy-now sensitive form parts. The review-grid + #review-id are
     CRITICAL — printing leaks the customer's identity-document filename
     and full PII to the print queue. ms-step:not(.is-active) hidden too
     so a print mid-wizard doesn't dump fields the user didn't even
     intend to submit yet. */
  .file-upload,
  .file-upload__hint,
  .file-upload__filename,
  .ms-progress,
  .ms-nav,
  .ms-step:not(.is-active),
  .ms-terms,
  .review-grid,
  .review-item,
  #review-id,
  .cf-turnstile,
  .dpelite-form__honeypot {
    display: none !important;
  }
  a {
    color: #000 !important;
    text-decoration: underline;
  }
  /* Show URLs after links so printed pages remain useful when offline. */
  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    word-wrap: break-word;
  }
  /* Don't print URLs for in-page anchors or javascript hooks. */
  a[href^="#"]::after,
  a[href^="javascript:"]::after {
    content: "";
  }
  /* Filter chips append a "remove this filter" URL via a[href]::after which
     adds visual noise on print. Strip URL append for chips specifically. */
  .filters__active a::after,
  .chip[href]::after {
    content: "";
  }
  .card,
  .section,
  main {
    box-shadow: none !important;
    background: #fff !important;
    color: #000 !important;
  }
  /* Cards as a unit — don't split a card's image and price across a
     page break. The earlier rule only protected images. */
  .card,
  .card-wrap {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  /* Inventory grid — collapse to a 2-column print layout for legibility
     on letter / A4. The on-screen 3-4 column grid prints unreadably small. */
  .inventory-grid,
  .cards-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12pt !important;
  }
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }
  h1, h2, h3 {
    page-break-after: avoid;
  }
  /* Strip any hero/page-hero background gradients — they render as
     unpredictable gray washes on B&W printers. */
  .page-hero,
  .hero {
    background: #fff !important;
  }
}
