/* cars.css — v5: lively cards + animated borders + parallax feel + proper inner spacing */

/* ---------- Mast ---------- */
.cars-hero {
  background: linear-gradient(135deg, #0b2740, #0e5875);
  color: #fff;
  padding: 48px 0 24px
}

.cars-title {
  font-size: clamp(28px, 4vw, 42px);
  margin: 0 0 6px
}

.cars-sub {
  opacity: .9;
  margin: 0
}

.view-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px
}

.view-switch {
  display: flex;
  gap: 8px
}

.view-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .08);
  color: #fff;
  cursor: pointer;
  transition: transform .2s ease, background .2s ease
}

.view-btn:hover {
  transform: translateY(-1px)
}

.view-btn[aria-pressed="true"] {
  background: #fff;
  color: #0b2740
}

/* Chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .35);
  font-size: 14px;
  backdrop-filter: blur(4px)
}

.chip button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 700
}

/* ---------- Layout ---------- */
.cars-wrap {
  padding: 28px 0 72px;
  background: #f8fafc
}

.cars-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 28px;
  align-items: start
}

/* ---------- Filters ---------- */
.filters {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
  position: sticky;
  top: 96px;
  overflow: hidden
}

.filters__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 54px;
  border-bottom: 1px solid #eef2f7;
  background: #fff
}

.filters__head h2 {
  font-size: 18px;
  margin: 0
}

.filters__open,
.filters__close {
  display: none
}

.filters form {
  padding: 14px 18px 18px
}

.f-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px
}

.f-group {
  display: grid;
  gap: 8px;
  margin-bottom: 12px
}

.f-group label {
  font-weight: 600;
  color: #0f172a
}

.f-group input,
.f-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  transition: border-color .2s, box-shadow .2s, background-color .2s, transform .08s
}

.f-group input:focus,
.f-group select:focus {
  outline: 0;
  border-color: #ff6b35;
  box-shadow: 0 0 0 3px rgba(255, 107, 53, .18)
}

.f-group input:hover,
.f-group select:hover {
  transform: translateY(-1px)
}

.f-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px
}

/* ---------- Results ---------- */
.results {
  min-width: 0
}

.results-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px
}

.results-count {
  color: #475569
}

.sort select {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff
}

/* ---------- Cards grid (2 columns kept) ---------- */
.cards {
  display: grid;
  gap: 18px
}

.cards.grid-view {
  grid-template-columns: repeat(2, minmax(0, 1fr))
}

.cards.list-view {
  grid-template-columns: 1fr
}

/* ---------- Motion primitives ---------- */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

@keyframes pulseBadge {

  0%,
  100% {
    transform: translateY(0)
  }

  50% {
    transform: translateY(-2px)
  }
}

@keyframes popIn {
  0% {
    transform: scale(.92);
    opacity: 0
  }

  100% {
    transform: scale(1);
    opacity: 1
  }
}

@keyframes glowBreath {

  0%,
  100% {
    box-shadow: 0 18px 40px rgba(2, 8, 23, .10)
  }

  50% {
    box-shadow: 0 22px 54px rgba(2, 8, 23, .16)
  }
}

/* ---------- Card shell ---------- */
.card {
  --r: 18px;
  --elev: 0 18px 40px rgba(2, 8, 23, .12);
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 230px 1fr auto;
  gap: 0;
  /* we’ll pad inside */
  background: #fff;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid #e5e7eb;
  box-shadow: 0 10px 24px rgba(2, 8, 23, .06);
  transition: transform .25s cubic-bezier(.2, .7, .2, 1), box-shadow .28s ease, filter .25s ease;
  animation: fadeUp .45s ease both;
}

.card.is-visible {
  animation-delay: .05s
}

.card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow: var(--elev);
  filter: saturate(1.02)
}

/* Animated gradient border ring */
.card::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: calc(var(--r) + 1px);
  background: conic-gradient(from 220deg, #a0c8ff, #7dd3fc, #a7f3d0, #fde68a, #a0c8ff);
  z-index: -1;
  opacity: 0;
  transition: opacity .35s ease;
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 0);
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 0);
}

.card:hover::before {
  opacity: .35
}

/* inner spacing so content never hugs edges */
.card__pad {
  display: contents
}

/* semantic helper if needed */
.card__media {
  position: relative;
  height: 210px;
  overflow: hidden;
  background: #0b1220
}

.card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
  transition: transform .9s cubic-bezier(.16, .84, .44, 1)
}

.card:hover .card__media img {
  transform: scale(1.08)
}

/* glossy diagonal sheen */
.card__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(75deg, transparent 35%, rgba(255, 255, 255, .18) 45%, transparent 55%);
  transform: translateX(-120%) skewX(-12deg);
  transition: transform .9s cubic-bezier(.2, .7, .2, 1)
}

.card:hover .card__media::after {
  transform: translateX(120%) skewX(-12deg)
}

.badge {
  position: absolute;
  left: 12px;
  top: 12px;
  background: #ff6b35;
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(255, 107, 53, .25)
}

.sale-badge {
  position: absolute;
  right: 12px;
  top: 12px;
  background: #0e5875;
  color: #fff;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(14, 88, 117, .25);
  animation: pulseBadge 2.2s ease-in-out infinite
}

/* sides padded so text/icons never touch borders */
.card__body {
  display: grid;
  align-content: center;
  gap: 12px;
  padding: 16px 16px 16px 16px
}

.card__aside {
  min-width: 210px;
  display: grid;
  align-content: center;
  justify-items: end;
  padding: 16px 16px 16px 8px;
  gap: 10px;
  text-align: right
}

/* subtle divider between media and content in grid view */
.cards.list-view .card__media {
  border-right: 1px solid #eef2f7
}

/* Title area */
.car-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px
}

.car-name {
  margin: 0;
  font-weight: 900;
  color: #0f172a;
  font-size: 20px;
  letter-spacing: .2px
}

.car-year {
  color: #475569;
  font-weight: 800;
  font-size: 12px;
  background: #eef2ff;
  border: 1px solid #e5e7ff;
  padding: 2px 8px;
  border-radius: 999px
}

/* Dealer chip */
.dealer {
  display: inline-grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
  align-items: center
}

.dealer-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #c7d2fe, #93c5fd);
  color: #0b2740;
  font-weight: 900;
  font-size: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 8px 18px rgba(59, 130, 246, .25);
  transition: transform .2s ease
}

.dealer-name {
  font-size: 13px;
  color: #334155;
  font-weight: 800
}

.dealer:hover .dealer-avatar {
  transform: translateY(-2px)
}

/* Spec chips */
.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px
}

.meta-chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fafc, #eef2f7);
  border: 1px solid #e5e7eb;
  transition: transform .15s ease, background-color .2s ease, box-shadow .2s ease
}

.meta-chip svg {
  width: 18px;
  height: 18px;
  color: #0e5875;
  stroke-width: 1.8
}

.meta-chip span {
  color: #475569;
  font-size: 13px;
  font-weight: 700
}

.meta-chip:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(2, 8, 23, .10)
}

/* Price group */
.price-group {
  display: grid;
  gap: 6px;
  justify-items: end
}

.price-old {
  color: #9aa3b2;
  font-weight: 800;
  font-size: 14px;
  text-decoration: line-through
}

.price-new {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #0a1224;
  font-weight: 900;
  background: radial-gradient(120% 110% at 32% 22%, #fff 0%, #f5f7fb 55%, #e8ecf3 100%);
  box-shadow: 0 12px 26px rgba(15, 23, 42, .18), inset 0 1px 0 rgba(255, 255, 255, .95);
  animation: popIn .25s ease both
}

.price-new small {
  font-weight: 700;
  opacity: .75
}

/* CTA */
.cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #0e5875;
  color: #0e5875;
  background: #fff;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease
}

.cta:hover {
  background: #0e5875;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(14, 88, 117, .22)
}

/* Grid-view stack */
.cards.grid-view .card {
  grid-template-columns: 1fr
}

.cards.grid-view .card__media {
  height: 220px
}

.cards.grid-view .card__aside {
  justify-items: start;
  text-align: left;
  padding: 0 16px 16px
}

/* Subtle breathing glow on visible cards */
.card.is-visible {
  animation: fadeUp .5s ease both, glowBreath 3.4s ease-in-out .5s infinite
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-top: 18px
}

.page-btn {
  min-width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  transition: transform .15s ease, background .2s
}

.page-btn:hover {
  transform: translateY(-2px);
  background: #f8fafc
}

.page-btn[aria-current="true"] {
  background: #ff6b35;
  color: #fff;
  border-color: #ff6b35
}

/* ---------- Mobile drawer (X pinned) ---------- */
@media (max-width:992px) {
  .cars-grid {
    grid-template-columns: 1fr
  }

  .filters {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(92vw, 420px);
    height: 100vh;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 1001;
    border-radius: 0;
    display: flex;
    flex-direction: column
  }

  .filters--open {
    transform: translateX(0)
  }

  .filters__open {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 10px 12px;
    border-radius: 10px
  }

  .filters__head {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px 56px;
    background: #fff;
    border-bottom: 1px solid #eef2f7
  }

  .filters__close {
    display: inline-flex;
    position: absolute;
    right: 12px;
    top: 10px;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    z-index: 3
  }

  .filters form {
    padding: 14px 16px 18px;
    overflow: auto
  }

  .cards.grid-view .card__media {
    height: 200px
  }
}

/* XS tweaks */
@media (max-width:480px) {
  .meta-chip {
    padding: 6px 10px
  }
}

/* a11y helper */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0
}

/* ====================================================================== */
/* ======================= RESPONSIVE & STICKY FIXES ===================== */
/* (Added overrides below; no existing blocks were removed or rewritten.) */
/* ====================================================================== */

/* Header height variable for sticky math */
:root {
  --header-h: 64px;
}

/* Ensure grid children don’t clip */
.card {
  min-width: 0;
}

.card__body {
  align-content: start;
  min-width: 0;
}

.card__aside {
  min-width: 0;
}

/* Filters: desktop sticky should scroll internally and stick earlier */
@media (min-width: 993px) {
  .cars-grid {
    align-items: start;
  }

  .filters {
    top: calc(var(--header-h) + 12px);
    overflow: auto;
    /* was hidden */
    max-height: calc(100vh - var(--header-h) - 24px);
    will-change: transform;
  }

  .filters__head {
    top: 0;
  }
}

/* Filters form: two→one column on narrow screens so fields aren’t cramped */
@media (max-width: 700px) {
  .f-row {
    grid-template-columns: 1fr;
  }
}

/* Cards: collapse to single column earlier (affects both list/grid variants) */
@media (max-width: 1100px) {
  .card {
    grid-template-columns: 1fr !important;
  }

  .card__media {
    height: 220px;
  }

  .card__body {
    padding: 14px;
  }

  .card__aside {
    justify-items: start;
    text-align: left;
    padding: 0 14px 14px;
    gap: 8px;
  }
}

/* Cards grid: drop to 1 column sooner so chips don’t get hidden */
@media (max-width: 900px) {
  .cards.grid-view {
    grid-template-columns: 1fr;
  }
}

/* Meta chips: tighter spacing + guaranteed wrapping on phones */
.card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.meta-chip {
  padding: 8px 10px;
  border-radius: 10px;
}

.meta-chip span {
  font-size: 12.5px;
}

@media (max-width: 480px) {
  .meta-chip {
    padding: 6px 8px;
  }

  .meta-chip svg {
    width: 16px;
    height: 16px;
  }
}

/* Inputs: remove hover “lift” on touch devices to avoid scroll jank */
@media (hover: none) {

  .f-group input:hover,
  .f-group select:hover {
    transform: none;
  }
}

/* Phone-sized tweaks */
@media (max-width: 640px) {
  .card__media {
    height: 200px;
  }

  .car-name {
    font-size: 18px;
  }
}
