/*
 * DW-Addon — Gallery Widget Stylesheet  v1.2.0
 * Filterable image grid + lightbox.
 *
 * Design reference: Gallery.png
 *   - Pill filter buttons in wrapping rows (brand-primary active, outline rest)
 *   - 2-column CSS Grid, left items tall (3:4), right items short (4:3)
 *   - Rounded images, no text overlays, hover expand icon
 *   - Full-screen lightbox with prev/next
 *   - Filter collapses to <select> on mobile ≤ 768px
 *
 * @package DW_Addon
 */

/* ============================================================
   GOOGLE FONTS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@400;500&display=swap');

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
.dw-gal-wrapper {
    --dw-gal-brand:       #c45a2e;
    --dw-gal-neutral-50:  #fafafa;
    --dw-gal-neutral-100: #f5f5f5;
    --dw-gal-neutral-200: #e5e5e5;
    --dw-gal-neutral-300: #d4d4d4;
    --dw-gal-neutral-400: #c8c8c8;
    --dw-gal-neutral-600: #525252;
    --dw-gal-neutral-900: #171717;
    --dw-gal-white:       #ffffff;
    --dw-gal-font:        'Lexend', sans-serif;
    --dw-gal-radius:      12px;
    --dw-gal-gap:         16px;
    --dw-gal-transition:  0.25s ease;

    box-sizing: border-box;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.dw-gal-wrapper *,
.dw-gal-wrapper *::before,
.dw-gal-wrapper *::after {
    box-sizing: inherit;
}

/* ============================================================
   FILTER BAR
   ============================================================ */
.dw-gal-filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    align-items: center;
}

/* Desktop: wrapping pill rows */
.dw-gal-filters__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

/* ---- Filter pill button ---- */
.dw-gal-filter__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 20px;
    border-radius: 100px;
    border: 1.5px solid var(--dw-gal-neutral-300);
    background-color: transparent;
    color: var(--dw-gal-neutral-600);
    font-family: var(--dw-gal-font);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color var(--dw-gal-transition),
                border-color    var(--dw-gal-transition),
                color           var(--dw-gal-transition);
    -webkit-appearance: none;
    appearance: none;
    line-height: 1;
    outline-offset: 3px;
}

.dw-gal-filter__btn:hover:not(.dw-gal-filter__btn--active) {
    border-color: var(--dw-gal-neutral-600);
    color: var(--dw-gal-neutral-900);
}

.dw-gal-filter__btn--active {
    background-color: var(--dw-gal-brand);
    border-color: var(--dw-gal-brand);
    color: var(--dw-gal-white);
}

/* Mobile select dropdown (hidden on desktop) */
.dw-gal-filters__select-wrap {
    display: none;
    position: relative;
    width: 100%;
    max-width: 300px;
}

.dw-gal-filter__select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--dw-gal-neutral-100);
    border: 1.5px solid var(--dw-gal-neutral-300);
    border-radius: 100px;
    padding: 10px 42px 10px 20px;
    font-family: var(--dw-gal-font);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--dw-gal-neutral-600);
    cursor: pointer;
    transition: border-color var(--dw-gal-transition);
    outline: none;
}

.dw-gal-filter__select:focus {
    border-color: var(--dw-gal-brand);
}

.dw-gal-filters__chevron {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--dw-gal-neutral-600);
    display: flex;
    align-items: center;
}

/* ============================================================
   GRID
   ============================================================ */
.dw-gal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--dw-gal-gap);
    width: 100%;
    align-items: start; /* prevents stretching — each item governs its own height */
}

/* ============================================================
   GALLERY ITEM
   ============================================================ */
.dw-gal-item {
    transition: opacity var(--dw-gal-transition), transform var(--dw-gal-transition);
}

/* Hidden state (filtered out) */
.dw-gal-item--hidden {
    display: none;
}

/* Image wrapper */
.dw-gal-item__img-wrap {
    position: relative;
    border-radius: var(--dw-gal-radius);
    overflow: hidden;
    background-color: var(--dw-gal-neutral-200);
    cursor: pointer;
    display: block;
    width: 100%;
}

/* Tall tiles (left column / odd-indexed) */
.dw-gal-item--tall .dw-gal-item__img-wrap {
    aspect-ratio: 3 / 4;
}

/* Short tiles (right column / even-indexed) */
.dw-gal-item--short .dw-gal-item__img-wrap {
    aspect-ratio: 4 / 3;
}

/* Image */
.dw-gal-item__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.dw-gal-item__img-wrap:hover .dw-gal-item__img,
.dw-gal-item__img-wrap:focus-visible .dw-gal-item__img {
    transform: scale(1.04);
}

/* Hover overlay with expand icon */
.dw-gal-item__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transition: opacity 0.28s ease;
    border-radius: inherit;
}

.dw-gal-item__img-wrap:hover .dw-gal-item__overlay,
.dw-gal-item__img-wrap:focus-visible .dw-gal-item__overlay {
    opacity: 1;
}

/* Placeholder when no featured image */
.dw-gal-item__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dw-gal-neutral-200), var(--dw-gal-neutral-300));
}

/* Focus ring for keyboard users */
.dw-gal-item__img-wrap:focus-visible {
    outline: 3px solid var(--dw-gal-brand);
    outline-offset: 2px;
}

/* Empty state */
.dw-gal-empty {
    text-align: center;
    color: var(--dw-gal-neutral-600);
    font-family: var(--dw-gal-font);
    padding: 48px 0;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */

/* Body scroll lock */
body.dw-modal-open {
    overflow: hidden;
}

.dw-lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background-color: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.dw-lb-overlay--open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.dw-lb-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 56px 80px;
    gap: 16px;
}

/* Image */
.dw-lb-img-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    width: 100%;
}

.dw-lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    display: block;
    transition: opacity 0.2s ease;
}

.dw-lb-img--loading {
    opacity: 0.4;
}

/* Caption */
.dw-lb-caption {
    font-family: var(--dw-gal-font);
    font-size: 14px;
    color: rgba(255, 255, 255, 0.75);
    text-align: center;
    max-width: 600px;
    line-height: 1.5;
    flex-shrink: 0;
}

/* Close button */
.dw-lb-close {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease;
    outline-offset: 3px;
}

.dw-lb-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

/* Prev / Next navigation */
.dw-lb-prev,
.dw-lb-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease;
    outline-offset: 3px;
}

.dw-lb-prev { left: 20px; }
.dw-lb-next { right: 20px; }

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

/* ============================================================
   RESPONSIVE — Mobile ≤ 768px: filter → dropdown
   ============================================================ */
@media (max-width: 768px) {
    /* Switch filter UI */
    .dw-gal-filters__buttons {
        display: none;
    }

    .dw-gal-filters__select-wrap {
        display: block;
    }

    /* Grid: stay 2-col but tighten gap */
    .dw-gal-grid {
        gap: 10px;
    }

    /* Lightbox nav */
    .dw-lb-container {
        padding: 64px 48px 32px;
    }

    .dw-lb-prev { left: 8px; }
    .dw-lb-next { right: 8px; }
}

/* ============================================================
   RESPONSIVE — Small mobile ≤ 480px: single column
   ============================================================ */
@media (max-width: 480px) {
    .dw-gal-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* All tiles equal aspect in single col */
    .dw-gal-item--tall  .dw-gal-item__img-wrap,
    .dw-gal-item--short .dw-gal-item__img-wrap {
        aspect-ratio: 4 / 3;
    }

    .dw-lb-container {
        padding: 56px 16px 24px;
    }

    .dw-lb-prev,
    .dw-lb-next {
        width: 38px;
        height: 38px;
    }
}
