/* Copyright © 2026 Living Legacy LLC d/b/a Legacy Health and Fitness. All Rights Reserved.
 * Proprietary and confidential. Unauthorized use, copying, or distribution
 * is prohibited. See LICENSE file in project root.
 */

/* ===== Hero ===== */
.gallery-page-hero {
    position: relative;
    min-height: clamp(280px, 42vh, 480px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    border-bottom: 1px solid #333333;
}

.gallery-page-hero-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    filter: grayscale(15%) brightness(0.75);
    transform: scale(1.02);
}

.gallery-page-hero-bg.is-lqip { filter: grayscale(15%) brightness(0.6) blur(14px); }

/* Admin-picked hero photo (gallery-v2.js applyHero): a <picture> injected into
   the bg layer so AVIF/WebP negotiation and the load event come for free. The
   LQIP sits in the parent's background-image until the real image decodes. */
.gallery-page-hero-bg picture,
.gallery-page-hero-bg img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.gallery-page-hero-bg img {
    object-fit: cover;
    object-position: center;
    opacity: 0;
    transition: opacity 0.45s ease;
}

.gallery-page-hero-bg img.is-loaded { opacity: 1; }

.gallery-page-hero-overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0.35) 45%, rgba(13, 13, 13, 0.85) 100%);
}

.gallery-page-hero-inner {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: clamp(2rem, 5vw, 3.5rem) 5%;
}

.gallery-hero-ctas {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.gallery-hero-ctas .btn-tour-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 48px;
    padding: 0.85rem 1.6rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.06);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

.gallery-hero-ctas .btn-tour-link:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

/* ===== Category filter pills ===== */
.gallery-filters {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
    padding: 0.25rem 0 1.75rem;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.gallery-filters::-webkit-scrollbar { display: none; }

.gallery-filter-pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    border: 1px solid #2a2a2a;
    background: #1a1a1a;
    color: #c7c7c7;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    white-space: nowrap;
}

.gallery-filter-pill:hover { border-color: rgba(255, 107, 53, 0.4); color: #e5e5e5; }

.gallery-filter-pill.active {
    background: #ff6b35;
    border-color: #ff6b35;
    color: #fff;
}

.gallery-filter-pill .count {
    font-size: 0.78rem;
    opacity: 0.75;
    font-weight: 500;
}

/* ===== Masonry-style grid (CSS-only, no JS layout library) ===== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-flow: dense;
    gap: 1rem;
}

@media (min-width: 640px) {
    .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }
}

@media (min-width: 1024px) {
    .gallery-grid { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
}

@media (min-width: 1440px) {
    .gallery-grid { grid-template-columns: repeat(5, 1fr); }
}

.gallery-item {
    position: relative;
    background: #1a1a1a;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    grid-row: span 1;
}

/* Deterministic visual variety for the masonry look — every 5th/7th tile runs taller. */
.gallery-item.tall { grid-row: span 2; }

.gallery-item .gallery-item-media-wrap {
    position: relative;
    width: 100%;
    height: 100%;
    aspect-ratio: 4 / 5;
    background-size: cover;
    background-position: center;
}

.gallery-item.tall .gallery-item-media-wrap { aspect-ratio: 4 / 10; }

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.gallery-item img.is-loaded { opacity: 1; }

.gallery-item:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
}

.gallery-item:hover img { transform: scale(1.06); filter: brightness(1.05); }

.gallery-item-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 1rem 0.9rem 0.75rem;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.82) 85%);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

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

.video-indicator {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 107, 53, 0.92);
    color: white;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    z-index: 1;
}

/* ===== Shimmer skeleton (replaces the old spinner) ===== */
.gallery-skeleton-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

@media (min-width: 640px) { .gallery-skeleton-grid { grid-template-columns: repeat(3, 1fr); gap: 1.25rem; } }
@media (min-width: 1024px) { .gallery-skeleton-grid { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; } }

.gallery-skeleton-tile {
    aspect-ratio: 4 / 5;
    border-radius: 10px;
    background: linear-gradient(100deg, #1a1a1a 30%, #232323 50%, #1a1a1a 70%);
    background-size: 220% 100%;
    animation: gallery-shimmer 1.4s ease-in-out infinite;
}

@keyframes gallery-shimmer {
    0% { background-position: 120% 0; }
    100% { background-position: -20% 0; }
}

.no-images { text-align: center; padding: 3rem 1rem; color: #a0a0a0; }
.no-images h2 { font-size: clamp(1.35rem, 4vw, 1.75rem); color: #e5e5e5; font-weight: 800; margin-bottom: 0.75rem; }
.no-images p { font-size: 1.05rem; margin-bottom: 1.5rem; line-height: 1.6; }
.no-images a {
    display: inline-block;
    background: #ff6b35;
    color: white;
    padding: 0.85rem 1.75rem;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 700;
    transition: background 0.2s, transform 0.2s;
}
.no-images a:hover { background: #ff8c5a; transform: translateY(-1px); }

/* ===== Lightbox ===== */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.96);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.lightbox.active { display: flex; }

.lightbox-chrome {
    opacity: 1;
    transition: opacity 0.35s ease;
}

.lightbox.chrome-idle .lightbox-chrome { opacity: 0; }

.lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(1rem, 4vw, 2.5rem);
    touch-action: pan-y pinch-zoom;
}

.lightbox-media-wrap {
    position: relative;
    max-width: 92vw;
    max-height: 72vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox img, .lightbox video {
    max-width: 92vw;
    max-height: 72vh;
    object-fit: contain;
    border-radius: 8px;
}

.lightbox-caption {
    max-width: 680px;
    margin-top: 1.25rem;
    text-align: center;
    color: #e5e5e5;
}

.lightbox-caption .category-tag {
    display: inline-block;
    color: #ff6b35;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.lightbox-caption .caption-text { font-size: 1rem; color: #cfcfcf; }

.lightbox-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem clamp(1rem, 4vw, 2rem);
}

.lightbox-position {
    color: #cfcfcf;
    font-size: 0.85rem;
    font-weight: 600;
}

.lightbox-top-actions { display: flex; gap: 0.5rem; }

.lightbox-icon-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s, border-color 0.2s;
}

.lightbox-icon-btn:hover { background: rgba(255, 107, 53, 0.85); border-color: rgba(255, 107, 53, 0.85); }

.lightbox-icon-btn.copied { background: #2e7d32; border-color: #2e7d32; }

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 2rem;
    cursor: pointer;
    border-radius: 10px;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.lightbox-nav:hover { background: rgba(255, 107, 53, 0.85); }
.lightbox-prev { left: clamp(0.5rem, 2vw, 1.5rem); }
.lightbox-next { right: clamp(0.5rem, 2vw, 1.5rem); }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

@media (max-width: 768px) {
    .gallery-page-hero { min-height: clamp(240px, 46vh, 400px); }
    .lightbox-nav { width: 44px; height: 44px; font-size: 1.5rem; }
}

/* ===== Glass + motion layer (2026-10-31, David: "a bit more glassy animation for eye appeal") =====
 * Everything below is additive: frosted-glass caption and filter pills, a
 * light-sheen sweep on hover, a staggered blur-to-sharp reveal as tiles
 * scroll into view, slow drifting light orbs behind the hero, and glass
 * lightbox chrome. All motion is disabled under prefers-reduced-motion.
 */
.gallery-page-hero::before,
.gallery-page-hero::after {
    content: '';
    position: absolute;
    z-index: 1;
    width: 46vmax;
    height: 46vmax;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(70px);
    opacity: 0.55;
    mix-blend-mode: screen;
}
.gallery-page-hero::before {
    left: -12vmax;
    top: -18vmax;
    background: radial-gradient(circle at 40% 40%, rgba(255, 107, 53, 0.55), rgba(255, 107, 53, 0) 62%);
    animation: gallery-orb-a 18s ease-in-out infinite alternate;
}
.gallery-page-hero::after {
    right: -14vmax;
    bottom: -20vmax;
    background: radial-gradient(circle at 60% 60%, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 60%);
    animation: gallery-orb-b 22s ease-in-out infinite alternate;
}
@keyframes gallery-orb-a { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(9vmax, 7vmax, 0) scale(1.15); } }
@keyframes gallery-orb-b { from { transform: translate3d(0, 0, 0) scale(1.1); } to { transform: translate3d(-8vmax, -6vmax, 0) scale(0.95); } }

.gallery-page-hero-inner h1,
.gallery-page-hero-inner p,
.gallery-hero-ctas {
    animation: gallery-rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.gallery-page-hero-inner p { animation-delay: 0.12s; }
.gallery-hero-ctas { animation-delay: 0.24s; }
@keyframes gallery-rise { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }

/* Filter pills: frosted glass with a soft top highlight */
.gallery-filter-pill {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.12);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
    backdrop-filter: blur(10px) saturate(140%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: background 0.25s, border-color 0.25s, color 0.25s, transform 0.25s, box-shadow 0.25s;
}
.gallery-filter-pill:hover { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 6px 18px rgba(0, 0, 0, 0.35); }
.gallery-filter-pill.active {
    background: linear-gradient(135deg, rgba(255, 107, 53, 0.95), rgba(229, 90, 43, 0.95));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 8px 22px rgba(255, 107, 53, 0.28);
}

/* Tiles: glass rim + light sheen sweep */
.gallery-item {
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.45s ease, border-color 0.3s ease;
}
.gallery-item::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    border-radius: inherit;
    background: linear-gradient(115deg, rgba(255, 255, 255, 0) 35%, rgba(255, 255, 255, 0.22) 48%, rgba(255, 255, 255, 0.05) 52%, rgba(255, 255, 255, 0) 65%);
    transform: translateX(-120%) skewX(-8deg);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.gallery-item:hover::before,
.gallery-item:focus-visible::before { opacity: 1; animation: gallery-sheen 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
@keyframes gallery-sheen { from { transform: translateX(-120%) skewX(-8deg); } to { transform: translateX(120%) skewX(-8deg); } }
.gallery-item:hover { border-color: rgba(255, 107, 53, 0.45); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 107, 53, 0.15), 0 0 32px rgba(255, 107, 53, 0.12); }

/* Caption: frosted glass slab instead of a flat gradient */
.gallery-item-caption {
    margin: 0 0.6rem 0.6rem;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    background: rgba(18, 18, 18, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.14);
    -webkit-backdrop-filter: blur(12px) saturate(150%);
    backdrop-filter: blur(12px) saturate(150%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 6px 20px rgba(0, 0, 0, 0.35);
    transform: translateY(10px) scale(0.98);
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.gallery-item:hover .gallery-item-caption,
.gallery-item:focus-visible .gallery-item-caption { transform: translateY(0) scale(1); }
.video-indicator {
    background: rgba(255, 107, 53, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.25);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* Scroll-in reveal: blur-to-sharp rise, staggered by the JS via --reveal-delay */
.gallery-item.will-reveal {
    opacity: 0;
    transform: translateY(22px) scale(0.97);
    filter: blur(8px);
}
.gallery-item.is-revealed {
    opacity: 1;
    transform: none;
    filter: blur(0);
    transition: opacity 0.6s ease var(--reveal-delay, 0s), transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) var(--reveal-delay, 0s), filter 0.6s ease var(--reveal-delay, 0s), box-shadow 0.45s ease, border-color 0.3s ease;
}
.gallery-item.is-revealed:hover { transition-delay: 0s; }

/* Lightbox chrome: glass bars and buttons, soft zoom-in on the media */
.lightbox-top-bar,
.lightbox-caption.lightbox-chrome {
    background: rgba(18, 18, 18, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    backdrop-filter: blur(14px) saturate(140%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.lightbox-caption.lightbox-chrome { padding: 0.9rem 1.2rem; }
.lightbox-icon-btn,
.lightbox-nav {
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.lightbox.active .lightbox-media-wrap { animation: gallery-pop 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes gallery-pop { from { opacity: 0; transform: scale(0.96); filter: blur(6px); } to { opacity: 1; transform: none; filter: blur(0); } }

@media (prefers-reduced-motion: reduce) {
    .gallery-page-hero::before, .gallery-page-hero::after,
    .gallery-page-hero-inner h1, .gallery-page-hero-inner p, .gallery-hero-ctas,
    .gallery-item::before, .lightbox.active .lightbox-media-wrap { animation: none !important; }
    .gallery-item.will-reveal { opacity: 1; transform: none; filter: none; }
    .gallery-item, .gallery-item-caption, .gallery-filter-pill { transition-duration: 0.01s !important; }
}
/* Crawler-visible intro copy (the grid below is filled in by JS) */
.gallery-intro { padding-bottom: 0; }
.gallery-intro-copy { max-width: 760px; margin: 0 auto; color: #e5e5e5; line-height: 1.7; }
.gallery-intro-copy h2 { margin: 0 0 0.75rem; }
.gallery-intro-copy p { margin: 0 0 1rem; }
.gallery-intro-copy ul { padding-left: 1.25rem; margin: 0 0 1rem; }
.gallery-intro-copy a { color: #ff6b35; }
