/* Gallery page (/pl/gallery/, /en/gallery/) and the photo strip at the end of
   every expedition page. Uses the site's custom properties from BaseLayout. */

/* ---------- Gallery page ---------- */

.gallery { padding-top: clamp(2rem, 5vw, 3.5rem); }

.gallery__chips {
    display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem;
    margin: 0 auto clamp(1.75rem, 4vw, 2.75rem); max-width: 60rem;
}
.gallery__chip {
    font: 500 .92rem/1 var(--font-body);
    color: var(--color-ink-soft);
    background: var(--color-canvas);
    border: 1px solid var(--color-rule);
    border-radius: var(--radius-pill);
    padding: .62rem 1.05rem;
    cursor: pointer;
    display: inline-flex; align-items: center; gap: .45rem;
    transition: background .2s, color .2s, border-color .2s, box-shadow .2s;
}
.gallery__chip:hover { border-color: var(--color-sage); color: var(--color-ink); }
.gallery__chip:focus-visible { outline: 2px solid var(--color-sienna); outline-offset: 2px; }
.gallery__chip[aria-pressed="true"] {
    background: var(--color-sage-deep); border-color: var(--color-sage-deep); color: #fff;
    box-shadow: var(--shadow-soft);
}
.gallery__chip-count {
    font-size: .75rem; font-weight: 600; min-width: 1.5em; padding: .2em .45em; border-radius: var(--radius-pill);
    background: var(--color-ivory-tint); color: var(--color-sage-deep); text-align: center;
}
.gallery__chip[aria-pressed="true"] .gallery__chip-count { background: rgb(255 255 255 / .18); color: #fff; }

/* Phones: the filter is one row you swipe, not a tower of pills. */
@media (max-width: 559px) {
    .gallery__chips {
        flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto;
        margin-inline: calc(-1 * clamp(1rem, 4vw, 2rem)); padding: 2px clamp(1rem, 4vw, 2rem) 6px;
        scrollbar-width: none; scroll-snap-type: x proximity; scroll-padding-inline: clamp(1rem, 4vw, 2rem);
    }
    .gallery__chips::-webkit-scrollbar { display: none; }
    .gallery__chip { flex: none; scroll-snap-align: start; }
}

/* Masonry on a grid of 1px rows: gallery.js gives each tile a row span equal to
   its height plus the gap. Unlike CSS columns, photos then read left to right,
   so "newest first" and the admin's Earlier/Later order is what visitors see. */
.gallery__grid {
    --cols: 2; --gallery-gap: 10px;
    display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    grid-auto-rows: 1px; column-gap: var(--gallery-gap); align-items: start;
}
@media (min-width: 560px)  { .gallery__grid { --gallery-gap: 14px; } }
@media (min-width: 900px)  { .gallery__grid { --cols: 3; } }
@media (min-width: 1400px) { .gallery__grid { --cols: 4; } }

.gallery__tile {
    position: relative; display: block; margin: 0;
    border-radius: var(--radius-card); overflow: hidden;
    background: var(--color-ivory-tint);
    box-shadow: var(--shadow-soft);
    transform: translateZ(0); /* keeps the rounded corners clipping the zoom in Safari */
    opacity: 0; translate: 0 10px;
    transition: opacity .6s ease, translate .6s ease, box-shadow .3s ease;
}
.gallery__tile.is-loaded { opacity: 1; translate: 0 0; }
.gallery__tile[hidden] { display: none; }
.gallery__tile img {
    display: block; width: 100%; height: auto;
    transition: transform .7s cubic-bezier(.2, .7, .2, 1);
}
.gallery__tile:hover, .gallery__tile:focus-visible { box-shadow: var(--shadow-lift); }
.gallery__tile:hover img, .gallery__tile:focus-visible img { transform: scale(1.04); }
.gallery__tile:focus-visible { outline: 3px solid var(--color-sienna); outline-offset: 3px; }

.gallery__meta {
    position: absolute; inset: auto 0 0 0;
    padding: 2.6rem 1rem .9rem;
    background: linear-gradient(to top, rgb(20 28 24 / .78), rgb(20 28 24 / 0));
    color: #fff; display: grid; gap: .2rem;
    opacity: 0; translate: 0 8px;
    transition: opacity .35s ease, translate .35s ease;
    pointer-events: none;
}
.gallery__tile:hover .gallery__meta, .gallery__tile:focus-visible .gallery__meta { opacity: 1; translate: 0 0; }
.gallery__trip { font: 600 .7rem/1.2 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--color-ivory); }
.gallery__caption { font: 400 1rem/1.35 var(--font-display); }
.gallery__meta:empty { display: none; }

.gallery__empty {
    text-align: center; color: var(--color-ink-muted);
    font: 400 clamp(1.15rem, 2.4vw, 1.4rem)/1.4 var(--font-display);
    padding: 3rem 0 2rem;
}

/* ---------- Lightbox ---------- */

body.lightbox-open { overflow: hidden; }

.lightbox {
    position: fixed; inset: 0; z-index: 1000;
    background: rgb(14 20 17 / .95);
    display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto 1fr;
    align-items: center;
    color: #fff;
    animation: lb-in .25s ease;
    /* Horizontal swipes go to gallery.js instead of panning the page, or a
       touch browser cancels the gesture and the photo never changes. */
    touch-action: pan-y pinch-zoom;
}
.lightbox[hidden] { display: none; }
@keyframes lb-in { from { opacity: 0; } }

.lightbox__top {
    grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center;
    padding: clamp(.75rem, 2vw, 1.25rem) clamp(.75rem, 2.5vw, 1.75rem);
}
.lightbox__count { font: 400 1rem/1 var(--font-display); color: rgb(255 255 255 / .75); letter-spacing: .04em; }

.lightbox__btn {
    width: 48px; height: 48px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgb(255 255 255 / .08); color: #fff;
    border: 1px solid rgb(255 255 255 / .18);
    cursor: pointer; transition: background .2s, border-color .2s, transform .2s;
}
.lightbox__btn:hover { background: rgb(255 255 255 / .18); border-color: rgb(255 255 255 / .35); }
.lightbox__btn:focus-visible { outline: 2px solid var(--color-ivory); outline-offset: 3px; }
.lightbox__nav { margin: 0 clamp(.5rem, 2vw, 1.5rem); }
.lightbox__nav[disabled] { opacity: .25; cursor: default; }

.lightbox__figure {
    margin: 0; height: 100%; min-height: 0;
    display: grid; grid-template-rows: 1fr auto; justify-items: center; gap: .9rem;
    padding-bottom: clamp(.75rem, 2.5vw, 1.75rem);
}
/* An explicit row/column: with the default auto track, the photo's
   max-height: 100% would refer back to its own height and portrait photos
   would run off the bottom of the screen. */
.lightbox__frame {
    min-height: 0; height: 100%; width: 100%; display: grid; place-items: center;
    grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
}
.lightbox__frame img {
    max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
    border-radius: 6px; box-shadow: 0 30px 80px rgb(0 0 0 / .45);
    animation: lb-photo .35s ease;
}
@keyframes lb-photo { from { opacity: 0; scale: .985; } }
.lightbox__caption {
    display: flex; flex-wrap: wrap; gap: .35rem 1.25rem; justify-content: center; align-items: baseline;
    max-width: 60rem; padding: 0 1rem; text-align: center;
    font: 400 clamp(1rem, 2vw, 1.15rem)/1.4 var(--font-display);
}
.lightbox__caption:empty, .lightbox__caption span:empty { display: none; }
.lightbox__trip {
    font: 600 .78rem/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase;
    color: var(--color-ivory); text-decoration: none; border-bottom: 1px solid rgb(184 216 203 / .45); padding-bottom: .2rem;
}
.lightbox__trip:hover { color: #fff; border-color: #fff; }
.lightbox__trip[hidden] { display: none; }

/* Phones: swipe, plus small arrows over the photo's edges. */
@media (max-width: 700px) {
    .lightbox { grid-template-columns: 1fr; }
    .lightbox__nav {
        position: absolute; top: 50%; translate: 0 -50%; z-index: 1; margin: 0;
        width: 40px; height: 40px; background: rgb(14 20 17 / .55);
    }
    .lightbox__nav--prev { left: 8px; }
    .lightbox__nav--next { right: 8px; }
}

/* ---------- Strip at the end of expedition pages ---------- */

.gallery-strip { overflow: hidden; }
.gallery-strip[hidden] { display: none; }
/* On the expeditions list the cards section above already ends with padding. */
.gallery-strip--catalogue { padding-top: 0; }
.gallery-strip__head { text-align: center; margin-bottom: clamp(1.5rem, 3.5vw, 2.25rem); }
.gallery-strip__head h2 { font-family: var(--font-display); font-size: clamp(1.8rem, 3.5vw, 2.6rem); margin: .6rem 0 .35rem; }
.gallery-strip__head p { color: var(--color-ink-muted); margin: 0; }

.gallery-strip__viewport {
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
    mask-image: linear-gradient(to right, transparent, #000 6%, #000 94%, transparent);
}
.gallery-strip__track {
    display: flex; width: max-content; /* tiles carry their own right margin: a flex gap would leave the two halves 7px apart and the loop would jump */
    animation: strip-slide var(--strip-duration, 60s) linear infinite;
}
.gallery-strip__viewport:hover .gallery-strip__track,
.gallery-strip__viewport:focus-within .gallery-strip__track,
.gallery-strip__viewport.is-touching .gallery-strip__track { animation-play-state: paused; }
@keyframes strip-slide { to { transform: translateX(-50%); } }

.gallery-strip__tile {
    flex: none; height: 280px; margin-right: 14px; border-radius: var(--radius-card); overflow: hidden;
    box-shadow: var(--shadow-soft); background: var(--color-ivory-tint); display: block;
}
.gallery-strip__tile img { display: block; height: 100%; width: auto; transition: transform .6s cubic-bezier(.2, .7, .2, 1); }
.gallery-strip__tile:hover img, .gallery-strip__tile:focus-visible img { transform: scale(1.05); }
.gallery-strip__tile:focus-visible { outline: 3px solid var(--color-sienna); outline-offset: -3px; }
@media (max-width: 560px) { .gallery-strip__tile { height: 220px; } }

.gallery-strip__cta { text-align: center; margin-top: clamp(1.5rem, 3.5vw, 2.25rem); }

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
    .gallery__tile, .gallery__tile img, .gallery__meta, .gallery-strip__tile img { transition: none; }
    .gallery__tile { opacity: 1; translate: none; }
    .gallery__tile:hover img, .gallery__tile:focus-visible img, .gallery-strip__tile:hover img { transform: none; }
    .lightbox, .lightbox__frame img { animation: none; }
    .gallery-strip__track { animation: none; width: auto; }
    .gallery-strip__viewport { overflow-x: auto; scroll-snap-type: x mandatory; -webkit-mask-image: none; mask-image: none; }
    .gallery-strip__tile { scroll-snap-align: start; }
    .gallery-strip__tile[aria-hidden="true"] { display: none; }
}
