
/* ===== Fluid Typography ===== */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    overflow-wrap: break-word;
}
h1 { font-size: clamp(1.5rem, 4vw + 0.5rem, 2.5rem); }
h2 { font-size: clamp(1.25rem, 3vw + 0.4rem, 2rem); }
h3 { font-size: clamp(1.1rem, 2vw + 0.4rem, 1.5rem); }
h4 { font-size: clamp(1rem, 1.5vw + 0.4rem, 1.25rem); }
p { font-size: clamp(0.875rem, 1vw + 0.5rem, 1rem); }
a, button, input, select, textarea, label, span { overflow-wrap: break-word; }

/* ===== Global overflow safety ===== */
html, body {
    overflow-x: hidden;
    max-width: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
img, svg, video, iframe, canvas, table, pre {
    max-width: 100%;
    height: auto;
}
img { display: block; }

/* ===== Root container ===== */
.container-custom {
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 clamp(0.75rem, 3vw, 2rem);
}

/* ===== Responsive Product Grid (auto-fit, no fixed 1-col jump) ===== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
    gap: clamp(0.75rem, 2vw, 1.25rem);
}
@media (min-width: 640px) {
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
}
@media (min-width: 1024px) {
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
}

/* ===== Product Cards: equal height, no cropped content ===== */
.product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0;
}
.product-card .slider-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
}
.product-card .slider-track img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.product-card > div:last-child {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.product-card .add-to-cart-btn {
    min-height: 34px;
    white-space: nowrap;
}
.product-card h3 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 1.6em;
}

/* ===== Combined Hero + Promo Cross Layout ===== */
.hero-promo-wrap {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: minmax(70px, 13vw) minmax(90px, 18vw) minmax(70px, 13vw);
    grid-template-areas:
        "left top right"
        "left hero right"
        "left bottom right";
    gap: clamp(0.5rem, 1.5vw, 0.9rem);
    background: #f8fafc;
    border-radius: 1rem;
    padding: clamp(0.5rem, 1.5vw, 0.9rem);
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.banner-cell {
    min-width: 0;
    border-radius: 0.65rem;
    overflow: hidden;
    background: #fff;
}

.banner-top { grid-area: top; }
.banner-left { grid-area: left; }
.banner-right { grid-area: right; }
.banner-bottom { grid-area: bottom; }
.banner-hero { grid-area: hero; }

/* Center hero fills its grid cell */
.banner-hero .hero-grid-item,
.banner-hero .slider-container {
    height: 100%;
}
.banner-hero .slider-container {
    aspect-ratio: 16 / 9;
    min-height: 100%;
}

/* Promo side cells fill their grid cells */
.promo-cell,
.promo-cell .slider-container {
    height: 100%;
}
.promo-cell .slider-container {
    aspect-ratio: 16 / 9;
}

/* Ensure slider tracks fill their containers */
.banner-cell .slider-container {
    width: 100%;
}
.banner-cell .slider-track img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mobile: show all banners in a compact 2-column layout */
@media (max-width: 767px) {
    .hero-promo-wrap {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: auto auto auto;
        grid-template-areas:
            "left right"
            "hero hero"
            "top bottom";
        gap: 12px;
    }

    /* Main hero */
    .banner-hero .slider-container {
        width: 100%;
        aspect-ratio: 9 / 16;
        overflow: hidden;
    }

    /* Side banners */
    .banner-cell .slider-container {
        width: 100%;
        aspect-ratio: 16 / 9;
        overflow: hidden;
    }

    .banner-left,
    .banner-right,
    .banner-top,
    .banner-bottom {
        display: block;
    }

    .banner-cell .slider-container img,
    .banner-hero .slider-container img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    .slider-track {
        height: 100%;
    }
}

/* ===== Responsive Header ===== */
header .container-custom {
    gap: 0.5rem;
}
.store-search {
    flex: 1 1 180px;
    min-width: 0;
    max-width: 36rem;
}
.store-search input {
    min-width: 0;
    font-size: clamp(0.8125rem, 1.5vw, 0.9375rem);
}
/* Collapse header search to full-width row on small screens */
@media (max-width: 767px) {
    header .container-custom {
        flex-wrap: wrap;
    }
    .store-search {
        order: 3;
        flex-basis: 100%;
        max-width: 100%;
        margin: 0.25rem 0 0;
    }
    .search-btn-text { display: none; }
    .store-search .search-btn {
        width: 2.5rem;
        padding: 0.5rem 0;
        text-align: center;
    }
    .store-search .search-btn i { margin-right: 0; }
    .store-search input { padding-right: 3.25rem; }
}

/* ===== Mobile Navigation Drawer ===== */
.hamburger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #1e293b;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.hamburger-btn:hover { background: #f1f5f9; }
.hamburger-btn:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

.mobile-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 9990;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.mobile-nav-overlay.open {
    opacity: 1;
    visibility: visible;
}
.mobile-nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(84vw, 320px);
    max-width: 84vw;
    background: #fff;
    z-index: 9991;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom);
}
.mobile-nav-drawer.open {
    transform: translateX(0);
}
.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
}
.mobile-nav-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #334155;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.mobile-nav-links {
    flex: 1;
    padding: 0.5rem 0;
}
.mobile-nav-links a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.25rem;
    color: #1e293b;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.mobile-nav-links a i { width: 22px; text-align: center; color: #2563eb; }
.mobile-nav-links a:hover,
.mobile-nav-links a:focus-visible {
    background: #f1f5f9;
    border-left-color: #2563eb;
}
.mobile-nav-links .nav-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 700;
    padding: 1rem 1.25rem 0.25rem;
}
.mobile-nav-footer {
    padding: 1rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
    border-top: 1px solid #e2e8f0;
    font-size: 0.8rem;
    color: #64748b;
}
body.drawer-open {
    overflow: hidden;
}

/* Hide hamburger on desktop where nav is inline */
@media (min-width: 768px) {
    .hamburger-btn { display: none; }
    .mobile-nav-overlay, .mobile-nav-drawer { display: none; }
}

/* ===== Responsive Modals ===== */
.modal-overlay,
#orderModal, .fixed.inset-0 {
    padding: 1rem;
}
.modal, #orderModal .bg-white {
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
@media (max-width: 640px) {
    .modal, #orderModal .bg-white {
        max-width: 100%;
        margin: 0.5rem;
        border-radius: 1rem;
    }
}

/* ===== Responsive Forms ===== */
input, select, textarea, button {
    font-size: 16px; /* prevent iOS zoom on focus */
    max-width: 100%;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="tel"], input[type="number"], input[type="url"],
select, textarea {
    width: 100%;
    min-height: 44px;
}
textarea { min-height: 80px; }
.form-row { grid-template-columns: 1fr; }
@media (min-width: 640px) {
    .form-row { grid-template-columns: 1fr 1fr; }
}

/* ===== Responsive Tables ===== */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}
.table-container table {
    min-width: 600px;
    width: 100%;
}
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ===== Responsive Buttons ===== */
.btn, .btn-hover, button, a.btn {
    min-height: 44px;
    touch-action: manipulation;
}
.btn-sm { min-height: 36px; }

/* ===== Focus states (accessibility) ===== */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

/* ===== Responsive Footer ===== */
footer .grid {
    gap: clamp(1rem, 3vw, 2rem);
}
footer iframe {
    width: 100%;
    height: 120px;
    border: 0;
}

/* ===== Floating buttons (safe-area aware) ===== */
.floating-social {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(100px, calc(env(safe-area-inset-bottom) + 100px));
}
.floating-cta {
    right: max(16px, env(safe-area-inset-right));
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 24px));
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Hide product count displays on storefront ===== */
#productCount,
#filterResultCount,
#mobileFilterResultCount,
#totalProductsCount,
#mobileFilterCount {
    display: none !important;
}
