/* =====================================================================
   GALLERY PAGE — gallery.php
   Masonry-style grid (CSS grid with row spans), filters, lightbox.
   ===================================================================== */

.gallery-hero { padding-block: clamp(48px, 6vw, 88px) clamp(24px, 3vw, 40px); }
.gallery-hero__grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: clamp(24px, 5vw, 72px); align-items: end; }
.gallery-hero h1 { margin: 0; max-width: 14ch; }
.gallery-hero .lead { margin-bottom: 16px; }

/* ---------- Filters ---------- */
.gallery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}
.gallery-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--white);
    font-family: var(--font-head);
    font-size: 0.92rem;
    font-weight: var(--fw-semibold);
    color: var(--ink);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.gallery-filter span { font-size: var(--fs-xs); color: var(--muted); font-weight: var(--fw-medium); }
.gallery-filter:hover { border-color: var(--ink); }
.gallery-filter.is-active { background: var(--ink); border-color: var(--ink); color: var(--white); }
.gallery-filter.is-active span { color: var(--amber); }

/* ---------- Grid ---------- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 180px;
    grid-auto-flow: dense;
    gap: 14px;
    list-style: none;
}
.gallery-item { grid-row: span 2; animation: galleryIn 0.5s var(--ease) both; }
.gallery-item--tall { grid-row: span 3; }
.gallery-item--wide { grid-column: span 2; grid-row: span 2; }
.gallery-item[hidden] { display: none; }
@keyframes galleryIn { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }

.gallery-item__btn {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--paper-2);
    cursor: zoom-in;
}
.gallery-item__btn img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.8s var(--ease); }
.gallery-item__btn::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 50%, rgba(14, 18, 24, 0.82));
    opacity: 0.7;
    transition: opacity 0.3s;
}
.gallery-item__meta {
    position: absolute;
    left: 18px; right: 18px; bottom: 16px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
    color: var(--white);
    transform: translateY(6px);
    transition: transform 0.35s var(--ease);
}
.gallery-item__cat { font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); }
.gallery-item__cap { font-family: var(--font-head); font-weight: var(--fw-semibold); }
.gallery-item__flag {
    position: absolute;
    top: 12px; right: 12px;
    z-index: 1;
    padding: 3px 8px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    font-size: 0.7rem;
    font-weight: var(--fw-semibold);
    border-radius: var(--radius-sm);
}
.gallery-item__btn:hover img, .gallery-item__btn:focus-visible img { transform: scale(1.05); }
.gallery-item__btn:hover::after { opacity: 1; }
.gallery-item__btn:hover .gallery-item__meta { transform: none; }

/* ---------- Lightbox ---------- */
.lightbox {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(10, 13, 18, 0.96);
    color: var(--white);
}
.lightbox::backdrop { background: rgba(10, 13, 18, 0.8); }
.lightbox[open] { animation: lbIn 0.3s var(--ease); }
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }
.lightbox__inner { position: relative; display: grid; grid-template-columns: 72px 1fr 72px; align-items: center; height: 100%; padding: 24px; }
.lightbox__figure { display: flex; flex-direction: column; align-items: center; gap: 16px; margin: 0; max-height: 100%; }
.lightbox__figure img { max-width: 100%; max-height: calc(100vh - 140px); width: auto; height: auto; object-fit: contain; border-radius: var(--radius-sm); transition: opacity 0.25s; }
.lightbox__figure img.is-loading { opacity: 0.3; }
.lightbox__figure figcaption { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 6px 16px; text-align: center; }
.lightbox__figure figcaption span { font-size: var(--fs-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); }
.lightbox__figure figcaption strong { color: var(--white); font-family: var(--font-head); }
.lightbox__figure figcaption em { font-style: normal; font-size: var(--fs-xs); color: var(--muted-light); }
.lightbox__nav, .lightbox__close {
    display: grid;
    place-items: center;
    width: 52px; height: 52px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: transparent;
    color: var(--white);
    transition: background 0.2s, color 0.2s;
}
.lightbox__nav:hover, .lightbox__close:hover { background: var(--white); color: var(--ink); }
.lightbox__close { position: absolute; top: 20px; right: 20px; z-index: 2; }

@media (max-width: 1100px) {
    .gallery-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 160px; }
}
@media (max-width: 900px) {
    .gallery-hero__grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .gallery-grid { grid-template-columns: 1fr; grid-auto-rows: 120px; }
    .gallery-item--wide { grid-column: auto; }
    .gallery-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter); }
    .gallery-filter { flex: none; }
    .lightbox__inner { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr auto; padding: 72px 12px 20px; gap: 16px; }
    .lightbox__figure { grid-column: 1 / -1; grid-row: 1; }
    .lightbox__nav--prev { grid-row: 2; justify-self: end; }
    .lightbox__nav--next { grid-row: 2; justify-self: start; }
}
