/* Masonry Layout */
.alienity-gallery-wrapper {
    display: flex;
    gap: 20px;
    position: relative;
    align-items: flex-start; /* Important for sticky */
}

.alienity-gallery {
    flex: 1;
    min-width: 0; /* Fix flex overflow */
}

/* Flex-based masonry: each column is its own DOM container so new items
   appended via infinite scroll always go to the bottom of a column rather
   than getting redistributed across columns by the CSS column algorithm. */
.alienity-masonry {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.alienity-masonry-column {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

@media (max-width: 768px) {
    .alienity-gallery-wrapper {
        flex-direction: column;
    }
    .alienity-timeline {
        display: none; /* Hide timeline on mobile for simplicity */
    }
}

.alienity-masonry-item {
    width: 100%;
    display: block;
    margin: 0;
    padding: 0;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 4px;
    background: #ebe7df;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.alienity-masonry-item:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.alienity-masonry-item:hover img {
    transform: scale(1.02);
}

/* Skeleton base: a soft two-tone diagonal placeholder. Static — no repaint cost. */
.alienity-masonry-item::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #efece5 0%, #ebe7df 50%, #e3dfd6 100%);
    opacity: 1;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 1;
}

/* Skeleton sheen: a translated overlay so the animation is compositor-only
   (no per-frame paint), which scales much better across many tiles.
   `translate3d` self-promotes for the duration of the animation, so we
   don't need a permanent `will-change` hint that would leak GPU layers. */
.alienity-masonry-item::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        115deg,
        rgba(255, 255, 255, 0) 35%,
        rgba(255, 255, 255, 0.55) 47%,
        rgba(255, 255, 255, 0.85) 50%,
        rgba(255, 255, 255, 0.55) 53%,
        rgba(255, 255, 255, 0) 65%
    );
    transform: translate3d(-100%, 0, 0);
    animation: alienity-shimmer 1.6s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    opacity: 1;
    transition: opacity 0.4s ease;
    pointer-events: none;
    z-index: 1;
}

.alienity-masonry-item.is-loaded::before {
    opacity: 0;
}

/* Stop the animation outright on load (rather than just pausing) so the
   sheen snaps back to its off-screen origin instead of freezing mid-sweep
   while it fades, and the compositor layer is released. */
.alienity-masonry-item.is-loaded::after {
    opacity: 0;
    animation: none;
}

@keyframes alienity-shimmer {
    0%   { transform: translate3d(-100%, 0, 0); }
    100% { transform: translate3d( 100%, 0, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .alienity-masonry-item {
        transition: box-shadow 0.2s ease;
    }
    /* Deepen the static placeholder so it's still perceptible without the
       sheen for low-vision users on the cream page background. */
    .alienity-masonry-item::before {
        background: linear-gradient(135deg, #ddd6c8 0%, #cfc7b6 100%);
    }
    .alienity-masonry-item::after {
        display: none;
    }
    .alienity-masonry-item img,
    .alienity-masonry-item:hover img {
        transition: opacity 0.2s ease;
        transform: none;
    }
}

.alienity-masonry-item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
    position: relative;
    z-index: 2;
}

.alienity-masonry-item.is-loaded img {
    opacity: 1;
}

.alienity-masonry-item figcaption {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
    color: #fff;
    font-size: 0.9em;
    text-align: center;
    padding: 24px 8px 10px;
    margin: 0;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 3;
    pointer-events: none;
}

.alienity-masonry-item.is-loaded figcaption {
    opacity: 1;
}

/* Video Indicator */
.alienity-masonry-item.is-video .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    width: 64px;
    height: 64px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.35s ease 0.05s, transform 0.35s ease;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35));
    z-index: 3;
}

.alienity-masonry-item.is-video.is-loaded .play-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.alienity-masonry-item.is-video:hover .play-icon {
    transform: translate(-50%, -50%) scale(1.08);
}

.alienity-masonry-item.is-video .play-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Hide broken-image glyph if a thumbnail fails to load */
.alienity-masonry-item.has-error img {
    visibility: hidden;
}

/* Keep a static, slightly darker placeholder visible on error and stop
   the sheen — the animation lives on ::after now. */
.alienity-masonry-item.has-error::before {
    background: linear-gradient(135deg, #ede8df 0%, #ddd5c5 100%);
    opacity: 1;
}

.alienity-masonry-item.has-error::after {
    display: none;
}

/* Timeline */
.alienity-timeline {
    width: 60px;
    flex-shrink: 0;
    position: sticky;
    top: 20px;
    height: auto;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    padding-top: 10px;
}

.alienity-timeline-item {
    font-size: 12px;
    margin-bottom: 15px;
    cursor: pointer;
    color: #999;
    transition: all 0.3s;
    text-align: center;
    position: relative;
}

.alienity-timeline-item::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    margin: 5px auto 0;
}

.alienity-timeline-item.active {
    color: #333;
    font-weight: bold;
    font-size: 14px;
}

.alienity-timeline-item.active::after {
    background: #333;
    transform: scale(1.2);
}

/* Lightbox */
.alienity-lightbox {
    border: none;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    padding: 0;
    max-width: 90vw;
    max-height: 90vh;
    background: transparent;
    overflow: hidden;
}

.alienity-lightbox::backdrop {
    background: rgba(0, 0, 0, 0.8);
}

.alienity-lightbox-content {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #000;
}

.alienity-lightbox-content img,
.alienity-lightbox-content video,
.alienity-lightbox-content iframe {
    max-width: 100%;
    max-height: 90vh;
    display: block;
}

.alienity-lightbox-content iframe {
    width: 80vw;
    height: 45vw; /* 16:9 aspect ratio approx */
}

.alienity-lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.5);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s;
    z-index: 10;
}

.alienity-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.8);
}
