/* 
   ==========================================================================
   5-responsive.css
   ==========================================================================
   This file handles all the Media Queries for mobile and tablet devices.
   It overrides styles defined in the previous files to ensure a great
   experience on smaller screens.
*/

/* 
  Mobile & Tablet Styles (Max-width: 900px) 
  We use 900px breakpoint to better handle tablets and large phones.
*/
@media (max-width: 900px) {

    /* 1. Global Typography Adjustments */
    body {
        font-size: 14px;
        /* Slightly smaller base text */
    }

    .section-title {
        font-size: 1.5rem;
        margin: 2rem 0;
    }

    /* 2. Navigation */
    .hamburger {
        display: block !important;
        /* Show hamburger */
        cursor: pointer;
    }

    .nav-links {
        display: none;
        /* Hide default nav menu */
    }

    /* 3. Product Grid */
    .products-grid {
        gap: 0.8rem;
        padding: 0.5rem;
        justify-content: flex-start;
    }

    /* 4. Product Cards - Stacked Layout */
    .product-card {
        padding: 0.5rem;
        /* Two cards per row (50%) minus gap */
        flex: 0 0 calc(50% - 0.5rem);
        max-width: calc(50% - 0.5rem);
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-width: 0;
        /* Prevent flex item overflow */
        overflow: hidden;
        /* Contain content */
    }

    .product-card img {
        height: 200px;
        /* Give product images more presence on mobile */
        width: 100%;
        margin: 0 auto;
        display: block;
        object-fit: contain;
    }

    .product-card h3 {
        font-size: 0.85rem;
        margin-bottom: 0.2rem;
        min-height: 2.4em;
        max-height: 2.4em;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        -webkit-box-orient: vertical;
        word-wrap: break-word;
        word-break: break-word;
        text-overflow: ellipsis;
        line-height: 1.2;
        text-align: center;
    }

    .product-card .price {
        font-size: 0.8rem;
        margin-bottom: 0.3rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .cta-button {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.8rem !important;
        width: 100%;
        margin-top: auto;
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 5. Controls Bar (Search, Filter, Sort) */
    .controls-bar {
        padding-top: 5rem;
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .controls-wrapper {
        width: 100%;
        display: flex;
        flex-direction: column;
        /* Stack controls vertically */
        gap: 0.8rem;
    }

    .search-wrapper {
        width: 100%;
        /* Full width search */
    }

    .title-wrapper {
        width: 100%;
        text-align: center;
        margin-bottom: 0.5rem;
    }

    .controls-bar .section-title {
        position: static;
        transform: none;
        margin: 0;
    }

    .controls-bar label {
        display: none;
        /* Saving space */
    }

    .sort-select {
        width: 100%;
        margin-left: 0;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    /* 6. Product Details Page overrides */
    .product-info-section h1 {
        font-size: 1.8rem !important;
    }

    .product-info-section .price {
        font-size: 1.4rem !important;
    }
}

/* 
   Extra Small Devices (Mini Mobile < 380px)
   Switch to single column to ensure text is readable.
*/
@media (max-width: 380px) {
    .products-grid {
        justify-content: center;
        /* Center single column */
    }

    .product-card {
        flex: 0 0 100%;
        /* Full width */
        max-width: 100%;
        margin-bottom: 1rem;
    }

    .product-card h3 {
        font-size: 1rem;
        /* Restore readable font size */
        height: auto;
        /* Allow full height */
        -webkit-line-clamp: 3;
        /* Show more lines */
        line-clamp: 3;
    }

    .product-card img {
        height: 220px;
        /* Larger image for single column */
    }
}

/* 
   Desktop Styles (Min-width: 901px)
   Restores horizontal layouts where needed.
*/
@media (min-width: 901px) {
    .controls-bar {
        flex-direction: row;
        margin-top: 6rem;
        align-items: center;
    }

    .controls-wrapper {
        flex-direction: row;
    }

    .search-wrapper {
        width: auto;
    }
}

/* 
   Lightbox Responsive Styles 
*/
@media (max-width: 900px) {

    /* Lightbox adjustments for mobile */
    .lightbox-close {
        top: 10px;
        right: 15px;
        font-size: 30px;
    }

    .lightbox-arrow {
        font-size: 1.5rem;
        padding: 10px 12px;
    }

    .lightbox-content {
        max-width: 95vw;
        max-height: 70vh;
    }

    .lightbox-image,
    .lightbox-video {
        max-height: 70vh;
    }

    .lightbox-counter {
        bottom: 10px;
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    /* Thumbnail strip mobile adjustments */
    .thumbnail-strip {
        gap: 6px;
        margin-top: 10px;
    }

    .thumbnail-item {
        width: 50px;
        height: 50px;
    }

    .thumbnail-item .video-play-overlay {
        width: 20px;
        height: 20px;
    }

    .thumbnail-item .video-play-overlay::after {
        border-left-width: 6px;
        border-top-width: 4px;
        border-bottom-width: 4px;
    }

    /* Product image section mobile */
    .product-image-section {
        padding: 1rem !important;
    }

    .product-image-section video,
    .product-image-section img {
        max-height: 300px;
    }

    .media-type-badge {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    .video-play-overlay {
        width: 50px;
        height: 50px;
    }

    .video-play-overlay::after {
        border-left-width: 16px;
        border-top-width: 10px;
        border-bottom-width: 10px;
    }
}

/* Extra small devices */
@media (max-width: 380px) {
    .thumbnail-item {
        width: 40px;
        height: 40px;
    }

    .lightbox-arrow {
        font-size: 1.2rem;
        padding: 8px 10px;
    }
}