/* =========================================================================
   CASA MODESTA: COMPLETE HOMEPAGE ARCHITECTURE (CLS & BOUNDARY OPTIMIZED)
   ========================================================================= */

/* --- 0. PRE-HYDRATION CLS REPAIR ENGINE --- */
/* Locks raw Swiper elements into stable rows before JavaScript loads */
.swiper {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    overflow: hidden;
    list-style: none;
    padding: 0;
    z-index: 1;
    display: block;
}

.swiper-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    transition-property: transform;
    box-sizing: border-box;
}

.swiper-slide {
    flex-shrink: 0;
    height: 100%;
    position: relative;
    transition-property: transform;
    box-sizing: border-box;
}

/* --- 1. APP CONTAINER ENVELOPE --- */
.cm-homepage-wrapper { 
    max-width: 600px; 
    margin: 0 auto 30px auto !important; 
    padding: 0 15px !important; 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
    overflow-x: hidden; 
    box-sizing: border-box;
}

/* Master Glassmorphic Pills (Strictly No Shadows) */
.cm-sp-pill {
    background: var(--cm-surface) !important; 
    backdrop-filter: blur(30px) !important; 
    -webkit-backdrop-filter: blur(30px) !important;
    border: 1px solid var(--cm-border) !important; 
    border-radius: 32px !important; 
    padding: 20px !important; 
    box-shadow: none !important; 
    box-sizing: border-box;
}

.cm-sp-pill h2 { 
    font-family: 'Bebas Neue', sans-serif; 
    font-size: 20px; 
    margin: 0 0 16px 0; 
    color: var(--cm-text-static); 
    letter-spacing: 1px; 
    text-transform: uppercase; 
    text-align: center; 
}

/* --- A. TOP HERO BANNER (Zero-Gap Desktop & 28vw Fluid Mobile) --- */
.cm-hero-promo-pill { 
    padding: 0 !important; 
    background: transparent !important; 
    border: none !important; 
    margin-top: 0 !important; 
    margin-bottom: 0 !important; 
    width: 100% !important;
    box-sizing: border-box !important;
}

.cm-hero-swiper { 
    width: 100% !important; 
    border-radius: 20px !important; 
    border: 1px solid var(--cm-accent) !important; 
    overflow: hidden !important; 
    position: relative !important;
    box-sizing: border-box !important;
    background: #15090d !important; /* fixed dark brand base: theme vars turn light/pink in light mode and show through slide seams */
    padding: 0 !important;
    margin: 0 !important;
}

.cm-hero-swiper .swiper-wrapper {
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.cm-hero-slide { 
    background: #15090d !important;
    /* No width override: Swiper's inline px width keeps slide pitch == translate step (pre-init width is set by an inline <style>) */
    height: 100% !important;
    display: flex !important; 
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important; 
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 0 !important;
}

/* Optimized combined rule for banner picture and image nodes */
.cm-hero-slide picture,
.cm-hero-slide img,
.cm-hero-img { 
    width: 100% !important; 
    height: 100% !important;
    min-width: 100% !important; /* Added to kill the 0x0 structural layout shift */
    min-height: 100% !important; /* Added to kill the 0x0 structural layout shift */
    display: block !important; 
    line-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    object-fit: cover !important;
    object-position: center !important;
}

/* Hard-Locked Universal Image Fill */
.cm-hero-swiper .swiper-slide img,
.cm-hero-img { 
    width: 100% !important; 
    height: 100% !important; 
    object-fit: cover !important; 
    object-position: center !important; 
    display: block !important; 
    pointer-events: none !important; 
    padding: 0 !important;
    margin: 0 !important;
}

/* 1. Desktop Viewport (>= 768px): Zero-Padding Border Snap (No White Gaps) */
@media (min-width: 768px) {
    .cm-hero-swiper {
        aspect-ratio: 1920 / 380 !important;
        max-height: 280px !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .cm-hero-swiper .swiper-slide img,
    .cm-hero-img { 
        aspect-ratio: 1920 / 380 !important;
    }
}

/* 2. Mobile Viewport (<= 767px): Fluid 28vw Scale (Natural Zoom-Out & Readable Text) */
@media (max-width: 767px) {
    .cm-hero-swiper {
        height: 28vw !important; 
        max-height: none !important;
        aspect-ratio: auto !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .cm-hero-swiper .swiper-slide img,
    .cm-hero-img { 
        height: 100% !important;
        aspect-ratio: auto !important;
    }
}

/* --- B. CATEGORIES ROW (Horizontal 1x5 Layout) --- */
.cm-category-nav-pill { 
    padding: 16px 14px !important; 
    overflow: hidden;
}

.cm-category-swiper {
    width: 100%;
    overflow: visible;
}

.cm-cat-slide {
    width: auto;
    flex-shrink: 0;
    box-sizing: border-box;
}

.cm-cat-card { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 8px; 
    text-decoration: none !important; 
    width: 100%;
}

.cm-cat-img-wrap { 
    width: 68px; 
    height: 68px; 
    border-radius: 20px; 
    padding: 4px; 
    background: transparent !important; 
    border: 1px solid var(--cm-border) !important; 
    box-sizing: border-box;
    transition: transform 0.2s ease, border-color 0.2s ease; 
}

.cm-cat-img-wrap img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    border-radius: 16px; 
    pointer-events: none; 
    display: block;
}

.cm-cat-card:active .cm-cat-img-wrap { 
    border-color: var(--cm-accent); 
    transform: scale(0.95); 
}

.cm-cat-name { 
    font-size: 9px; 
    font-weight: 800; 
    color: var(--cm-text-muted); 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    text-align: center;
    white-space: nowrap;
}

/* =========================================================================
   C & D. UNIFIED FLAT PRODUCT CARD (shared by New Arrivals + Parent Aisles)
   Card children (direct siblings): wishlist btn, .cm-card-img-link, .cm-grid-title, .price, .cm-grid-atc
   ========================================================================= */
.cm-home-card {
    position: relative;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    height: auto !important;
    min-width: 0;
    /* NO margin here: Swiper writes spaceBetween as inline margin-right on slides (Section D);
       an !important margin reset would glue the cards together. */
    padding: 12px !important;
    box-sizing: border-box !important;
    text-align: center !important;
    list-style: none !important;
    background: var(--cm-card-glass) !important;
    backdrop-filter: blur(12px) saturate(160%) !important;
    -webkit-backdrop-filter: blur(12px) saturate(160%) !important;
    border: 1px solid var(--cm-card-border) !important;
    border-radius: 20px !important;
    box-shadow: var(--cm-card-gloss) !important;
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease !important;
}

.cm-home-card:hover {
    background: var(--cm-card-glass-hover) !important;
    border-color: var(--cm-accent) !important;
    box-shadow: var(--cm-card-gloss-hover) !important;
}

.cm-card-img-link {
    display: block;
    flex: 0 0 auto;
    text-decoration: none !important;
}

.cm-grid-img,
.cm-naked-img {
    display: block;
    width: 100%;
    object-fit: cover;
    border-radius: 12px !important;
    margin: 0 0 8px 0 !important;
    pointer-events: none; /* image only: card links stay tappable */
}

.cm-grid-img  { height: 150px !important; }
.cm-naked-img { height: 120px !important; }

/* Title: 3-line readable boundary (42px desktop, 36px mobile) */
.cm-home-card .cm-grid-title {
    display: -webkit-box !important;
    -webkit-line-clamp: 3 !important;
    -webkit-box-orient: vertical !important;
    flex: 0 0 auto;
    height: 42px !important;
    margin: 0 0 2px 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: normal !important;
    text-align: center !important;
    text-decoration: none !important;
    font-family: inherit !important;
    font-size: 11.5px !important;
    font-weight: 700 !important;
    line-height: 14px !important;
    color: var(--cm-accent) !important;
}

/* Price: single hard-locked horizontal line (currency never wraps above the amount) */
.cm-home-card .price,
.cm-home-card .price span,
.cm-home-card .price bdi {
    display: inline-flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 4px !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    color: var(--cm-accent) !important;
}

.cm-home-card .price {
    align-self: center;
    max-width: 100%;
    margin: 0 0 6px 0 !important;
}

.cm-home-card .price del {
    opacity: 0.6;
    font-size: 11px !important;
    font-weight: 400 !important;
}

.cm-home-card .price ins {
    display: inline-flex !important;
    flex-direction: row !important;
    white-space: nowrap !important;
    text-decoration: none !important;
}

/* Action button: slim luxury deck, strict flex centering, zero vertical padding */
.cm-home-card .cm-grid-atc,
.cm-home-card .button {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 0 0 auto;
    width: 100% !important;
    height: 30px !important;
    min-height: 30px !important;
    margin: 6px 0 0 0 !important;
    padding: 0 6px !important;
    box-sizing: border-box !important;
    border: none !important;
    border-radius: 8px !important;
    background: var(--cm-accent) !important;
    color: var(--cm-bg) !important;
    font-size: 11px !important;
    font-weight: 800;
    line-height: 1 !important;
    text-align: center !important;
    text-indent: 0 !important;
    text-transform: uppercase !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.cm-home-card .cm-grid-atc:active,
.cm-home-card .button:active {
    transform: scale(0.96);
    opacity: 0.85;
}

.cm-home-card .added_to_cart { display: none !important; }

/* --- C. NEW ARRIVALS: slide itself is the 2x2 grid --- */
.cm-home-grid-pill {
    padding: 16px 12px 24px 12px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.cm-home-grid-pill h2 {
    text-align: center !important;
    margin-bottom: 14px !important;
    padding: 0 !important;
}

.cm-new-arrivals-swiper {
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
    cursor: grab;
}

.cm-new-arrivals-swiper:active { cursor: grabbing; }

.cm-2x2-panel-slide {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
    height: auto !important;
    box-sizing: border-box !important;
}

/* --- D. PARENT AISLES: slide is the card; width comes ONLY from Swiper --- */
.cm-naked-aisle-pill {
    padding: 16px 12px 24px 12px !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.cm-naked-aisle-pill h2 {
    text-align: center !important;
    margin-bottom: 14px !important;
    padding: 0 !important;
    font-size: 18px !important;
}

.cm-aisle-swiper {
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important; /* exact 3/4 visible cards: no partial leaks */
    cursor: grab;
}

.cm-aisle-swiper:active { cursor: grabbing; }

/* Slide width/margin are written by Swiper inline (slidesPerView + spaceBetween).
   NEVER set width on .swiper-slide here. The column gutter between cards comes from
   Swiper's spaceBetween (12px mobile / 16px desktop); slide padding is not used because
   the slide IS the bordered card (padding would shrink the card's content, not separate cards). */
.cm-naked-aisle-pill .swiper-slide {
    box-sizing: border-box !important;
}

/* Cards are content-height and equalised per row (wrapper stretches them), so no dead space
   appears between title, price and button. Title box is fixed, so every card matches. */
.cm-aisle-swiper .swiper-wrapper {
    align-items: stretch !important;
}

/* --- D. COMPACT PARENT-AISLE CARDS (shorter section; (0,3,0) selectors beat the shared card rules) --- */
.cm-naked-aisle-pill {
    padding: 14px 12px 14px 12px !important;
}

.cm-naked-aisle-pill h2 {
    margin-bottom: 10px !important;
}

/* Square image instead of a tall fixed box: shaves ~20px off every card */
.cm-aisle-swiper .cm-home-card .cm-naked-img {
    height: auto !important;
    aspect-ratio: 1 / 1;
    margin-bottom: 6px !important;
}

/* Compact 3-up Parent Aisle cards: smooth horizontal marquee loop for readable titles */
.cm-aisle-swiper .cm-home-card .cm-grid-title,
.cm-naked-aisle-pill .cm-home-card .cm-grid-title,
.cm-naked-aisle-pill .cm-grid-title {
    display: block !important;
    -webkit-line-clamp: unset !important;
    -webkit-box-orient: initial !important;
    height: 18px !important;
    line-height: 18px !important;
    font-size: 10px !important;
    margin: 0 0 2px 0 !important;
    white-space: nowrap !important;
    word-break: normal !important;
    text-overflow: clip !important;
    overflow: hidden !important;
}

.cm-grid-title-marquee .cm-marquee-track {
    display: inline-flex !important;
    align-items: center;
    white-space: nowrap !important;
    will-change: transform;
    animation: cmTitleMarquee 10s linear infinite;
}

.cm-grid-title-marquee:hover .cm-marquee-track {
    animation-play-state: paused;
}

@keyframes cmTitleMarquee {
    0%, 15% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-50%, 0, 0); }
}

.cm-aisle-swiper .cm-home-card .price { margin-bottom: 5px !important; }

/* Slimmer button that always fits inside its card (label never spills past the edges) */
.cm-aisle-swiper .cm-home-card .cm-grid-atc,
.cm-aisle-swiper .cm-home-card .button {
    height: 26px !important;
    min-height: 26px !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin-top: 0 !important;
    padding: 0 4px !important;
    letter-spacing: 0 !important;
    font-size: 10px !important;
}

/* =========================================================================
   RESPONSIVE COMPACTION (<= 768px MOBILE)
   ========================================================================= */
@media (max-width: 768px) {
    .cm-home-card {
        padding: 10px !important; /* matches cart upsell spacing (Sections C and D) */
        border-radius: 16px !important;
    }

    /* Card height is content-driven (no fixed height => no dead space between title/price/button) */
    .cm-grid-img  { height: 130px !important; border-radius: 10px !important; margin-bottom: 6px !important; }
    .cm-naked-img { height: 100px !important; border-radius: 10px !important; margin-bottom: 6px !important; }

    .cm-home-card .cm-grid-title {
        font-size: 10px !important;
        line-height: 12px !important;
        -webkit-line-clamp: 3 !important;
        height: 36px !important;
        margin-bottom: 3px !important;
    }

    .cm-home-card .price,
    .cm-home-card .price span,
    .cm-home-card .price bdi {
        font-size: 11px !important;
    }

    .cm-home-card .price { margin-bottom: 5px !important; }

    /* Slim button (Sections C and D): 26px, zero vertical padding, flex-centered */
    .cm-home-card .cm-grid-atc,
    .cm-home-card .button {
        height: 26px !important;
        min-height: 26px !important;
        margin-top: 0 !important;
        padding: 0 !important;
        font-size: 10px !important;
        border-radius: 6px !important;
    }

    /* Parent aisles: extra-slim button, label sized to fit the narrow 3-up cards */
    .cm-aisle-swiper .cm-home-card .cm-grid-atc,
    .cm-aisle-swiper .cm-home-card .button {
        height: 22px !important;
        min-height: 22px !important;
        padding: 0 3px !important;
        font-size: 9px !important;
        border-radius: 6px !important;
    }

    .cm-aisle-swiper .cm-home-card .cm-grid-title {
        display: block !important;
        -webkit-line-clamp: unset !important;
        font-size: 10px !important;
        line-height: 18px !important;
        height: 18px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }
}

/* --- TRUST MATRIX --- */
.cm-trust-matrix-pill { 
    padding: 16px 20px !important; 
}

.cm-trust-svg-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    gap: 8px; 
    width: 100%; 
}

.cm-trust-svg-item { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 6px; 
    flex: 1; 
    text-align: center; 
    color: var(--cm-accent); 
}

.cm-trust-svg-item span { 
    font-size: 9px; 
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    color: var(--cm-text-muted); 
}

/* =========================================================================
   E. GLOBAL REVIEWS (Exact 1:1 Copy from Single Product Stylesheet)
   ========================================================================= */
/* --- E. GLOBAL REVIEWS: Handled sitewide by global.css unified 1-size engine --- */

