@import url("/styles/modules/system-primitives.css");

.pht-sys.v2.pht-gal {

    /* ---------- BACK LINK + DESCRIPTION ---------- */
    .back {
        text-decoration: none;
        color: var(--link-color);
        letter-spacing: 0.1em;
        text-transform: uppercase;
        transition: opacity 0.15s;
    }

    .back:hover {
        opacity: 0.7;
    }

    .desc {
        max-width: 58ch;
    }

    .count strong {
        color: var(--text-color);
    }

    /* ---------- PHOTO GRID (masonry-ish) ---------- */
    .grid {
        list-style: none;
        padding: 0;
        margin: 0;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        grid-auto-flow: dense;
        gap: 0.875rem;
    }

    .photo[data-featured="1"] {
        grid-column: span 2;
        grid-row: span 2;
    }

    @media (max-width: 700px) {
        .photo[data-featured="1"] {
            grid-column: span 2;
            grid-row: auto;
        }
    }

    .photo-btn {
        position: relative;
        width: 100%;
        aspect-ratio: 4 / 3;
        padding: 0;
        border: none;
        background: hsl(from var(--text-color) h s l / 0.08);
        color: inherit;
        font: inherit;
        cursor: pointer;
        overflow: hidden;
        display: block;
        transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    }

    .photo[data-featured="1"] .photo-btn {
        aspect-ratio: 1 / 1;
    }

    .photo-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 24px hsl(from var(--text-color) h s l / 0.15);
    }

    .photo-cover {
        position: absolute;
        inset: 0;
    }

    .photo-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

    /* Typography from `fnt_t-4`; bg + color from `.bg-bx ulk-bg` in HTML. */
    .photo-badge {
        position: absolute;
        top: 0;
        left: 0;
        padding: 0.4em 0.75em;
        z-index: 2;
    }

    /* `.bg-bx ulk-bg` in HTML — gradient terminates at --background so the
       fade matches the (flipped) text-color end of the contrast pair. */
    .photo-overlay {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 0.875em 1em;
        background: linear-gradient(transparent, var(--background));
        opacity: 0;
        transition: opacity 0.2s;
        pointer-events: none;
    }

    .photo-btn:hover .photo-overlay,
    .photo-btn:focus-visible .photo-overlay {
        opacity: 1;
    }

    .photo-title {
        font-size: 0.9375rem;
    }

    /* ---------- LIGHTBOX ----------
     * `.bg-bx ulk-bg` in HTML gives the lightbox its own flipped palette
     * context. The near-opaque backdrop uses --background (palette-aware),
     * borders/buttons use translucent --text-color so they pick up the
     * flipped foreground tone. Color and basic text inherit from .bg-bx.
     */
    .lightbox {
        position: fixed;
        inset: 0;
        z-index: 9999;
        background: hsl(from var(--background) h s l / 0.96);
        display: flex;
        flex-direction: column;
    }

    .lightbox[hidden] {
        display: none;
    }

    .lightbox-bar {
        flex: 0 0 auto;
        border-bottom: 1px solid hsl(from var(--text-color) h s l / 0.1);
    }

    .lightbox-gallery {
        letter-spacing: 0.1em;
        text-transform: uppercase;
    }

    .lightbox-close {
        border: none;
        background: transparent;
        color: inherit;
        cursor: pointer;
        padding: 0.25em 0.5em;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .lightbox-close:hover {
        opacity: 0.7;
    }

    .lightbox-stage {
        flex: 1 1 auto;
        position: relative;
        min-height: 0;
        overflow: hidden;
    }

    .lightbox-img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        display: block;
    }

    .lightbox-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 48px;
        height: 48px;
        border-radius: 50%;
        border: 1px solid hsl(from var(--text-color) h s l / 0.3);
        background: hsl(from var(--text-color) h s l / 0.15);
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s, transform 0.15s;
    }

    .lightbox-nav:hover {
        background: hsl(from var(--text-color) h s l / 0.3);
        transform: translateY(-50%) scale(1.05);
    }

    .lightbox-nav--prev { left: 1rem; }
    .lightbox-nav--next { right: 1rem; }

    .lightbox-caption {
        flex: 0 0 auto;
        border-top: 1px solid hsl(from var(--text-color) h s l / 0.1);
        max-width: 60ch;
        margin-inline: auto;
        text-align: center;
    }

    .lightbox-title {
        font-size: 1.125rem;
    }
}

/* Body scroll lock when lightbox is open — can't nest under .pht-sys
   because <body> sits above the system root in the DOM. */
body.pht-lock { overflow: hidden; }
