/* Companion Image Gallery - Grid Layout */
.companion-gallery {
    margin: 4rem 0;
    padding: 0;
}

section.companion-gallery h2 {
    font-size: 1.875rem !important;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text);
}

/* Grid Container */
.gallery-grid-container {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* Blur Effect for Uncensored Content */
.gallery-grid-container.gallery-blurred .gallery-main-image img,
.gallery-grid-container.gallery-blurred .gallery-thumbnail img {
    filter: blur(20px);
    transition: filter 0.3s ease;
}

/* 18+ Blur Overlay */
.gallery-blur-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px;
    transition: opacity 0.3s ease;
}

.gallery-blur-warning {
    text-align: center;
    color: white;
    max-width: 400px;
    padding: 2rem;
}

.blur-warning-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    animation: pulse-warning 2s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.gallery-blur-warning h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #ff6b6b;
    font-weight: 700;
}

.gallery-blur-warning p {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.9);
}

.blur-reveal-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-8);
    background-color: var(--accent-blue);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 120px;
    justify-content: center;
}

.blur-reveal-btn:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.blur-reveal-btn:active {
    transform: translateY(0);
}

/* Main Image */
.gallery-main-image {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    aspect-ratio: 16 / 9;
}

.gallery-main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.3s ease;
}

.gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 2rem 1.5rem 1rem;
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-main-image:hover .gallery-caption {
    opacity: 1;
}

/* Thumbnails Sidebar */
.gallery-thumbnails-sidebar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    width: 180px;
}

.gallery-thumbnail {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    background: var(--surface);
    aspect-ratio: 16 / 9;
}

.gallery-thumbnail:hover {
    opacity: 0.9;
    transform: translateX(-4px);
    border-color: var(--primary-light, #ccc);
}

.gallery-thumbnail.active {
    opacity: 1;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary);
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Loading State */
.gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--text-muted);
}

.gallery-loading::after {
    content: '⏳';
    font-size: 2rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Empty State */
.gallery-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.gallery-empty::before {
    content: '🖼️';
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .companion-gallery {
        margin: 2rem 0;
        padding: 0 1rem;
    }

    section.companion-gallery h2 {
        margin-bottom: 1.5rem;
    }

    /* Stack vertically on mobile */
    .gallery-grid-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto;
        gap: 1rem;
        max-width: 100%;
    }

    /* Main image adjustments */
    .gallery-main-image {
        aspect-ratio: 4 / 3;
        border-radius: 8px;
        width: 100%;
    }

    .gallery-caption {
        font-size: 0.85rem;
        padding: 1.5rem 1rem 0.75rem;
    }

    /* Thumbnails horizontal scroll on mobile */
    .gallery-thumbnails-sidebar {
        flex-direction: row;
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
        padding: 0.5rem 0;
        gap: 0.75rem;
        scroll-snap-type: x mandatory;
        justify-content: center;
    }

    .gallery-thumbnail {
        min-width: 120px;
        max-width: 120px;
        height: 80px;
        flex-shrink: 0;
        scroll-snap-align: start;
        aspect-ratio: 3 / 2;
    }

    .gallery-thumbnail:hover {
        transform: translateY(-2px);
    }

    .gallery-thumbnail:active {
        transform: scale(0.95);
    }

    /* Mobile blur overlay adjustments */
    .gallery-blur-warning {
        padding: 1.5rem;
        max-width: 90%;
    }

    .blur-warning-icon {
        font-size: 3rem;
    }

    .gallery-blur-warning h3 {
        font-size: 1.25rem;
    }

    .gallery-blur-warning p {
        font-size: 0.9rem;
    }

    .blur-reveal-btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.9rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .companion-gallery {
        padding: 0 0.5rem;
        margin: 1.5rem 0;
    }

    .companion-gallery h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .gallery-grid-container {
        gap: 0.75rem;
    }

    .gallery-thumbnail {
        min-width: 100px;
        max-width: 100px;
        height: 70px;
    }
}

/* Tablet Optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .gallery-thumbnails-sidebar {
        width: 140px;
    }

    .gallery-thumbnail {
        aspect-ratio: 4 / 3;
    }
}

/* Desktop Enhancements */
@media (min-width: 1025px) {
    .gallery-grid-container {
        gap: 1.5rem;
    }

    .gallery-thumbnails-sidebar {
        width: 200px;
        gap: 1rem;
    }

    .gallery-main-image {
        aspect-ratio: 16 / 9;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .gallery-main-image,
    .gallery-thumbnail {
        background: rgba(30, 30, 30, 0.5);
    }

    .gallery-thumbnail:hover {
        border-color: rgba(255, 255, 255, 0.3);
    }
}

/* Accessibility - Focus states */
.gallery-thumbnail:focus {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.gallery-thumbnail:focus:not(:focus-visible) {
    outline: none;
}

/* Print styles */
@media print {
    .gallery-thumbnails-sidebar {
        display: none;
    }

    .gallery-main-image {
        break-inside: avoid;
    }
}
