/* ========================
   MOBILE-FIRST CARD GALLERY REDESIGN
   Revolutionary UX for viewing cards on all devices
   ======================== */

/* ========================
   MOBILE GALLERY OPTIMIZATIONS
   ======================== */

@media (max-width: 767px) {
    /* Gallery modal - maximize screen usage */
    #card-gallery-modal .modal-content {
        width: 98% !important;
        height: 95vh !important;
        max-height: 95vh !important;
        max-width: none !important;
        margin: 2.5vh auto !important;
        padding: 10px 8px !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }
    
    /* Gallery header - compact and efficient */
    .gallery-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px !important;
        padding: 0 5px !important;
        margin-bottom: 15px !important;
    }
    
    .gallery-header h2 {
        font-size: 1.6rem !important;
        margin: 0 !important;
        text-align: center !important;
        color: var(--gold-color) !important;
    }
    
    /* SMART DROPDOWN INSTEAD OF TABS */
    .gallery-category-selector {
        width: 100% !important;
        max-width: 280px !important;
        padding: 12px 16px !important;
        font-size: 1.1rem !important;
        font-weight: bold !important;
        background: linear-gradient(135deg, #2c3e50, #34495e) !important;
        color: var(--gold-color) !important;
        border: 2px solid var(--gold-color) !important;
        border-radius: 10px !important;
        cursor: pointer !important;
        text-align: center !important;
        appearance: none !important;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23f0c33c' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") !important;
        background-repeat: no-repeat !important;
        background-position: right 12px center !important;
        background-size: 20px !important;
        padding-right: 40px !important;
    }
    
    .gallery-category-selector:focus {
        outline: 3px solid rgba(240, 195, 60, 0.5) !important;
        outline-offset: 2px !important;
    }
    
    /* Hide old tab system on mobile */
    .gallery-tabs {
        display: none !important;
    }
    
    /* REVOLUTIONARY SINGLE-CARD MOBILE VIEW */
    .gallery-content {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding: 0 5px !important;
        gap: 15px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        max-height: none !important;
    }
    
    /* Mobile card display - focus on one card */
    .gallery-mobile-card-container {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        background: rgba(0, 0, 0, 0.6) !important;
        border-radius: 15px !important;
        padding: 20px 15px !important;
        margin-bottom: 15px !important;
        border: 2px solid rgba(240, 195, 60, 0.3) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    }
    
    .gallery-mobile-card-container .card {
        width: 200px !important;
        height: 280px !important;
        margin-bottom: 15px !important;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4) !important;
        border-radius: 12px !important;
        border: 3px solid rgba(255, 255, 255, 0.2) !important;
        transition: transform 0.3s ease !important;
    }
    
    /* Card information section */
    .gallery-card-info-mobile {
        width: 100% !important;
        text-align: center !important;
        color: white !important;
    }
    
    .gallery-card-name-mobile {
        font-size: 1.4rem !important;
        font-weight: bold !important;
        color: var(--gold-color) !important;
        margin-bottom: 10px !important;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7) !important;
    }
    
    .gallery-card-description-mobile {
        font-size: 1rem !important;
        line-height: 1.5 !important;
        color: rgba(255, 255, 255, 0.9) !important;
        margin-bottom: 15px !important;
        padding: 0 10px !important;
        text-align: center !important;
        max-height: 4.5em !important;
        overflow: hidden !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 3 !important;
        -webkit-box-orient: vertical !important;
    }
    
    /* SMART INFO BUTTON */
    .gallery-info-button {
        background: var(--treasure-gradient) !important;
        color: var(--dark-color) !important;
        border: none !important;
        padding: 10px 20px !important;
        border-radius: 8px !important;
        font-size: 1rem !important;
        font-weight: bold !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2) !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
    }
    
    .gallery-info-button:active {
        transform: scale(0.95) !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
    }
    
    .gallery-info-button::before {
        content: "ℹ️" !important;
        font-size: 1.1rem !important;
    }
    
    /* Navigation controls */
    .gallery-mobile-navigation {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        width: 100% !important;
        padding: 15px 20px !important;
        background: rgba(0, 0, 0, 0.4) !important;
        border-radius: 10px !important;
        margin-top: 10px !important;
    }
    
    .gallery-nav-button {
        background: rgba(240, 195, 60, 0.2) !important;
        border: 2px solid var(--gold-color) !important;
        color: var(--gold-color) !important;
        padding: 10px 15px !important;
        border-radius: 8px !important;
        font-size: 1.1rem !important;
        font-weight: bold !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        min-width: 80px !important;
        min-height: 44px !important;
    }
    
    .gallery-nav-button:active {
        background: rgba(240, 195, 60, 0.4) !important;
        transform: scale(0.95) !important;
    }
    
    .gallery-nav-button:disabled {
        opacity: 0.3 !important;
        cursor: not-allowed !important;
        transform: none !important;
    }
    
    .gallery-card-counter {
        color: white !important;
        font-size: 1rem !important;
        font-weight: bold !important;
        text-align: center !important;
        padding: 8px 12px !important;
        background: rgba(0, 0, 0, 0.6) !important;
        border-radius: 6px !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
    }
    
    /* Card Detail Modal - Full Information */
    .gallery-detail-modal {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        background: rgba(0, 0, 0, 0.9) !important;
        z-index: 2001 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: all 0.3s ease !important;
    }
    
    .gallery-detail-modal.active {
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    .gallery-detail-content {
        background: linear-gradient(135deg, #2c3e50, #34495e) !important;
        border-radius: 15px !important;
        padding: 25px 20px !important;
        width: 95% !important;
        max-width: 400px !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
        border: 3px solid var(--gold-color) !important;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
        text-align: center !important;
        color: white !important;
        position: relative !important;
    }
    
    .gallery-detail-card {
        width: 180px !important;
        height: 252px !important;
        margin: 0 auto 20px !important;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4) !important;
    }
    
    .gallery-detail-title {
        font-size: 1.6rem !important;
        font-weight: bold !important;
        color: var(--gold-color) !important;
        margin-bottom: 15px !important;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7) !important;
    }
    
    .gallery-detail-description {
        font-size: 1.1rem !important;
        line-height: 1.6 !important;
        margin-bottom: 20px !important;
        color: rgba(255, 255, 255, 0.95) !important;
    }
    
    .gallery-detail-stats {
        background: rgba(0, 0, 0, 0.4) !important;
        border-radius: 10px !important;
        padding: 15px !important;
        margin-bottom: 20px !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
    }
    
    .gallery-detail-stat {
        display: flex !important;
        justify-content: space-between !important;
        margin-bottom: 8px !important;
        font-size: 1rem !important;
    }
    
    .gallery-detail-stat:last-child {
        margin-bottom: 0 !important;
    }
    
    .gallery-detail-close {
        position: absolute !important;
        top: 15px !important;
        right: 15px !important;
        background: rgba(244, 67, 54, 0.2) !important;
        border: 2px solid #f44336 !important;
        color: #f44336 !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 1.2rem !important;
        font-weight: bold !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }
    
    .gallery-detail-close:active {
        background: rgba(244, 67, 54, 0.4) !important;
        transform: scale(0.95) !important;
    }
}

/* ========================
   TABLET AND LARGER SCREENS
   ======================== */

@media (min-width: 768px) {
    /* Keep original grid layout for larger screens */
    .gallery-category-selector {
        display: none !important;
    }
    
    .gallery-tabs {
        display: flex !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        margin-bottom: 20px !important;
    }
    
    .gallery-content {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
        gap: 20px !important;
        padding: 20px !important;
        max-height: 65vh !important;
        overflow-y: auto !important;
        background: rgba(0, 0, 0, 0.3) !important;
        border-radius: 12px !important;
        border: 2px solid rgba(255, 255, 255, 0.2) !important;
    }
    
    .gallery-card-container {
        background: rgba(0, 0, 0, 0.6) !important;
        border-radius: 12px !important;
        padding: 15px !important;
        border: 2px solid rgba(240, 195, 60, 0.3) !important;
        transition: all 0.3s ease !important;
    }
    
    .gallery-card-container:hover {
        border-color: rgba(240, 195, 60, 0.6) !important;
        transform: translateY(-5px) !important;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4) !important;
    }
    
    /* Hide mobile-specific elements on larger screens */
    .gallery-mobile-card-container,
    .gallery-mobile-navigation {
        display: none !important;
    }
}

/* ========================
   LANDSCAPE MOBILE
   ======================== */

@media (max-width: 767px) and (orientation: landscape) {
    #card-gallery-modal .modal-content {
        height: 98vh !important;
        margin: 1vh auto !important;
    }
    
    .gallery-mobile-card-container {
        flex-direction: row !important;
        align-items: center !important;
        padding: 15px !important;
    }
    
    .gallery-mobile-card-container .card {
        width: 140px !important;
        height: 196px !important;
        margin-right: 15px !important;
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
    }
    
    .gallery-card-info-mobile {
        flex: 1 !important;
        text-align: left !important;
        padding-left: 15px !important;
    }
    
    .gallery-mobile-navigation {
        margin-top: 5px !important;
        padding: 10px 15px !important;
    }
}

/* ========================
   ACCESSIBILITY IMPROVEMENTS
   ======================== */

@media (max-width: 767px) {
    /* Better focus indicators */
    .gallery-nav-button:focus,
    .gallery-info-button:focus,
    .gallery-category-selector:focus {
        outline: 3px solid var(--gold-color) !important;
        outline-offset: 2px !important;
    }
    
    /* High contrast mode support */
    @media (prefers-contrast: high) {
        .gallery-mobile-card-container {
            border-width: 3px !important;
            border-color: white !important;
        }
        
        .gallery-card-name-mobile,
        .gallery-card-description-mobile,
        .gallery-card-counter {
            color: white !important;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.9) !important;
        }
    }
    
    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        .gallery-mobile-card-container .card,
        .gallery-nav-button,
        .gallery-info-button,
        .gallery-detail-modal {
            transition: none !important;
        }
    }
}

/* ========================
   LOADING AND ERROR STATES
   ======================== */

@media (max-width: 767px) {
    .gallery-loading {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 40px 20px !important;
        color: white !important;
        text-align: center !important;
    }
    
    .gallery-loading-spinner {
        width: 40px !important;
        height: 40px !important;
        border: 4px solid rgba(240, 195, 60, 0.2) !important;
        border-top: 4px solid var(--gold-color) !important;
        border-radius: 50% !important;
        animation: spin 1s linear infinite !important;
        margin-bottom: 15px !important;
    }
    
    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    
    .gallery-error {
        text-align: center !important;
        padding: 40px 20px !important;
        color: #f44336 !important;
    }
    
    .gallery-empty {
        text-align: center !important;
        padding: 40px 20px !important;
        color: rgba(255, 255, 255, 0.7) !important;
        font-style: italic !important;
    }
}
