/* ============================================================================
   Kitchee Screenshot Gallery Styles
   Interactive 4x4 grid with filters, hover effects, and modal viewer
   ============================================================================ */

/* Gallery Wrapper */
.screenshot-gallery-wrapper {
    width: 100%;
    max-width: fit-content;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* Filter Controls */
.screenshot-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 18px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border-radius: 10px;
    flex-wrap: wrap;
    justify-content: center;
    width: fit-content;
    max-width: 100%;
}

.filter-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.filter-divider {
    width: 1px;
    height: 22px;
    background: var(--border-color);
    margin: 0 4px;
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 9px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-blue);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.filter-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

.filter-btn.active .material-icons {
    color: white;
}

.platform-filter {
    padding: 4px 6px;
    min-width: 28px;
}

.platform-filter .material-icons {
    font-size: 14px;
    color: var(--text-secondary);
}

.platform-filter:hover .material-icons,
.platform-filter.active .material-icons {
    color: var(--accent-blue);
}

.platform-filter.active .material-icons {
    color: white;
}

.shuffle-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, var(--accent-orange), var(--accent-green));
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.shuffle-btn .material-icons {
    font-size: 13px;
    color: white;
}

.shuffle-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(68, 166, 130, 0.4);
}

.shuffle-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Gallery Grid - 6x3 on desktop, 4x4 on tablet, 3x3 on mobile */
.screenshot-gallery {
    display: grid;
    grid-template-columns: repeat(6, 120px);
    gap: 16px 16px;
    position: relative;
    min-height: 420px;
    justify-content: center;
}

/* Loading State */
.gallery-loading {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.gallery-loading p {
    font-size: 14px;
    margin: 0;
}

/* Gallery Item */
.screenshot-item {
    position: relative;
    width: 120px;
    height: 120px;
    overflow: visible;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg-secondary);
    z-index: 1;
}

.screenshot-item:hover {
    transform: scale(1.1);
    z-index: 100;
}

/* Thumbnail Wrapper */
.screenshot-thumbnail-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow-light);
    transition: box-shadow 0.3s ease;
}

.screenshot-item:hover .screenshot-thumbnail-wrapper {
    box-shadow: 0 12px 32px var(--shadow-medium);
}

.screenshot-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.screenshot-item:hover .screenshot-thumbnail {
    transform: scale(1.05);
}

/* Badges */
.gallery-badges {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.screenshot-item:hover .gallery-badges {
    opacity: 1;
}

.gallery-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    animation: badgeEntrance 0.3s ease;
}

@keyframes badgeEntrance {
    from {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.gallery-badge .material-icons {
    font-size: 16px;
}

/* Premium Badge */
.gallery-badge.badge-premium {
    background: linear-gradient(135deg, #FFD700, #FFA500);
}

.gallery-badge.badge-premium .material-icons {
    color: white;
}

/* Platform Badges */
.gallery-badge.badge-ios .material-icons {
    color: #007AFF;
}

.gallery-badge.badge-ipad .material-icons {
    color: #5856D6;
}

.gallery-badge.badge-macos .material-icons {
    color: #34C759;
}

.gallery-badge.badge-web .material-icons {
    color: #FF9500;
}

.gallery-badge.badge-vision .material-icons {
    color: #FF2D55;
}

/* Caption */
.screenshot-caption {
    display: none;
}

/* Hover Preview */
.screenshot-hover-preview {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.screenshot-hover-preview.active {
    opacity: 1;
}

.screenshot-hover-preview img {
    display: block;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Desktop: 400x400 max */
@media (min-width: 769px) {
    .screenshot-hover-preview img {
        max-width: 400px;
        max-height: 400px;
        object-fit: contain;
    }
}

/* Mobile: Full screen */
@media (max-width: 768px) {
    .screenshot-hover-preview {
        top: 0 !important;
        left: 0 !important;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.95);
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: auto;
    }

    .screenshot-hover-preview img {
        max-width: 90vw;
        max-height: 90vh;
        object-fit: contain;
    }
}

/* Full-Screen Modal (kept for fallback/mobile tap) */
.screenshot-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none;
}

.screenshot-modal.active {
    display: flex;
    pointer-events: auto;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.screenshot-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    animation: modalImageZoom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalImageZoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.screenshot-modal-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

/* Modal Controls */
.modal-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10001;
}

.modal-close:hover {
    background: white;
    transform: rotate(90deg);
}

.modal-close .material-icons {
    font-size: 24px;
    color: #000;
}

/* Navigation Arrows */
.modal-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10001;
}

.modal-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.modal-nav.prev {
    left: 20px;
}

.modal-nav.next {
    right: 20px;
}

.modal-nav .material-icons {
    font-size: 28px;
    color: #000;
}

/* Modal Caption */
.modal-caption {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    max-width: 80%;
    text-align: center;
    z-index: 10001;
}

/* Dark Mode Adjustments */
[data-theme="dark"] .filter-btn {
    background: var(--bg-secondary);
}

[data-theme="dark"] .filter-btn:hover {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .screenshot-thumbnail-wrapper {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .screenshot-item:hover .screenshot-thumbnail-wrapper {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .screenshot-thumbnail {
    border-color: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .screenshot-hover-preview img {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Tablet - 4x4 grid */
@media (min-width: 769px) and (max-width: 1024px) {
    .screenshot-gallery {
        grid-template-columns: repeat(4, 120px);
        min-height: 540px;
    }
}

/* Mobile - 3x3 grid centered */
@media (max-width: 768px) {
    .screenshot-gallery-wrapper {
        max-width: 100%;
    }

    .screenshot-filters {
        padding: 10px;
        gap: 8px;
    }

    .filter-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .shuffle-btn {
        padding: 5px 10px;
        font-size: 12px;
        margin-left: 0;
    }

    .shuffle-btn span:not(.material-icons) {
        display: none;
    }

    .screenshot-gallery {
        grid-template-columns: repeat(3, 120px);
        gap: 16px;
        min-height: 420px;
        justify-content: center;
    }

    .screenshot-item {
        width: 120px;
        height: 120px;
    }

    .gallery-badges {
        top: 2px;
        right: 2px;
        gap: 2px;
    }

    .gallery-badge {
        width: 16px;
        height: 16px;
    }

    .gallery-badge .material-icons {
        font-size: 11px;
    }

    .modal-close,
    .modal-nav {
        width: 36px;
        height: 36px;
    }

    .modal-close {
        top: 10px;
        right: 10px;
    }

    .modal-nav.prev {
        left: 10px;
    }

    .modal-nav.next {
        right: 10px;
    }

    .modal-close .material-icons,
    .modal-nav .material-icons {
        font-size: 20px;
    }

    .modal-caption {
        bottom: 20px;
        font-size: 12px;
        padding: 8px 16px;
    }
}

@media (max-width: 480px) {
    .screenshot-gallery {
        gap: 12px;
    }

    .filter-divider {
        display: none;
    }
}


/* Animation for filtered items */
.screenshot-item.filtered-out {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.screenshot-item.filtered-in {
    animation: filterIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes filterIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Touch feedback for mobile */
@media (hover: none) {
    .screenshot-item:active {
        transform: scale(0.95);
    }

    .filter-btn:active {
        transform: scale(0.95);
    }

    .shuffle-btn:active {
        transform: scale(0.95);
    }
}
