/* ============================================
   UNIVERSAL GALLERY VIEWER  (UGV)
   gallery-viewer.css — v2.0

   ONE file for everything gallery-related:
   • In-page masonry / mosaic layout + hover effects
   • Fullscreen viewer (modal, nav, autoslide)
   • Copyright badges
   • Responsive breakpoints

   Uses global --color-* tokens from global.css
   with hardcoded fallbacks for safety.

   Pair with gallery-viewer.js on any page.
   ============================================ */


/* ╔══════════════════════════════════════════╗
   ║  PART 1 — IN-PAGE GALLERY LAYOUT        ║
   ╚══════════════════════════════════════════╝ */

/* ── Theme tokens ────────────────────────── */
.gallery-section {
    --gold-primary: var(--color-accent, #c9a962);
    --frame-border: rgba(201, 169, 98, 0.3);
    --transition-prime: cubic-bezier(0.23, 1, 0.32, 1);
    --cream: #f5f0e6;
    --text-primary: var(--color-text-primary, #f0ede8);
    --text-muted: var(--color-text-muted, #888888);
    --shadow-soft: rgba(0, 0, 0, 0.6);
    /* Always dark — gallery section never inherits the page's light theme background.
       Using a hardcoded value instead of --color-bg-base which resolves to white/cream
       on light themes and would wash out the mosaic canvas behind the portraits. */
    --bg-dark: #070502;

    /* Full-bleed: break out of any parent max-width/padding
       NOTE: margin-left approach (not transform) — transform on a container
       breaks Safari pointer-event hit-testing (clicks land at wrong coords) */
    width: 100vw;
    position: relative;
    left: auto;
    margin-left: calc(-50vw + 50%);
    isolation: isolate;   /* stacking context without transform */
    padding: 6rem 2rem;
    background: var(--bg-dark);
    overflow: hidden;
}


/* ── Gallery header ──────────────────────── */
.gallery-header {
    text-align: center;
    margin-bottom: 4rem;
}

.gallery-number {
    font-family: var(--font-serif);
    font-size: 4rem;
    font-weight: 300;
    color: var(--gold-primary);
    opacity: 0.2;
    line-height: 1;
}

.gallery-title {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 400;
    letter-spacing: 0.1em;
    color: var(--text-primary);
    margin-top: -1.5rem;
    margin-bottom: 0.5rem;
}

/* ── Portrait-row masonry layout ─────────── */
.masonry-portrait-rows {
    --masonry-row-min-h: 260px;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.masonry-row-5 {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1.25rem;
    min-height: 260px;
    align-items: stretch;
}

.masonry-row-5 .masonry-item {
    min-height: 260px;
}

.masonry-row-hero {
    display: flex;
    justify-content: center;
}

/* Last row: modest "hero" — at most ~2× the row cell height, natural aspect ratio */
.masonry-row-hero button.masonry-item {
    width: auto;
    max-width: min(520px, 92vw);
    height: auto;
    min-height: 0;
}

.masonry-row-hero .masonry-item {
    max-height: calc(var(--masonry-row-min-h) * 2 + 1.25rem);
}

.masonry-row-hero .masonry-item img {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: calc(var(--masonry-row-min-h) * 2);
    object-fit: contain;
    object-position: center center;
}

.masonry-row-5 .masonry-item img {
    object-fit: cover;
    object-position: center 22%;
}


/* ── Mosaic texture background canvas ────── */
.gallery-mosaic-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.4;
    mix-blend-mode: screen;
}

.gallery-header,
.masonry-portrait-rows {
    position: relative;
    z-index: 1;
}


/* ── Masonry item base ───────────────────── */
.masonry-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    contain: layout style;    /* isolate repaints per gallery item */
    /* SCROLL-013: removed blanket `transform: translateZ(0)` (a permanent GPU layer per item) —
       matches what Apple already does (.ua-webkit-apple override below). Hover still promotes on
       demand via the scale transform; `contain` keeps paint isolation; identity transform = no visual change. */
}

button.masonry-item,
button.hexagon-item {
    font: inherit;
    color: inherit;
    text-align: inherit;
    border: none;
    background: none;
    padding: 0;
    display: block;
    appearance: none;
    -webkit-appearance: none;
}

button.masonry-item {
    width: 100%;
    height: 100%;
    min-height: 0;
}

button.hexagon-item {
    flex-shrink: 0;
}

button.masonry-item:focus:not(:focus-visible) {
    outline: none;
}

button.masonry-item:focus-visible,
button.hexagon-item:focus-visible {
    outline: 2px solid var(--gold-primary);
    outline-offset: 4px;
    z-index: 5;
    position: relative;
}


/* ── Hover borders (smooth) ──────────────── */
/* NOTE: inset shorthand avoided — Safari 14.0 does not support it */
.masonry-item::before {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    border: 1px solid var(--frame-border);
    z-index: 2;
    pointer-events: none;
    transition: border-color 0.5s var(--transition-prime),
                top 0.5s var(--transition-prime), right 0.5s var(--transition-prime),
                bottom 0.5s var(--transition-prime), left 0.5s var(--transition-prime);
}

.masonry-item::after {
    content: '';
    position: absolute;
    top: 8px; right: 8px; bottom: 8px; left: 8px;
    border: 1px solid transparent;
    z-index: 2;
    pointer-events: none;
    transition: border-color 0.5s var(--transition-prime), opacity 0.5s var(--transition-prime);
}

.masonry-item:hover::before {
    border-color: var(--gold-primary);
    top: -2px; right: -2px; bottom: -2px; left: -2px;
}

.masonry-item:hover::after {
    border-color: var(--gold-primary);
    opacity: 0.5;
}


/* ── Image hover (smooth zoom + opacity) ──── */
.masonry-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s var(--transition-prime), opacity 0.5s var(--transition-prime);
    opacity: 0.82;
    /* SCROLL-013: removed blanket `transform: translateZ(0)` — see .masonry-item above (the hover scale still promotes on demand; Apple already drops it). */
}

.masonry-item:hover img {
    transform: scale(1.08) translateZ(0);
    opacity: 1;
}


/* ── Corner ornaments ────────────────────── */
.corner-ornament {
    position: absolute;
    width: 20px;
    height: 20px;
    z-index: 3;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s var(--transition-prime);
}

.masonry-item:hover .corner-ornament {
    opacity: 1;
}

.corner-tl { top: 12px; left: 12px; }
.corner-tr { top: 12px; right: 12px; transform: rotate(90deg); }
.corner-bl { bottom: 12px; left: 12px; transform: rotate(-90deg); }
.corner-br { bottom: 12px; right: 12px; transform: rotate(180deg); }

.corner-ornament svg {
    width: 100%;
    height: 100%;
}


/* ── SVG glyph overlay ───────────────────── */
.glyph-overlay {
    position: absolute;
    z-index: 4;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s var(--transition-prime);
}

.masonry-item:hover .glyph-overlay {
    opacity: 1;
}

.glyph-center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
}

.glyph-tl { top: 25px; left: 25px; width: 24px; height: 24px; }
.glyph-br { bottom: 25px; right: 25px; width: 24px; height: 24px; }


/* ── Caption (appears on hover) ──────────── */
.item-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1.5rem 1.5rem;
    background: linear-gradient(to top, var(--shadow-soft), transparent);
    z-index: 5;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s var(--transition-prime), transform 0.5s var(--transition-prime);
    pointer-events: none; /* decorative overlay — never absorbs clicks */
}

.masonry-item:hover .item-caption,
.masonry-item:focus-visible .item-caption {
    opacity: 1;
    transform: translateY(0);
}

/* A11Y-006: touch devices have no reliable hover (a tap opens the viewer), so show the
   caption as a compact strip — mobile users get the image title/series too. Only home's
   #masonry uses .item-caption, and those items carry no credit badge, so no overlap. */
@media (hover: none) {
    .item-caption {
        opacity: 1;
        transform: none;
        padding: 1.1rem 0.9rem 0.7rem;
    }
}

.item-caption h4 {
    font-family: var(--font-serif);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.1em;
    color: var(--cream);
    margin-bottom: 0.3rem;
}

.item-caption p {
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 300;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--gold-primary);
}


/* ╔══════════════════════════════════════════╗
   ║  PART 2 — IN-PAGE COPYRIGHT BADGE       ║
   ╚══════════════════════════════════════════╝ */

.gv-credit-badge {
    position: absolute;
    bottom: 6px;
    left: 8px;
    z-index: 6;
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.75);
    background: rgba(0, 0, 0, 0.55);
    padding: 2px 7px;
    border-radius: 2px;
    line-height: 1.55;
    user-select: text;
    -webkit-user-select: text;
    pointer-events: auto;
    opacity: 0.8;
    transition: opacity 0.4s ease;
}

/* Hide badge on hover — item-caption takes over.
   Scoped to the exact gallery-item types (= JS ITEM_SELECTOR) that the badge
   is ever appended to, instead of the universal *:hover (which forced a wide
   style-recalc on every hover change anywhere). Behaviour is identical: the
   badge is always a direct child of one of these. (PERF-016) */
.masonry-item:hover > .gv-credit-badge,
.mosaic-item:hover > .gv-credit-badge,
.hexagon-item:hover > .gv-credit-badge,
.gallery-item:hover > .gv-credit-badge,
[data-gallery-item]:hover > .gv-credit-badge {
    opacity: 0;
}

/* Touch devices: always show badge */
@media (hover: none) {
    .gv-credit-badge {
        opacity: 0.85;
    }
}
@media (max-width: 768px) {
    .gv-credit-badge,
    .gv-credit,
    .item-caption p {
        font-size: 0.875rem;
    }
}


/* ╔══════════════════════════════════════════╗
   ║  PART 3 — FULLSCREEN VIEWER  v2.0       ║
   ╚══════════════════════════════════════════╝ */

/* ── Modal: full-viewport flex column ────── */
/* NOTE: inset shorthand NOT used — Safari 14.0 does not support it (added 14.1).
   Without explicit top/right/bottom/left, position:fixed falls back to auto
   positions and the modal does not cover the viewport. */
.gv-modal {
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    /* Pure dark background — NO backdrop-filter (massive GPU saving) */
    background: rgba(8, 8, 10, 0.97);
    z-index: 10050;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-out;
    box-sizing: border-box;
    /* Respect notched / rounded phone screens */
    padding-top:    env(safe-area-inset-top,    0px);
    padding-right:  env(safe-area-inset-right,  0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left:   env(safe-area-inset-left,   0px);
}

.gv-modal.active {
    opacity: 1;
    pointer-events: auto;
}


/* ── Top bar ─────────────────────────────── */
.gv-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    flex-shrink: 0;
    height: 48px;
    box-sizing: border-box;
    z-index: 120;
    /* Keep topbar controls close to image edges on ultra-wide screens */
    width: 100%;
    max-width: min(88vw, 1200px);
    margin-left: auto;
    margin-right: auto;
}


/* ── Layout mode buttons (left of topbar) ── */
.gv-layout-modes {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: auto; /* push counter/auto/close to the right */
}

.gv-layout-btn {
    background: transparent;
    border: 1px solid rgba(240, 215, 140, 0.18);
    color: rgba(240, 215, 140, 0.4);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    padding: 0;
    font-family: inherit;
    border-radius: 3px;
    line-height: 1;
    flex-shrink: 0;
}

.gv-layout-btn:hover,
.gv-layout-btn.active {
    background: rgba(240, 215, 140, 0.1);
    border-color: rgba(240, 215, 140, 0.65);
    color: var(--color-accent, #f0d78c);
}

.gv-layout-btn:focus           { outline: none; }
.gv-layout-btn:focus-visible   { outline: 2px solid var(--color-accent, #f0d78c); outline-offset: 2px; }


/* ── Counter (centre-right of topbar) ────── */
.gv-counter {
    color: var(--color-accent, #f0d78c);
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.15em;
    white-space: nowrap;
}


/* ── Autoslide toggle ────────────────────── */
.gv-autoslide-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.gv-autoslide-label {
    color: var(--color-text-secondary, #b8b3a8);
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.gv-autoslide-switch {
    position: relative;
    width: 44px;
    height: 22px;
    background: rgba(240, 215, 140, 0.1);
    border: 1px solid rgba(240, 215, 140, 0.38);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.25s ease;
    flex-shrink: 0;
}

.gv-autoslide-switch.active {
    background: rgba(240, 215, 140, 0.3);
}

.gv-autoslide-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--color-accent, #f0d78c);
    border-radius: 50%;
    transition: transform 0.25s ease;
}

.gv-autoslide-switch.active::after {
    transform: translateX(22px);
    background: var(--color-bg-base, #0d0d0f);
}

.gv-autoslide-switch:focus           { outline: none; }
.gv-autoslide-switch:focus-visible   { outline: 2px solid var(--color-accent, #f0d78c); outline-offset: 3px; }


/* ── Close button ────────────────────────── */
.gv-close {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary, #b8b3a8);
    font-size: 1.75rem;
    line-height: 0;          /* let flex centering handle vertical alignment */
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    border: 1px solid rgba(240, 215, 140, 0.35); /* always visible border */
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    flex-shrink: 0;
    margin-left: 32px; /* wide gap to keep X well away from auto toggle */
}

.gv-close:hover {
    color: var(--color-accent, #f0d78c);
    border-color: rgba(240, 215, 140, 0.8);
    background: rgba(240, 215, 140, 0.12); /* subtle gold fill on hover */
}


/* ── Stage: image area (fills remaining space) */
.gv-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}


/* ── Image / video frame ─────────────────── */
/* Default (full): frame fills entire stage edge-to-edge */
.gv-frame {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    overflow: hidden;
    background: #000;
    /* layout mode changes are instant — no compositor-friendly equivalent for 4-side inset */
}

/* Framed mode: centered content box with golden border */
.gv-modal[data-layout="framed"] .gv-frame {
    top: 8px;
    bottom: 8px;
    left: 50%;
    right: auto;
    width: min(88vw, 1080px);
    transform: translateX(-50%);
    border: 1px solid rgba(240, 215, 140, 0.18);
    background: #0d0d0f;
}

/* Portrait mode: narrow centered column for portrait images */
.gv-modal[data-layout="portrait"] .gv-frame {
    top: 8px;
    bottom: 8px;
    left: 50%;
    right: auto;
    width: min(46vw, 560px);
    transform: translateX(-50%);
    border: 1px solid rgba(240, 215, 140, 0.18);
    background: #0d0d0f;
}


/* ── Image wrap ──────────────────────────── */
.gv-image-wrap {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100%;
    height: 100%;
}


/* ── Image & video ───────────────────────── */
.gv-image,
.gv-video {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
    opacity: 1;
    /* Fast fade — JS drives opacity 1→0→1 */
    transition: opacity 0.22s ease;
    /* Horizontal swipe handled by JS; allow vertical gestures */
    touch-action: pan-y;
}

.gv-video {
    background: #000;
    touch-action: auto; /* video needs full touch control */
}


/* ── Effect overlay (future hook) ───────── */
.gv-effect {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 8;
    pointer-events: none;
}


/* ── Navigation arrows: screen sides ────── */
/* Arrows are absolute within .gv-stage (position:relative)
   so they sit at the actual edges of the viewport */
.gv-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 56px;
    background: rgba(8, 8, 10, 0.42);
    border: none;
    color: var(--color-accent, #f0d78c);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 2.4rem;
    transition: background 0.2s ease, opacity 0.2s ease;
    z-index: 50;
    padding: 0;
    font-family: inherit;
    line-height: 1;
    opacity: 0.55;
    /* No pointer events on the full height — let image area through */
}

.gv-nav:hover {
    background: rgba(20, 20, 24, 0.72);
    opacity: 1;
}

.gv-prev { left: 0; }
.gv-next { right: 0; }


/* ── Progress bar ────────────────────────── */
.gv-progress {
    height: 2px;
    background: var(--color-accent, #f0d78c);
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
    /* transition handled by JS setInterval — no CSS transition needed */
    flex-shrink: 0;
}


/* ── Bottom bar: caption (left) | credit (right)
   Constrained to image width so text sits under the image,
   not spread across the full screen. Centred with margin auto. */
.gv-bottombar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 7px 16px;
    flex-shrink: 0;
    min-height: 36px;
    box-sizing: border-box;
    /* Align text under the image — match framed mode image width */
    width: 100%;
    max-width: min(88vw, 1080px);
    margin-left: auto;
    margin-right: auto;
}

/* Framed mode: match frame width */
.gv-modal[data-layout="framed"] .gv-bottombar {
    max-width: min(88vw, 1080px);
}

/* Portrait mode: match frame width */
.gv-modal[data-layout="portrait"] .gv-bottombar {
    max-width: min(46vw, 560px);
}


/* ── Caption ─────────────────────────────── */
.gv-caption {
    font-family: var(--font-serif);
    font-size: 1rem;
    letter-spacing: 0.06em;
    color: var(--color-text-primary, #f0ede8);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ── Copyright (right side of bottom bar) ── */
.gv-credit {
    font-family: var(--font-display);
    font-size: 0.875rem;
    letter-spacing: 0.08em;
    color: var(--color-text-muted, #888);
    white-space: nowrap;
    user-select: text;
    -webkit-user-select: text;
    flex-shrink: 0;
}


/* ╔══════════════════════════════════════════╗
   ║  PART 4 — RESPONSIVE                    ║
   ╚══════════════════════════════════════════╝ */

/* ── Tablet ───────────────────────────────── */
@media (max-width: 1024px) {
    /* Masonry grid */
    .masonry-row-5 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    /* Fullscreen nav */
    .gv-nav { width: 44px; font-size: 2rem; }

    /* Portrait mode: wider on tablet */
    .gv-modal[data-layout="portrait"] .gv-frame {
        width: min(58vw, 560px);
    }
}

/* ── Mobile ───────────────────────────────── */
@media (max-width: 768px) {
    /* Gallery section: tighter side padding on tablet/mobile */
    .gallery-section { padding: 5rem 1rem; }

    /* Masonry grid */
    .masonry-portrait-rows {
        --masonry-row-min-h: 200px;
    }

    .masonry-row-5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        min-height: 200px;
    }

    /* Fullscreen viewer */
    .gv-topbar {
        height: 44px;
        padding: 4px 8px;
        gap: 7px;
        /* Full-width on mobile — ensures X truly reaches the screen corner
           (the desktop max-width:88vw centers the bar, landing X mid-screen
           on Android and away from the corner on iPhone) */
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
    }

    /* Hide layout mode buttons on small screens — always full */
    .gv-layout-modes {
        display: none;
    }

    /* Framed / portrait → revert to full on mobile */
    .gv-modal[data-layout="framed"] .gv-frame,
    .gv-modal[data-layout="portrait"] .gv-frame {
        position: absolute;
        top: 0; right: 0; bottom: 0; left: 0;
        width: 100%;
        transform: none;
        border: none;
        background: #000;
    }

    .gv-nav  { width: 38px; font-size: 1.8rem; opacity: 0.5; }

    .gv-close {
        width: 36px;
        height: 36px;
        font-size: 1.6rem;
        /* Auto left margin pushes X alone to the far right.
           Counter + Auto switch stay naturally on the left. */
        margin-left: auto;
    }

    .gv-autoslide-label { font-size: 0.875rem; }
    .gv-autoslide-switch { width: 38px; height: 20px; }
    .gv-autoslide-switch::after { width: 14px; height: 14px; }
    .gv-autoslide-switch.active::after { transform: translateX(18px); }

    /* Mobile bottombar: hide caption, show only copyright */
    .gv-caption { display: none; }

    .gv-bottombar {
        padding: 5px 12px;
        gap: 0;
        min-height: 28px;
        justify-content: flex-end;
    }

    .gv-credit   { font-size: 0.875rem; }
    .gv-counter  { font-size: 0.875rem; margin-right: 0; }
}

/* ── Small phones ─────────────────────────── */
@media (max-width: 520px) {
    /* Gallery section: minimum side padding on small phones */
    .gallery-section { padding: 4rem 0.75rem; }

    /* Masonry grid */
    .masonry-row-5 {
        grid-template-columns: 1fr;
    }

    /* Fullscreen nav */
    .gv-nav  { width: 34px; font-size: 1.6rem; }

    /* Caption already hidden at ≤768px — credit is the only bottombar item.
       Allow it to wrap if very long (e.g. "© Photographer Name / Agency") */
    .gv-credit {
        white-space: normal;
        line-height: 1.3;
    }
}


/* ============================================
   APPLE SAFARI PERFORMANCE OVERRIDES
   (.ua-webkit-apple on <html> — Safari macOS/iOS
    only, excludes Chrome / Android / Edge)

   MacBook Air / iPhone have integrated GPU with
   shared RAM. transform:translateZ(0) force-promotes
   elements to GPU layers permanently. With 7 items
   × 2 layers each = 14 always-on GPU textures just
   for the gallery — exhausts tile memory and causes
   scroll jank. Hover scale still fires correctly
   (browser creates the layer on demand for the
   active animation then releases it).
   ============================================ */

/* Remove always-on GPU layer promotion — layer still
   created on demand during hover animation */
.ua-webkit-apple .masonry-item {
    transform: none;
}

.ua-webkit-apple .masonry-item img {
    transform: none;
}

/* Hover: keep scale, drop the force-layer hint */
.ua-webkit-apple .masonry-item:hover img {
    transform: scale(1.08);
}

/* mix-blend-mode: screen forces the CPU paint path on
   Safari — browser can't reuse cached GPU texture.
   Normal blend mode stays on the compositing fast path. */
.ua-webkit-apple .gallery-mosaic-bg {
    mix-blend-mode: normal;
    opacity: 0.18; /* screen at 0.4 is visually brighter — compensate */
}
