/* ==========================================================================
   gx-lightbox — immersive fullscreen photo viewer (Airbnb / Apple Photos)
   --------------------------------------------------------------------------
   No boxed container: the image scales naturally inside the whole viewport
   (portrait fills height, landscape fills width) over a near-black backdrop.
   Chrome (top bar, info line, filmstrip) floats above and auto-hides.
   Requires viewport-fit=cover (set in the layouts) for safe-area padding.
   ========================================================================== */

.gx-lb {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, .95);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .28s ease;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}
.gx-lb.gx-lb--open { opacity: 1; }
html.gx-lb-lock,
html.gx-lb-lock body { overflow: hidden !important; }

/* --- Stage: the image owns the screen ----------------------------------- */
.gx-lb-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: grab;
}
.gx-lb-stage.gx-lb-stage--panning { cursor: grabbing; }

.gx-lb-slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: transform, opacity;
}
.gx-lb-slide img {
    max-width: 100vw;
    max-height: 100dvh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    will-change: transform;
    -webkit-user-drag: none;
}
/* Slide transitions (JS toggles these classes) */
.gx-lb-slide--anim { transition: transform .34s cubic-bezier(.2, 0, .2, 1), opacity .34s ease; }
.gx-lb-slide--out-left  { transform: translateX(-18vw); opacity: 0; }
.gx-lb-slide--out-right { transform: translateX(18vw);  opacity: 0; }
.gx-lb-slide--in-left   { transform: translateX(-18vw); opacity: 0; }
.gx-lb-slide--in-right  { transform: translateX(18vw);  opacity: 0; }

/* --- Loading skeleton ---------------------------------------------------- */
.gx-lb-skeleton {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(62vw, 460px);
    height: min(44vh, 320px);
    transform: translate(-50%, -50%);
    border-radius: 16px;
    background: linear-gradient(100deg, rgba(255,255,255,.05) 30%, rgba(255,255,255,.12) 50%, rgba(255,255,255,.05) 70%);
    background-size: 220% 100%;
    animation: gx-lb-shimmer 1.2s linear infinite;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}
.gx-lb-skeleton.gx-lb-skeleton--on { opacity: 1; }
@keyframes gx-lb-shimmer {
    to { background-position: -120% 0; }
}

/* --- Floating top bar ---------------------------------------------------- */
.gx-lb-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 26px;
    background: linear-gradient(rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
    transition: opacity .3s ease, transform .3s ease;
}
.gx-lb-title {
    flex: 1;
    min-width: 0;
    color: #fff;
    text-align: center;
}
.gx-lb-title strong {
    display: block;
    font-size: 14px;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gx-lb-counter {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, .72);
    margin-top: 1px;
    font-variant-numeric: tabular-nums;
}
.gx-lb-actions { display: flex; align-items: center; gap: 6px; }

.gx-lb-btn {
    appearance: none;
    border: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s ease, transform .15s ease;
}
.gx-lb-btn:hover { background: rgba(255, 255, 255, .22); }
.gx-lb-btn:active { transform: scale(.92); }
.gx-lb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.gx-lb-btn--fav.gx-lb-btn--on { color: #ff385c; }

/* --- Desktop side arrows -------------------------------------------------- */
.gx-lb-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    width: 46px;
    height: 46px;
    font-size: 18px;
    transition: opacity .3s ease, background .15s ease;
}
.gx-lb-arrow--prev { left: 18px; }
.gx-lb-arrow--next { right: 18px; }
@media (max-width: 767px), (pointer: coarse) {
    .gx-lb-arrow { display: none; }
}

/* --- Info line (image title / category, only when available) ------------- */
.gx-lb-info {
    position: absolute;
    left: 50%;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    z-index: 4;
    max-width: 86vw;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .45);
    color: rgba(255, 255, 255, .92);
    font-size: 12.5px;
    font-weight: 550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity .3s ease, transform .3s ease;
}
.gx-lb-info:empty { display: none; }

/* --- Bottom filmstrip ------------------------------------------------------ */
.gx-lb-film {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, .55));
    transition: opacity .3s ease, transform .3s ease;
}
.gx-lb-film::-webkit-scrollbar { display: none; }
.gx-lb-film-inner {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 auto; /* centers the strip when it fits the viewport */
}
.gx-lb-thumb {
    appearance: none;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 9px;
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    overflow: hidden;
    cursor: pointer;
    opacity: .55;
    background: rgba(255, 255, 255, .06);
    transition: width .22s ease, height .22s ease, opacity .22s ease, border-color .22s ease;
    -webkit-tap-highlight-color: transparent;
}
.gx-lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}
.gx-lb-thumb--active {
    width: 62px;
    height: 62px;
    opacity: 1;
    border-color: #fff;
}
.gx-lb-thumb:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* --- Auto-hidden chrome ----------------------------------------------------- */
.gx-lb--ui-hidden .gx-lb-top    { opacity: 0; transform: translateY(-14px); pointer-events: none; }
.gx-lb--ui-hidden .gx-lb-info   { opacity: 0; transform: translate(-50%, 10px); pointer-events: none; }
.gx-lb--ui-hidden .gx-lb-film   { opacity: 0; transform: translateY(14px); pointer-events: none; }
.gx-lb--ui-hidden .gx-lb-arrow  { opacity: 0; pointer-events: none; }

/* --- Toast (share fallback etc.) ------------------------------------------ */
.gx-lb-toast {
    position: absolute;
    left: 50%;
    top: calc(72px + env(safe-area-inset-top, 0px));
    transform: translateX(-50%);
    z-index: 5;
    padding: 8px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    color: #111;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}
.gx-lb-toast--on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .gx-lb, .gx-lb-slide, .gx-lb-slide img,
    .gx-lb-top, .gx-lb-info, .gx-lb-film, .gx-lb-thumb { transition: none !important; }
}
