.homepage-lightbox {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 5vw, 56px);
    background:
        radial-gradient(
            circle at 18% 18%,
            rgba(var(--prev-rgb), 0.14),
            transparent 26%
        ),
        radial-gradient(
            circle at 50% 22%,
            rgba(var(--active-rgb), 0.1),
            transparent 28%
        ),
        radial-gradient(
            circle at 84% 24%,
            rgba(var(--next-rgb), 0.14),
            transparent 26%
        ),
        rgba(3, 4, 8, 0.92);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 120;
}

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

.homepage-lightbox-frame {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    width: min(92vw, 1600px);
    height: 100%;
}

.homepage-lightbox-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.homepage-lightbox-placeholder,
.homepage-lightbox-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
}

.homepage-lightbox-placeholder {
    position: absolute;
    inset: 0;
    margin: auto;
    pointer-events: none;
    z-index: 0;
    opacity: 1;
    transition: opacity 180ms ease;
}

.homepage-lightbox-image {
    position: relative;
    z-index: 1;
    opacity: 1;
    transition: opacity 180ms ease;
}

.homepage-lightbox.is-loading-image .homepage-lightbox-image {
    opacity: 0.35;
}

.homepage-lightbox.has-placeholder.is-loading-image .homepage-lightbox-image {
    opacity: 0;
}

.homepage-lightbox.is-image-ready .homepage-lightbox-image {
    opacity: 1;
}

.homepage-lightbox.is-image-ready .homepage-lightbox-placeholder {
    opacity: 0;
}

.homepage-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.42);
    font-family: "Space Mono", monospace;
    font-size: 1.45rem;
    cursor: pointer;
    transition:
        color 0.2s ease,
        transform 0.2s ease;
}

.homepage-lightbox.has-multiple .homepage-lightbox-nav {
    display: inline-flex;
}

.homepage-lightbox:not(.has-multiple) .homepage-lightbox-nav {
    display: none;
}

.homepage-lightbox-nav:hover,
.homepage-lightbox-nav:focus-visible {
    color: #fff;
    outline: none;
}

.homepage-lightbox-nav.prev {
    left: 0;
    transform: translate(-175%, -50%);
}

.homepage-lightbox-nav.prev:hover,
.homepage-lightbox-nav.prev:focus-visible {
    transform: translate(-190%, -50%);
}

.homepage-lightbox-nav.next {
    right: 0;
    transform: translate(175%, -50%);
}

.homepage-lightbox-nav.next:hover,
.homepage-lightbox-nav.next:focus-visible {
    transform: translate(190%, -50%);
}

.homepage-lightbox-thumbnails {
    display: none;
    width: 100%;
    justify-content: center;
    gap: 0.65rem;
    overflow-x: auto;
    padding: 0.25rem 0 0.4rem;
    scrollbar-width: none;
}

.homepage-lightbox-thumbnails::-webkit-scrollbar {
    display: none;
}

.homepage-lightbox.has-multiple .homepage-lightbox-thumbnails {
    display: flex;
}

.homepage-lightbox-thumb {
    position: relative;
    flex: 0 0 auto;
    width: 72px;
    height: 52px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    opacity: 0.55;
    cursor: pointer;
    overflow: hidden;
    transition:
        opacity 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.homepage-lightbox-thumb:hover,
.homepage-lightbox-thumb:focus-visible {
    opacity: 0.82;
    border-color: rgba(255, 255, 255, 0.45);
    outline: none;
}

.homepage-lightbox-thumb.is-active {
    opacity: 1;
    border-color: transparent;
}

.homepage-lightbox-thumb.is-active::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 1px;
    background: rgb(var(--lightbox-rgb, var(--active-rgb)));
    -webkit-mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#000 0 0) content-box,
        linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
    z-index: 2;
}

.homepage-lightbox-thumb.is-active::after {
    content: "";
    position: absolute;
    left: -1px;
    right: -1px;
    bottom: -1px;
    height: 2px;
    background: rgb(var(--lightbox-rgb, var(--active-rgb)));
    pointer-events: none;
}

.homepage-lightbox-thumb img {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.homepage-lightbox-close {
    position: absolute;
    top: clamp(18px, 2.5vw, 28px);
    right: clamp(18px, 2.5vw, 28px);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-family: "Space Mono", monospace;
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition:
        color 0.3s ease,
        transform 0.3s ease;
}

.homepage-lightbox-close:hover,
.homepage-lightbox-close:focus-visible {
    color: var(--text);
    transform: translateX(-4px);
    outline: none;
}

/* Project Justified Mosaic Grid Styles */
.project-image-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
    margin: 0;
}

/* Pseudo-element to absorb remaining space in the last row and prevent extreme stretching */
.project-image-grid::after {
    content: "";
    flex-grow: 99999;
    height: 0;
    margin: 0;
    padding: 0;
}

.project-image-grid .grid-item {
    --row-height: 220px;
    position: relative;
    margin: 0;
    height: auto;
    flex-grow: calc(var(--aspect-ratio, 1.5) * 100);
    flex-shrink: 1;
    flex-basis: calc(var(--row-height) * var(--aspect-ratio, 1.5));
    max-width: 100%;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.03);
}

.project-image-grid .grid-item img {
    display: block;
    width: 100% !important;
    height: auto !important;
    aspect-ratio: var(--aspect-ratio, 1.5);
    max-width: 100% !important;
    object-fit: cover !important;
    cursor: zoom-in;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.project-image-grid .grid-item img.loaded {
    opacity: 1;
}

/* Fallback for safety */
.project-image-grid .grid-item figcaption {
    display: none;
}

@media (max-width: 768px) {
    .project-image-grid .grid-item {
        --row-height: 180px;
    }
}

@media (max-width: 480px) {
    .project-image-grid .grid-item {
        --row-height: 140px;
    }
    .project-image-grid {
        gap: 0.35rem;
    }
}

.project-image-grid.stretch-last-row::after {
    display: none;
}

/* Lightbox Video Styling */
.homepage-lightbox-video {
    display: none;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
    position: relative;
    z-index: 1;
    outline: none;
}

/* Video Content Block Card / Thumbnail */
.project-video-thumbnail {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    display: block;
    margin: 0;
    background: #000;
    box-sizing: border-box;
    border: 1px solid
        color-mix(
            in srgb,
            rgb(
                    var(
                        --active-rgb,
                        var(--row-rgb, var(--detail-rgb, 255, 255, 255))
                    )
                )
                42%,
            #050608
        );
    transition:
        border-color 0.25s ease,
        box-shadow 0.25s ease;
    /* Hardware acceleration to prevent subpixel rendering / border leak glitches during transitions */
    transform: translate3d(0, 0, 0);
    will-change: transform;
    backface-visibility: hidden;
}

.project-video-thumbnail img {
    display: block;
    width: 100%;
    height: auto;
    transform: scale(1.03);
    will-change: transform;
    backface-visibility: hidden;
    transition:
        filter 0.3s ease,
        transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.project-video-thumbnail:hover img,
.project-video-thumbnail:focus-within img {
    filter: brightness(0.82);
    transform: scale(1.05);
}

.project-video-thumbnail img:focus {
    outline: none;
}

.project-video-thumbnail:hover,
.project-video-thumbnail:focus-within,
.project-video-thumbnail:active {
    border-color: color-mix(
        in srgb,
        rgb(
                var(
                    --active-rgb,
                    var(--row-rgb, var(--detail-rgb, 255, 255, 255))
                )
            )
            82%,
        #050608
    );
    box-shadow: inset 0 0 18px
        rgba(
            var(
                --active-rgb,
                var(--row-rgb, var(--detail-rgb, 255, 255, 255))
            ),
            0.16
        );
}

/* Hollow accent triangle matching the site's crosshair visual language. */
.video-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 2;
}

.video-play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgb(var(--active-rgb, var(--row-rgb, var(--detail-rgb, 255, 255, 255))));
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
    opacity: 0.85;
}

.video-play-btn svg {
    width: 60px;
    height: 60px;
    display: block;
    filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.6));
}

.video-play-btn svg polygon {
    fill: none;
    stroke: currentColor;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.video-play-btn svg polygon.video-play-glow {
    stroke-width: 8px;
    opacity: 0.2;
    transition: opacity 0.25s ease, stroke-width 0.25s ease;
}

.video-play-btn svg polygon.video-play-core {
    stroke-width: 1.5px;
}

.project-video-thumbnail:hover .video-play-btn,
.project-video-thumbnail:focus-within .video-play-btn {
    transform: scale(1.15);
    opacity: 1;
}

.project-video-thumbnail:hover .video-play-btn svg polygon.video-play-glow,
.project-video-thumbnail:focus-within
    .video-play-btn
    svg
    polygon.video-play-glow {
    opacity: 0.45;
    stroke-width: 10px;
}

/* Video Placeholder (when no thumbnail is configured) */
.project-video-placeholder {
    width: 100%;
    aspect-ratio: 16/9;
    background: #0d0e11;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.project-video-placeholder:hover {
    background: #18191f;
    border-color: rgba(255, 255, 255, 0.15);
}

.video-placeholder-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.5);
}

.video-placeholder-content i {
    font-size: 3rem;
    transition: transform 0.2s ease, color 0.2s ease;
}

.project-video-placeholder:hover .video-placeholder-content i {
    transform: scale(1.1);
    color: #ffffff;
}

.video-placeholder-content span {
    font-family: "Space Mono", monospace;
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

/* Lightbox Thumbnail Video Overlay */
.homepage-lightbox-thumb .thumb-video-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    color: rgba(255, 255, 255, 0.85);
    z-index: 2;
    pointer-events: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.homepage-lightbox-thumb .thumb-video-overlay svg {
    width: 14px;
    height: 14px;
    margin-left: 1px;
    display: block;
}

.homepage-lightbox-thumb .thumb-video-overlay svg polygon {
    fill: none;
    stroke: currentColor;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}

.homepage-lightbox-thumb .thumb-video-overlay svg polygon.video-play-glow {
    display: none;
}

.homepage-lightbox-thumb .thumb-video-overlay svg polygon.video-play-core {
    stroke-width: 2px;
}

.homepage-lightbox-thumb:hover .thumb-video-overlay {
    background: rgba(0, 0, 0, 0.25);
    color: #ffffff;
}
