/* ── Gallery Base Styles ────────────────────────────────────── */

.gallery-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.gallery-toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

@media (max-width: 768px) {
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

@media (max-width: 480px) {
    .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: var(--spacing-sm); }
}

/* ── Gallery: Stories Modifier ─────────────────────────────── */
.gallery-grid--stories {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--spacing-sm);
}

.gallery-grid--stories .gallery-card {
    aspect-ratio: 9 / 16;
    overflow: hidden;
}

@media (max-width: 480px) {
    .gallery-grid--stories {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }
}

/* ── Gallery Card ──────────────────────────────────────────── */
.gallery-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--toi-surface);
    border: 1px solid var(--toi-border);
    cursor: pointer;
    transition: all var(--transition-smooth);
}

.gallery-card:hover {
    transform: translateY(-4px);
    border-color: rgba(96, 200, 240, 0.3);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.gallery-thumb {
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    background: none;
    display: block;
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: transform var(--transition-slow);
}

.gallery-card:hover .gallery-thumb {
    transform: scale(1.05);
}

.gallery-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-slow);
}

.gallery-video-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Sentinel & Loading ────────────────────────────────────── */
.gallery-sentinel {
    padding: var(--spacing-3xl) 0;
    text-align: center;
    min-height: 100px;
}

@keyframes gallery-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Lightbox (litterbox) ──────────────────────────────────── */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(4, 5, 8, 0.96);
    backdrop-filter: blur(12px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
}

.gallery-lightbox[hidden] {
    display: none;
}

.gallery-lb-close {
    position: absolute;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    width: 44px; height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 3100;
}

.gallery-lb-close:hover {
    background: var(--toi-accent);
    color: var(--toi-bg);
}

.gallery-lb-prev, .gallery-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    color: white;
    width: 50px; height: 80px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 3100;
}

.gallery-lb-prev:hover, .gallery-lb-next:hover {
    background: rgba(255,255,255,0.1);
}

.gallery-lb-prev { left: var(--spacing-xl); }
.gallery-lb-next { right: var(--spacing-xl); }

.gallery-lb-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.gallery-lb-img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 0 60px rgba(0,0,0,0.8);
    animation: lb-in 0.3s var(--ease-out);
}

.gallery-lb-video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-md);
    box-shadow: 0 0 60px rgba(0,0,0,0.8);
    outline: none;
    display: block;
}

.custom-video-player {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    animation: lb-in 0.4s var(--ease-out);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    background: #000;
}

.gallery-lb-video {
    width: 100%;
    display: block;
    cursor: pointer;
}

.video-controls {
    position: absolute;
    bottom: var(--spacing-sm);
    left: var(--spacing-sm);
    right: var(--spacing-sm);
    background: rgba(10, 15, 20, 0.85);
    backdrop-filter: blur(16px);
    padding: 10px 14px;
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    z-index: 10;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255,255,255,0.08);
}

.custom-video-player:hover .video-controls,
.custom-video-player:not(.is-playing) .video-controls {
    opacity: 1;
    transform: translateY(0);
}

.video-play-btn, .video-fullscreen-btn, .video-mute-btn {
    background: none;
    border: none;
    color: white;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.video-play-btn {
    width: 32px;
    height: 32px;
}

.video-play-btn:hover, .video-fullscreen-btn:hover, .video-mute-btn:hover {
    color: var(--toi-accent);
    transform: scale(1.1);
}

.video-time-display {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.8);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 70px;
}

.video-progress-bar {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    transition: height 0.2s, background 0.2s;
}

.video-progress-bar:hover {
    height: 6px;
    background: rgba(255,255,255,0.25);
}

.video-progress-fill {
    height: 100%;
    background: var(--toi-accent);
    border-radius: 2px;
    width: 0%;
    position: relative;
}

.video-volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px;
}

.video-volume-slider {
    width: 0;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
    opacity: 0;
}

.video-volume-container:hover .video-volume-slider,
.video-volume-slider:active {
    width: 60px;
    opacity: 1;
}

.video-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    transition: transform 0.1s;
}

.video-volume-slider::-webkit-slider-thumb:hover {
    background: var(--toi-accent);
    transform: scale(1.2);
}

.video-fullscreen-btn {
    width: 28px;
    height: 28px;
    opacity: 0.8;
}

.video-fullscreen-btn:hover {
    opacity: 1;
}

/* Play/Pause Feedback Animation */
.video-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    background: rgba(0,0,0,0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    pointer-events: none;
    opacity: 0;
    z-index: 15;
}

.video-feedback svg {
    width: 32px;
    height: 32px;
}

.video-feedback.animate {
    animation: video-feedback-ping 0.6s ease-out forwards;
}

@keyframes video-feedback-ping {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

.video-progress-bar:hover .video-progress-fill {
    box-shadow: 0 0 10px var(--toi-accent);
}

.gallery-video-thumb {
    filter: brightness(0.8);
    transition: filter 0.3s ease;
}

.gallery-card:hover .gallery-video-thumb {
    filter: brightness(1);
}

.gallery-video-icon {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 5;
    pointer-events: none;
}

.gallery-lb-img--story {
    max-height: 85vh;
    aspect-ratio: 9 / 16;
}

@keyframes lb-in {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.gallery-lb-meta {
    margin-top: var(--spacing-lg);
    text-align: center;
    color: white;
}

.gallery-lb-caption {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 4px;
}
