/**
 * ============================================================================
 *  PROPERTY GALLERY — FULLSCREEN MODAL (single source of truth)
 * ============================================================================
 *
 * Minimalist, full-bleed photo viewer. Apple-Photos / Airbnb-zoom feel:
 *
 *  ┌─────────────────────────────────────────────────────────[X]──┐
 *  │                                                              │
 *  │ [<]              <image fills viewport>             [>]      │
 *  │                                                              │
 *  │                       6 / 37                                 │
 *  └──────────────────────────────────────────────────────────────┘
 *
 * Rules in this file are the ONLY modal rules. The legacy `.gallery-modal*`
 * block in detail/gallery.css has been removed — do not re-add it there.
 *
 *  - .gallery-modal              fixed full-viewport overlay (pure black)
 *  - .gallery-modal-content      stage; child elements are absolute siblings
 *  - .gallery-modal-stage        image wrapper (centers via flex)
 *  - .gallery-modal-image        the picture (object-fit: contain)
 *  - .gallery-modal-prev/next    glass pill nav buttons (mid-edges)
 *  - .gallery-modal-close        glass close button (top-right)
 *  - .gallery-modal-status       counter pill (bottom-center)
 *
 * No vendor-prefix gymnastics: backdrop-filter is supported in every browser
 * we ship to. Safe-area insets are respected for iPhone notch / home bar.
 */

/* ── Overlay ─────────────────────────────────────────────────────────────── */

.gallery-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;             /* above navbar (10000) */
    background: #000;
    width: 100dvw;
    height: 100dvh;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.gallery-modal.active,
.gallery-modal.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ── Content shell — pure positioning context, no visible chrome ────────── */

.gallery-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    display: block;              /* siblings position absolutely */
    overflow: hidden;
}

/* ── Image stage ─────────────────────────────────────────────────────────── */

.gallery-modal-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
}

.gallery-modal-image {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    margin: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    user-select: none;
    -webkit-user-drag: none;
    transition: opacity 0.2s ease;
}

/* ── Close button — top-right glass ───────────────────────────────────── */

.gallery-modal-close {
    position: absolute;
    top: max(env(safe-area-inset-top, 16px), 16px);
    right: 16px;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
    z-index: 5;
}

.gallery-modal-close i { font-size: 1.05rem; line-height: 1; }

.gallery-modal-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.05);
}

/* ── Prev / next — mid-edge glass pills ─────────────────────────────── */

.gallery-modal-control,
.gallery-modal-prev,
.gallery-modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.10);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #fff;
    display: grid;
    place-items: center;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0.7;
    transition: background 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
    z-index: 5;
}

.gallery-modal-prev { left: 16px; }
.gallery-modal-next { right: 16px; }

.gallery-modal-content:hover .gallery-modal-prev,
.gallery-modal-content:hover .gallery-modal-next { opacity: 1; }

.gallery-modal-control:hover,
.gallery-modal-prev:hover,
.gallery-modal-next:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-50%) scale(1.08);
    opacity: 1;
}

.gallery-modal-control:active,
.gallery-modal-prev:active,
.gallery-modal-next:active {
    background: rgba(255, 255, 255, 0.30);
}

.gallery-modal-control i,
.gallery-modal-prev i,
.gallery-modal-next i { font-size: 1.1rem; line-height: 1; }

/* Larger buttons on desktop */
@media (min-width: 768px) {
    .gallery-modal-control,
    .gallery-modal-prev,
    .gallery-modal-next { width: 56px; height: 56px; }
    .gallery-modal-prev { left: 28px; }
    .gallery-modal-next { right: 28px; }
}

/* ── Counter — bottom-center pill ─────────────────────────────────────── */

.gallery-modal-status {
    position: absolute;
    left: 50%;
    bottom: max(env(safe-area-inset-bottom, 16px), 20px);
    transform: translateX(-50%);
    /* Reset any inherited flex/grid sizing — old detail/gallery.css ghosts. */
    top: auto;
    right: auto;
    width: auto;
    height: auto;
    min-width: 0;
    margin: 0;
    flex: 0 0 auto;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;

    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    color: #fff;

    font-size: 0.82rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    line-height: 1;
    white-space: nowrap;

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 5;
}

.gallery-modal-status__sep { opacity: 0.5; margin: 0 2px; }

/* ── Hide legacy parts that may still be in the DOM ────────────────────── */

.gallery-modal-thumbs,
.gallery-modal-header { display: none !important; }

.gallery-modal-controls { display: contents; }

/* ── Mobile tuning ─────────────────────────────────────────────────────── */

@media (max-width: 767px) {
    .gallery-modal-close {
        width: 40px; height: 40px;
        top: max(env(safe-area-inset-top, 12px), 12px);
        right: 12px;
    }
    .gallery-modal-prev { left: 8px; }
    .gallery-modal-next { right: 8px; }
    .gallery-modal-control,
    .gallery-modal-prev,
    .gallery-modal-next { width: 42px; height: 42px; }
    .gallery-modal-status { font-size: 0.78rem; padding: 5px 12px; }
}

/* ── Body lock helper ──────────────────────────────────────────────────── */

body.gallery-modal-open { overflow: hidden; }
