/* Responsive layer for the live site. Inline styles carry the desktop design;
   container queries on [data-site-frame] reflow it for tablets and phones.
   Shared components (header, footer, cards, chat) are marked data-keep and handle their own layout. */
[data-site] img, [data-site] iframe, [data-site] video { max-width: 100%; }
/* Engine 1.15 (request #6): a long word or address (a URL in a feed description) breaks inside its box instead of running past it. */
[data-site] :is(p, li, dd, td, th, blockquote, figcaption) { overflow-wrap: break-word; }
[data-site-frame] { container: site / inline-size; }

@container site (max-width: 1180px) {
  [data-site] :is([style*="repeat(4"], [style*="repeat(5"], [style*="repeat(6"]):not([data-keep], [data-keep] *) { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

@container site (max-width: 1023px) {
  [data-site] [style*="grid-template-columns"]:not([data-keep], [data-keep] *) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [data-site] :is([style*="fr) minmax"], [style*="grid-template-columns: 2"], [style*="grid-template-columns: 3"]):not([style*="repeat("]):not([data-keep], [data-keep] *) { grid-template-columns: minmax(0, 1fr) !important; }
  [data-site] h1:not([data-keep] *) { font-size: clamp(40px, 7vw, 72px) !important; }
}

@container site (max-width: 819px) {
  [data-site] [style*="grid-template-columns"]:not([data-keep], [data-keep] *) { grid-template-columns: minmax(0, 1fr) !important; }
  [data-site] [data-m2]:not([data-keep] *) { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [data-site] h1:not([data-keep] *) { font-size: clamp(36px, 10.5vw, 52px) !important; line-height: 1.02 !important; letter-spacing: -0.035em !important; }
  [data-site] h2:not([data-keep] *) { font-size: clamp(26px, 7.4vw, 34px) !important; line-height: 1.08 !important; }
  [data-site] h3:not([data-keep] *) { font-size: 20px !important; }
  [data-site] [data-big]:not([data-keep] *) { font-size: clamp(40px, 17vw, 64px) !important; line-height: .95 !important; }
  [data-site] :is([style*="font-size: 5"], [style*="font-size: 6"], [style*="font-size: 7"]):not([style*="font-size: 5px"], [style*="font-size: 6px"], [style*="font-size: 7px"], [style*="font-size: 5."], [style*="font-size: 6."], [style*="font-size: 7."]):not([data-big]):not([data-keep], [data-keep] *) { font-size: clamp(28px, 10.4vw, 40px) !important; line-height: 1 !important; overflow-wrap: break-word; }
  [data-site] [style*="font-size: 4"]:not([style*="font-size: 4px"], [style*="font-size: 4."]):not([data-keep], [data-keep] *) { font-size: clamp(26px, 8.6vw, 32px) !important; line-height: 1.05 !important; overflow-wrap: break-word; }
  /* Small tags above a heading ("Venta o intercambio · …"): wrap instead of running past the column. */
  [data-site] :is(span, div)[style*="align-self: flex-start"][style*="white-space: nowrap"]:not([data-keep], [data-keep] *) { white-space: normal !important; max-width: 100%; }
  [data-site] :is([style*="padding: 3"], [style*="padding: 4"], [style*="padding: 5"], [style*="padding: 6"], [style*="padding: 7"], [style*="padding: 8"]):not([style*="padding: 3px"], [style*="padding: 4px"], [style*="padding: 5px"], [style*="padding: 6px"], [style*="padding: 7px"], [style*="padding: 8px"]):not([data-keep], [data-keep] *) { padding: 22px 16px !important; }
  [data-site] [style*="padding: 20px"]:not([data-keep], [data-keep] *) { padding: 12px !important; }
  [data-site] [style*="margin: 0 20px"]:not([data-keep], [data-keep] *) { margin-left: 10px !important; margin-right: 10px !important; }
  [data-site] :is([style*="gap: 4"], [style*="gap: 5"], [style*="gap: 6"]):not([style*="gap: 4px"], [style*="gap: 5px"], [style*="gap: 6px"]):not([data-keep], [data-keep] *) { gap: 24px !important; }
  /* Engine 1.15 (request #6): rows that hold a round dot, icon or avatar (status dot, "↗" badge, WhatsApp icon, assistant photo)
     and accordion headers (<summary>) do not wrap: the text wraps beside the small item instead of leaving it alone on its own line. */
  [data-site] [style*="display: flex"]:not([style*="flex-direction: column"]):not([style*="border-radius: 999px"], [style*="border-radius: var(--r-pill)"], [style*="999px"] *, [style*="var(--r-pill)"] *):not([data-nowrap], [data-carousel], [data-marquee-row]):not(summary, :has(> [style*="border-radius: 50%"])):not([data-keep], [data-keep] *) { flex-wrap: wrap; }
  /* the open/closed status (a dot, then the text): the dot stays at the start of the first line when the text wraps */
  [data-site] [style*="display: flex"]:has(> span:empty[style*="border-radius: 50%"]:first-child):not([data-keep], [data-keep] *) { align-items: flex-start !important; }
  [data-site] [style*="display: flex"] > span:empty[style*="border-radius: 50%"]:first-child:not([style*="margin-top"]):not([data-keep] *) { flex: none; margin-top: .45em; }
  /* accordion headers: the "+" / "−" sign stays in the right-hand column, level with the first line of a question that wraps */
  [data-site] details > summary { align-items: flex-start !important; }
  [data-site] details > summary > span[aria-hidden="true"] { flex: none; }
  /* the "latest arrival" caption over the home hero is left out on phones (it covered the hero text) */
  [data-site] [data-hero-car] { display: none !important; }
  [data-site] [data-tall]:not([data-keep] *) { height: auto !important; min-height: 0 !important; }
  [data-site] [data-tall][style*="position: relative"]:not([data-keep] *) { height: 340px !important; }
  /* the site header stays sticky on phones too (engine 1.10): its wrapper holds the header itself */
  [data-site] [style*="position: sticky"]:not([data-keep], [data-keep] *):not(:has(> header)) { position: static !important; }
  [data-site] :is([style*="border-radius: 999px"], [style*="border-radius: var(--r-pill)"]):not([data-keep], [data-keep] *) { white-space: nowrap; max-width: 100%; }
  /* engine 1.15: a pill link button (44 px tall) whose text is longer than the screen (an address in "Visit us at …") wraps inside the button instead of running past it */
  [data-site] a:is([style*="border-radius: 999px"], [style*="border-radius: var(--r-pill)"])[style*="min-height: 44px"]:not([data-keep], [data-keep] *) { white-space: normal; text-align: center; line-height: 1.25; }
  [data-site] [data-desk-only], [data-site] [data-mfilters][data-open="0"] { display: none !important; }
  [data-site] [data-carousel] { display: flex !important; flex-wrap: nowrap !important; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; gap: 12px !important; grid-template-columns: none !important; scroll-behavior: smooth; }
  [data-site] [data-carousel]::-webkit-scrollbar { display: none; }
  [data-site] [data-carousel] > * { flex: 0 0 100%; min-width: 0; scroll-snap-align: start; }
}
@container site (max-width: 1023px) {
  [data-site] [data-vd-main] { display: flex !important; flex-direction: column; gap: 12px !important; }
  [data-site] [data-vd-left] { display: contents !important; }
  [data-site] [data-vd-left] > * { order: 3; width: 100%; }
  [data-site] [data-vd-left] > [data-vd-gal] { order: 1; }
  [data-site] [data-vd-left] > [data-vd-thumbs] { order: 1; }
  [data-site] [data-vd-aside] { order: 2; width: 100%; }
  /* stacked layout: the side panel must not stay sticky, or it floats over Equipment / Similar vehicles while scrolling (seen at 892px) */
  [data-site] [data-vd-aside], [data-site] [data-vd-aside] [style*="position: sticky"] { position: static !important; top: auto !important; }
}
@container site (max-width: 819px) {
  [data-site] [data-vd-thumbs] { display: flex !important; gap: 8px !important; overflow-x: auto; scrollbar-width: none; margin-top: -4px; }
  [data-site] [data-vd-thumbs]::-webkit-scrollbar { display: none; }
  [data-site] [data-vd-thumbs] > button { flex: 0 0 calc((100% - 16px) / 3) !important; aspect-ratio: 4/3; border-radius: var(--r-md) !important; }
}
@container site (min-width: 820px) {
  [data-site] [data-mob-only] { display: none !important; }
}
@container site (max-width: 819px) {
  [data-site] [data-qs-go] { min-height: 56px; padding: 0 22px !important; font-size: 16px !important; justify-content: center; margin-top: 6px; border-radius: var(--r-md) !important; }
}
@keyframes asMarquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }


@container site (max-width: 819px) {
  [data-site] [data-budget-pills] { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; width: 100% !important; gap: 8px !important; padding: 0 !important; background: none !important; border: 0 !important; border-radius: 0 !important; }
  [data-site] [data-budget-pills] > a { display: flex !important; justify-content: space-between !important; align-items: center !important; min-height: 44px !important; padding: 10px 16px !important; background: var(--color-surface) !important; border: 1px solid var(--color-divider) !important; border-radius: var(--r-pill) !important; }
  [data-site] [data-budget-pills] { margin-top: 4px; }
}

[data-marquee-row] { flex-wrap: nowrap !important; width: max-content !important; }
[data-marquee-row] > * { flex: none; white-space: nowrap; }

@container site (max-width: 819px) {
  [data-site] [data-seg][data-seg][data-seg][style] { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)) !important; gap: 4px !important; border-radius: var(--r-md) !important; }
  [data-site] [data-seg][data-seg][data-seg][style] > * { min-height: 44px; }
}

/* Cards: two per row from tablets up to 1183px (three were too narrow next to the filter column, one per row left big empty gaps) */
@container site (min-width: 600px) and (max-width: 1183px) {
  [data-site] [data-results][style*="repeat(3"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
/* Home "Latest arrivals": 2 x 2 grid on tablets instead of a one-card slider */
@container site (min-width: 600px) and (max-width: 819px) {
  [data-site] [data-carousel][style*="grid-template-columns"]:not([data-keep], [data-keep] *) { display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; overflow: visible !important; flex-wrap: initial !important; }
  [data-site] [data-carousel] > * { flex: none; }
  [data-site] [data-slider-ctl] { display: none !important; }
}
/* Side column that stays sticky only while the page is two-column; stacked (<= 1023px) it must scroll with the page or it floats over the form */
@container site (max-width: 1023px) {
  [data-site] [data-unstick] { position: static !important; top: auto !important; }
}
/* While the site header component loads, its placeholder takes the real header height (78px compact header < 892px, 103px desktop), so the page below does not jump when it appears */
.sc-placeholder[title="Site Header"] { height: 103px !important; }
@media (max-width: 891.98px) { .sc-placeholder[title="Site Header"] { height: 78px !important; } }

/* Home hero (design layer): split night stage — text left, the newest car in a lit frame right, the search capsule below. On desktop and laptop
   (window 1040 px or wider, 125 % zoom included) the whole stage, search bar included, fits the window under the header (96 px), its text follows the
   window height, and the search bar ends before the chat button (--as-chat-room, measured by the chat widget). The poster is the LCP, sized by aspect-ratio. */
@media (min-width: 1040px) {
  [data-hero-media] { --hero-gap: 161px; min-height: min(calc(100vh - 120px - var(--ak-gap)), 920px); min-height: min(calc(100svh - 120px - var(--ak-gap)), 920px); display: flex; flex-direction: column; }
  [data-ak-hero-grid] { flex: 1; padding-top: clamp(10px, 2.6vh, 52px) !important; }
  [data-hero-content] { gap: clamp(8px, 1.6vh, 22px) !important; }
  [data-hero-h1] { font-size: clamp(30px, min(5vw, 7.6vh), 76px) !important; }
  [data-hero-sub] { font-size: clamp(15px, 2.3vh, 22px) !important; }
  [data-hero-text] { font-size: clamp(14px, 2.05vh, 18.5px) !important; line-height: 1.5 !important; }
  [data-ak-hero-photo] { max-height: calc(100svh - 120px - 230px); }
  [data-ak-hero-search-wrap] { padding-top: clamp(10px, 1.8vh, 30px) !important; padding-bottom: 12px !important; padding-right: max(12px, calc(var(--as-chat-room, 270px) - var(--ak-side) - max(0px, (100vw - 1440px) / 2))) !important; }
}
@media (min-width: 1040px) and (max-height: 780px) {
  [data-hero-rot] { display: none !important; }
  [data-ak-hero-grid] { padding-top: 12px !important; }
}
@media (min-width: 1040px) and (max-height: 700px) {
  [data-hero-text] { display: none !important; }
  [data-hero-h1] { font-size: clamp(26px, min(4vw, 6.6vh), 56px) !important; }
  [data-hero-content] { gap: 8px !important; }
  [data-hero-ctas] a { min-height: 44px !important; }
}
@container site (max-width: 1023px) {
  [data-site] [data-ak-hero-grid] { grid-template-columns: minmax(0, 1fr) !important; }
  [data-site] [data-hero-search] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [data-site] [data-hero-search] > [data-qs-go] { grid-column: 1 / -1; }
  [data-site] [data-ak-fin], [data-site] [data-ak-about], [data-site] [data-ak-trade], [data-site] [data-ak-faq] { grid-template-columns: minmax(0, 1fr) !important; }
  [data-site] [data-ak-visit] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [data-site] [data-ak-visit] > :first-child { grid-column: 1 / -1; }
  [data-site] [data-ak-makes] { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}
@container site (max-width: 819px) {
  [data-site] [data-ak-hero-photo] { aspect-ratio: 4 / 3 !important; }
  [data-site] [data-hero-h1] { font-size: clamp(38px, 11vw, 56px) !important; }
  [data-site] [data-hero-search] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [data-site] [data-hero-search] label { padding: 8px 12px !important; }
  [data-site] [data-ak-types] > a > span:nth-child(2) > h3 { font-size: 15px !important; overflow-wrap: normal !important; hyphens: auto; }
  [data-site] [data-ak-types] > a > span:nth-child(2) { padding: 12px 12px 2px !important; flex-wrap: wrap; }
  [data-site] [data-ak-types] > a > span:nth-child(3) { padding: 0 12px 12px !important; }
  [data-site] [data-ak-chances], [data-site] [data-ak-why] { grid-template-columns: minmax(0, 1fr) !important; }
  [data-site] [data-ak-makes] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  [data-site] [data-ak-visit] { grid-template-columns: minmax(0, 1fr) !important; }
  [data-site] [data-ak-chances] > a { min-height: 0 !important; }
  [data-site] [data-ak-chances] > a > span:first-child { font-size: 64px !important; }
  [data-site] [data-about-stick] { aspect-ratio: 4 / 3 !important; }
}
/* hover: car photos in type cards zoom gently */
[data-ak-types] > a:hover img { transform: scale(1.06); }
@media (prefers-reduced-motion: reduce) { [data-ak-types] > a:hover img { transform: none; } }

/* Contact cards: with four cards (call, WhatsApp, email, visit) a 1024-1180 px window shows them two by two, not three plus one alone */
@container site (min-width: 1024px) and (max-width: 1180px) {
  [data-site] [data-ch-grid][style*="repeat(4"] { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}

/* Accordions (engine 1.12): the sign follows the state, "+" closed, "−" open, in every <details> accordion (FAQ, landing and extra pages);
   the Financing page's own accordion switches its sign in the template. */
details[open] > summary > span[aria-hidden="true"] { font-size: 0 !important; }
details[open] > summary > span[aria-hidden="true"]::after { content: "−"; font-size: 22px; line-height: 1; }
/* filter switches: the knob is not a status dot (the phone rule that drops a leading dot to the text line must not move it) */
[data-site] button > span[style*="width: 40px"][style*="height: 24px"] { align-items: center !important; flex: none; }
[data-site] button > span[style*="width: 40px"][style*="height: 24px"] > span { margin-top: 0 !important; }
/* filter switches: the off state is visible in both themes (outlined track, contrasting knob); on = brand track */
[data-site] button > span[style*="width: 40px"][style*="height: 24px"][style*="flex-start"] { box-shadow: inset 0 0 0 1px var(--as-line-strong); }
[data-theme="dark"] button > span[style*="width: 40px"][style*="height: 24px"][style*="flex-start"] { background: rgba(238, 242, 251, .12) !important; box-shadow: inset 0 0 0 1px rgba(238, 242, 251, .28); }
[data-theme="dark"] button > span[style*="width: 40px"][style*="height: 24px"][style*="flex-start"] > span { background: #c9d2ea !important; }
[data-theme="dark"] button > span[style*="width: 40px"][style*="height: 24px"][style*="flex-end"] { box-shadow: 0 0 14px rgba(31, 211, 191, .45); }
/* the About photo column is sticky side by side; stacked (<= 1023 px) it scrolls with the page but stays the positioned box of its photo */
@container site (max-width: 1023px) {
  [data-site] [data-about-stick][data-unstick]:not(#ak-none) { position: relative !important; top: auto !important; }
}
/* Contact opening hours on phones: one list card (day left, hours right, today highlighted), like the Home visit card and the footer */
@container site (max-width: 819px) {
  [data-site] [data-ak-hours][data-m2]:not(#ak-none) { grid-template-columns: minmax(0, 1fr) !important; gap: 2px !important; }
  [data-site] [data-ak-hours] > div:not(#ak-none) { flex-direction: row !important; justify-content: space-between; align-items: center; gap: 12px !important; padding: 11px 14px !important; border-radius: var(--r-sm) !important; background: transparent !important; color: var(--color-text) !important; }
  [data-site] [data-ak-hours] > div > span:first-child { font-size: 15px !important; font-weight: 500 !important; opacity: .85 !important; }
  [data-site] [data-ak-hours] > div > span:last-child { font-size: 15px !important; font-weight: 600 !important; }
  [data-site] [data-ak-hours] > div[style*="var(--as-ink)"]:not(#ak-none) { background: var(--as-surface-2) !important; }
  [data-site] [data-ak-hours] > div[style*="var(--as-ink)"] > span { font-weight: 800 !important; opacity: 1 !important; }
}
