/* ═══════════════════════════════════════════════════════════════════════════
   Auto Launch Gallery – Frontend CSS
   Uses theme CSS variables: --accent, --contrast, --base-3
   Falls back to sensible defaults if theme vars are not set
═══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables — defined on the outer container so all children inherit ── */
.al-gallery-outer {
    --al-accent:   var(--accent, #333333);
    --al-contrast: var(--contrast, #111111);
    --al-base3:    var(--base-3, #f5f5f5);
    width: 100%;
}

.al-gallery-wrap {
    --al-radius: 6px;
    --al-gap:    12px;
}

/* ── Regular Grid ────────────────────────────────────────────────────────── */
.al-gallery-wrap.al-layout-grid {
    display: grid;
    gap: var(--al-gap);
}
.al-gallery-wrap.al-layout-grid.al-cols-2 { grid-template-columns: repeat(2, 1fr); }
.al-gallery-wrap.al-layout-grid.al-cols-3 { grid-template-columns: repeat(3, 1fr); }
.al-gallery-wrap.al-layout-grid.al-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .al-gallery-wrap.al-layout-grid.al-cols-3,
    .al-gallery-wrap.al-layout-grid.al-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 540px) {
    .al-gallery-wrap.al-layout-grid { grid-template-columns: 1fr; }
}

/* ── Masonry Grid ────────────────────────────────────────────────────────── */
.al-gallery-wrap.al-layout-masonry {
    columns: 3;
    column-gap: var(--al-gap);
}
.al-gallery-wrap.al-layout-masonry.al-cols-2 { columns: 2; }
.al-gallery-wrap.al-layout-masonry.al-cols-3 { columns: 3; }
.al-gallery-wrap.al-layout-masonry.al-cols-4 { columns: 4; }
.al-gallery-wrap.al-layout-masonry .al-gallery-item {
    break-inside: avoid;
    margin-bottom: var(--al-gap);
    display: block;
}

@media (max-width: 900px) {
    .al-gallery-wrap.al-layout-masonry.al-cols-3,
    .al-gallery-wrap.al-layout-masonry.al-cols-4 { columns: 2; }
}
@media (max-width: 540px) {
    .al-gallery-wrap.al-layout-masonry { columns: 1; }
}

/* ── Gallery Item ────────────────────────────────────────────────────────── */
.al-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--al-item-radius, var(--al-radius, 6px));
    cursor: pointer;
    background: var(--al-base3);
}

.al-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
    /* Prevent subpixel blur */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    will-change: transform;
    /* Force crisp rendering */
    image-rendering: auto;
    -webkit-font-smoothing: antialiased;
}

.al-gallery-wrap.al-layout-grid .al-gallery-item {
    aspect-ratio: 4/3;
}

.al-gallery-item:hover img {
    transform: scale(1.04) translateZ(0);
}

/* Overlay */
.al-gallery-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s ease;
}
.al-gallery-item:hover .al-gallery-overlay {
    background: rgba(0,0,0,0.3);
}
.al-gallery-icon {
    opacity: 0;
    color: #fff;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    transition: opacity 0.25s ease, transform 0.25s ease;
    width: 48px;
    height: 48px;
    background: var(--al-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-style: normal;
}
.al-gallery-item:hover .al-gallery-icon {
    opacity: 1;
    transform: scale(1.1);
}

/* ── Lightbox ────────────────────────────────────────────────────────────── */
.al-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.al-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.9);
}

.al-lightbox-inner {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

.al-lightbox-close {
    position: fixed;
    top: 18px;
    right: 22px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    transition: background 0.15s;
    line-height: 1;
}
.al-lightbox-close:hover { background: var(--al-accent); border-color: var(--al-accent); }

.al-lightbox-img-wrap {
    position: relative;
    width: 100%;
    max-width: 85vw;
    max-height: 72vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
}

#al-lightbox-img {
    max-width: 85vw;
    max-height: 72vh;
    object-fit: contain;
    display: block;
}

/* ── Thumbnail strip — floats over bottom-left of the image ── */
.al-lightbox-thumbs {
    position: absolute;
    bottom: 12px;
    left: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
    padding: 6px 8px;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border-radius: 8px;
}

.al-lightbox-thumb {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border-radius: 5px;
    cursor: pointer;
    opacity: 0.6;
    border: 2.5px solid transparent;
    transition: opacity 0.15s, border-color 0.15s, transform 0.15s;
    display: block;
    flex-shrink: 0;
}

.al-lightbox-thumb:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.al-lightbox-thumb.active {
    opacity: 1;
    border-color: var(--al-accent);
}

/* ── Info bar — title/type left, View Project right ── */
.al-lightbox-info {
    background: #ffffff;
    padding: 12px 18px;
    width: 100%;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 58px;
}

.al-lightbox-meta {
    flex: 1;
    min-width: 0;
}

#al-lightbox-title {
    color: #111111;
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 2px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.al-lightbox-type {
    font-size: 11px;
    color: var(--al-accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
}

.al-lightbox-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    background: var(--al-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity 0.15s;
}
.al-lightbox-btn:hover {
    opacity: 0.85;
    color: #fff;
    text-decoration: none;
}

/* Mobile — smaller thumbnails */
@media (max-width: 540px) {
    .al-lightbox-thumb {
        width: 52px;
        height: 40px;
    }
    .al-lightbox-thumbs {
        bottom: 8px;
        left: 8px;
        gap: 5px;
        padding: 4px 6px;
    }
}

.al-gallery-empty { color: #888; text-align: center; padding: 32px 0; }

@media (prefers-reduced-motion: reduce) {
    .al-gallery-item img,
    .al-gallery-overlay,
    .al-gallery-icon { transition: none; }
}

/* ── Type Filter Nav ──────────────────────────────────────────────────────── */

.al-type-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    align-items: center;
}

.al-type-btn {
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
    padding: 7px 18px;
    background: transparent;
    color: var(--al-contrast, #111);
    border: 1.5px solid rgba(0,0,0,0.15);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.18s ease;
    line-height: 1.4;
}

.al-type-btn:hover {
    border-color: var(--al-accent);
    color: var(--al-accent);
    background: color-mix(in srgb, var(--al-accent) 8%, transparent);
}

.al-type-btn.al-type-btn-active {
    background: var(--al-accent);
    border-color: var(--al-accent);
    color: #fff;
}

/* Hidden gallery items (filtered out) */
.al-gallery-item.al-type-hidden {
    display: none !important;
}

/* Masonry reflow helper */
.al-gallery-wrap.al-layout-masonry {
    transition: none;
}

/* ── Slider Layout ────────────────────────────────────────────────────────── */
.al-gallery-slider-outer {
    --al-slider-cols: 3;
    position: relative;
    overflow: hidden;
    width: 100%;
}
.al-slider-track {
    display: flex;
    transition: transform 0.4s ease;
    will-change: transform;
}
.al-slider-slide {
    flex: 0 0 calc(100% / var(--al-slider-cols));
    min-width: calc(100% / var(--al-slider-cols));
    padding: 0 6px;
    box-sizing: border-box;
    border-radius: var(--al-item-radius, 6px);
    overflow: hidden;
}
.al-slider-slide img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    border-radius: var(--al-item-radius, 6px);
    backface-visibility: hidden;
}
.al-slider-prev,
.al-slider-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.55);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
}
.al-slider-prev:hover,
.al-slider-next:hover { background: var(--al-accent); }
.al-slider-prev { left: 8px; }
.al-slider-next { right: 8px; }
.al-slider-prev:disabled,
.al-slider-next:disabled { opacity: 0.3; cursor: default; }

@media (max-width: 640px) {
    .al-slider-slide {
        flex: 0 0 100%;
        min-width: 100%;
    }
}

/* ── Show More Button ─────────────────────────────────────────────────────── */
.al-show-more-wrap {
    text-align: center;
    margin-top: 28px;
}
.al-show-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: transparent;
    color: var(--al-accent);
    border: 2px solid var(--al-accent);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    font-family: inherit;
}
.al-show-more-btn:hover {
    background: var(--al-accent);
    color: #fff;
}
.al-show-more-btn.al-hidden { display: none; }

/* Items hidden by show-more */
.al-gallery-item.al-more-hidden {
    display: none !important;
}

/* ── Title Overlay ────────────────────────────────────────────────────────── */
.al-gallery-title-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 12px;
    z-index: 2;
    pointer-events: none;
}

.al-gallery-title-overlay span {
    display: inline-block;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    padding: 4px 10px;
    border-radius: 4px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
