/*
 * Theme 2 — Front Page Responsive Final Layer
 * Scope: homepage only (.phase1-home).
 * Purpose: consolidate the final mobile/tablet/laptop/desktop responsive fixes
 * without changing storefront business logic or other pages.
 */

/* --------------------------------------------------------------------------
   1) One alignment system from phone to wide desktop
   -------------------------------------------------------------------------- */
.phase1-home {
    --cub-home-gutter: 16px;
    --cub-home-content-max: 1320px;
    overflow-x: hidden;
}

.phase1-home :is(
    .stx-header-container,
    .pdf1-hero-container,
    .pdf1-promo-container,
    .pdf2-section-container,
    .pdf3-section > .container,
    .pdf3-showcase-section > .container,
    .pdf4-home-container
) {
    width: 100% !important;
    max-width: calc(var(--cub-home-content-max) + (var(--cub-home-gutter) * 2)) !important;
    margin-inline: auto !important;
    padding-inline: var(--cub-home-gutter) !important;
}

/* Do not use a percentage-width header on small screens. The same gutter is
   shared by header, hero, categories and lower homepage sections. */
@media (max-width: 991.98px) {
    .phase1-home {
        --cub-home-gutter: 12px;
    }
}

@media (max-width: 575.98px) {
    .phase1-home {
        --cub-home-gutter: 10px;
    }
}

/* Intentional moving/scrolling components own their overflow. This prevents a
   wide child from silently altering the page width while avoiding page-level
   horizontal scrollbars. */
.phase1-home .page-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: visible;
}

.phase1-home :is(
    .pdf1-promo-marquee,
    .pdf4-partners,
    .cub-marquee,
    .pdf2-scroll-shell,
    .pdf3-scroll-shell
) {
    max-width: 100%;
}

/* --------------------------------------------------------------------------
   2) Header / navigation scalability
   -------------------------------------------------------------------------- */
@media (min-width: 992px) {
    .phase1-home .stx-categorybar__desktop,
    .phase1-home .stx-category-list {
        min-width: 0;
        height: auto;
    }

    /* Dynamic category names/counts are allowed to wrap to a second clean row
       instead of being clipped outside the viewport. Dropdowns remain visible. */
    .phase1-home .stx-category-list {
        flex-wrap: wrap;
        align-content: center;
        row-gap: 0;
    }

    .phase1-home .stx-categorybar,
    .phase1-home .stx-categorybar__desktop {
        min-height: 42px;
        height: auto;
    }

    .phase1-home .stx-nav-item > a,
    .phase1-home .stx-cat-toggle {
        min-height: 40px;
    }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    .phase1-home .stx-nav-item > a {
        padding-inline: 7px !important;
        font-size: 11.5px !important;
    }

    .phase1-home .stx-cat-toggle {
        width: 18px;
        margin-left: -5px;
        padding-right: 3px;
    }
}

/* Compact mobile top area: row 1 = menu/logo/actions, row 2 = full search. */
@media (max-width: 991.98px) {
    .phase1-home .stx-mainbar__inner {
        grid-template-columns: 64px minmax(0, 1fr) 64px !important;
        grid-template-rows: 38px 40px !important;
        grid-template-areas:
            "menu logo mobile-actions"
            "search search search" !important;
        column-gap: 6px !important;
        row-gap: 6px !important;
        padding: 7px 0 8px !important;
    }

    .phase1-home .stx-logo {
        justify-self: center !important;
        justify-content: center !important;
    }

    .phase1-home .stx-mobile-menu-btn {
        justify-self: start !important;
    }

    .phase1-home .stx-mobile-actions {
        justify-self: end !important;
        justify-content: flex-end !important;
        width: 64px !important;
    }

    .phase1-home .stx-logo__surface {
        width: 82px !important;
        height: 38px !important;
        padding: 1px 3px !important;
    }

    .phase1-home .stx-logo img {
        max-width: 80px !important;
        max-height: 34px !important;
    }

    .phase1-home .stx-search__box,
    .phase1-home .stx-search__box input[type="search"],
    .phase1-home .stx-search__submit {
        height: 40px !important;
    }

    .phase1-home .stx-search__box {
        grid-template-columns: minmax(0, 1fr) 42px !important;
    }

    .phase1-home .stx-search__submit {
        width: 42px !important;
        min-width: 42px !important;
    }
}

@media (max-width: 575.98px) {
    .phase1-home .stx-mainbar__inner {
        grid-template-columns: 60px minmax(0, 1fr) 60px !important;
        grid-template-rows: 34px 36px !important;
        column-gap: 4px !important;
        row-gap: 4px !important;
        padding: 5px 0 6px !important;
    }

    .phase1-home .stx-logo__surface {
        width: 74px !important;
        height: 34px !important;
    }

    .phase1-home .stx-logo img {
        max-width: 72px !important;
        max-height: 31px !important;
    }

    .phase1-home .stx-mobile-actions {
        width: 60px !important;
        gap: 0 !important;
    }

    .phase1-home .stx-mobile-menu-btn.vl-offcanvas-toggle,
    .phase1-home .stx-mobile-action {
        width: 30px !important;
        min-width: 30px !important;
        height: 32px !important;
        flex-basis: 30px !important;
        border-radius: 8px !important;
    }

    .phase1-home .stx-search__box,
    .phase1-home .stx-search__box input[type="search"],
    .phase1-home .stx-search__submit {
        height: 36px !important;
    }

    .phase1-home .stx-search__box {
        grid-template-columns: minmax(0, 1fr) 40px !important;
        border-radius: 7px !important;
    }

    .phase1-home .stx-search__box input[type="search"] {
        padding-inline: 10px !important;
        font-size: 11.5px !important;
        line-height: 36px !important;
    }

    .phase1-home .stx-search__submit {
        width: 40px !important;
        min-width: 40px !important;
        font-size: 14px !important;
    }

    .phase1-home .stx-categorybar,
    .phase1-home .stx-categorybar__mobile {
        min-height: 32px !important;
    }

    .phase1-home .stx-categorybar__mobile.d-flex {
        display: grid !important;
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
        width: 100% !important;
        overflow: hidden !important;
    }

    .phase1-home .stx-categorybar__mobile > a {
        min-width: 0 !important;
        min-height: 32px !important;
        padding: 2px 1px !important;
        font-size: 9.5px !important;
        line-height: 1.05 !important;
        white-space: normal !important;
        overflow-wrap: normal !important;
        text-align: center !important;
    }

    .phase1-home .stx-categorybar__mobile > a:nth-child(n + 6) {
        display: none !important;
    }
}

@media (max-width: 359.98px) {
    .phase1-home .stx-mainbar__inner {
        grid-template-columns: 56px minmax(0, 1fr) 56px !important;
    }

    .phase1-home .stx-mobile-actions {
        width: 56px !important;
    }

    .phase1-home .stx-logo__surface {
        width: 68px !important;
    }

    .phase1-home .stx-logo img {
        max-width: 66px !important;
    }

    .phase1-home .stx-categorybar__mobile > a {
        font-size: 9px !important;
    }
}

/* --------------------------------------------------------------------------
   3) Hero: responsive without destructive cropping
   -------------------------------------------------------------------------- */
.phase1-home .pdf1-hero-frame,
.phase1-home .pdf1-hero-slide,
.phase1-home .pdf1-hero-media,
.phase1-home .phase6-banner-picture {
    min-width: 0;
    max-width: 100%;
}

@media (max-width: 767.98px) {
    .phase1-home .pdf1-hero-section {
        padding-block: 8px 4px !important;
    }

    .phase1-home .pdf1-hero-frame {
        border-radius: 10px !important;
    }

    /* Dedicated mobile banners get a useful portrait-ish viewport. */
    .phase1-home .pdf1-hero-slide.has-mobile-image .pdf1-hero-image {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 4 / 3 !important;
        object-fit: cover !important;
        object-position: center !important;
    }

    /* If admin has not supplied a mobile banner, never crop the desktop artwork
       into a square. Show the complete wide banner inside a neutral frame. */
    .phase1-home .pdf1-hero-slide.uses-desktop-fallback .pdf1-hero-media {
        background: #f3f5f6;
    }

    .phase1-home .pdf1-hero-slide.uses-desktop-fallback .pdf1-hero-image {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16 / 7.5 !important;
        object-fit: contain !important;
        object-position: center !important;
        background: #f3f5f6;
    }

    .phase1-home .banner-six-card {
        max-width: min(74%, 320px) !important;
        padding: 10px 11px !important;
        border-radius: 10px !important;
    }

    .phase1-home .banner-six-subtitle {
        font-size: clamp(9px, 2.5vw, 11px) !important;
        line-height: 1.15 !important;
    }

    .phase1-home .banner-six-title {
        display: -webkit-box;
        max-width: 100%;
        margin-top: 3px !important;
        overflow: hidden;
        font-size: clamp(15px, 4.7vw, 23px) !important;
        line-height: 1.08 !important;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 3;
        text-wrap: balance;
    }

    .phase1-home .banner-six-card .mt-3,
    .phase1-home .banner-six-card .mt-4 {
        margin-top: 7px !important;
    }

    .phase1-home .banner-six-card .create-btn-base {
        min-height: 30px !important;
        padding: 6px 10px !important;
        font-size: 10px !important;
    }

    .phase1-home .pdf1-hero-dots {
        bottom: 7px !important;
    }
}

@media (max-width: 575.98px) {
    .phase1-home .banner-six-card {
        max-width: min(76%, 265px) !important;
        padding: 8px 9px !important;
    }

    .phase1-home .banner-six-title {
        font-size: clamp(14px, 4.5vw, 19px) !important;
        -webkit-line-clamp: 3;
    }

    .phase1-home .pdf1-hero-slide.uses-desktop-fallback .banner-six-card {
        max-width: 58% !important;
    }

    .phase1-home .pdf1-hero-slide.uses-desktop-fallback .banner-six-title {
        font-size: clamp(11px, 3.5vw, 15px) !important;
        -webkit-line-clamp: 2;
    }
}

/* --------------------------------------------------------------------------
   4) Shop-by-category and category showcase rails
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    /* Arrows are intentionally hidden on touch layouts, so remove the desktop
       34/46px arrow reservation that caused the visible blank side gaps. */
    .phase1-home .pdf2-category-shell,
    .phase1-home .pdf3-rail-shell:not(.is-expanded) {
        padding-inline: 0 !important;
    }

    .phase1-home .pdf2-category-shell .pdf2-scroll-btn,
    .phase1-home .pdf3-rail-shell .pdf3-scroll-btn {
        display: none !important;
    }

    .phase1-home .pdf2-category-track,
    .phase1-home .pdf3-rail-shell:not(.is-expanded) .pdf3-rail-track {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 2px 0 7px !important;
        scroll-padding-inline: 0;
        scroll-snap-type: x proximity !important;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-inline: contain;
        touch-action: pan-x pan-y pinch-zoom !important;
    }

    .phase1-home .pdf2-category-track::-webkit-scrollbar,
    .phase1-home .pdf3-rail-track::-webkit-scrollbar {
        display: none;
    }

    .phase1-home .pdf2-category-item,
    .phase1-home .pdf3-rail-item {
        scroll-snap-align: start;
    }
}

/* Tablet is the old weak point: use the entire width and show useful density. */
@media (min-width: 768px) and (max-width: 991.98px) {
    .phase1-home .pdf2-category-track {
        gap: 12px !important;
    }

    .phase1-home .pdf2-category-item {
        flex: 0 0 clamp(112px, 14.5vw, 136px) !important;
        width: clamp(112px, 14.5vw, 136px) !important;
    }

    .phase1-home .pdf3-rail-track {
        gap: 14px !important;
    }

    .phase1-home .pdf3-rail-item {
        flex: 0 0 clamp(140px, 18vw, 166px) !important;
        width: clamp(140px, 18vw, 166px) !important;
    }
}

@media (max-width: 767.98px) {
    .phase1-home .pdf2-category-track {
        gap: 9px !important;
    }

    .phase1-home .pdf2-category-item {
        flex: 0 0 clamp(92px, 30vw, 116px) !important;
        width: clamp(92px, 30vw, 116px) !important;
        min-width: 0 !important;
    }

    .phase1-home .pdf2-category-name {
        font-size: 11px !important;
        line-height: 1.18 !important;
    }

    .phase1-home .pdf3-rail-track {
        gap: 10px !important;
    }

    .phase1-home .pdf3-rail-item {
        flex: 0 0 clamp(118px, 40vw, 142px) !important;
        width: clamp(118px, 40vw, 142px) !important;
        min-width: 0 !important;
    }

    .phase1-home .pdf3-rail-item-title {
        font-size: 11.5px !important;
        line-height: 1.2 !important;
    }

    .phase1-home .pdf3-rail-shell.is-expanded {
        padding-inline: 0 !important;
    }

    .phase1-home .pdf3-rail-shell.is-expanded .pdf3-rail-track {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
        overflow: visible !important;
        padding-bottom: 0 !important;
    }

    .phase1-home .pdf3-rail-shell.is-expanded .pdf3-rail-item {
        width: 100% !important;
        max-width: none !important;
    }
}

@media (max-width: 359.98px) {
    .phase1-home .pdf2-category-item {
        flex-basis: 88px !important;
        width: 88px !important;
    }

    .phase1-home .pdf3-rail-item {
        flex-basis: 114px !important;
        width: 114px !important;
    }
}

/* --------------------------------------------------------------------------
   5) Lower homepage safety: newsletter/brands/testimonials stay within gutter
   -------------------------------------------------------------------------- */
.phase1-home :is(
    .cub-home-newsletter__content,
    .cub-home-newsletter__action,
    .cub-home-newsletter__form,
    .cub-home-newsletter__meta-row,
    .cub-home-newsletter__support,
    .pdf4-testimonials,
    .pdf4-partners
) {
    min-width: 0;
    max-width: 100%;
}

.phase1-home .cub-home-newsletter__contact-copy {
    min-width: 0;
}

.phase1-home .cub-home-newsletter__contact-copy strong {
    overflow-wrap: anywhere;
}

@media (max-width: 575.98px) {
    .phase1-home .cub-home-newsletter__support {
        width: 100%;
        grid-template-columns: 1fr !important;
    }

    .phase1-home .cub-home-newsletter__contact {
        width: 100%;
    }
}

/* --------------------------------------------------------------------------
   6) Accessibility / motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .phase1-home .pdf2-category-track,
    .phase1-home .pdf3-rail-track {
        scroll-behavior: auto !important;
    }
}
