/* ==========================================================================
   Photo Gallery — editorial film exhibition
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300&display=swap');

/* ---------- gallery grid ---------- */

.photo-gallery {
    --gallery-gap: 6px;
    --gallery-cols: 2;
    --gallery-row-h: 4px;
    display: grid;
    grid-template-columns: repeat(var(--gallery-cols), 1fr);
    grid-auto-rows: var(--gallery-row-h);
    grid-auto-flow: dense;
    gap: var(--gallery-gap);
    margin: 2rem calc(var(--gap, 40px) * -0.5);
    padding: 0;
}

.photo-gallery .gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 2px;
    background: rgb(20, 20, 20);
    line-height: 0;
    /* row span set by JS based on aspect ratio */
}

.photo-gallery .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    border-radius: 0;
    cursor: zoom-in;
    transition: transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1),
                filter 0.4s ease;
    will-change: transform;
}

.photo-gallery .gallery-item:hover img {
    transform: scale(1.03);
    filter: brightness(1.08) contrast(1.02);
}

/* subtle frame number overlay — contact-sheet vibe */
.photo-gallery .gallery-item::after {
    content: attr(data-index);
    position: absolute;
    bottom: 10px;
    right: 12px;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 13px;
    font-weight: 300;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0);
    transition: color 0.3s ease;
    pointer-events: none;
    line-height: 1;
}

.photo-gallery .gallery-item:hover::after {
    color: rgba(255, 255, 255, 0.5);
}

/* title label on gallery items */
.gallery-item-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 28px 14px 10px;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 14px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0);
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
    pointer-events: none;
    transition: color 0.3s ease;
    line-height: 1.3;
    letter-spacing: 0.3px;
    z-index: 1;
}

.photo-gallery .gallery-item:hover .gallery-item-label {
    color: rgba(255, 255, 255, 0.9);
}

/* scroll-reveal entrance */
.photo-gallery .gallery-item {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease, transform 0.6s ease,
                box-shadow 0.3s ease;
}

.photo-gallery .gallery-item.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* gallery header */
.gallery-header {
    text-align: center;
    margin: 3rem 0 1.2rem;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 300;
    color: var(--secondary);
    position: relative;
}

.gallery-header::before,
.gallery-header::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 60px;
    height: 1px;
    background: var(--border);
}

.gallery-header::before { right: calc(50% + 80px); }
.gallery-header::after  { left:  calc(50% + 80px); }

/* gallery count badge */
.gallery-count {
    text-align: center;
    margin: 0 0 2rem;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 13px;
    font-weight: 300;
    font-style: italic;
    color: var(--secondary);
    opacity: 0.7;
}

/* ---------- responsive ---------- */

@media (min-width: 900px) {
    .photo-gallery {
        margin: 2rem calc(var(--gap, 40px) * -1);
    }
}

@media (max-width: 480px) {
    .photo-gallery {
        --gallery-cols: 2;
        --gallery-gap: 4px;
        --gallery-row-h: 3px;
        margin: 1.5rem 0;
    }

    .gallery-header::before,
    .gallery-header::after {
        width: 30px;
    }

    .gallery-header::before { right: calc(50% + 50px); }
    .gallery-header::after  { left:  calc(50% + 50px); }
}

/* ---------- lightbox overlay ---------- */

.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s ease;
    cursor: zoom-out;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.lightbox-overlay.active {
    opacity: 1;
}

.lightbox-img-wrapper {
    position: relative;
    max-width: 92vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-overlay img {
    max-width: 92vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 2px;
    transform: scale(0.92);
    transition: transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
    cursor: default;
    user-select: none;
    -webkit-user-drag: none;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
}

.lightbox-overlay.active img {
    transform: scale(1);
}

.lightbox-caption {
    position: fixed;
    bottom: 52px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    max-width: 520px;
    width: 90vw;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.3s ease;
    z-index: 10000;
}

.lightbox-caption-title {
    display: block;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 20px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.5px;
    line-height: 1.3;
}

.lightbox-caption-desc {
    display: block;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 14px;
    font-weight: 300;
    font-style: italic;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
    line-height: 1.5;
}

.lightbox-caption-title:empty,
.lightbox-caption-desc:empty {
    display: none;
}

.lightbox-counter {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.35);
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 13px;
    font-weight: 300;
    letter-spacing: 3px;
    pointer-events: none;
    user-select: none;
}

.lightbox-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 48px;
    font-weight: 200;
    cursor: pointer;
    padding: 24px;
    transition: color 0.25s ease, transform 0.25s ease;
    user-select: none;
    z-index: 10000;
    line-height: 1;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
}

.lightbox-btn:hover {
    color: rgba(255, 255, 255, 0.85);
}

.lightbox-btn.prev {
    left: 8px;
}

.lightbox-btn.prev:hover {
    transform: translateY(-50%) translateX(-3px);
}

.lightbox-btn.next {
    right: 8px;
}

.lightbox-btn.next:hover {
    transform: translateY(-50%) translateX(3px);
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 24px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.35);
    font-size: 24px;
    font-weight: 200;
    cursor: pointer;
    padding: 10px;
    transition: color 0.25s ease;
    z-index: 10000;
    line-height: 1;
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    letter-spacing: 1px;
}

.lightbox-close:hover {
    color: rgba(255, 255, 255, 0.85);
}

@media (max-width: 640px) {
    .lightbox-btn {
        font-size: 36px;
        padding: 16px;
    }

    .lightbox-btn.prev { left: 0; }
    .lightbox-btn.next { right: 0; }
}

/* ==========================================================================
   Homepage Photo Grid Mosaic
   ========================================================================== */

.entry-photo-grid {
    display: grid;
    gap: 3px;
    margin-bottom: var(--gap);
    border-radius: var(--radius);
    overflow: hidden;
    line-height: 0;
    position: relative;
}

.entry-photo-grid .grid-cell {
    overflow: hidden;
    position: relative;
    background: rgb(20, 20, 20);
}

.entry-photo-grid .grid-cell img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    transition: transform 0.6s cubic-bezier(0.25, 0.1, 0.25, 1),
                filter 0.5s ease;
}

.has-photo-grid:hover .entry-photo-grid .grid-cell img {
    transform: scale(1.04);
}

/* ---------- 5-image asymmetric mosaic ----------
   Layout:
   ┌──────────┬─────────┐
   │          │    1    │
   │    0     ├─────────┤
   │          │    2    │
   ├────┬─────┴─────────┤
   │  3 │       4       │
   └────┴───────────────┘
   -------------------------------------------- */

.mosaic-5 {
    grid-template-columns: 1.2fr 1fr;
    grid-template-rows: 1fr 1fr 0.8fr;
    aspect-ratio: 16 / 10;
}

.mosaic-5 .cell-0 { grid-row: 1 / 3; grid-column: 1 / 2; }
.mosaic-5 .cell-1 { grid-row: 1 / 2; grid-column: 2 / 3; }
.mosaic-5 .cell-2 { grid-row: 2 / 3; grid-column: 2 / 3; }
.mosaic-5 .cell-3 { grid-row: 3 / 4; grid-column: 1 / 2; }
.mosaic-5 .cell-4 { grid-row: 3 / 4; grid-column: 2 / 3; }

/* ---------- 4-image mosaic ---------- */

.mosaic-4 {
    grid-template-columns: 1.3fr 1fr;
    grid-template-rows: 1fr 1fr;
    aspect-ratio: 16 / 9;
}

.mosaic-4 .cell-0 { grid-row: 1 / 3; grid-column: 1 / 2; }
.mosaic-4 .cell-1 { grid-row: 1 / 2; grid-column: 2 / 3; }
.mosaic-4 .cell-2 { grid-row: 2 / 3; grid-column: 2 / 3; }

/* put the 4th in a second row spanning full width — or tuck it */
.mosaic-4 .cell-3 { display: none; }

/* ---------- 3-image mosaic ---------- */

.mosaic-3 {
    grid-template-columns: 1.4fr 1fr;
    grid-template-rows: 1fr 1fr;
    aspect-ratio: 16 / 9;
}

.mosaic-3 .cell-0 { grid-row: 1 / 3; grid-column: 1 / 2; }
.mosaic-3 .cell-1 { grid-row: 1 / 2; grid-column: 2 / 3; }
.mosaic-3 .cell-2 { grid-row: 2 / 3; grid-column: 2 / 3; }

/* ---------- grid on first-entry (featured) ---------- */

.first-entry.has-photo-grid .entry-photo-grid {
    border-radius: var(--radius);
}

/* ---------- mobile grid ---------- */

@media (max-width: 560px) {
    .mosaic-5 {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1.2fr 1fr 0.9fr;
        aspect-ratio: 4 / 5;
    }
}

/* ---------- hide original stacked layout artifacts ---------- */

.post-content.has-gallery > h4:empty,
.post-content.has-gallery > hr {
    display: none;
}

/* keep non-gallery content (intro text etc) visible */
.post-content.has-gallery > p {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-size: 18px;
    line-height: 1.7;
    font-weight: 300;
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    color: var(--secondary);
}
