/* ============================================================
   PORTFOLIO GALLERY PAGE
   ============================================================ */

.portfolio-page {
    background-color: var(--color-surface-container-lowest);
    min-height: 100vh;
    padding-top: var(--header-height);
    position: relative;
}


/* ============================================================
   SCROLL PROGRESS BAR
   Thin line at very top of viewport, grows as you scroll
   ============================================================ */

.gallery-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 200;           /* above header */
    background: transparent;
    pointer-events: none;
}

.gallery-progress__bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(
        90deg,
        var(--color-primary-container) 0%,
        var(--color-secondary) 100%
    );
    transition: width 0.1s linear;
    transform-origin: left;
}


/* ============================================================
   BOTTOM FADE
   Fixed gradient at bottom edge dims the last row of photos
   ============================================================ */

.gallery-bottom-fade {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 18vh;
    background: linear-gradient(
        to top,
        var(--color-surface-container-lowest) 0%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 10;
}


/* ============================================================
   MASONRY GRID — 4 columns, generous side padding
   ============================================================ */

.gallery-masonry {
    max-width: 1600px;
    margin-inline: auto;
    /* Generous side padding so gallery doesn't touch viewport edges */
    padding: 16px 48px 120px;    /* extra bottom padding clears the fade */
    column-count: 1;
    column-gap: 12px;
}

@media (min-width: 540px)  { .gallery-masonry { column-count: 2; padding-inline: 32px; } }
@media (min-width: 900px)  { .gallery-masonry { column-count: 3; padding-inline: 40px; } }
@media (min-width: 1100px) { .gallery-masonry { column-count: 4; padding-inline: 48px; } }


/* ============================================================
   GALLERY ITEM
   ============================================================ */

.gallery-item {
    break-inside: avoid;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
    background-color: var(--color-surface-container);

    /* Film-roll reveal: start dimmed + shifted down with perspective */
    opacity: 0;
    transform: translateY(40px) scale(0.97);
    filter: brightness(0.4);
    transition:
        opacity   0.75s cubic-bezier(0.22, 1, 0.36, 1),
        transform 0.75s cubic-bezier(0.22, 1, 0.36, 1),
        filter    0.75s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-item.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: brightness(1);
}

/* Button reset */
.gallery-item__link {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Image wrapper — respects the aspect-ratio inline style */
.gallery-item__img-wrap {
    width: 100%;
    overflow: hidden;
    display: block;
    position: relative;
}

.gallery-item__img {
    width: 100%;
    height: auto;
    display: block;
    transform: scale(1.04);
    transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
    -webkit-user-drag: none;
    user-select: none;
    pointer-events: none;
}

/* When aspect ratio is forced, img fills the wrapper */
.gallery-item__img-wrap[style*="aspect-ratio"] .gallery-item__img {
    height: 100%;
    object-fit: cover;
}

.gallery-item__link:hover .gallery-item__img,
.gallery-item__link:focus-visible .gallery-item__img {
    transform: scale(1);
}

/* Transparent overlay blocks right-click on image */
.gallery-item__link::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Hover overlay */
.gallery-item__overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(to top, rgba(13,13,13,0.75) 0%, transparent 50%);
    opacity: 0;
    display: flex;
    align-items: flex-end;
    padding: var(--space-4) var(--space-5);
    transition: opacity 350ms ease;
    pointer-events: none;
}

.gallery-item__link:hover .gallery-item__overlay,
.gallery-item__link:focus-visible .gallery-item__overlay { opacity: 1; }

.gallery-item__exif {
    font-family: var(--font-label);
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--color-secondary);
    display: block;
}


/* ============================================================
   LIGHTBOX — full site dim
   ============================================================ */

.lightbox {
    position: fixed; inset: 0;
    z-index: 9999;
    display: flex; align-items: center; justify-content: center;
}

.lightbox[aria-hidden="true"] { pointer-events: none; }

.lightbox__backdrop {
    position: absolute; inset: 0;
    background-color: rgba(8, 8, 8, 0.97);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
    opacity: 0; transition: opacity 0.35s ease; cursor: pointer;
}

.lightbox.is-open .lightbox__backdrop { opacity: 1; }

.lightbox__stage {
    position: relative; z-index: 1;
    display: flex; flex-direction: column; align-items: center; gap: var(--space-4);
    max-width: min(92vw, 1400px); max-height: calc(100vh - 6rem);
}

.lightbox__img {
    max-width: 100%; max-height: calc(100vh - 8rem); object-fit: contain; display: block;
    opacity: 0; transform: scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 40px 100px rgba(0,0,0,0.8);
    -webkit-user-drag: none; user-select: none; pointer-events: none;
}

.lightbox.is-open .lightbox__img { opacity: 1; transform: scale(1); }

/* Removed ::after overlay — was causing a click dead zone after lightbox close */

.lightbox__caption {
    font-family: var(--font-label); font-size: 0.6875rem;
    text-transform: uppercase; letter-spacing: 0.18em;
    color: var(--color-secondary); text-align: center; margin: 0;
}

.lightbox__close,
.lightbox__prev,
.lightbox__next {
    position: fixed; z-index: 2;
    background: none; border: none;
    color: rgba(255,255,255,0.7); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: var(--space-3); border-radius: var(--radius-sm);
    transition: color var(--transition-base), opacity var(--transition-base);
    opacity: 0; pointer-events: none;
}

.lightbox.is-open .lightbox__close,
.lightbox.is-open .lightbox__prev,
.lightbox.is-open .lightbox__next { opacity: 1; pointer-events: auto; }

.lightbox__close:hover,
.lightbox__prev:hover,
.lightbox__next:hover { color: var(--color-primary); }

.lightbox__close { top: var(--space-6); right: var(--space-6); }
.lightbox__prev  { left: var(--space-6); top: 50%; transform: translateY(-50%); }
.lightbox__next  { right: var(--space-6); top: 50%; transform: translateY(-50%); }

.lightbox__close .material-symbols-outlined,
.lightbox__prev  .material-symbols-outlined,
.lightbox__next  .material-symbols-outlined { font-size: 1.75rem; }

.lightbox__prev:disabled,
.lightbox__next:disabled { opacity: 0.2; cursor: default; }

.lightbox__counter {
    position: fixed; bottom: var(--space-6); left: 50%; transform: translateX(-50%);
    font-family: var(--font-label); font-size: 0.625rem;
    text-transform: uppercase; letter-spacing: 0.2em; color: #555;
    z-index: 2; opacity: 0; transition: opacity var(--transition-base); pointer-events: none;
}

.lightbox.is-open .lightbox__counter { opacity: 1; }

body.lightbox-open { overflow: hidden; }


/* ============================================================
   ADMIN EMPTY STATE
   ============================================================ */

.gallery-notice {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--space-6); min-height: 60vh; text-align: center;
    padding: var(--space-16); color: var(--color-on-surface-variant);
}

.gallery-notice__icon { font-size: 3.5rem; color: var(--color-outline); opacity: 0.4; }
.gallery-notice p { max-width: 28rem; line-height: 1.7; }
