/* Details page global overrides */
.details-main > .details-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  text-align: left;
}

.details-main > .details-container .details-card {
  width: min(148rem, 100%);
  justify-self: center;
}

/* small desktop */
@media (max-width: 84em) {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    min-width: 0;
  }

  html,
  body,
  main,
  section,
  .section-full,
  .container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .hero {
    max-width: 120rem;
  }
  .heading-primary {
    font-size: 4.4rem;
  }
  #hero-btn {
    margin-bottom: 12px;
    display: flex;
    max-width: 30rem;
    font-size: 2rem;
    justify-content: center;
  }
}

/* How cards responsive layout */
@media (max-width: 59em) {
  .grid-5-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-5-cols .how-card {
    grid-column: span 1;
  }
  .grid-5-cols .how-card:nth-child(4),
  .grid-5-cols .how-card:nth-child(5) {
    grid-column: span 1;
  }
}

@media (max-width: 34em) {
  .grid-5-cols {
    grid-template-columns: 1fr;
  }
  .grid-5-cols .how-card {
    grid-column: span 1;
  }
}

/* 1200 landscape tablets */

@media (max-width: 75em) {
  .hero {
    padding: 0 2rem;
    box-sizing: border-box;
  }
  .main-nav {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 75%;
    max-width: 320px;
    background: var(--bg-elev);
    padding: 9.6rem 2.4rem;
    transform: translateX(100%);
    transition: transform 0.35s ease;
  }
  .main-nav-list {
    flex-direction: column;
    gap: 2.4rem;
    justify-self: center;
  }
  .nav-open .main-nav {
    display: block;
    transform: translateX(0);
  }
  .nav-open .bar:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
  }
  .nav-open .bar:nth-child(2) {
    opacity: 0;
  }
  .nav-open .bar:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
  }
  .header-actions {
    margin-left: auto;
    display: flex;

    align-items: center;
    gap: 1.6rem;
  }

  .btn-mobile-nav {
    display: block;
  }
  .btn-search {
    display: block;
  }
}

/* 944 tablets */
@media (max-width: 59em) {
  html {
    font-size: 50%;
    scroll-behavior: smooth;
    overflow-x: hidden;
    overflow-x: clip;
  }
  body {
    overflow-x: hidden;
    overflow-x: clip;
  }
  .header {
    padding: 0 2.4rem;
    height: 10rem;
    flex-wrap: nowrap;
    gap: 1.2rem;
  }
  .brand,
  .header-actions {
    flex-shrink: 0;
  }
  .user-greeting {
    flex: 1;
    min-width: 0;
    margin-left: 0.8rem;
    font-size: 1.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hero {
    padding: 0 2rem;
    box-sizing: border-box;
  }
  .hero-video {
    object-fit: cover;
    object-position: center;
    background: #000;
  }
  .hero-text-box {
    text-align: center;
    margin: 0 auto;
  }
  .hero-text-box h1 {
    font-size: 4rem;
  }

  .hero-text-box p {
    font-size: 1.6rem;
  }
  .our-stock,
  .our-stock .container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }
  .our-stock #carsGrid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    overscroll-behavior-inline: contain;
    scrollbar-width: none;
  }
  .our-stock #carsGrid::-webkit-scrollbar {
    display: none;
  }
  .grid-3-cols {
    grid-template-columns: repeat(2, 1fr);
  }

  .select-form {
    flex-wrap: wrap;
  }
  .select-form select {
    flex: 1 1 calc(50% - 16px);
    min-width: 0;
  }
  .select-form .btn {
    flex: 1 1 100%;
    width: 100%;
    max-width: 22rem;
  }

  .main-nav {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 75%;
    max-width: 320px;
    background: var(--bg-elev);
    padding: 9.6rem 2.4rem;
    transform: translateX(100%);
    transition: transform 0.35s ease;
  }

  .main-nav-list {
    flex-direction: column;
    gap: 2.4rem;
  }

  .nav-open .main-nav {
    display: block;
    transform: translateX(0);
  }

  /* X animation */
  .nav-open .bar:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
  }

  .nav-open .bar:nth-child(2) {
    opacity: 0;
  }

  .nav-open .bar:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
  }

  .how-cards.grid-5-cols {
    display: flex !important;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    max-width: 80%;
    grid-template-columns: none !important;
  }

  .reach-cards.grid-3-cols {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    grid-template-columns: none !important;
  }

  .reach-cards.grid-3-cols .reach-card {
    flex: 1;
    max-width: 280px;
  }

  .our-stock .grid-3-cols {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 18px;
    padding: 0 24px;
    width: 100%;
    min-width: 0;
    margin: 0;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 24px;
    -webkit-overflow-scrolling: touch;

    box-sizing: border-box;
    max-width: 100%;
  }
  .our-stock .car-card {
    flex: 0 0 min(42rem, calc(100% - 48px));
    max-width: 420px;
    scroll-snap-align: center;
    min-width: 0;
  }
  .card-actions .btn {
    width: 100%;
    text-align: center;
  }
  .our-stock .car-details {
    width: 100%;
    min-width: 0;
    font-size: 1.6rem;
  }
  .our-stock .specs-grid,
  .our-stock .card-actions {
    min-width: 0;
  }
  .our-stock .grid-3-cols::-webkit-scrollbar {
    display: none;
  }
  .our-stock .grid-3-cols {
    scrollbar-width: none;
  }

  .our-stock .stock-grid img,
  .our-stock .car-card .card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    padding: 0.6rem;
  }

  .our-stock .select-form {
    align-items: center;
  }

  .footer .grid--footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-items: center;
    gap: 3.2rem;
  }
  .footer .grid--footer > * {
    min-width: 0;
  }

  .footer-socials {
    justify-content: center;
  }

  .footer .logo-col,
  .footer .nav-col,
  .footer .address-col {
    width: 100%;
  }
  .pagination {
    display: none;
  }

  .admin-body .admin-grid {
    grid-template-columns: repeat(2, minmax(18rem, 1fr));
  }
  .admin-body .admin-table {
    min-width: 104rem;
    table-layout: auto;
  }
  .admin-body .admin-table th {
    white-space: nowrap;
    padding-left: 1.6rem;
    padding-right: 1.6rem;
  }
  .admin-body .admin-table th + th {
    border-left: 1px solid var(--border);
  }
  .admin-table-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .admin-sort-control {
    width: 100%;
  }
  .admin-sort-select {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 48em) {
  .how-it-works {
    margin: 10.8rem 0;
  }
  .how-card {
    padding: 2rem;
  }
}
/* 704px small tablet /big phone screen */

@media (max-width: 44em) {
  .nav-links {
    font-size: 2.4rem;
  }
  .grid-2-cols {
    grid-template-columns: 1fr;
    gap: 1.2rem;
  }
  .build-form {
    padding: 16px;
    box-sizing: border-box;
  }
  .build-form select,
  .client-info input,
  #modelOther {
    width: 100%;
  }
  .pagination {
    display: none;
  }

  .select-form select,
  .select-form .btn {
    width: 100%;
    max-width: 100%;
  }
  .hero-cta {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .container {
    text-align: center;
  }
  .footer .grid--footer {
    grid-template-columns: repeat(2, 1fr);
  }
  .footer .footer-heading,
  .footer .footer-tagline,
  .footer .contacts,
  .footer .address {
    text-align: center;
  }
  .footer .footer-nav {
    align-items: center;
  }
  .footer .footer-link {
    justify-content: center;
  }
  .footer-bottom {
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }
  .admin-body .admin-grid {
    grid-template-columns: 1fr;
  }
  .reach-cards.grid-3-cols {
    display: flex !important;
    flex-direction: column;
    justify-self: center;
    gap: 2.4rem;
  }
}

/* 544px phone */

@media (max-width: 34em) {
  .footer .grid--footer {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 2.2rem;
  }

  .footer .logo-col,
  .footer .address-col,
  .footer .nav-col {
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
  }

  .footer .footer-heading,
  .footer .footer-tagline,
  .footer .contacts,
  .footer .address {
    text-align: center;
  }

  .footer .footer-nav {
    align-items: center;
  }

  .footer .footer-link {
    justify-content: center;
  }

  .footer .contacts,
  .footer .address,
  .footer .footer-link {
    overflow-wrap: anywhere;
  }

  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .our-stock .container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
  }

  #carsGrid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    overscroll-behavior-inline: contain;
  }

  .heading-secondary {
    font-size: 3.6rem;
  }

  .subtitle {
    font-size: 1.6rem;
    margin-bottom: 0;
    padding-bottom: 1.6rem;
  }
  .grid-2-cols,
  .grid-3-cols {
    grid-template-columns: 1fr;
    width: 100%;
    min-width: 0;
  }

  .grid {
    row-gap: 4.8rem;
  }

  .btn,
  .btn:link,
  .btn:visited {
    padding: 12px;
  }
  .section-hero {
    padding-left: 0;
    padding-right: 0;
    align-items: center;
  }
  .hero {
    grid-template-columns: 1fr;
    padding: 0 2rem;
    box-sizing: border-box;
  }
  .user-greeting {
    max-width: 14rem;
  }
  #hero-btn {
    font-size: 1.6rem;
    padding: 12px;
    justify-self: center;
    width: 22rem;
    justify-content: center;
  }
  .hero-img-box {
    display: none;
  }
  .select-form {
    flex-direction: column;
    gap: 16px;
  }
  .card-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  .select-form select,
  .select-form .btn {
    width: 100%;
    max-width: 100%;
  }
  .card-actions .btn {
    width: 100%;
    text-align: center;
  }

  .build-form {
    max-width: 100%;
    padding: 16px;
    box-sizing: border-box;
    margin: 0 auto 4.8rem;
  }

  .build-form select {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
  .build-form label:not(.sr-only) {
    display: block;
    width: 100%;
    text-align: left;
  }
  .build-form .full-field,
  .build-form .grid-2-cols {
    width: 100%;
    max-width: 100%;
  }

  .build-form,
  .build-form .form,
  .build-form .full-field,
  .build-form .grid-2-cols {
    min-width: 0;
  }

  .features {
    display: flex;
    flex-wrap: wrap;
    gap: 1.2rem 1.6rem;
  }
  .client-info {
    flex-direction: column;
    max-width: 40rem;
    gap: 16px;
  }
  .send-request {
    max-width: 40rem;
  }

  .our-stock .grid-3-cols {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 16px;
    padding: 0 16px;
    width: 100%;
    min-width: 0;
    margin: 0;
    max-width: 100%;
    box-sizing: border-box;

    scroll-snap-type: x mandatory;
    scroll-padding-inline: 16px;

    -webkit-overflow-scrolling: touch;
  }

  .our-stock .car-card {
    flex: 0 0 min(36rem, calc(100% - 32px));
    max-width: 360px;
    scroll-snap-align: center;
    min-width: 0;
  }

  .our-stock .car-details {
    width: 100%;
    min-width: 0;
    font-size: 1.4rem;
  }

  .our-stock .grid-3-cols::-webkit-scrollbar {
    display: none;
  }
  .our-stock .grid-3-cols {
    scrollbar-width: none;
  }
  .our-stock .card-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
  }
  .pagination {
    display: none;
  }
  .footer .grid--footer {
    gap: 2.4rem;
    object-fit: fill;
  }
}

/* iPhone-specific refinements */
@media (max-width: 27em) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  main,
  footer,
  .section-full,
  .container {
    max-width: 100%;
    overflow-x: clip;
  }

  /* .header {
    padding: 0 1.2rem;
  } */

  .logo {
    width: 6.4rem;
  }

  .main-nav {
    display: none;
    right: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    transform: translateX(100%);
    transition: transform 0.35s ease;
  }

  .header.nav-open .main-nav {
    display: block;
    transform: translateX(0);
  }

  .main-nav-list {
    flex-direction: column;
    gap: 2.4rem;
    justify-self: center;
  }

  .our-stock.section-full,
  .about-us.section-full {
    align-items: flex-start;
  }

  .our-stock .grid-3-cols {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0 auto;
    padding: 0 12px;
    scroll-padding-inline: 12px;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .our-stock .car-card {
    flex: 0 0 calc(100% - 24px);
    max-width: none;
    min-width: 0;
  }

  .our-stock .stock-grid img,
  .our-stock .card-img {
    padding: 0.6rem;
    box-sizing: border-box;
    aspect-ratio: 16 / 10;
    min-height: 20rem;
    max-height: 24rem;
    object-fit: contain;
    object-position: center;
  }

  .reach-cards.grid-3-cols {
    align-items: center;
  }

  .reach-cards.grid-3-cols .reach-card {
    width: min(100%, 32rem);
    max-width: 32rem;
  }

  .build-form {
    max-width: 90%;
    padding: 16px;
    box-sizing: border-box;
    margin: 0 auto 4.8rem;
    justify-self: center;
  }

  .build-form select {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }
  .build-form label:not(.sr-only) {
    display: block;
    width: 100%;
    text-align: left;
  }
  .build-form .full-field,
  .build-form .grid-2-cols {
    width: 100%;
    max-width: 100%;
  }

  .build-form,
  .build-form .form,
  .build-form .full-field,
  .build-form .grid-2-cols {
    min-width: 0;
  }
}

/* Stock on small screens: paginated grid (no horizontal carousel) */
@media (max-width: 75em) {
  .our-stock {
    overflow-x: clip;
  }

  .our-stock #carsGrid.grid-3-cols {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 16px;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow: visible !important;
    scroll-snap-type: none;
  }

  .our-stock #carsGrid .car-card {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: initial !important;
    scroll-snap-align: none;
  }
}

@media (max-width: 34em) {
  .our-stock #carsGrid.grid-3-cols {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

/* Landing mobile stock swipe mode */
@media (max-width: 59em) {
  .pagination-wrap {
    display: none;
  }

  .stock-mobile-stage #carsGrid.grid-3-cols {
    display: flex !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    gap: 12px;
    padding: 0 6px;
    width: 100%;
    min-width: 0;
    margin: 0;
    box-sizing: border-box;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 6px;
    scroll-behavior: smooth;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  .stock-mobile-stage #carsGrid.grid-3-cols::-webkit-scrollbar {
    display: none;
  }

  .stock-mobile-stage #carsGrid.grid-3-cols {
    scrollbar-width: none;
  }

  .stock-mobile-stage #carsGrid .car-card {
    flex: 0 0 calc(100% - 12px) !important;
    min-width: calc(100% - 12px);
    width: calc(100% - 12px);
    max-width: none;
    margin: 0;
    scroll-snap-align: start !important;
    scroll-snap-stop: normal;
  }
}
