/**
 * La Gritta Elementor — Gallery
 *
 * Masonry gallery with sidebar navigation (desktop),
 * tab bar + FAB (mobile), caption hover, fade-in,
 * and fullscreen lightbox.
 *
 * Migrated from la-gritta-theme.php shortcode CSS.
 * All CSS variables use the --lge-* namespace.
 */

/* ===== Container ===== */
.lg-gallery {
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    padding: 96px 24px;
}
@media (max-width: 1023px) {
    .lg-gallery {
        padding: 0;
    }
}

/* ===== Desktop layout: sidebar + grid ===== */
.lg-gallery__layout {
    display: flex;
    gap: 32px;
}
.lg-gallery__grid-wrap {
    flex: 1;
    min-width: 0;
}

/* ===== Sidebar (desktop only, hidden on mobile) ===== */
.lg-gallery__sidebar {
    display: none;
    width: 224px;
    flex-shrink: 0;
    position: sticky;
    top: 96px;
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: none;
}
.lg-gallery__sidebar::-webkit-scrollbar { display: none; }
body.admin-bar .lg-gallery__sidebar {
    top: 128px;
    max-height: calc(100vh - 152px);
}
.lg-gallery__sidebar-inner {
    background: var(--lge-surface);
    border: 1px solid rgba(var(--lge-foreground-rgb), .05);
    padding: 16px 0;
}
.lg-gallery__cat {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 20px;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--lge-muted-fg) !important;
    background: none !important;
    border: none !important;
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: color 0.2s;
}
.lg-gallery__cat:hover {
    color: var(--lge-foreground) !important;
}
.lg-gallery__cat.is-active {
    color: var(--lge-primary) !important;
    border-left-color: var(--lge-primary);
    padding-left: 18px;
}
.lg-gallery__cat-divider {
    height: 1px;
    background: rgba(var(--lge-foreground-rgb), .05);
    margin: 8px 20px;
}

@media (min-width: 1024px) {
    .lg-gallery__sidebar { display: block; }
    .lg-gallery__tabbar { display: none !important; }
    .lg-gallery__fab { display: none !important; }
}

/* ===== Mobile tab bar (in-flow, becomes fixed via JS when scrolled past navbar) ===== */
.lg-gallery__tabbar {
    display: none;
    align-items: stretch;
    background: var(--lge-surface);
    border-bottom: none;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    z-index: 1000;
}
@media (max-width: 1023px) {
    .lg-gallery__tabbar { display: flex; }
    .lg-gallery__tabbar:not(.is-stuck) {
        width: 100vw;
        margin-left: calc(-50vw + 50%);
    }
    .lg-gallery__tabbar.is-stuck {
        position: fixed;
        z-index: 999;
        box-shadow: 0 10px 15px -3px rgba(0,0,0,.5);
        /* top, left, width set by JS */
    }
    .lg-gallery__grid-wrap { padding-top: 16px; }
    /* Remove Elementor container spacing above gallery widget on mobile */
    .elementor-element-51b378e { gap: 0px !important; }
    .elementor-element-dbbf755 { --padding-top: 0px !important; }
}
.lg-gallery__tabbar-placeholder {
    display: none;
}
.lg-gallery__tab--all {
    flex-shrink: 0;
    padding: 12px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--lge-muted-fg) !important;
    background: var(--lge-surface) !important;
    border: none !important;
    border-right: 1px solid rgba(var(--lge-foreground-rgb), .05) !important;
    cursor: pointer;
    transition: color 0.2s;
}
.lg-gallery__tab--all.is-active {
    color: var(--lge-primary) !important;
    border-bottom: 2px solid var(--lge-primary) !important;
}
/* Tabs wrapper with arrows */
.lg-gallery__tabs-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}
.lg-gallery__tabs-scroll {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.lg-gallery__tabs-scroll::-webkit-scrollbar { display: none; }
.lg-gallery__tab {
    flex-shrink: 0;
    padding: 12px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--lge-muted-fg) !important;
    background: none !important;
    border: none !important;
    border-bottom: 2px solid transparent !important;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.lg-gallery__tab.is-active {
    color: var(--lge-primary) !important;
    border-bottom: 2px solid var(--lge-primary) !important;
}
/* Scroll arrows with gradient fade */
.lg-gallery__tabs-arrow {
    position: absolute;
    z-index: 10;
    height: 100%;
    padding: 0 8px;
    border: none !important;
    color: rgba(255,255,255,.7) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.lg-gallery__tabs-arrow--left {
    left: 0;
    background: linear-gradient(to right, var(--lge-surface), var(--lge-surface) 40%, transparent) !important;
}
.lg-gallery__tabs-arrow--right {
    right: 0;
    background: linear-gradient(to left, var(--lge-surface), var(--lge-surface) 40%, transparent) !important;
}
.lg-gallery__tabs-arrow svg {
    width: 16px;
    height: 16px;
}
/* ===== FAB (mobile only) ===== */
.lg-gallery__fab {
    position: fixed !important;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
}
.lg-gallery__fab-btn {
    width: 48px !important;
    height: 48px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: var(--lge-primary) !important;
    border: none !important;
    color: #fff !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(239,122,35,.25);
    transition: transform 0.2s, box-shadow 0.2s;
}
.lg-gallery__fab-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 32px rgba(239,122,35,.35);
}
/* Icon toggle: main ↔ close */
.lg-gallery__fab-icon--close { display: none; }
.lg-gallery__fab-btn.is-open .lg-gallery__fab-icon--main { display: none; }
.lg-gallery__fab-btn.is-open .lg-gallery__fab-icon--close { display: block; }
.lg-gallery__fab-menu {
    flex-direction: column;
    position: absolute;
    bottom: 60px;
    right: 0;
    background: var(--lge-surface);
    border: 1px solid rgba(var(--lge-foreground-rgb), .1);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,.25);
    min-width: 200px;
    padding: 8px 0;
}
.lg-gallery__fab-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 20px;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--lge-muted-fg) !important;
    background: none !important;
    border: none !important;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}
.lg-gallery__fab-item:hover {
    background: rgba(var(--lge-foreground-rgb), .05) !important;
}
.lg-gallery__fab-item.is-active {
    color: var(--lge-primary) !important;
}
@media (min-width: 1024px) {
    .lg-gallery__fab { display: none !important; }
}

/* ===== Masonry grid ===== */
.lg-gallery__grid {
    columns: 3;
    gap: 12px;
    transition: opacity .3s ease;
}
@media (max-width: 1024px) { .lg-gallery__grid { columns: 3 !important; } }
@media (max-width: 768px) { .lg-gallery__grid { columns: 2 !important; } }

.lg-gallery__item {
    break-inside: avoid;
    margin-bottom: 12px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

/* Image fade-in on load */
.lg-gallery__item img {
    width: 100%;
    display: block;
    opacity: 0;
    transform: scale(1.02);
    transition: opacity .7s ease-out, transform .7s ease-out;
}
.lg-gallery__item img.lg-loaded {
    opacity: 1;
    transform: scale(1);
}
.lg-gallery__item:hover img.lg-loaded { transform: scale(1.05); }

/* Item overlay */
.lg-gallery__item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.1);
    transition: background .5s ease;
    pointer-events: none;
}
.lg-gallery__item:hover::after {
    background: transparent;
}

/* Item caption */
.lg-gallery__item-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    background: linear-gradient(to top, rgba(0,0,0,.7), rgba(0,0,0,.3), transparent);
    opacity: 0;
    transition: opacity .3s ease;
    z-index: 1;
}
.lg-gallery__item:hover .lg-gallery__item-caption {
    opacity: 1;
}
.lg-gallery__item-caption span {
    font-size: 11px;
    letter-spacing: .25em;
    text-transform: uppercase;
    color: rgba(255,255,255,.9);
}

/* ===== Lightbox (appended to body via JS) ===== */
.lg-lightbox {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.lg-lightbox__counter {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,.5);
    font-size: 9px;
    letter-spacing: .25em;
}
.lg-lightbox__close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: none;
    border: none;
    color: rgba(255,255,255,.5);
    font-size: 2rem;
    cursor: pointer;
    transition: color .3s;
}
.lg-lightbox__close:hover { color: #fff; }
.lg-lightbox__prev, .lg-lightbox__next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,.3);
    cursor: pointer;
    padding: 20px;
    transition: color .3s;
}
.lg-lightbox__prev:hover, .lg-lightbox__next:hover { color: rgba(255,255,255,.8); }
.lg-lightbox__prev { left: 12px; }
.lg-lightbox__next { right: 12px; }
.lg-lightbox__img {
    max-width: 80vw;
    max-height: 75vh;
    object-fit: contain;
}
.lg-lightbox__caption {
    position: absolute;
    bottom: 32px;
    color: rgba(255,255,255,.7);
    font-size: 10px;
    letter-spacing: .25em;
    text-transform: uppercase;
}
@media (min-width: 768px) {
    .lg-lightbox__prev { left: 32px; }
    .lg-lightbox__next { right: 32px; }
}
