/* Referencia Masonry Galéria */
.referencia-galeria-wrap {
    margin: 24px 0;
    position: relative;
}

.referencia-galeria-mask {
    position: relative;
    max-height: var(--rg-height, 600px);
    overflow: hidden;
    transition: max-height 0.5s ease;
}

.referencia-galeria-wrap.is-expanded .referencia-galeria-mask {
    max-height: none;
}

/* Masonry: alapból CSS column-layout (megjelenik akkor is, ha a JS nem fut
   le, pl. az Elementor szerkesztő iframe-jében), a JS pedig flexbox-os
   oszlopokra váltja át a tényleges frontenden. */
.referencia-galeria-masonry {
    column-count: var(--rg-columns, 3);
    column-gap: 16px;
}

.referencia-galeria-masonry .referencia-galeria-item {
    margin-bottom: 16px;
    break-inside: avoid;
}

/* Ha a JS lefutott és létrehozta az oszlopokat, a flexbox vezérli az elrendezést */
.referencia-galeria-masonry:has(.referencia-galeria-col) {
    display: flex;
    column-count: initial;
    column-gap: initial;
    gap: 16px;
    align-items: flex-start;
}

.referencia-galeria-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.referencia-galeria-item {
    display: block;
    width: 100%;
}

.referencia-galeria-item.is-hidden,
.referencia-galeria-item[data-hidden="1"] {
    display: none;
}

/* Új képek szép betöltődése */
.referencia-galeria-item.is-new {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.referencia-galeria-item.is-new.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.referencia-galeria-img,
.referencia-galeria-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 6px;
}

/* Fehér átmenet alul */
.referencia-galeria-fade {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 180px;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.85) 60%,
        rgba(255, 255, 255, 1) 100%
    );
    transition: opacity 0.3s ease;
}

.referencia-galeria-wrap.is-expanded .referencia-galeria-fade {
    opacity: 0;
}

/* Gomb */
.referencia-galeria-actions {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

.referencia-galeria-btn {
    background: #1f398a;
    border: 1px solid #1e3a8a;
    color: #fff;
    border-radius: 999px;
    padding: 12px 28px;
    font-size: 1rem;
    font-family: "Montserrat", Sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.referencia-galeria-btn:hover,
.referencia-galeria-btn:focus {
    background: transparent;
    color: #1f398a;
    transform: translateY(-1px);
}

.referencia-galeria-empty {
    padding: 20px;
    text-align: center;
    color: #666;
}

/* Kattintható link a képen */
.referencia-galeria-link {
    display: block;
    cursor: zoom-in;
    overflow: hidden;
    border-radius: 6px;
    line-height: 0;
}

.referencia-galeria-link img {
    transition: transform 0.4s ease;
}

.referencia-galeria-link:hover img {
    transform: scale(1.04);
}

/* ====== Lightbox ====== */
.referencia-galeria-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.referencia-galeria-lightbox.is-open {
    display: flex;
    opacity: 1;
}

.rg-lb-stage {
    position: relative;
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rg-lb-img {
    max-width: 92vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    display: block;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: scale(0.96);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.rg-lb-img.is-loaded {
    opacity: 1;
    transform: scale(1);
}

.rg-lb-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rg-lb-spin 0.8s linear infinite;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.rg-lb-spinner.is-visible {
    opacity: 1;
}

@keyframes rg-lb-spin {
    to { transform: rotate(360deg); }
}

/* Gombok */
.rg-lb-close,
.rg-lb-prev,
.rg-lb-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 0;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 2;
    font-family: inherit;
}

.rg-lb-close:hover,
.rg-lb-prev:hover,
.rg-lb-next:hover {
    background: rgba(255, 255, 255, 0.25);
}

.rg-lb-close {
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    font-size: 32px;
    line-height: 1;
}

.rg-lb-prev,
.rg-lb-next {
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    font-size: 22px;
}

.rg-lb-prev { left: 24px; }
.rg-lb-next { right: 24px; }

.rg-lb-prev:hover { transform: translateY(-50%) translateX(-2px); }
.rg-lb-next:hover { transform: translateY(-50%) translateX(2px); }

.rg-lb-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}

@media (max-width: 600px) {
    .rg-lb-close { top: 12px; right: 12px; width: 40px; height: 40px; font-size: 26px; }
    .rg-lb-prev, .rg-lb-next { width: 44px; height: 44px; font-size: 18px; }
    .rg-lb-prev { left: 8px; }
    .rg-lb-next { right: 8px; }
}

/* Body scroll lock ha nyitva a lightbox */
body.rg-lb-locked {
    overflow: hidden;
}
