/* Responsive / Mobile Styles */

/* Hide centered brand on smaller screens to prevent overlap */
@media (max-width: 1200px) {
    .nav-center-brand {
        display: none;
    }
}

/* Tablet / Mobile (max-width: 1024px) */
@media (max-width: 1024px) {

    /* Mobile Navbar Refined */
    .shop-nav {
        padding: 0;
        /* Let container handle padding */
    }

    .nav-container,
    .shop-nav-container {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "logo brand icons"
            "nav nav nav";
        align-items: center;
        gap: 10px 0;
        width: 100%;
        padding: 10px 20px;
        /* Mobile Padding */
    }

    /* --- MOBILE NAVBAR REDESIGN --- */

    /* Hide Desktop Elements */
    .nav-desktop,
    .nav-logo-desktop {
        display: none;
    }

    /* Navbar Container becomes flex row for Mobile */
    .nav-container {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;
        height: 60px;
        padding: 0 15px;
    }

    /* Hamburger Button */
    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        color: white;
        font-size: 1.5rem;
        cursor: pointer;
        z-index: 11;
        margin-right: auto;
    }

    /* Brand Name - Top Row */
    .nav-center-brand {
        display: block;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        text-align: center;
        width: auto;
        font-size: 1.5rem;
        white-space: nowrap;
        z-index: 10;
    }

    /* Mobile Icons */
    .nav-mobile-icons {
        display: flex;
        gap: 15px;
        font-size: 1.3rem;
        z-index: 11;
    }

    .nav-mobile-icons a {
        color: white;
        text-decoration: none;
    }

    /* Mobile Search Bar - Row 2 */
    .mobile-search-bar {
        display: block;
        width: 100%;
        padding: 5px 15px 15px 15px;
        background: var(--color-primary);
        /* Blend with header */
        cursor: pointer;
    }

    .search-fake-input {
        background: white;
        border-radius: 20px;
        padding: 10px 15px;
        color: #888;
        display: flex;
        align-items: center;
        font-size: 0.95rem;
    }

    /* SIDE DRAWER */
    .mobile-side-drawer {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 250px;
        height: 100vh;
        background: var(--color-primary);
        z-index: 1000;
        /* High Z-index */
        transform: translateX(-100%);
        /* Hidden by default */
        transition: transform 0.3s ease;
        padding: 20px;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    }

    .mobile-side-drawer.open {
        transform: translateX(0);
        /* Slide In */
    }

    .close-menu-btn {
        background: none;
        border: none;
        color: white;
        font-size: 2rem;
        position: absolute;
        top: 10px;
        right: 15px;
        cursor: pointer;
    }

    .drawer-links {
        margin-top: 50px;
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .drawer-links a {
        color: white;
        text-decoration: none;
        font-size: 1.2rem;
        font-weight: 500;
    }

    .drawer-links hr {
        border: 0;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        width: 100%;
    }

    /* Overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .mobile-overlay.open {
        display: block;
    }

    /* BOTTOM ICON BAR */
    .mobile-bottom-bar {
        position: relative;
        /* Change from absolute */
        top: 0;
        /* Reset top */
        display: flex;
        justify-content: space-around;
        align-items: center;
        background: var(--color-primary);
        padding: 15px;
        width: 100%;
        z-index: 20;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .mobile-bottom-bar a {
        color: white;
        font-size: 1.5rem;
    }

    /* Adjust Navbar Layout to accommodate 2 rows? */
    /* Wait, the HTML structure I added put .mobile-bottom-bar OUTSIDE .navbar? */
    /* If I want it to look like a 2-row header, I should style it to sit right below. */
    /* Since it is a sibling of header, it will naturally flow below. */

    .navbar {
        padding: 0 20px;
        /* Reduced vertical padding since we have 2 rows height */
    }

    /* Ensure hero starts AFTER the bottom bar */
    /* .mobile-bottom-bar height is approx 50-60px. Navbar is 60px. Total ~120px. */
    /* Shop Hero padding might need adjustment */

    /* Adjust links font size for mobile */
    .nav-links a {
        font-size: 0.9rem;
        margin-left: 0;
        text-transform: uppercase;
        font-weight: 500;
        letter-spacing: 1px;
    }

    /* Product Grid */
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    .shop-layout {
        grid-template-columns: 1fr;
        /* Stack sidebar on top */
    }

    /* 3. Pull the video card UP so it doesn't leave a huge gap */
    #hero.animate-phase-2 .hero-video {
        top: 50% !important;
        transform: translateY(-50%);
        left: 5% !important;
        width: 90% !important;
        height: auto !important;
        aspect-ratio: 16 / 9;
        /* Force horizontal aspect ratio */
        border-radius: 15px;
    }

    /* Fix Toolbar Overlap */
    .shop-toolbar {
        flex-direction: column;
        align-items: stretch;
        /* Full width */
        gap: 20px;
    }

    /* Stack Reviews Layout */
    .reviews-split-layout {
        grid-template-columns: 1fr !important;
        gap: 40px !important;
    }

    .user-images-gallery {
        border-left: none !important;
        padding-left: 0 !important;
        border-top: 1px solid #eee;
        padding-top: 30px;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100%;
        display: flex;
        justify-content: flex-start;
        /* Exact match */
        align-items: center;
        gap: 5px;
        /* Exact match */
    }

    /* Prevent text wrapping on labels and ALIGN them */
    .filter-label,
    .sort-wrapper label {
        white-space: nowrap;
        width: 80px;
        /* Increased to accommodate "Sort by:" comfortably */
        flex-shrink: 0;
        /* Prevent compression */
        display: inline-block;
        font-size: 1rem !important;
        /* Standardize font size */
        color: var(--color-secondary);
    }

    /* Standardize Dropdown/Select Text */
    .dropdown-btn {
        font-size: 1rem !important;
        font-family: var(--font-body) !important;
        color: var(--color-secondary);
        padding: 5px 10px;
        /* Add horizontal padding */
        width: 140px;
        /* Slightly wider for breathing room */
        justify-content: space-between;
        /* Text Left, Icon Right */
        border: 1px solid rgba(0, 0, 0, 0.1);
        /* Optional: subtle border to define area */
        border-radius: 4px;
        background: rgba(255, 255, 255, 0.5);
        /* Optional: slight background */
        display: flex;
        align-items: center;
        text-align: left;
    }

    /* Remove native select styles if any remain */

    .sort-wrapper {
        display: flex;
        gap: 15px;
        /* Match toolbar-left gap */
        align-items: center;
        width: 100%;
        /* Ensure it takes full width */
    }

    #result-count {
        display: none;
        /* Hidden for alignment testing */
    }

    .product-page-container {
        padding-top: 20px;
    }

    .product-meta {
        margin-top: 30px;
        padding-top: 50px;
        border-top: 1px solid #eee;
        color: #888;
        font-size: 0.9rem;
        line-height: 1.8;
    }

    .product-details {
        padding: 15px;
        text-align: center;
    }

    /* Fix Footer Overlap */
    .footer-content {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }

    .footer-links {
        margin-top: 10px;
    }

    .footer-links a {
        margin: 0 10px;
        /* Even spacing for centered links */
        display: inline-block;
        margin-bottom: 10px;
    }

    .shop-sidebar {
        margin-bottom: 30px;
    }

    .shop-sidebar ul {
        display: flex;
        overflow-x: auto;
        padding-bottom: 10px;
    }

    .shop-sidebar li {
        margin-right: 15px;
        margin-bottom: 0;
        white-space: nowrap;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2 Columns Mobile */
        gap: 15px;
    }

    .shop-hero {
        padding-top: 20px;
        padding-bottom: 10px;
        height: 10vh;
        margin-top: 10px;
    }

    .shop-hero h1 {
        font-size: 2.5rem;
        text-align: center !important;
    }

    .shop-hero p {
        text-align: center !important;
    }

    /* Hero Video Section Mobile Control */
    #hero {
        height: auto;
        min-height: auto;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding-top: 10px;
        /* Space under nav */
        padding-bottom: 20px;
        /* Extended space exactly for the gradient fade */
        background: linear-gradient(to bottom, var(--color-primary) 0%, var(--color-primary) calc(100% - 120px), var(--color-white) 100%);
    }

    #hero .hero-video {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 16 / 9;
        transform: none !important;
        border-radius: 0;
        /* Optional: stretch edge-to-edge if width=100%, else give margin */
    }

    #hero.animate-phase-2 .hero-video {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        width: 90% !important;
        margin: 0 auto;
        border-radius: 15px;
    }

    .video-placeholder {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .hero-text-container {
        display: block !important;
        position: absolute !important;
        top: calc(28vw + 10px) !important;
        /* Center of the 16:9 video player on mobile */
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        z-index: 5;
        transition: opacity 0.8s ease;
    }

    /* Fade out the text animation when the mobile video is ready */
    #hero.animate-phase-2 .hero-text-container {
        opacity: 0 !important;
        pointer-events: none;
    }

    .hero-content {
        position: relative !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        width: 100%;
        padding: 20px 20px 0 20px;
        text-align: center;
        opacity: 0;
        /* Start hidden so animations can trigger properly */
        transition: opacity 1s ease;
    }

    #hero.animate-phase-2 .hero-content {
        opacity: 1 !important;
        /* Trigger fade in */
    }

    .hero-content h1 {
        font-size: 2rem;
        color: white;
        /* Ensure it's dark text since the background is now the sage page color, not the dark video */
        margin-bottom: 15px;
    }

    .hero-content p {
        font-size: 1rem;
        color: white;
        margin-bottom: 30px;
        /* Adjusted to fit the nested button */
    }

    /* Mobile Explore Button embedded in hero */
    .btn-mobile-explore {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.95);
        color: var(--color-primary-dark);
        border: 2px solid white;
        padding: 12px 35px;
        font-weight: 600;
        font-family: var(--font-heading);
        font-size: 1.1rem;
        border-radius: 30px;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
        text-transform: none;
        /* Keep it sentence case for modern aesthetic */
        letter-spacing: 0.5px;
        transition: all 0.3s ease;
        text-decoration: none;
    }

    .btn-mobile-explore:active {
        transform: scale(0.95) translateY(2px);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        background: white;
    }

    /* --- HOME CAROUSEL MOBILE REFINEMENTS --- */
    .carousel-split,
    .carousel-split.reverse {
        flex-direction: column;
        /* Force text on top, image below for BOTH variations */
        max-height: none;
        /* Remove height limits so vertically stacked elements don't get clipped */
        height: auto;
        /* Create a vertical split background to match the stacking */
        background: linear-gradient(to bottom, var(--color-primary) auto, #f4f6f5 auto);
    }

    .carousel-split {
        background: linear-gradient(to bottom, var(--color-primary) 50%, #f4f6f5 50%);
    }

    .carousel-split.reverse {
        background: linear-gradient(to bottom, var(--color-primary) 50%, #f4f6f5 50%);
    }

    .carousel-left {
        flex: none;
        max-width: 100%;
        width: 100%;
        min-height: auto;
        padding: 40px 20px !important;
    }

    .carousel-right {
        flex: none;
        max-width: 100%;
        width: 100%;
        min-height: 400px;
        /* Remove the heavy horizontal mask that squeezes images on mobile */
        mask-image: none;
        -webkit-mask-image: none;
        padding: 20px 0;
    }

    .carousel-text-area h3 {
        font-size: 3rem !important;
        /* Scale down the massive 5rem desktop font */
        margin-bottom: 10px !important;
    }

    .carousel-text-area p {
        font-size: 1rem !important;
        margin-bottom: 25px !important;
    }

    /* Reduce card dimensions for mobile so the 3-card stack fits */
    .card-stack {
        width: 180px;
        /* Scale down from 340px */
    }

    /* Reduce vertical padding around carousel sections */
    #featured-carousel,
    .dynamic-section {
        padding: 20px 0 !important;
    }

    /* Hide or shrink the connecting SVG on mobile to save space */
    .section-connector {
        height: 60px !important;
        margin: -10px 0 !important;
    }

    /* Scale down product image on mobile so title/price are visible */
    .product-gallery img {
        aspect-ratio: 4 / 4;
        max-height: 55vh;
    }

    .enlarge-hint {
        display: flex;
        align-items: center;
    }
}