/* =============================================================
   Home Gallery Section
   Dark-theme masonry grid + lightbox – consistent with Innova
   ============================================================= */

/* ── Section wrapper ───────────────────────────────────────── */
.home-gallery-section {
    padding: 150px 0 100px;
    background: #000;
}

/* ── Header ───────────────────────────────────────────────── */
.home-gallery-header {
    text-align: center;
    margin-bottom: 48px;
}

.home-gallery-title {
    color: #ffffff !important;
    font-size: clamp(20px, 3vw, 30px);
    font-weight: 800;
    letter-spacing: -0.2px;
    margin-bottom: 16px;
    line-height: 1.2;
}

.home-gallery-divider {
    width: 56px;
    height: 3px;
    margin: 0 auto;
    background: linear-gradient(90deg, #c41ccd, #3a4bdb, #1eb7d4);
    border-radius: 2px;
}

/* ── Grid ─────────────────────────────────────────────────── */
.home-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 230px;
    gap: 12px;
    grid-auto-flow: dense;
}

/* Span helpers */
.gallery-item.col-span-2 { grid-column: span 2; }
.gallery-item.col-span-3 { grid-column: span 3; }
.gallery-item.row-span-2 { grid-row: span 2; }
.gallery-item.row-span-3 { grid-row: span 3; }

/* ── Individual item ──────────────────────────────────────── */
.gallery-item {
    position: relative;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    background: #0d0d14;
    /* Fade-in initial state */
    opacity: 0;
    transition:
        opacity 0.5s ease,
        transform 0.35s ease,
        box-shadow 0.35s ease;
    /* Subtle static border */
    outline: 1.5px solid rgba(255, 255, 255, 0.06);
    outline-offset: 0;
    /* Prevent text-selection on rapid clicks */
    user-select: none;
    -webkit-user-select: none;
}

/* Gradient border that appears on hover/focus */
.gallery-item::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    padding: 1.5px;
    background: linear-gradient(135deg, #c41ccd, #3a4bdb, #1eb7d4);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Visible state (set by IntersectionObserver) */
.gallery-item.is-visible {
    opacity: 1;
}

/* Hover / focus */
.gallery-item:hover,
.gallery-item:focus-visible {
    transform: scale(1.025);
    box-shadow:
        0 6px 24px rgba(196, 28, 205, 0.25),
        0 2px 10px rgba(0, 0, 0, 0.7);
    z-index: 1;
}

.gallery-item:hover::after,
.gallery-item:focus-visible::after {
    opacity: 1;
}

.gallery-item:focus-visible {
    outline: 2px solid #1eb7d4;
    outline-offset: 3px;
}

/* ── Media (img / video) ──────────────────────────────────── */
.gallery-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.45s ease;
    will-change: transform;
}

.gallery-item:hover .gallery-media {
    transform: scale(1.06);
}

/* ── Gradient vignette overlay ────────────────────────────── */
.gallery-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.55) 0%,
        transparent 55%
    );
    z-index: 1;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-item-overlay {
    opacity: 0.4;
}

/* ── Video play button ────────────────────────────────────── */
.gallery-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 54px;
    height: 54px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1.5px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
    pointer-events: none;
}

.gallery-play-btn svg {
    width: 22px;
    height: 22px;
    color: #fff;
    margin-left: 3px; /* optical centering of ▶ */
    pointer-events: none;
}

.gallery-item:hover .gallery-play-btn {
    background: rgba(196, 28, 205, 0.55);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%) scale(1.12);
}

/* ── Lightbox ─────────────────────────────────────────────── */
.gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-lightbox.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* Blurred dark backdrop */
.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: zoom-out;
}

/* Shell (z-index above backdrop) */
.lightbox-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 64px 88px;
    box-sizing: border-box;
}

/* Media wrapper */
.lightbox-media-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 85vh;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.lightbox-media-wrapper.is-transitioning {
    opacity: 0;
    transform: scale(0.96);
}

.lightbox-media-wrapper img,
.lightbox-media-wrapper video {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 12px;
    object-fit: contain;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.85);
    display: block;
}

/* YouTube / embedded video iframe – 16:9 */
.lightbox-media-wrapper iframe {
    width: 800px;
    aspect-ratio: 16 / 9;
    height: auto;
    max-width: 90vw;
    border-radius: 12px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.85);
    display: block;
    border: none;
}

/* Close button */
.lightbox-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 2;
}

.lightbox-close:hover {
    background: rgba(196, 28, 205, 0.45);
    transform: rotate(90deg);
}

.lightbox-close svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
}

/* Navigation arrows */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    z-index: 2;
}

.lightbox-prev { left: 14px; }
.lightbox-next { right: 14px; }

.lightbox-nav:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav:disabled {
    cursor: default;
}

.lightbox-nav svg {
    width: 22px;
    height: 22px;
    pointer-events: none;
}

/* Counter pill */
.lightbox-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 4px 14px;
    color: rgba(255, 255, 255, 0.65);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1.5px;
    white-space: nowrap;
    z-index: 2;
}

/* =============================================================
   Responsive
   ============================================================= */

/* Tablet – 3 cols */
@media (max-width: 1024px) {
    .home-gallery-grid {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 190px;
    }
}

/* Mobile landscape / small tablet – 2 cols */
@media (max-width: 768px) {
    .home-gallery-section {
        padding: 56px 0 72px;
    }

    .home-gallery-header {
        margin-bottom: 32px;
    }

    .home-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 160px;
        gap: 8px;
    }

    /* Force all col-span-2 to stay as 2 on mobile (fill width) */
    .gallery-item.col-span-2 { grid-column: span 2; }
    /* Downgrade col-span-3 to 2 */
    .gallery-item.col-span-3 { grid-column: span 2; }

    .lightbox-shell {
        padding: 56px 16px;
    }

    .lightbox-prev { left: 6px; }
    .lightbox-next { right: 6px; }

    .lightbox-nav {
        width: 40px;
        height: 40px;
    }
}

/* Mobile portrait */
@media (max-width: 480px) {
    .home-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 130px;
        gap: 6px;
    }

    .gallery-play-btn {
        width: 42px;
        height: 42px;
    }

    .gallery-play-btn svg {
        width: 18px;
        height: 18px;
    }
}

/* Reduced motion – respect user preferences */
@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .gallery-media,
    .gallery-lightbox,
    .lightbox-media-wrapper {
        transition: none !important;
    }

    .gallery-item { opacity: 1 !important; }
}

