/* =========================================================
   AutoWorld – shared responsive layer
   Loaded AFTER each page's own <style>, so it refines the
   original design (colours, themes, fonts) without replacing it.
   Breakpoints: 1024 (laptop/tablet landscape) · 768 (tablet) · 480 (phone)
   ========================================================= */

/* ---------- Global safety nets ---------- */
html { -webkit-text-size-adjust: 100%; }
body { overflow-x: hidden; }
img, svg, video { max-width: 100%; }
img { height: auto; }
a, button, select, input, textarea { -webkit-tap-highlight-color: transparent; }

/* Broken-image fallback (set by assets/js/site.js) */
img.img-fallback {
  object-fit: contain !important;
  background: #151515;
}

/* ---------- Navigation (all pages) ---------- */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1.5px solid #e6c07b;
  color: #e6c07b;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.nav-toggle:focus-visible { outline: 2px solid #ffd700; outline-offset: 2px; }

@media (max-width: 768px) {
  nav {
    padding: 12px 16px !important;
    flex-wrap: wrap;
    gap: 8px;
    background: rgba(0, 0, 0, 0.92) !important; /* page text no longer shows through the sticky bar */
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
  nav h1 { font-size: 1.6rem !important; letter-spacing: 2px !important; }
  nav ul {
    flex-wrap: wrap;
    width: 100%;
    gap: 4px 18px !important;
  }
  nav ul li a { display: inline-block; padding: 6px 0; font-size: 1rem !important; }

  /* With JS: collapse into a hamburger menu */
  .js-nav nav .nav-toggle { display: inline-flex; }
  .js-nav nav ul {
    display: none;
    flex-direction: column;
    gap: 0 !important;
    border-top: 1px solid #e6c07b44;
    padding-top: 6px;
  }
  .js-nav nav.open ul { display: flex; }
  .js-nav nav ul li a { display: block; padding: 12px 4px; }
}

/* ---------- Home page ---------- */
.bgg {
  width: calc(100% - 32px);
  max-width: 1200px;
}
.brands-track > a { flex: 0 0 auto; display: block; }

@media (max-width: 900px) {
  /* "fixed" backgrounds are janky / ignored on phones */
  body { background-attachment: scroll !important; }
  .hero { padding: 90px 20px 70px !important; }
  .hero h2 { font-size: clamp(1.9rem, 8vw, 2.8rem) !important; }
  .head h2 { font-size: clamp(1.6rem, 6.5vw, 2.4rem) !important; }
  .bgg { padding: 28px 16px !important; margin: 24px auto 56px !important; }
  /* one card per slide, always fitting its container */
  .brands-track { gap: 16px !important; }
  .brands-track > a { flex: 0 0 100%; }
  .brand { width: 100% !important; }
  .next-btn {
    right: 24px !important;
    transform: translateY(-50%) !important;
    width: 44px !important;
    height: 44px !important;
  }
  .next-btn:hover, .next-btn:active { transform: translateY(-50%) scale(1.05) !important; }
}
@media (min-width: 560px) and (max-width: 900px) {
  /* tablets: two cards per view */
  .brands-track > a { flex: 0 0 calc(50% - 8px); }
}
@media (max-width: 900px) {
  .footer-bottom { font-size: 14px !important; }
  footer { padding: 32px 20px 16px !important; }
}

/* ---------- Contact page ---------- */
@media (max-width: 768px) {
  .contact-section { padding: 36px 16px !important; }
  .contact-info h2 { font-size: 1.9rem !important; }
  .info-list { line-height: 1.9 !important; overflow-wrap: anywhere; }
}
@media (max-width: 480px) {
  .contact-info, .contact-form { padding: 22px 18px !important; }
}

/* ---------- Search page ---------- */
.searchbar { padding: 24px 16px 40px; max-width: 1100px; margin: 0 auto; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 460px; }
@media (max-width: 600px) {
  #h1 { font-size: 1.6rem; }
  #h2 { font-size: 1rem; }
  .filters select { width: 100%; max-width: 360px; }
  th, td { padding: 10px 8px !important; font-size: .85rem; }
}

/* ---------- Warranty page ---------- */
@media (max-width: 768px) {
  body > h1 { font-size: 1.5rem; padding: 0 8px; }
  .brand-list li { padding: 16px !important; }
}
#details {
  top: 50% !important;
  width: min(92%, 700px) !important;
  max-height: 85vh;
  overflow-y: auto;
}
@media (max-width: 480px) {
  #details { padding: 16px !important; }
  #detail-title { font-size: 18px !important; padding-right: 22px; }
  #detail-content { font-size: 14px !important; }
}

/* ---------- Brand pages (Lamborghini, Aston Martin, McLaren, Ferrari, Audi, Ford) ---------- */
body:has(> .container) {
  align-items: flex-start !important;
  min-height: 100vh;
}
.container {
  width: min(100%, 1100px) !important;
  height: auto !important;
  min-height: 100vh;
  padding-bottom: 32px;
}
/* top logo / banner image */
.container > img {
  width: 100% !important;
  max-width: 400px;
  height: auto !important;
  aspect-ratio: 4 / 3;
  object-fit: contain; /* logos/banners are never cropped or stretched */
  margin: 24px 0;
}
.model-head { height: auto !important; min-height: 80px; padding: 12px 16px; text-align: center; }
.model-head h1 { font-size: clamp(1.3rem, 5vw, 2rem); }

/* dealer box: was absolutely positioned (overlapped on small screens) – now in normal flow */
.dealers-info {
  position: static !important;
  width: calc(100% - 32px) !important;
  height: auto !important;
  margin: 28px 16px 0 !important;
  padding: 20px !important;
}
.d-h1 { margin: 0 0 20px !important; text-align: center; font-size: clamp(1.2rem, 4.5vw, 2rem); }
.d-h3 { margin-bottom: 6px !important; }
.d-p { margin: 0 0 14px !important; overflow-wrap: anywhere; }

/* model grid: wraps instead of overflowing */
.models {
  height: auto !important;
  flex-wrap: wrap;
  margin: 32px 0 0 !important;
  padding: 0 16px;
  gap: 24px !important;
}
.model {
  width: min(400px, 100%) !important;
  height: auto !important;
  aspect-ratio: 400 / 270;
}
.model img { width: 100% !important; height: 100% !important; }
.container > hr { margin-top: 32px; }

/* touch screens have no hover – always show the model name */
@media (hover: none) {
  .model-name { transform: translateY(0) !important; opacity: 1 !important; }
}

/* detail modal */
.modal { padding: 12px; }
.modal-content { max-height: 92vh; overflow-y: auto; }
.modal-left img {
  width: 100% !important;
  height: auto !important;
  max-height: 55vh;
  object-fit: cover;
}
@media (max-width: 700px) {
  .modal-body { flex-direction: column !important; }
  .modal-right {
    border-left: none !important;
    border-top: 2px solid rgba(255,255,255,.2);
    padding: 14px 0 0 !important;
  }
  .modal-content { padding: 16px !important; }
  .close-btn { z-index: 2; }
}
@media (max-width: 480px) {
  .models { gap: 18px !important; }
}

/* Reduce motion for people who ask for it */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* =========================================================
   Shared footer + "Back to Home" bar (added for non-home pages)
   ========================================================= */
html { background: #000; }

/* sticky-footer layout: page always fills the screen, footer sits at the bottom */
body:has(> .site-footer) {
  min-height: 100vh;
  display: flex !important;
  flex-direction: column;
}
body:has(> .site-footer) > .site-footer { margin-top: auto; }
/* children of a column-flex body must keep their full width */
.searchbar, .brand-list { width: 100%; }
.searchbar { margin-left: auto; margin-right: auto; }
.brand-list { padding: 0 16px !important; }
body:has(#details) { margin: 0 !important; background-attachment: scroll !important; }
body:has(#details) > h1 { margin: 40px 0 20px; }

/* brand pages: stack  back-bar → container → footer */
body:has(> .container) {
  flex-direction: column !important;
  align-items: center !important;
  justify-content: flex-start !important;
}
body:has(> .container) > .container { min-height: 0; }

.site-footer {
  width: 100%;
  background: #0a0a0a;
  color: #e6c07b;
  padding: 40px 30px 16px;
  font-size: 14px;
  box-shadow: inset 0 0 50px #000000aa;
  text-align: left;
}
.sf-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto 20px;
}
.sf-grid > div { flex: 1 1 220px; min-width: 0; }
.site-footer h3 {
  margin-bottom: 16px;
  font-size: 20px;
  font-weight: 700;
  border-bottom: 2px solid #e6c07b;
  padding-bottom: 8px;
  letter-spacing: 1px;
}
.site-footer p { margin-bottom: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.site-footer .sf-hours { font-size: 18px; font-weight: 670; color: yellow; }
.sf-bottom {
  text-align: center;
  border-top: 1px solid #333;
  padding-top: 12px;
  color: #aaa;
}
.sf-bottom p { margin: 0; }
@media (max-width: 900px) {
  .site-footer { padding: 32px 20px 14px; }
  .sf-grid > div { flex-basis: 100%; }
  .site-footer .sf-hours { font-size: 16px; }
}

/* Back to Home bar (car pages) */
.back-bar {
  width: 100%;
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 15px #e6c07baa;
  padding: 10px 16px;
}
.back-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1.5px solid #e6c07b;
  border-radius: 999px;
  color: #e6c07b;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  transition: background .25s, color .25s;
}
.back-home:hover, .back-home:focus-visible { background: #e6c07b; color: #000; outline: none; }