/* ==========================================================================
   GLOBAL RESPONSIVE RESETS & OVERFLOW PREVENTION
   ========================================================================== */
html, body {
    max-width: 100vw;
    overflow-x: hidden !important;
    width: 100%;
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
    object-fit: cover;
}

/* Dynamic design variables */
:root {
    --fluid-gap: clamp(8px, 1.8vw, 24px);
    --fluid-padding: clamp(10px, 2.5vw, 40px);
}

/* ==========================================================================
   1. SMALL MOBILE DEVICE TIER (320px - 480px)
   ========================================================================== */
@media (min-width: 320px) and (max-width: 480px) {
    html {
        font-size: 13px; /* Fluid Typography scale down */
    }
    
    .container, .container-fluid {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    /* Force grids to single columns where appropriate */
    .row > * {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }

    /* Shrink spacing to fit smaller screens */
    .section-b-space, .section-t-space {
        padding-top: 25px !important;
        padding-bottom: 25px !important;
    }

    /* Header & logo scaling */
    .header-logo img, 
    .brand-logo img {
        max-width: 90px !important;
        height: auto !important;
    }

    .header-right-menu {
        gap: 6px !important;
    }

    /* Oversized touch targets for mobile thumb navigation */
    button, 
    a.btn, 
    .addcart-button,
    .btn-solid,
    .btn-outline {
        min-height: 48px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 8px 14px !important;
    }

    /* Toys Page Banner layouts adjustment */
    .tbs-desktop-wrap {
        flex-direction: column !important;
        height: auto !important;
    }

    .tbs-main {
        width: 100% !important;
        flex: none !important;
        height: 180px !important;
    }

    .tbs-side {
        width: 100% !important;
        flex: none !important;
        gap: 8px !important;
    }

    .tbs-side-card {
        height: 120px !important;
        flex: none !important;
    }
}

/* ==========================================================================
   2. MOBILE TIER (481px - 767px)
   ========================================================================== */
@media (min-width: 481px) and (max-width: 767px) {
    html {
        font-size: 13.5px;
    }

    .container, .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Spacing adjustments */
    .section-b-space, .section-t-space {
        padding-top: 35px !important;
        padding-bottom: 35px !important;
    }

    /* Grids to double column on mobile landscape */
    .row-cols-2-mob > * {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
}

/* ==========================================================================
   3. TABLET TIER (768px - 1024px)
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    html {
        font-size: 14.5px;
    }

    /* Adjust Grid templates */
    .grid-3-tab {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 16px !important;
    }

    .tbs-desktop-wrap {
        flex-direction: column !important;
        height: auto !important;
    }

    .tbs-main {
        height: 280px !important;
        width: 100% !important;
        flex: none !important;
    }

    .tbs-side {
        flex-direction: row !important;
        height: 160px !important;
    }
}

/* ==========================================================================
   4. LAPTOP TIER (1025px - 1440px)
   ========================================================================== */
@media (min-width: 1025px) and (max-width: 1440px) {
    html {
        font-size: 15.5px;
    }
}

/* ==========================================================================
   5. DESKTOP TIER (1441px - 1920px)
   ========================================================================== */
@media (min-width: 1441px) and (max-width: 1920px) {
    html {
        font-size: 16px;
    }
}

/* ==========================================================================
   6. LARGE SCREEN / 4K TIER (1921px+)
   ========================================================================== */
@media (min-width: 1921px) {
    html {
        font-size: 18px; /* Fluid Typography upscale */
    }

    /* Clamp maximum visual width to prevent layout stretching */
    body {
        background: #fdfdfd;
    }

    .container,
    .container-fluid,
    .tbs-desktop-wrap,
    .ttc-inner,
    .tbs2-inner,
    .tos-strip__inner,
    .header-nav,
    .footer-section,
    footer,
    header {
        max-width: 1900px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* ==========================================================================
   GENERIC FLUID COMPONENT LAYOUTS
   ========================================================================== */
/* Responsive Product Card Lists using dynamic CSS Grid auto-fill */
.product-grid-fluid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
    gap: var(--fluid-gap) !important;
}

@media (max-width: 576px) {
    .product-grid-fluid {
        grid-template-columns: repeat(2, 1fr) !important; /* Force 2-columns on mobile */
        gap: 8px !important;
    }
}

/* Responsive flex forms */
.form-grid-fluid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: 16px !important;
}

@media (max-width: 480px) {
    .form-grid-fluid {
        grid-template-columns: 1fr !important;
    }
}
