/*
  GoCarSale UI v3 layer
  ------------------------------------------------------------
  Loaded after site.css. Contains only V3 components and targeted fixes so the
  original stylesheet stays intact and easy to diff.

  Sections
   1. Global fixes (layout, footer, focus, motion, kbd)
   2. Home: hero, quick search, budget finder, pulse, tiles
   3. Listing cards: specs, flags, list view
   4. Search: sidebar filters, toolbar, mobile drawer, empty state
   5. Listing details: action bar, sticky mobile CTA
   6. Recently viewed
   7. Print
*/

/* 1. Global fixes ------------------------------------------------------- */

:root{
  --v3-radius: 18px;
  --v3-gap: 18px;
  --v3-accent-soft: rgba(47,107,255,.10);
  --v3-good: #0f9d58;
  --v3-drop: #d93f0b;
}
html[data-theme="dark"]{
  --v3-accent-soft: rgba(79,140,255,.16);
  --v3-good: #34d399;
  --v3-drop: #fb923c;
}

/* Footer links were rendering inline and running together. */
.footer-grid .footer-link{display:block;padding:3px 0;color:var(--muted);}
.footer-grid .footer-link:hover{color:var(--text);}

/* Visible keyboard focus everywhere (WCAG 2.4.7). */
:where(a,button,input,select,textarea,summary,[tabindex]):focus-visible{
  outline:3px solid var(--accent);
  outline-offset:2px;
  border-radius:8px;
}

kbd{
  font:600 .78em/1 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  padding:2px 6px;border-radius:6px;border:1px solid var(--border-strong);
  background:var(--surface);box-shadow:inset 0 -1px 0 var(--border-strong);
}

@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{animation-duration:.001ms !important;animation-iteration-count:1 !important;transition-duration:.001ms !important;scroll-behavior:auto !important;}
  .listing-card:hover{transform:none;}
}

.btn.mini{padding:6px 10px;font-size:.85rem;}
.tiny{font-size:.75rem;}

/* 2. Home ---------------------------------------------------------------- */

.v3-hero{
  display:grid;
  grid-template-columns:minmax(0,1.55fr) minmax(300px,1fr);
  gap:var(--v3-gap);
  align-items:stretch;
  margin:6px 0 18px;
}
@media (max-width: 960px){ .v3-hero{grid-template-columns:1fr;} }

.v3-hero-main{
  position:relative;overflow:hidden;
  padding:30px 30px 24px;
  border-radius:calc(var(--v3-radius) + 6px);
  border:1px solid var(--border);
  background:
    radial-gradient(900px 300px at 0% 0%, rgba(47,107,255,.16), transparent 60%),
    radial-gradient(600px 260px at 100% 100%, rgba(16,185,129,.10), transparent 60%),
    var(--surface);
  box-shadow:var(--shadow-md);
}
@media (max-width: 600px){ .v3-hero-main{padding:22px 18px;} }

.v3-eyebrow{
  display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap;
  margin:0 0 12px;padding:6px 12px;border-radius:999px;
  background:var(--v3-accent-soft);color:var(--text);font-weight:650;font-size:.88rem;
}
.v3-eyebrow-sep{opacity:.5;}
.v3-live-dot{width:8px;height:8px;border-radius:50%;background:var(--v3-good);box-shadow:0 0 0 0 rgba(16,185,129,.6);animation:v3pulse 2s infinite;}
@keyframes v3pulse{0%{box-shadow:0 0 0 0 rgba(16,185,129,.55);}70%{box-shadow:0 0 0 9px rgba(16,185,129,0);}100%{box-shadow:0 0 0 0 rgba(16,185,129,0);}}

.v3-hero h1{font-size:clamp(1.9rem, 3.6vw, 2.9rem);letter-spacing:-.025em;margin:0 0 10px;max-width:18ch;}
.v3-lead{font-size:1.05rem;color:var(--muted);max-width:60ch;margin:0 0 18px;}

.v3-quicksearch{
  display:grid;
  grid-template-columns:minmax(0,2fr) minmax(0,1fr) minmax(0,1fr) auto;
  gap:10px;align-items:end;
  padding:12px;border-radius:var(--v3-radius);
  background:var(--surface);border:1px solid var(--border-strong);
  box-shadow:var(--shadow-sm);
}
@media (max-width: 860px){
  .v3-quicksearch{grid-template-columns:1fr 1fr;}
  .v3-qs-wide,.v3-qs-submit{grid-column:1 / -1;}
}
.v3-qs-field{display:flex;flex-direction:column;gap:4px;min-width:0;}
.v3-qs-field label{font-size:.78rem;font-weight:700;color:var(--muted);padding-left:2px;}
.v3-qs-field input,.v3-qs-field select{width:100%;min-height:44px;}
.v3-qs-submit{min-height:44px;display:inline-flex;align-items:center;justify-content:center;gap:8px;white-space:nowrap;padding-inline:18px;}
.v3-hint{margin:10px 2px 0;}

.v3-chip-scroller{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px;}
.v3-count{display:inline-block;margin-left:4px;padding:0 6px;border-radius:999px;background:var(--surface2);color:var(--muted);font-size:.75rem;font-weight:700;}

.v3-hero-side{display:flex;}
.v3-budget{
  flex:1;display:flex;flex-direction:column;gap:12px;
  padding:22px;border-radius:calc(var(--v3-radius) + 6px);
  border:1px solid var(--border);background:var(--surface);box-shadow:var(--shadow-md);
}
.v3-budget h2{font-size:1.2rem;margin:0 0 4px;}
.v3-budget-head p{margin:0;}
.v3-budget-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;}
.v3-budget-grid label{display:flex;flex-direction:column;gap:4px;font-size:.78rem;font-weight:700;color:var(--muted);}
.v3-budget-grid input,.v3-budget-grid select{width:100%;min-height:40px;}
.v3-budget-out{padding:14px;border-radius:14px;background:var(--v3-accent-soft);text-align:center;}
.v3-budget-price{font-size:2rem;font-weight:900;letter-spacing:-.02em;color:var(--text);font-variant-numeric:tabular-nums;}
.v3-budget-cta{text-align:center;justify-content:center;}

.v3-pulse{
  display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin:0 0 8px;
}
@media (max-width: 760px){ .v3-pulse{grid-template-columns:repeat(2,minmax(0,1fr));} }
.v3-pulse-item{
  display:flex;flex-direction:column;gap:2px;padding:14px 16px;border-radius:16px;
  background:var(--surface);border:1px solid var(--border);color:var(--text);
  transition:border-color .15s ease, transform .15s ease;
}
.v3-pulse-item:hover{text-decoration:none;border-color:var(--accent);transform:translateY(-1px);}
.v3-pulse-num{font-size:1.5rem;font-weight:900;font-variant-numeric:tabular-nums;}
.v3-pulse-label{color:var(--muted);font-size:.88rem;}

.v3-section{margin:34px 0 0;}
.v3-section-head{display:flex;justify-content:space-between;align-items:flex-end;gap:12px;margin-bottom:12px;}
.v3-section-head h2{margin:0;}
.v3-more{font-weight:700;white-space:nowrap;}

.v3-body-grid{display:grid;grid-template-columns:repeat(8,minmax(0,1fr));gap:10px;}
@media (max-width: 1100px){ .v3-body-grid{grid-template-columns:repeat(4,minmax(0,1fr));} }
@media (max-width: 520px){ .v3-body-grid{grid-template-columns:repeat(2,minmax(0,1fr));} }
.v3-body-tile{
  display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 8px 12px;
  border-radius:16px;border:1px solid var(--border);background:var(--surface);color:var(--text);text-align:center;
  transition:border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.v3-body-tile:hover{text-decoration:none;border-color:var(--accent);box-shadow:var(--shadow-md);transform:translateY(-2px);}
.v3-body-tile img{width:100%;height:auto;aspect-ratio:3/2;object-fit:cover;border-radius:10px;}
.v3-body-name{font-weight:800;}

.v3-budget-chips{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:10px;}
@media (max-width: 900px){ .v3-budget-chips{grid-template-columns:repeat(3,minmax(0,1fr));} }
.v3-budget-chip{
  display:flex;flex-direction:column;padding:14px 16px;border-radius:16px;
  border:1px solid var(--border);background:var(--surface);color:var(--text);
}
.v3-budget-chip strong{font-size:1.25rem;}
.v3-budget-chip:hover{text-decoration:none;border-color:var(--accent);}

.v3-why-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;}
@media (max-width: 860px){ .v3-why-grid{grid-template-columns:1fr;} }
.v3-why{padding:20px;border-radius:var(--v3-radius);border:1px solid var(--border);background:var(--surface);}
.v3-why h3{margin:10px 0 6px;font-size:1.05rem;}
.v3-why p{margin:0;}
.v3-why-icon{width:42px;height:42px;border-radius:12px;display:grid;place-items:center;background:var(--v3-accent-soft);color:var(--accent);}

.v3-sell-band{
  margin:34px 0 0;padding:26px 28px;border-radius:calc(var(--v3-radius) + 6px);
  display:flex;justify-content:space-between;align-items:center;gap:18px;flex-wrap:wrap;
  background:linear-gradient(120deg, #0b1220, #1b2d55 60%, #2f6bff);color:#fff;
}
.v3-sell-band h2{color:#fff;margin:0 0 6px;}
.v3-sell-band p{margin:0;max-width:62ch;color:rgba(255,255,255,.82);}
.v3-sell-actions{display:flex;gap:10px;flex-wrap:wrap;}
.v3-sell-band .btn.ghost{color:#fff;border-color:rgba(255,255,255,.4);}

.v3-explore-links{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;}
@media (max-width: 860px){ .v3-explore-links{grid-template-columns:repeat(2,minmax(0,1fr));} }
.v3-explore-links a{display:flex;flex-direction:column;gap:2px;padding:14px 16px;border-radius:16px;border:1px solid var(--border);background:var(--surface);color:var(--text);}
.v3-explore-links a:hover{text-decoration:none;border-color:var(--accent);}

.v3-empty{
  display:flex;flex-direction:column;align-items:center;text-align:center;gap:8px;
  padding:40px 20px;border-radius:var(--v3-radius);border:1px dashed var(--border-strong);background:var(--surface);
  color:var(--muted);
}
.v3-empty h2,.v3-empty h3{color:var(--text);margin:6px 0 0;}
.v3-empty p{max-width:52ch;margin:0;}
.v3-empty-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:center;margin-top:6px;}

/* 3. Listing cards --------------------------------------------------------- */

.listing-card{display:flex;flex-direction:column;}
.listing-card .card-body{flex:1;}
.v3-specs{
  list-style:none;margin:-2px 0 0;padding:0;display:flex;flex-wrap:wrap;gap:4px 0;
  color:var(--muted);font-size:.86rem;
}
.v3-specs li + li::before{content:"·";margin:0 7px;opacity:.6;}

.v3-card-flags{position:absolute;left:10px;top:10px;z-index:3;display:flex;gap:6px;flex-wrap:wrap;}
.v3-flag{
  padding:4px 9px;border-radius:999px;font-size:.75rem;font-weight:800;letter-spacing:.01em;
  background:rgba(255,255,255,.94);color:#0b1220;box-shadow:0 2px 8px rgba(0,0,0,.15);
}
.v3-flag.new{background:var(--accent);color:#fff;}
.v3-flag.drop{background:var(--v3-drop);color:#fff;}
.listing-card .badge.sponsored ~ .v3-card-flags{top:42px;}

.v3-photo-count{
  position:absolute;right:10px;bottom:10px;z-index:3;display:inline-flex;align-items:center;gap:4px;
  padding:3px 8px;border-radius:999px;font-size:.75rem;font-weight:700;color:#fff;background:rgba(0,0,0,.55);
  backdrop-filter:blur(4px);
}

/* List view (toggled on search) */
.v3-list-view .listings-grid{grid-template-columns:1fr !important;}
.v3-list-view .listing-card{flex-direction:row;}
.v3-list-view .listing-card .card-media{flex:0 0 min(320px, 40%);}
.v3-list-view .listing-card .card-media img{height:100%;aspect-ratio:auto;min-height:200px;}
@media (max-width: 600px){
  .v3-list-view .listing-card{flex-direction:column;}
  .v3-list-view .listing-card .card-media{flex-basis:auto;}
}

/* 4. Search ----------------------------------------------------------------- */

.v3-search-head{display:flex;justify-content:space-between;align-items:flex-end;gap:12px;flex-wrap:wrap;}
.v3-search-head h1{margin:0 0 4px;font-size:clamp(1.5rem,2.6vw,2rem);}
.v3-search-head-actions{display:flex;gap:8px;}
.v3-search-head-actions .btn{display:inline-flex;align-items:center;gap:6px;}
.v3-filter-toggle{display:none !important;}

.v3-search-layout{
  display:grid;grid-template-columns:300px minmax(0,1fr);gap:var(--v3-gap);align-items:start;margin-top:14px;
}
.v3-filters{
  position:sticky;top:84px;max-height:calc(100vh - 100px);overflow:auto;overscroll-behavior:contain;
  padding:16px;border-radius:var(--v3-radius);border:1px solid var(--border);background:var(--surface);
  scrollbar-width:thin;
}
.v3-filters .filters-box{border:0;padding:0;margin:14px 0 0;background:transparent;box-shadow:none;}
.v3-filters .filters-grid,
.v3-filters .advanced-grid{grid-template-columns:1fr 1fr !important;gap:10px;}
.v3-filters .filters-grid .field:has(#Q),
.v3-filters .filters-grid .field:has(#Make),
.v3-filters .filters-grid .field:has(#Model),
.v3-filters .filters-grid .field:has(#Country),
.v3-filters .filters-grid .field:has(#Sort),
.v3-filters .advanced-grid .field:has(input[type=checkbox]){grid-column:1 / -1;}
.v3-filters .filters-actions{position:sticky;bottom:-16px;margin:14px -16px -16px;padding:12px 16px;background:var(--surface);border-top:1px solid var(--border);display:flex;gap:8px;flex-wrap:wrap;}
.v3-filters .filters-actions .btn.primary{flex:1;}
.v3-filter-title{font-size:.78rem;font-weight:800;text-transform:uppercase;letter-spacing:.05em;color:var(--muted);margin-bottom:8px;}
.v3-filters-mobile-head{display:none;}
html.v3-js .v3-form-sort{display:none;}

.v3-results-toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:12px;}
.v3-toolbar-right{display:flex;gap:10px;align-items:center;}
.v3-sort{display:flex;align-items:center;gap:8px;}
.v3-sort select{min-height:38px;}
.v3-view-toggle{display:flex;gap:4px;}
.v3-view-toggle .icon-btn[aria-pressed="true"]{background:var(--v3-accent-soft);color:var(--accent);border-color:var(--accent);}

.v3-sponsored{margin-bottom:16px;padding:12px;border-radius:var(--v3-radius);background:var(--surface2);border:1px solid var(--border);}
.v3-sponsored-head{display:flex;justify-content:space-between;gap:8px;margin-bottom:10px;}

.v3-search .listings-grid{grid-template-columns:repeat(auto-fill,minmax(260px,1fr));}

@media (max-width: 980px){
  .v3-search-layout{grid-template-columns:1fr;}
  .v3-filter-toggle{display:inline-flex !important;}
  .v3-filters{
    position:fixed;inset:0 auto 0 0;z-index:1000;width:min(420px,92vw);max-height:none;height:100%;
    border-radius:0 var(--v3-radius) var(--v3-radius) 0;transform:translateX(-105%);transition:transform .22s var(--ease);
    box-shadow:var(--shadow-lg);
  }
  .v3-filters.is-open{transform:none;}
  .v3-filters-mobile-head{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px;}
  .v3-filters-backdrop{position:fixed;inset:0;z-index:999;background:rgba(2,6,23,.45);}
}

/* 5. Listing details ----------------------------------------------------------- */

.v3-detail-actions{display:flex;gap:8px;flex-wrap:wrap;}
.v3-detail-actions .btn{display:inline-flex;align-items:center;gap:6px;}

.v3-mobile-cta{display:none;}
@media (max-width: 760px){
  .v3-mobile-cta{
    display:flex;position:fixed;left:0;right:0;bottom:0;z-index:900;gap:10px;align-items:center;justify-content:space-between;
    padding:10px 14px calc(10px + env(safe-area-inset-bottom));background:var(--surface);border-top:1px solid var(--border);
    box-shadow:0 -8px 24px rgba(0,0,0,.08);
  }
  .v3-mobile-cta .price{font-size:1.15rem;}
  body.has-mobile-cta .site-footer{padding-bottom:84px;}
}

/* 6. Recently viewed ------------------------------------------------------------ */

.v3-recent-row{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(200px,240px);gap:12px;overflow-x:auto;padding-bottom:6px;scroll-snap-type:x mandatory;}
.v3-recent-card{scroll-snap-align:start;display:flex;flex-direction:column;border-radius:14px;overflow:hidden;border:1px solid var(--border);background:var(--surface);color:var(--text);}
.v3-recent-card:hover{text-decoration:none;border-color:var(--accent);}
.v3-recent-card img{width:100%;aspect-ratio:4/3;object-fit:cover;background:var(--surface2);}
.v3-recent-card .v3-recent-body{padding:10px 12px;display:flex;flex-direction:column;gap:2px;}
.v3-recent-card .v3-recent-title{font-weight:750;font-size:.92rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.v3-recent-card .v3-recent-price{font-weight:900;color:var(--success);}

/* 7. Print ---------------------------------------------------------------------- */

@media print{
  .site-header,.trust-bar,.site-footer,.compare-tray,.toast-host,.card-actions,.v3-mobile-cta,.ad-zone,.gcs-cookie,[data-gcs-cookie-banner]{display:none !important;}
  body{background:#fff;color:#000;}
  a{color:#000;text-decoration:none;}
}

/* 8. Layout fixes found in V3 review ------------------------------------------- */

/* body is a flex column; without this, <main> shrank to its content on sparse pages (e.g. search). */
.site-main{width:100%;}

/* Inputs could overflow their grid cells (min-year / combobox on narrow columns). */
input,select,textarea{box-sizing:border-box;max-width:100%;}
.v3-filters input:not([type=checkbox]):not([type=radio]),.v3-filters select{width:100%;}

/* Wider, less tall card photos = more cars per screen. */
.listing-card .card-media img{aspect-ratio:16/10;}

/* 9. Mobile polish ------------------------------------------------------------------ */
@media (max-width: 760px){
  /* Trust bar: one compact line instead of four stacked rows. */
  .trust-inner{flex-direction:row;align-items:center;flex-wrap:nowrap;gap:8px;padding:6px 0;min-height:0;font-size:12px;}
  .trust-close{width:28px;height:28px;flex:0 0 auto;}
  .trust-text{gap:6px;overflow:hidden;}
  .trust-text > span:last-child{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
  .trust-link{white-space:nowrap;}

  /* Listing page: SEO link rails scroll sideways instead of pushing the photos below the fold. */
  .listing-link-rails{gap:6px;}
  .link-rail{display:flex !important;align-items:center;gap:8px;overflow-x:auto;scrollbar-width:none;}
  .link-rail::-webkit-scrollbar{display:none;}
  .link-rail-label{flex:0 0 auto;font-size:.68rem;}
  .link-rail-chips{flex-wrap:nowrap !important;}
  .link-rail-chips .chip{white-space:nowrap;}

  .v3-hero-main{padding:20px 16px;}
  .v3-eyebrow{font-size:.8rem;}
}

/* 10. Development demo-mode notice ------------------------------------------------- */
.v3-demo-bar{background:#fff7e0;color:#5c4100;border-bottom:1px solid #f1d58a;font-size:13px;}
.v3-demo-bar .container{padding-top:6px;padding-bottom:6px;}
.v3-demo-bar code{background:rgba(0,0,0,.06);padding:1px 6px;border-radius:6px;}
html[data-theme="dark"] .v3-demo-bar{background:#2a2108;color:#f5dfa0;border-color:#5a4613;}

/* Quick sell: keep the sell CTA visible on phones (the main nav collapses into the menu). */
.nav-sell-mobile{display:none}
@media (max-width: 860px){
  .nav-sell-mobile{display:inline-flex;margin-left:auto;margin-right:8px;padding:6px 14px}
}
