/* =================================================================
   MOBILE RESPONSIVE OPTIMIZED CSS
   extracted from inline styles for better performance
   ================================================================= */

/* Mobile-first CSS Grid and Flexbox optimizations */
@media (max-width: 768px) {
    /* Global container optimizations */
    .container, .container-fluid {
        max-width: 100% !important;
        overflow-x: hidden !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Products slider container mobile optimization */
    .products-slider-container {
        min-height: 420px !important;
        overflow: hidden !important;
        padding: 0 !important;
    }
    
    /* Products grid - horizontal scroll optimization */
    .products-lineup-grid {
        display: flex !important;
        flex-direction: row !important;
        gap: 20px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-behavior: smooth !important;
        -webkit-overflow-scrolling: touch !important;
        scroll-snap-type: x mandatory !important;
        padding: 20px 15px !important;
        width: 100% !important;
    }
    
    /* Hide scrollbars but keep functionality */
    .products-lineup-grid::-webkit-scrollbar {
        display: none !important;
    }
    
    .products-lineup-grid {
        -ms-overflow-style: none !important;
        scrollbar-width: none !important;
    }
    
    /* Product cards - optimized sizing */
    .product-lineup-card {
        width: 240px !important;
        height: 380px !important;
        flex-shrink: 0 !important;
        scroll-snap-align: start !important;
        margin: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        border-radius: 16px !important;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Product card states unified */
    .product-lineup-card.active,
    .product-lineup-card.left,
    .product-lineup-card.right,
    .product-lineup-card.far-left,
    .product-lineup-card.far-right,
    .product-lineup-card.hidden {
        position: static !important;
        width: 240px !important;
        height: 380px !important;
        transform: none !important;
        opacity: 1 !important;
        z-index: auto !important;
    }
    
    /* Product card image optimization */
    .product-lineup-image {
        height: 120px !important;
        overflow: hidden !important;
        border-radius: 12px 12px 0 0 !important;
        flex-shrink: 0 !important;
    }
    
    /* Product card content optimization */
    .product-lineup-content {
        padding: 12px 16px 16px 16px !important;
        height: calc(100% - 120px) !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* Typography optimizations */
    .product-lineup-title {
        font-size: 0.95rem !important;
        line-height: 1.2 !important;
        margin-bottom: 6px !important;
        overflow: hidden !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        text-overflow: ellipsis !important;
        font-weight: 600 !important;
    }
    
    .product-lineup-description {
        font-size: 0.8rem !important;
        line-height: 1.3 !important;
        margin-bottom: 6px !important;
        overflow: auto !important;
        flex: 1 !important;
        color: #666 !important;
    }
    
    .product-lineup-price {
        font-size: 1rem !important;
        font-weight: 700 !important;
        color: #d4af17 !important;
        margin-bottom: 8px !important;
    }
    
    /* Action buttons optimization */
    .product-lineup-actions {
        margin-top: auto !important;
        display: flex !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
    }
    
    .product-lineup-actions .btn {
        font-size: 0.75rem !important;
        padding: 6px 8px !important;
        flex: 1 !important;
        min-width: 0 !important;
        min-height: 36px !important; /* Slightly smaller but still touch-friendly */
        white-space: nowrap !important;
        border-radius: 8px !important;
        font-weight: 500 !important;
    }
    
    /* Generation cards mobile optimization */
    .generation-row {
        justify-content: flex-start !important;
        padding: 20px 15px 20px 20px !important;
        gap: 15px !important;
        margin: 30px 0 20px !important;
        overflow-x: auto !important;
        scroll-behavior: smooth !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .generation-card {
        min-width: 180px !important;
        max-width: 200px !important;
        flex-shrink: 0 !important;
    }
    
    .generation-card:first-child {
        margin-left: 0 !important;
    }
    
    .generation-card:last-child {
        margin-right: 20px !important;
    }
    
    /* Header and navigation mobile optimization */
    .navbar {
        padding: 0.5rem 1rem !important;
        min-height: 85px !important;
    }
    
    .navbar-brand img {
        max-height: 75px !important;
    }
    
    /* Navigation buttons touch optimization */
    .nav-link, .btn {
        min-height: 44px !important;
        min-width: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
        cursor: pointer !important;
    }
    
    .hamburger-menu {
        min-height: 44px !important;
        min-width: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
    }
    
    /* Hero section mobile optimization */
    .hero-slider {
        height: calc(100vh - 85px) !important;
        min-height: 400px !important;
        max-height: none !important;
    }
    
    /* Hero slides mobile image optimization */
    .slide {
        background-size: cover !important;
        background-position: center center !important;
        background-attachment: scroll !important;
    }
    
    .hero-content {
        padding: 2rem 1rem !important;
        text-align: center !important;
    }
    
    .slide-content {
        padding: 2rem 1rem !important;
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .hero-title {
        font-size: clamp(1.8rem, 5vw, 2.5rem) !important;
        line-height: 1.3 !important;
        margin-bottom: 1rem !important;
    }
    
    .hero-subtitle {
        font-size: clamp(1rem, 3vw, 1.2rem) !important;
        line-height: 1.5 !important;
        margin-bottom: 1.5rem !important;
    }
    
    .hero-buttons {
        display: flex !important;
        flex-direction: column !important;
        gap: 1rem !important;
        align-items: center !important;
    }
    
    .btn-hero {
        padding: 12px 24px !important;
        font-size: 1rem !important;
        min-height: 44px !important;
        min-width: 200px !important;
        max-width: 280px !important;
        width: 100% !important;
        touch-action: manipulation !important;
    }
    
    /* Footer mobile optimization */
    .footer {
        padding: 2rem 0 !important;
    }
    
    .footer-content {
        text-align: center !important;
    }
    
    .footer-section {
        margin-bottom: 2rem !important;
    }
    
    /* Modal mobile optimization */
    .modal-content {
        max-width: 95vw !important;
        max-height: 90vh !important;
        margin: 5vh auto !important;
    }
    
    .modal-body {
        padding: 1rem !important;
    }
    
    /* News and content cards mobile optimization */
    .news-card, .content-card {
        margin-bottom: 1.5rem !important;
        border-radius: 12px !important;
    }
    
    .news-image, .content-image {
        height: 200px !important;
        object-fit: cover !important;
    }
    
    /* About page tradition images mobile optimization */
    .tradition-image {
        height: 250px !important;
        overflow: hidden !important;
        border-radius: 12px !important;
        margin-bottom: 1rem !important;
    }
    
    .tradition-image img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
        contain: none !important;
        content-visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Section spacing optimization */
    .section-title {
        font-size: 1.5rem !important;
        margin-bottom: 1rem !important;
        line-height: 1.3 !important;
    }
    
    .section-content {
        margin-bottom: 1.5rem !important;
    }
    
    .section-content p {
        font-size: 16px !important;
        line-height: 1.5 !important;
        margin-bottom: 1rem !important;
    }
    
    /* Form elements mobile optimization */
    input, textarea, select, button {
        font-size: 16px !important; /* Prevent zoom on iOS */
        min-height: 44px !important;
    }
    
    /* Text and link optimization */
    p, span, div, a {
        font-size: 16px !important;
        line-height: 1.5 !important;
    }
    
    .small, .text-small {
        font-size: 16px !important; /* No smaller than 16px for accessibility */
    }
    
    /* Table mobile optimization */
    .table-responsive {
        border: none !important;
    }
    
    .table {
        font-size: 16px !important;
    }
    
    .table td, .table th {
        padding: 0.75rem 0.5rem !important;
    }
}

/* Smaller mobile devices (480px and below) */
@media (max-width: 480px) {
    .products-slider-container {
        min-height: 380px !important;
    }
    
    .product-lineup-card {
        width: 220px !important;
        height: 340px !important;
    }
    
    .product-lineup-content {
        padding: 10px 14px 14px 14px !important;
        height: calc(100% - 100px) !important;
    }
    
    .product-lineup-image {
        height: 100px !important;
    }
    
    .product-lineup-title {
        font-size: 0.95rem !important;
        margin-bottom: 6px !important;
    }
    
    .product-lineup-description {
        font-size: 0.8rem !important;
        margin-bottom: 6px !important;
    }
    
    .product-lineup-price {
        font-size: 1rem !important;
        margin-bottom: 10px !important;
    }
    
    .product-lineup-actions .btn {
        font-size: 0.75rem !important;
        padding: 6px 10px !important;
    }
    
    .generation-card {
        min-width: 160px !important;
        max-width: 180px !important;
    }
    
    .navbar {
        min-height: 75px !important;
    }
    
    .navbar-brand img {
        max-height: 65px !important;
    }
    
    .hero-slider {
        height: calc(100vh - 75px) !important;
        min-height: 350px !important;
    }
    
    .hero-title {
        font-size: clamp(1.5rem, 6vw, 2rem) !important;
    }
    
    .hero-subtitle {
        font-size: clamp(0.9rem, 2.5vw, 1.1rem) !important;
    }
    
    /* About page tradition images for smaller screens */
    .tradition-image {
        height: 200px !important;
    }
}

/* Very small devices (360px and below) */
@media (max-width: 360px) {
    .products-slider-container {
        min-height: 360px !important;
    }
    
    .product-lineup-card {
        width: 200px !important;
        height: 320px !important;
    }
    
    .product-lineup-content {
        padding: 8px 12px 12px 12px !important;
        height: calc(100% - 90px) !important;
    }
    
    .product-lineup-image {
        height: 90px !important;
    }
    
    .product-lineup-title {
        font-size: 0.9rem !important;
        margin-bottom: 5px !important;
    }
    
    .product-lineup-description {
        font-size: 0.75rem !important;
        margin-bottom: 5px !important;
    }
    
    .product-lineup-price {
        font-size: 0.95rem !important;
        margin-bottom: 8px !important;
    }
    
    .product-lineup-actions .btn {
        font-size: 0.7rem !important;
        padding: 5px 8px !important;
    }
    
    .container, .container-fluid {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
    
    .navbar {
        min-height: 65px !important;
        padding: 0.25rem 0.5rem !important;
    }
    
    .navbar-brand img {
        max-height: 55px !important;
    }
    
    .hero-slider {
        height: calc(100vh - 65px) !important;
        min-height: 300px !important;
    }
    
    .hero-title {
        font-size: clamp(1.3rem, 5vw, 1.8rem) !important;
    }
    
    .hero-subtitle {
        font-size: clamp(0.8rem, 2vw, 1rem) !important;
    }
    
    /* About page tradition images for smallest screens */
    .tradition-image {
        height: 180px !important;
    }
}

/* =============================================================
   Featured product image gallery mobile fixes
   ============================================================= */
@media (max-width: 768px) {
    /* Featured image container fixes */
    .featured-image-container {
        padding: 15px !important;
        margin-bottom: 20px !important;
    }
    
    .image-frame {
        max-width: 100% !important;
        overflow: hidden !important;
    }
    
    /* Ensure main featured images scale nicely on mobile */
    .featured-image,
    .main-image,
    .modal-main-image,
    #mainCoasterImage {
        max-width: 100% !important;
        width: 100% !important;  /* fill parent width */
        height: auto !important; /* maintain aspect ratio */
        max-height: 280px !important; /* prevent excessive height */
        object-fit: contain !important; /* show whole image without crop */
        display: block !important;
        margin: 0 auto !important;
    }
    
    /* Fix inline styles on image container */
    .featured-image-container > .image-frame > div[style*="position: relative"] {
        width: 100% !important;
        text-align: center !important;
    }

    /* Thumbnail container fixes */
    .coaster-thumbnails {
        justify-content: center !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding: 10px 5px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Thumbnail sizing tweaks */
    .coaster-thumb,
    .thumbnail-image,
    .modal-coaster-thumb {
        width: 45px !important;
        height: 45px !important;
        flex-shrink: 0 !important;
    }
    
    /* Player caption adjustments */
    #playerCaption {
        font-size: 0.8rem !important;
        padding: 6px 10px !important;
        bottom: 5px !important;
        left: 10px !important;
    }
    
    /* Featured content adjustments */
    .featured-content {
        padding: 0 15px !important;
    }
    
    .featured-title {
        font-size: 1.3rem !important;
        line-height: 1.3 !important;
    }
    
    .featured-description {
        font-size: 0.9rem !important;
    }
}

/* Further adjust for very small devices */
@media (max-width: 480px) {
    .featured-image-container {
        padding: 10px !important;
    }
    
    .featured-image,
    .main-image,
    .modal-main-image,
    #mainCoasterImage {
        max-height: 240px !important;
    }

    .coaster-thumb,
    .thumbnail-image,
    .modal-coaster-thumb {
        width: 40px !important;
        height: 40px !important;
    }
    
    .coaster-thumbnails {
        gap: 6px !important;
        padding: 8px 3px !important;
    }
    
    .featured-title {
        font-size: 1.1rem !important;
    }
    
    .featured-description {
        font-size: 0.85rem !important;
    }
    
    .featured-buttons .btn {
        font-size: 0.85rem !important;
        padding: 10px 16px !important;
    }
}

@media (max-width: 360px) {
    .featured-image-container {
        padding: 8px !important;
    }
    
    .featured-image,
    .main-image,
    .modal-main-image,
    #mainCoasterImage {
        max-height: 200px !important;
    }

    .coaster-thumb,
    .thumbnail-image,
    .modal-coaster-thumb {
        width: 35px !important;
        height: 35px !important;
    }
    
    .coaster-thumbnails {
        gap: 5px !important;
        padding: 6px 2px !important;
    }
    
    .featured-badge {
        font-size: 0.75rem !important;
        padding: 4px 10px !important;
    }
    
    .featured-title {
        font-size: 1rem !important;
        margin-bottom: 8px !important;
    }
    
    .featured-description {
        font-size: 0.8rem !important;
        margin-bottom: 10px !important;
    }
    
    .featured-price {
        font-size: 1.1rem !important;
    }
    
    .featured-buttons {
        gap: 8px !important;
    }
    
    .featured-buttons .btn {
        font-size: 0.8rem !important;
        padding: 8px 12px !important;
        min-height: 38px !important;
    }
    
    #playerCaption {
        font-size: 0.7rem !important;
        padding: 4px 8px !important;
    }
}

/* =============================================================
   Product card image visibility fix
   ============================================================= */
.product-card .product-image {
    position: relative !important; /* override absolute positioning */
    width: 100% !important;
    height: auto !important; /* allow image natural height */
    padding-top: 0 !important; /* cancel aspect ratio padding */
    overflow: hidden !important;
}

.product-card .product-image img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    object-fit: cover !important;
}

/* Ensure product content no longer covers image */
.product-card .product-content {
    background: #fff !important;
    position: static !important;
}

/* Add subtle shadow on hover when image fixed */
.product-card:hover {
    box-shadow: 0 15px 35px rgba(0,0,0,0.15) !important;
}

/* Prevent horizontal scroll globally */
html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
}

/* Universal mobile touch improvements */
* {
    -webkit-tap-highlight-color: rgba(0,0,0,0.1) !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
}

/* Allow text selection where needed */
p, h1, h2, h3, h4, h5, h6, span, div.content {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* Performance optimizations */
* {
    box-sizing: border-box !important;
}

img {
    max-width: 100% !important;
    height: auto !important;
    display: block !important;
}

/* Smooth scrolling for all elements */
* {
    scroll-behavior: smooth !important;
}