/* ============================================================
   Lucas Gallery Pro — Frontend Styles
   v1.0.0
============================================================ */

/* ===== BASE ===== */
.lg-gallery {
    width: 100%;
    box-sizing: border-box;
}
.lg-gallery *,
.lg-gallery *::before,
.lg-gallery *::after {
    box-sizing: border-box;
}
.lg-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--lg-radius, 4px);
}
.lg-link {
    display: block;
    overflow: hidden;
    position: relative;
    border-radius: var(--lg-radius, 4px);
    text-decoration: none;
    color: inherit;
}
.lg-item img {
    display: block;
    width: 100%;
}

/* ============================================================
   LAYOUTS
============================================================ */

/* ===== GRID ===== */
.lg-layout-grid {
    display: grid;
    grid-template-columns: repeat(var(--lg-cols, 3), 1fr);
    gap: var(--lg-gap, 8px);
}
.lg-layout-grid .lg-item img {
    height: 220px;
    object-fit: cover;
}

/* ===== MASONRY ===== */
.lg-layout-masonry {
    column-count: var(--lg-cols, 3);
    column-gap: var(--lg-gap, 8px);
}
.lg-layout-masonry .lg-item {
    break-inside: avoid;
    margin-bottom: var(--lg-gap, 8px);
    display: block;
}
.lg-layout-masonry .lg-item img {
    height: auto;
}

/* ===== JUSTIFIED (controlled by JS) ===== */
.lg-layout-justified {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
}
.lg-layout-justified .lg-item {
    overflow: hidden;
    flex-shrink: 0;
}
.lg-layout-justified .lg-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== MOSAIC ===== */
.lg-layout-mosaic {
    display: grid;
    grid-template-columns: repeat(var(--lg-cols, 3), 1fr);
    gap: var(--lg-gap, 8px);
    grid-auto-rows: 200px;
}
.lg-layout-mosaic .lg-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.lg-layout-mosaic .lg-item:nth-child(1) {
    grid-column: span 2;
    grid-row: span 2;
}
/* Pattern: after featured, every 6th item gets featured treatment */
.lg-layout-mosaic .lg-item:nth-child(7n+1):not(:first-child) {
    grid-column: span 2;
    grid-row: span 2;
}

/* ============================================================
   HOVER EFFECTS
============================================================ */
.lg-hover-zoom .lg-item img {
    transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}
.lg-hover-zoom .lg-item:hover img {
    transform: scale(1.08);
}

/* ===== OVERLAY ===== */
.lg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    gap: 8px;
}
.lg-hover-overlay .lg-item:hover .lg-overlay,
.lg-hover-overlay .lg-link:hover .lg-overlay {
    opacity: 1;
}
.lg-overlay-icon {
    width: 36px;
    height: 36px;
    color: #fff;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.lg-overlay-caption {
    color: #fff;
    font-size: 0.85rem;
    text-align: center;
    padding: 0 12px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    line-height: 1.3;
}

/* ===== CAPTION BELOW ===== */
.lg-caption {
    padding: 6px 8px 8px;
    font-size: 0.82rem;
    color: #555;
    text-align: center;
    line-height: 1.4;
}

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 960px) {
    .lg-layout-grid {
        grid-template-columns: repeat(min(var(--lg-cols, 3), 3), 1fr) !important;
    }
    .lg-layout-mosaic {
        grid-template-columns: repeat(min(var(--lg-cols, 3), 3), 1fr) !important;
    }
    .lg-layout-masonry {
        column-count: min(var(--lg-cols, 3), 3) !important;
    }
}
@media (max-width: 680px) {
    .lg-layout-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .lg-layout-grid .lg-item img {
        height: 160px !important;
    }
    .lg-layout-mosaic {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: 150px !important;
    }
    .lg-layout-masonry {
        column-count: 2 !important;
    }
}
@media (max-width: 420px) {
    .lg-layout-grid {
        grid-template-columns: 1fr !important;
    }
    .lg-layout-grid .lg-item img {
        height: 200px !important;
    }
    .lg-layout-mosaic {
        grid-template-columns: 1fr !important;
        grid-auto-rows: 180px !important;
    }
    .lg-layout-mosaic .lg-item:nth-child(1) {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
    }
    .lg-layout-masonry {
        column-count: 1 !important;
    }
}

/* ============================================================
   LIGHTBOX
============================================================ */
.lg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 999990;
    display: none;
    align-items: center;
    justify-content: center;
}
.lg-lightbox.lg-active {
    display: flex;
}

/* Overlay */
.lg-lb-bg {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    cursor: pointer;
}

/* Close */
.lg-lb-close {
    position: fixed;
    top: 14px;
    right: 16px;
    z-index: 10;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    padding: 0;
    line-height: 1;
}
.lg-lb-close:hover {
    background: rgba(255,255,255,0.25);
    transform: rotate(90deg);
}

/* Nav buttons */
.lg-lb-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
    line-height: 1;
    font-size: 1.5rem;
}
.lg-lb-nav:hover { background: rgba(255,255,255,0.28); }
.lg-lb-nav:disabled { opacity: 0.18; cursor: default; pointer-events: none; }
.lg-lb-prev { left: 10px; }
.lg-lb-next { right: 10px; }

/* Main container */
.lg-lb-container {
    position: relative;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 95vw;
    max-height: 95vh;
}

/* Image wrap */
.lg-lb-img-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    max-width: 90vw;
    max-height: 82vh;
    cursor: zoom-in;
    border-radius: 3px;
}
.lg-lb-img-wrap.lg-zoomed {
    cursor: grab;
    overflow: visible;
}
.lg-lb-img-wrap.lg-zoomed:active {
    cursor: grabbing;
}

/* Image */
.lg-lb-img {
    max-width: 90vw;
    max-height: 82vh;
    object-fit: contain;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
    transform-origin: center center;
    transition: opacity 0.22s ease;
}

/* Loading spinner */
.lg-lb-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    min-height: 80px;
}
.lg-lb-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: rgba(255,255,255,0.8);
    border-radius: 50%;
    animation: lg-spin 0.75s linear infinite;
}
@keyframes lg-spin { to { transform: rotate(360deg); } }

/* Toolbar */
.lg-lb-toolbar {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 90vw;
    padding: 10px 0 0;
    gap: 10px;
    flex-wrap: wrap;
}
.lg-lb-counter {
    color: rgba(255,255,255,0.55);
    font-size: 0.82rem;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 44px;
}
.lg-lb-caption {
    color: rgba(255,255,255,0.85);
    font-size: 0.88rem;
    flex: 1;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.lg-lb-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.lg-lb-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.22);
    color: #fff;
    padding: 6px 13px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
    line-height: 1.2;
}
.lg-lb-btn:hover {
    background: rgba(255,255,255,0.24);
    transform: translateY(-1px);
}
.lg-lb-btn:active {
    transform: translateY(0);
}
.lg-lb-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}
.lg-lb-btn.lg-zoomed-active {
    background: rgba(255,220,100,0.2);
    border-color: rgba(255,220,100,0.5);
    color: #ffd860;
}

/* ===== Mobile lightbox ===== */
@media (max-width: 600px) {
    .lg-lb-nav { width: 38px; height: 38px; font-size: 1.2rem; }
    .lg-lb-prev { left: 4px; }
    .lg-lb-next { right: 4px; }
    .lg-lb-close { top: 10px; right: 10px; width: 36px; height: 36px; }
    .lg-lb-toolbar { padding: 8px 0 0; gap: 6px; }
    .lg-lb-btn { padding: 5px 10px; font-size: 0.72rem; }
    .lg-lb-caption { font-size: 0.78rem; }
}
