/* InteriorX Auto BD V1.9 — Mobile-first storefront stabilization */
:root {
    --app-gutter: 16px;
    --app-card-radius: 16px;
    --app-touch: 44px;
    --app-bottom-nav: 68px;
}

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

@supports (overflow: clip) {
    html,
    body,
    main {
        overflow-x: clip;
    }
}

body {
    min-width: 0;
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
}

main,
.header,
.footer,
.section,
.hero-wrap,
.round-categories,
.car-finder,
.benefit-strip,
.catalog-layout,
.product-detail,
.product-tabs,
.fitment {
    min-width: 0;
    max-width: 100%;
}

.container {
    width: min(var(--container), calc(100% - (var(--app-gutter) * 2)));
    max-width: var(--container);
    min-width: 0;
}

.hero-grid > *,
.premium-split > *,
.split-showcase > *,
.catalog-layout > *,
.product-detail > *,
.trust-faq > *,
.footer-grid > * {
    min-width: 0;
}

/* Header */
.header-main,
.search,
.header-actions,
.nav-in {
    min-width: 0;
}

.search input {
    width: 100%;
}

.header-actions a,
.nav-in a,
.category-toggle {
    white-space: nowrap;
}

/* Hero */
.hero-slide.has-image {
    background-repeat: no-repeat;
    background-position: center;
}

.hero-copy h1,
.hero-copy p {
    overflow-wrap: anywhere;
}

/* Horizontal category rails */
.scroll-row {
    width: 100%;
    max-width: 100%;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
    -webkit-overflow-scrolling: touch;
}

.scroll-row > a {
    scroll-snap-align: start;
}

/* Product rails */
.product-carousel {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    isolation: isolate;
    border-radius: 18px;
}

.product-carousel-track {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    align-items: stretch;
    gap: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 4px 18px;
    scroll-padding-inline: 4px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.product-carousel-track::-webkit-scrollbar {
    display: none;
}

.product-carousel-item {
    flex: 0 0 clamp(190px, calc((100% - 70px) / 6), 220px);
    width: auto;
    min-width: 0;
    max-width: 220px;
    scroll-snap-align: start;
    scroll-snap-stop: normal;
}

.product-carousel[data-count="1"] .product-carousel-item,
.product-carousel[data-count="2"] .product-carousel-item,
.product-carousel[data-count="3"] .product-carousel-item {
    flex-basis: 220px;
}

.product-carousel.is-static .carousel-arrow,
.carousel-arrow[hidden] {
    display: none !important;
}

.carousel-arrow {
    top: 43%;
    width: 42px;
    height: 42px;
    pointer-events: auto;
}

.carousel-arrow.prev {
    left: 7px;
}

.carousel-arrow.next {
    right: 7px;
}

.carousel-arrow:disabled {
    opacity: .28;
    cursor: default;
    transform: none;
}

.product-card {
    width: 100%;
    min-width: 0;
    height: 100%;
    contain: layout paint;
}

.product-media {
    width: 100%;
    aspect-ratio: 1 / 1;
}

.product-media img {
    object-position: center;
}

.product-body h3 {
    min-height: 2.8em;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.product-body .btn {
    min-height: 42px;
}

/* Reduce visual emptiness for short rails without stretching cards */
.product-carousel.is-static .product-carousel-track {
    justify-content: flex-start;
}

.category-showcase,
.premium-section {
    content-visibility: auto;
    contain-intrinsic-size: auto 520px;
}

/* Footer desktop structure */
.footer-brand-block,
.footer-group-content {
    min-width: 0;
}

.footer-group-toggle {
    display: none;
}

.footer-group-content {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.footer-group-content p {
    margin: 0 0 5px;
}

.footer-payment-row img {
    max-width: min(820px, 76%);
}

/* Catalog/product defensive sizing */
.catalog-results,
.catalog-products,
.filters,
.results-top,
.gallery,
.product-info,
.buy-box,
.tab-panel,
.richtext,
.fitment-models {
    min-width: 0;
    max-width: 100%;
}

.breadcrumb {
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.breadcrumb::-webkit-scrollbar {
    display: none;
}

.richtext,
.tab-panel,
.product-info p,
.footer p,
.footer a {
    overflow-wrap: anywhere;
}

@media (max-width: 1200px) {
    .product-carousel-item {
        flex-basis: clamp(185px, calc((100% - 42px) / 4), 215px);
        max-width: 215px;
    }
}

@media (max-width: 800px) {
    :root {
        --app-gutter: 12px;
    }

    body {
        padding-bottom: calc(var(--app-bottom-nav) + env(safe-area-inset-bottom));
        font-size: 15px;
    }

    .header {
        position: sticky;
        top: 0;
        z-index: 80;
        box-shadow: 0 8px 24px rgba(15, 23, 42, .10);
    }

    .topbar {
        font-size: 10.5px;
        line-height: 1.35;
    }

    .topbar-in {
        min-height: 31px;
        padding-block: 5px;
    }

    .topbar-in > span {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
    }

    .header-main {
        width: 100%;
        height: 66px;
        grid-template-columns: 88px minmax(0, 1fr) 38px;
        gap: 8px;
    }

    .brand {
        width: 88px;
        overflow: hidden;
    }

    .brand img {
        width: 82px;
        height: 45px;
        object-fit: contain;
    }

    .brand-word {
        font-size: 16px;
        letter-spacing: -1px;
    }

    .brand-word span {
        font-size: 21px;
    }

    .brand small {
        margin-left: 18px;
        font-size: 6px;
        letter-spacing: 2.5px;
    }

    .search {
        width: 100%;
        min-width: 0;
        height: 43px;
        border-radius: 11px;
    }

    .search input {
        min-width: 0;
        padding: 9px 10px;
        font-size: 12px;
        text-overflow: ellipsis;
    }

    .search button {
        flex: 0 0 43px;
        width: 43px;
        font-size: 23px;
    }

    .header-actions {
        width: 38px;
        justify-content: center;
    }

    .header-actions .cart-link {
        width: 34px;
        min-width: 34px;
        justify-content: center;
        font-size: 21px;
    }

    .header-actions .cart-link small {
        display: none;
    }

    .header-actions i {
        top: -8px;
        right: -2px;
    }

    .hero-wrap {
        padding: 10px 0 12px;
    }

    .hero-wrap .container {
        width: calc(100% - 20px);
    }

    .hero-slider,
    .hero-slide {
        width: 100%;
        max-width: 100%;
        height: clamp(355px, 102vw, 410px);
        min-height: 355px;
    }

    .hero-slide {
        border-radius: 17px;
    }

    .hero-slide.has-image {
        background-size: cover;
        background-position: center;
    }

    .hero-overlay {
        background: linear-gradient(90deg, rgba(255,255,255,.98) 0%, rgba(255,255,255,.90) 52%, rgba(255,255,255,.42) 76%, rgba(0,0,0,.06) 100%);
    }

    .hero-copy {
        inset: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        padding: 30px 20px;
        justify-content: center;
    }

    .hero-copy small {
        max-width: 88%;
        font-size: 11px;
    }

    .hero-copy h1 {
        max-width: 82%;
        font-size: clamp(25px, 7.7vw, 31px);
        line-height: 1.24;
        margin: 13px 0 10px;
    }

    .hero-copy p {
        max-width: 78%;
        font-size: 13.5px;
        line-height: 1.65;
        margin-bottom: 20px;
    }

    .hero-copy .btn {
        min-height: 46px;
        padding: 11px 20px;
    }

    .hero-fallback-art {
        inset: 0 0 0 30%;
    }

    .hero-arrow {
        display: none;
    }

    .hero-dots {
        bottom: 10px;
    }

    .round-categories {
        padding: 14px 0;
    }

    .scroll-row {
        gap: 12px;
        padding: 2px 1px 7px;
    }

    .scroll-row > a {
        min-width: 70px;
        max-width: 76px;
    }

    .scroll-row > a > div {
        width: 58px;
        height: 58px;
    }

    .scroll-row span {
        font-size: 25px;
    }

    .scroll-row b {
        font-size: 11px;
        line-height: 1.25;
    }

    .finder {
        gap: 14px;
        padding: 16px;
    }

    .finder form {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        width: 100%;
    }

    .finder select {
        min-width: 0;
        width: 100%;
    }

    .finder .btn {
        min-height: var(--app-touch);
        white-space: nowrap;
    }

    .benefits {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .benefits > div {
        min-width: 0;
        padding: 12px 10px;
        font-size: 21px;
    }

    .benefits > div:nth-child(odd) {
        border-right: 1px solid var(--line);
    }

    .benefits > div:nth-child(even) {
        border-right: 0;
    }

    .benefits > div:nth-child(n + 3) {
        border-top: 1px solid var(--line);
    }

    .benefits span {
        min-width: 0;
        font-size: 11px;
    }

    .benefits small {
        font-size: 9.5px;
    }

    .section,
    .premium-section {
        padding: 23px 0;
        overflow: hidden;
    }

    .section-title {
        gap: 10px;
        margin-bottom: 12px;
    }

    .section-title > div {
        min-width: 0;
    }

    .section-title h2 {
        font-size: 22px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .section-kicker {
        font-size: 9px;
    }

    .section-title > a {
        flex: 0 0 auto;
        font-size: 11px;
        padding: 7px 9px;
        white-space: nowrap;
    }

    .product-carousel {
        border-radius: 14px;
        overflow: hidden;
    }

    .product-carousel-track {
        gap: 10px;
        padding: 3px 1px 13px;
        scroll-padding-inline: 1px;
    }

    .product-carousel-item,
    .product-carousel[data-count="1"] .product-carousel-item,
    .product-carousel[data-count="2"] .product-carousel-item,
    .product-carousel[data-count="3"] .product-carousel-item {
        flex: 0 0 calc((100% - 10px) / 2);
        width: calc((100% - 10px) / 2);
        max-width: calc((100% - 10px) / 2);
    }

    .product-card {
        border-radius: 13px;
        box-shadow: 0 8px 22px rgba(15, 23, 42, .07);
    }

    .product-media {
        aspect-ratio: 1 / 1;
    }

    .no-image span {
        font-size: 36px;
    }

    .no-image small {
        display: block;
        max-width: 90%;
        text-align: center;
        font-size: 8.5px;
    }

    .product-body {
        padding: 10px;
    }

    .product-body > small {
        font-size: 9px;
    }

    .product-body h3 {
        min-height: 2.75em;
        margin: 4px 0 8px;
        font-size: 12.5px;
        line-height: 1.38;
    }

    .price {
        font-size: 15.5px;
        line-height: 1.3;
    }

    .price del {
        display: inline;
        font-size: 10px;
    }

    .rating {
        font-size: 10.5px;
        margin: 4px 0 8px;
    }

    .product-body .btn {
        min-height: 40px;
        padding: 7px 4px;
        border-radius: 9px;
        font-size: 10.5px;
        line-height: 1.2;
    }

    .discount {
        left: 7px;
        top: 7px;
        padding: 4px 7px;
        font-size: 10px;
    }

    .carousel-arrow {
        display: none !important;
    }

    .premium-split {
        display: block;
    }

    .car-model-panel {
        margin-top: 18px;
        padding: 14px;
    }

    .car-model-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 7px;
    }

    .car-model-grid a {
        min-width: 0;
        padding: 8px 4px;
    }

    .car-model-grid span {
        font-size: 27px;
    }

    .car-model-grid small {
        display: block;
        overflow-wrap: anywhere;
        font-size: 8.5px;
        line-height: 1.25;
    }

    .service-grid article {
        grid-template-columns: 34% minmax(0, 1fr);
    }

    .service-grid article > div:last-child {
        padding: 14px;
    }

    .trust-faq {
        gap: 25px;
    }

    .stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Category listing */
    .catalog-hero {
        margin-bottom: 8px;
    }

    .catalog-hero > .container {
        width: 100%;
        min-height: 160px;
        padding: 20px var(--app-gutter);
    }

    .catalog-hero h1 {
        max-width: 72%;
        font-size: 26px;
    }

    .catalog-hero p {
        max-width: 70%;
        width: auto;
    }

    .catalog-art {
        flex: 0 0 auto;
        font-size: 58px;
        margin: 0 3% 0 0;
    }

    .results-top {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 10px;
        align-items: end;
        padding: 13px;
    }

    .results-top h2 {
        font-size: 19px;
        line-height: 1.25;
    }

    .results-top select {
        min-width: 125px;
        max-width: 145px;
        padding: 9px 7px;
        font-size: 11px;
    }

    .catalog-products.product-grid.four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .filter-button {
        min-height: 44px;
        border-radius: 11px;
        box-shadow: 0 8px 22px rgba(15, 23, 42, .06);
    }

    /* Product details */
    .product-detail {
        width: calc(100% - (var(--app-gutter) * 2));
        padding: 12px;
        gap: 17px;
    }

    .main-image,
    .main-image img,
    .no-image.large {
        width: 100%;
        height: auto;
        min-height: 0;
        aspect-ratio: 1 / 1;
    }

    .main-image img {
        object-fit: contain;
    }

    .thumbs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .product-info h1 {
        font-size: 25px;
        line-height: 1.28;
    }

    .product-meta {
        flex-wrap: wrap;
        gap: 6px 12px;
    }

    .detail-price {
        font-size: 28px;
    }

    .buy-box {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        padding: 12px;
    }

    .buy-box label {
        min-width: 0;
    }

    .buy-box label select {
        width: 100%;
        min-width: 0;
    }

    .buy-box .quantity {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }

    .buy-box .btn {
        min-width: 0;
        width: 100%;
        min-height: 44px;
        padding-inline: 7px;
        font-size: 12px;
    }

    .product-tabs,
    .fitment {
        width: calc(100% - (var(--app-gutter) * 2));
    }

    .tab-buttons {
        display: flex;
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .tab-buttons::-webkit-scrollbar {
        display: none;
    }

    .tab-buttons button {
        flex: 0 0 auto;
    }

    /* Compact, app-like footer */
    .footer {
        padding-top: 30px;
    }

    .footer-grid {
        display: block;
    }

    .footer-brand-block {
        padding-bottom: 20px;
    }

    .footer-group {
        border-top: 1px solid rgba(255, 255, 255, .12);
    }

    .footer-group-toggle {
        width: 100%;
        min-height: 50px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 0;
        border: 0;
        background: transparent;
        color: #fff;
        text-align: left;
        font-weight: 700;
    }

    .footer-group-toggle::after {
        content: "+";
        font: 400 24px/1 Arial, sans-serif;
        transition: transform .2s ease;
    }

    .footer-group.open .footer-group-toggle::after {
        transform: rotate(45deg);
    }

    .footer-group .footer-group-content {
        display: grid;
        grid-template-rows: 0fr;
        gap: 0;
        opacity: .2;
        transition: grid-template-rows .25s ease, opacity .25s ease, padding .25s ease;
        padding: 0;
    }

    .footer-group .footer-group-content > .footer-group-inner {
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .footer-group.open .footer-group-content {
        grid-template-rows: 1fr;
        opacity: 1;
        padding: 0 0 17px;
    }

    .footer h4 {
        margin: 0;
        font-size: 16px;
    }

    .footer-payment-row {
        margin-top: 22px;
    }

    .footer-payment-row > .container {
        align-items: stretch;
        padding-block: 14px;
    }

    .footer-payment-row img {
        width: 100%;
        max-width: 100%;
        max-height: none;
        padding: 8px 10px;
    }

    .footer-bottom > .container {
        align-items: flex-start;
        font-size: 11px;
    }

    /* Bottom app navigation */
    .mobile-nav {
        height: calc(var(--app-bottom-nav) + env(safe-area-inset-bottom));
        align-items: start;
        padding: 7px 5px calc(5px + env(safe-area-inset-bottom));
        box-shadow: 0 -10px 30px rgba(15, 23, 42, .14);
        border-radius: 18px 18px 0 0;
    }

    .mobile-nav a {
        min-width: 0;
        gap: 2px;
        font-size: 9.5px;
        line-height: 1.1;
    }

    .mobile-nav span {
        font-size: 20px;
    }

    .mobile-cart i {
        right: 21%;
    }

    .contact-widget {
        right: 12px;
        bottom: calc(var(--app-bottom-nav) + 13px + env(safe-area-inset-bottom));
    }

    .contact-widget-toggle {
        width: 52px;
        min-width: 52px;
        height: 52px;
    }

    .contact-widget-panel {
        width: min(330px, calc(100vw - 24px));
        max-height: min(520px, calc(100vh - 150px));
        overflow-y: auto;
    }
}

@media (max-width: 420px) {
    :root {
        --app-gutter: 10px;
    }

    .header-main {
        grid-template-columns: 82px minmax(0, 1fr) 36px;
        gap: 6px;
    }

    .brand,
    .brand img {
        width: 78px;
    }

    .search input {
        font-size: 11px;
        padding-inline: 8px;
    }

    .hero-wrap .container {
        width: calc(100% - 16px);
    }

    .hero-slider,
    .hero-slide {
        height: 370px;
        min-height: 370px;
    }

    .hero-copy {
        padding: 25px 17px;
    }

    .hero-copy h1 {
        max-width: 88%;
        font-size: 25px;
    }

    .hero-copy p {
        max-width: 84%;
        font-size: 12.5px;
    }

    .finder form {
        grid-template-columns: 1fr;
    }

    .finder .btn {
        width: 100%;
    }

    .product-carousel-item,
    .product-carousel[data-count="1"] .product-carousel-item,
    .product-carousel[data-count="2"] .product-carousel-item,
    .product-carousel[data-count="3"] .product-carousel-item {
        flex-basis: calc((100% - 8px) / 2);
        width: calc((100% - 8px) / 2);
        max-width: calc((100% - 8px) / 2);
    }

    .product-carousel-track {
        gap: 8px;
    }

    .product-body {
        padding: 9px 8px;
    }

    .product-body h3 {
        font-size: 12px;
    }

    .product-body .btn {
        font-size: 9.5px;
    }

    .car-model-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .results-top {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .results-top select {
        width: 100%;
        max-width: none;
    }

    .buy-box {
        grid-template-columns: 1fr;
    }

    .buy-box .quantity {
        grid-column: auto;
    }
}

@media (max-width: 350px) {
    .product-carousel-item,
    .product-carousel[data-count="1"] .product-carousel-item,
    .product-carousel[data-count="2"] .product-carousel-item,
    .product-carousel[data-count="3"] .product-carousel-item {
        flex-basis: 72%;
        width: 72%;
        max-width: 72%;
    }

    .catalog-products.product-grid.four {
        grid-template-columns: 1fr;
    }
}

/* Final mobile interaction safeguards */
@media (max-width: 800px) {
    body.drawer-open,
    body.filter-open {
        overflow: hidden;
    }

    .footer-group > h4 {
        display: none;
    }
}
