/* Listing photo gallery (site detail sheet + admin preview) and the full-screen photo viewer */

.gallery {
    display: grid;
    gap: 2px;
    width: 100%;
    height: 100%;
    background: #ffffff;
}
.gallery[data-count="1"] { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.gallery[data-count="2"] { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
/* 3 or more shown: big picture on the left, two small ones stacked on the right */
.gallery[data-count="3"] { grid-template-columns: 1.7fr 1fr; grid-template-rows: 1fr 1fr; }
.gallery[data-count="3"] .g-tile:first-child { grid-row: 1 / span 2; }

.g-tile {
    position: relative;
    display: block;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    cursor: pointer;
    background: linear-gradient(90deg, #E2E6EC 0%, #F4F6F9 45%, #E2E6EC 90%);
    background-size: 240px 100%;
    animation: g-shimmer 1.2s linear infinite;
    -webkit-tap-highlight-color: transparent;
}
div.g-tile { cursor: default; }
@keyframes g-shimmer {
    0% { background-position: -240px 0; }
    100% { background-position: 240px 0; }
}
.g-tile img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.5s ease, filter 0.3s ease;
}
.g-tile img.loaded { opacity: 1; }
button.g-tile:hover img { transform: scale(1.03); }
button.g-tile:active img { transform: scale(1.01); }
.g-tile:focus-visible { outline: 2px solid #C5A059; outline-offset: -2px; }

/* the last visible tile when there are more pictures: blurred and darkened, with "+N" on top */
.g-blur img { filter: blur(3px) brightness(0.55); transform: scale(1.1); }
button.g-blur:hover img { transform: scale(1.12); }
.g-more {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #ffffff;
    font-size: 1.7rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}
@media (prefers-reduced-motion: reduce) {
    .g-tile { animation: none; }
    .g-tile img { transition: opacity 0.2s; }
}

/* ---------- full-screen photo viewer ---------- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    flex-direction: column;
    background: rgba(10, 12, 16, 0.97);
    animation: lb-in 0.22s ease-out;
}
.lightbox.hidden { display: none; }
.lightbox.is-closing { animation: lb-out 0.2s ease-in forwards; pointer-events: none; }
@keyframes lb-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes lb-out { from { opacity: 1; } to { opacity: 0; } }

.lb-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(0.75rem + env(safe-area-inset-top)) 1rem 0.75rem;
    color: #ffffff;
}
.lb-count { font-size: 0.85rem; font-weight: 600; letter-spacing: 0.05em; opacity: 0.9; }
.lb-close, .lb-nav {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(6px);
    -webkit-tap-highlight-color: transparent;
}
.lb-close:hover, .lb-nav:hover { background: rgba(255, 255, 255, 0.26); }

.lb-stage { position: relative; flex: 1; min-height: 0; display: flex; }
.lb-track {
    flex: 1;
    display: flex;
    overflow-x: auto;
    overscroll-behavior: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.lb-track::-webkit-scrollbar { display: none; }
.lb-slide {
    flex: 0 0 100%;
    display: grid;
    place-items: center;
    grid-template: minmax(0, 1fr) / minmax(0, 1fr);   /* the cell is as tall as the stage, so the photo is fitted inside it, never taller */
    min-height: 0;
    padding: 0 0.5rem calc(1rem + env(safe-area-inset-bottom));
    scroll-snap-align: center;
}
.lb-slide img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    min-height: 0;
    object-fit: contain;
    border-radius: 0.5rem;
}
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; }
.lb-prev { left: 0.75rem; }
.lb-next { right: 0.75rem; }
/* touch screens swipe; the arrows are for mouse users */
@media (pointer: coarse) { .lb-nav { display: none; } }
.lb-nav[disabled] { opacity: 0.25; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .lightbox { animation: none; } }

/* "Videos" pill on the photo header of the detail sheet */
.video-pill {
    display: inline-flex; align-items: center; gap: 0.45rem;
    padding: 0.28rem 0.8rem 0.28rem 0.3rem; border-radius: 9999px;
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; color: #ffffff;
    background: rgba(17, 20, 26, 0.55); border: 1px solid rgba(255, 255, 255, 0.28);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
    transition: transform 0.15s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.video-pill:hover { background: rgba(17, 20, 26, 0.72); }
.video-pill:active { transform: scale(0.95); }
.video-pill.hidden { display: none; }
.video-pill-icon {
    width: 1.5rem; height: 1.5rem; display: grid; place-items: center; padding-left: 0.08rem;
    border-radius: 9999px; font-size: 0.58rem; color: #ffffff; background: linear-gradient(135deg, #D4B26A, #B38A3E);
    box-shadow: 0 2px 6px rgba(179, 138, 62, 0.55);
}

/* a video slide in the full-screen viewer */
.lb-video video {
    max-width: 100%; max-height: 100%; width: auto; height: auto; min-height: 0;
    border-radius: 0.75rem; background: #000; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}
