/* ==========================================================================
   Gallery page
   Builds on main.css (tokens, header, footer, .section-eyebrow).
   ========================================================================== */

main {
    background: #ffffff;
    color: var(--color-muted);
}

.ghero__inner,
.album__inner {
    width: min(1320px, 100% - 2 * clamp(16px, 4vw, 48px));
    margin-inline: auto;
}

/* ==========================================================================
   Hero
   ========================================================================== */

.ghero {
    --away: max(0, calc(var(--p, 0.4) - 0.4));
    padding: clamp(120px, 15vw, 170px) 0 clamp(36px, 5vw, 56px);
    overflow-x: clip;
}

.ghero__inner {
    translate: 0 calc(var(--away) * -120px);
}

.ghero__title {
    margin: 0 0 clamp(24px, 3vw, 36px);
    font-size: clamp(3rem, 9vw, 8.5rem);
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -0.06em;
    color: var(--color-dark);
}

.ghero__title em {
    font-style: normal;
    color: var(--color-brand);
}

.ghero__line {
    display: block;
    overflow: hidden;
    padding-bottom: 0.06em;
}

.ghero__line > span {
    display: inline-block;
    animation: g-rise 1100ms cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--d) * 120ms + 150ms);
}

.ghero__fade {
    animation: g-fade 900ms var(--ease) both;
    animation-delay: calc(var(--d) * 120ms + 150ms);
}

@keyframes g-rise {
    from { transform: translateY(105%) rotate(5deg); }
}

@keyframes g-fade {
    from { opacity: 0; transform: translateY(20px); }
}

.ghero__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px 48px;
}

.ghero__lead {
    max-width: 52ch;
    margin: 0;
    font-size: clamp(1rem, 1.4vw, 1.15rem);
    line-height: 1.7;
}

.ghero__stats {
    display: flex;
    gap: 40px;
    margin: 0;
}

.ghero__stats div {
    display: flex;
    flex-direction: column-reverse;
}

.ghero__stats dd {
    margin: 0;
    font-size: clamp(2.4rem, 4.4vw, 3.6rem);
    font-weight: 300;
    line-height: 1;
    letter-spacing: -0.05em;
    color: var(--color-dark);
}

.ghero__stats dt {
    margin-top: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

/* --- Film strips --------------------------------------------------------- */

.strips {
    display: grid;
    gap: 14px;
    margin-top: clamp(40px, 5vw, 64px);
    rotate: -2deg;
    scale: 1.06;
    animation: g-fade 1000ms var(--ease) 500ms both;
}

.strips__row {
    overflow: hidden;
}

.strips__track {
    display: flex;
    gap: 14px;
    width: max-content;
    animation: strip-run 60s linear infinite;
}

.strips__row--b .strips__track {
    animation-direction: reverse;
    animation-duration: 70s;
}

.strips__row:hover .strips__track {
    animation-play-state: paused;
}

@keyframes strip-run {
    to { transform: translateX(-50%); }
}

.strips__item {
    flex: none;
    height: clamp(130px, 16vw, 210px);
    margin: 0;
    border-radius: 20px;
    overflow: hidden;
    background: #ece9e4;
}

.strips__item img {
    width: auto;
    height: 100%;
    object-fit: cover;
    filter: grayscale(0.3);
    transition: filter 400ms, transform 600ms var(--ease);
}

.strips__item:hover img {
    filter: none;
    transform: scale(1.05);
}

/* ==========================================================================
   Album
   ========================================================================== */

.album {
    padding: clamp(40px, 5vw, 64px) 0 clamp(72px, 9vw, 120px);
}

.album__bar {
    position: sticky;
    z-index: 40;
    top: 84px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-bottom: 28px;
    padding: 8px;
    border: 1px solid rgba(20, 20, 20, 0.08);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.86);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 16px 40px -24px rgba(20, 20, 20, 0.4);
    transition: top 450ms var(--ease);
}

:root:has(.site-header.is-hidden) .album__bar {
    top: 14px;
}

.album__filters {
    display: flex;
    flex: 1 1 auto;
    gap: 6px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.album__filters::-webkit-scrollbar {
    display: none;
}

.album__filters button {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.9rem;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--color-dark);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 250ms, color 250ms;
}

.album__filters button span {
    font-size: 0.72rem;
    opacity: 0.55;
}

.album__filters button:hover {
    background: rgba(20, 20, 20, 0.05);
}

.album__filters button[aria-pressed="true"] {
    background: var(--color-dark);
    color: #ffffff;
}

.album__filters button[aria-pressed="true"] span {
    color: var(--color-brand-light);
    opacity: 1;
}

.album__search {
    display: flex;
    flex: 0 1 260px;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border-radius: 999px;
    background: #f1f0ed;
    color: var(--color-muted);
    transition: box-shadow 250ms, background-color 250ms;
}

.album__search:focus-within {
    background: #ffffff;
    box-shadow: 0 0 0 2px var(--color-dark);
}

.album__search input {
    width: 100%;
    padding: 0.65rem 0;
    border: 0;
    background: none;
    color: var(--color-dark);
    font: inherit;
    font-size: 0.9rem;
    outline: none;
}

/* Masonry: photos keep their natural shape */
.album__grid {
    columns: 4 260px;
    column-gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.album__item {
    break-inside: avoid;
    margin-bottom: 14px;
}

.js .album__item[hidden] {
    display: none;
}

.album__tile {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 22px;
    background: #ece9e4;
    color: #ffffff;
    cursor: zoom-in;
    isolation: isolate;
}

.album__tile img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 900ms cubic-bezier(0.22, 1, 0.36, 1), filter 500ms;
}

.album__tile:hover img,
.album__tile:focus-visible img {
    transform: scale(1.06);
}

.album__tile:focus-visible {
    outline: 3px solid var(--color-brand);
    outline-offset: 3px;
}

/* Reveal: tiles unveil bottom-up as they scroll in (class from gallery-page.js) */
.js .album__item:not(.is-in) .album__tile {
    clip-path: inset(100% 0 0 0 round 22px);
}

.js .album__item:not(.is-in) .album__tile img {
    transform: scale(1.25);
}

.js .album__item.is-in .album__tile {
    clip-path: inset(0 0 0 0 round 22px);
    transition: clip-path 1000ms cubic-bezier(0.77, 0, 0.18, 1);
    transition-delay: var(--d, 0ms);
}

.js .album__item.is-in .album__tile img {
    transition-delay: var(--d, 0ms);
}

/* Caption overlay */
.album__tile::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(14, 14, 14, 0.82), rgba(14, 14, 14, 0) 55%);
    opacity: 0;
    transition: opacity 400ms;
}

.album__tile:hover::after,
.album__tile:focus-visible::after {
    opacity: 1;
}

.album__meta {
    position: absolute;
    z-index: 1;
    left: 16px;
    right: 16px;
    bottom: 14px;
    display: grid;
    justify-items: start;
    gap: 6px;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 400ms, transform 500ms var(--ease);
}

.album__tile:hover .album__meta,
.album__tile:focus-visible .album__meta {
    opacity: 1;
    transform: none;
}

.album__tag {
    padding: 0.22rem 0.6rem;
    border-radius: 999px;
    background: var(--color-brand);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.album__caption {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.35;
}

.album__zoom {
    position: absolute;
    z-index: 1;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #ffffff;
    color: var(--color-dark);
    opacity: 0;
    transform: scale(0.6) rotate(-45deg);
    transition: opacity 300ms, transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.album__tile:hover .album__zoom,
.album__tile:focus-visible .album__zoom {
    opacity: 1;
    transform: none;
}

/* Touch screens: no hover, so keep a small caption visible */
@media (hover: none) {
    .album__tile::after {
        opacity: 0.85;
    }

    .album__meta {
        opacity: 1;
        transform: none;
    }

    .album__caption {
        font-size: 0.78rem;
    }

    .album__tag {
        display: none;
    }
}

.album__empty {
    margin: 0;
    padding: 56px;
    border-radius: 28px;
    background: #f7f6f3;
    font-weight: 600;
    text-align: center;
    color: var(--color-dark);
}

/* ==========================================================================
   Viewer (lightbox)
   ========================================================================== */

html.has-viewer {
    overflow: hidden;
}

.viewer {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(10, 10, 10, 0.96);
    color: #ffffff;
}

.viewer[open] {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    animation: viewer-in 300ms ease;
}

@keyframes viewer-in {
    from { opacity: 0; }
}

.viewer::backdrop {
    background: rgba(10, 10, 10, 0.7);
}

.viewer__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px clamp(16px, 3vw, 28px);
}

.viewer__count {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    font-variant-numeric: tabular-nums;
}

.viewer__tools {
    display: flex;
    gap: 8px;
}

.viewer__btn,
.viewer__nav {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    transition: background-color 200ms, transform 200ms var(--ease);
}

.viewer__btn:hover,
.viewer__nav:hover {
    background: rgba(255, 255, 255, 0.18);
}

.viewer__icon-pause,
.viewer__btn[aria-pressed="true"] .viewer__icon-play {
    display: none;
}

.viewer__btn[aria-pressed="true"] .viewer__icon-pause {
    display: block;
}

.viewer__stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 0;
    margin: 0;
    padding: 0 clamp(16px, 7vw, 110px);
}

.viewer__img {
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
    user-select: none;
}

.viewer__img.is-entering {
    animation: img-in 450ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes img-in {
    from { opacity: 0; transform: translateX(calc(var(--dir, 1) * 40px)) scale(0.97); }
}

.viewer__caption {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px 12px;
    font-size: 0.95rem;
    text-align: center;
}

.viewer__tag {
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: var(--color-brand);
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.viewer__progress {
    width: min(240px, 50%);
    height: 2px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.15);
    overflow: hidden;
    opacity: 0;
    transition: opacity 300ms;
}

.viewer.is-playing .viewer__progress {
    opacity: 1;
}

.viewer__progress span {
    display: block;
    height: 100%;
    background: var(--color-brand);
    transform: scaleX(var(--tick, 0));
    transform-origin: left;
}

.viewer__nav {
    position: fixed;
    top: 50%;
    width: 54px;
    height: 54px;
    translate: 0 -50%;
}

.viewer__nav--prev { left: clamp(10px, 2vw, 28px); }
.viewer__nav--next { right: clamp(10px, 2vw, 28px); }

.viewer__nav--prev:hover { transform: translateX(-3px); }
.viewer__nav--next:hover { transform: translateX(3px); }

/* Thumbnail rail */
.viewer__rail {
    display: flex;
    gap: 8px;
    padding: 14px clamp(16px, 3vw, 28px) 18px;
    overflow-x: auto;
    scrollbar-width: none;
}

.viewer__rail::-webkit-scrollbar {
    display: none;
}

.viewer__thumb {
    flex: none;
    width: 64px;
    height: 48px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    background: #222222;
    opacity: 0.45;
    transition: opacity 250ms, border-color 250ms, transform 250ms var(--ease);
}

.viewer__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.viewer__thumb:hover {
    opacity: 0.85;
}

.viewer__thumb.is-current {
    border-color: var(--color-brand);
    opacity: 1;
    transform: translateY(-3px);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 760px) {
    .album__grid {
        columns: 2;
        column-gap: 10px;
    }

    .album__item {
        margin-bottom: 10px;
    }

    .album__tile {
        border-radius: 16px;
    }

    .album__bar {
        top: 76px;
        border-radius: 22px;
    }

    .album__search {
        flex: 1 1 100%;
    }

    .viewer__nav {
        top: auto;
        bottom: 84px;
        width: 46px;
        height: 46px;
        translate: none;
    }

    .viewer__stage {
        padding: 0 12px 64px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .strips__track {
        animation: none;
    }

    .ghero__inner {
        translate: none;
    }

    .js .album__item .album__tile,
    .js .album__item .album__tile img {
        clip-path: none !important;
        transform: none !important;
    }
}
