/* ============================================================
   AEIG Gallery – Frontend Styles
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────────── */
.wgp-gallery {
    --wgp-bg:              #faf9f7;
    --wgp-surface:         #ffffff;
    --wgp-border:          #e8e4df;
    --wgp-text:            #1a1917;
    --wgp-muted:           #6b665f;
    --wgp-accent:          #027eed;
    --wgp-accent-hover:    #2a99f9;
    --wgp-accent-light:    #d6e3f0;
    --wgp-chip-bg:         #f0ede8;
    --wgp-chip-active:     #1a1917;
    --wgp-chip-active-txt: #faf9f7;
    --wgp-shadow:          0 2px 12px rgba(26,25,23,.08);
    --wgp-shadow-hover:    0 8px 32px rgba(26,25,23,.14);
    --wgp-radius:          10px;
    --wgp-gap:             20px;
    --wgp-transition:      0.25s cubic-bezier(.4,0,.2,1);
    --wgp-toggle-w:        44px;
    --wgp-sidebar-w:       240px;
    font-family: 'Georgia', 'Times New Roman', serif;
    color: var(--wgp-text);
    padding: 32px 0;
    position: relative;
}

/* ── Always-visible filter sidebar ──────────────────────────── */

.wgp-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--wgp-border);
    /* No longer sticky — the whole controls block scrolls as one */
    background: var(--wgp-surface);
}

.wgp-sidebar__heading {
    font-family: -apple-system, 'Montserrat', sans-serif;
    font-size: 11px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--wgp-muted);
    font-weight: 600;
}

.wgp-sidebar__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: var(--wgp-chip-bg);
    cursor: pointer;
    color: var(--wgp-muted);
    transition: background var(--wgp-transition), color var(--wgp-transition);
}

.wgp-sidebar__close:hover { background: var(--wgp-accent-light); color: var(--wgp-accent); }
.wgp-sidebar__close svg { width: 14px; height: 14px; }

.wgp-sidebar__body {
    padding: 16px 18px 32px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Permanent sidebar panel — sits in the flex flow as a static column */
.wgp-sidebar__panel {
    flex-shrink: 0;
    width: var(--wgp-sidebar-w);
    background: var(--wgp-surface);
    border: 1.5px solid var(--wgp-border);
    border-radius: var(--wgp-radius);
    box-shadow: var(--wgp-shadow);
    display: flex;
    flex-direction: column;
    /* Sticky so it stays in view as the user scrolls the grid */
    position: sticky;
    top: 24px;
    align-self: flex-start;
    max-height: calc(100vh - 48px);
    overflow: hidden;
}

/* Controls scrolls inside the fixed-height panel */
.wgp-sidebar__controls {
    display: flex;
    flex-direction: column;
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Hide the close button — not needed when sidebar is always visible */
.wgp-sidebar__close { display: none; }

/* Hide the toggle button entirely */
.wgp-sidebar__toggle { display: none; }
.wgp-gallery__inner {
    display: flex;
    align-items: flex-start;
    gap: 0;
}

/* ── Inner flex row: [sidebar panel] [grid] ────────────────── */
.wgp-gallery__inner {
    display: flex;
    align-items: flex-start;
    gap: 24px;
}

/* Active filter count badge on the heading */
.wgp-sidebar__active-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--wgp-accent);
    color: #fff;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    line-height: 1;
    margin-left: 6px;
    vertical-align: middle;
}

.wgp-sidebar__active-count[hidden] { display: none; }

/* ── Filter buttons (inside panel) ──────────────────────────── */
.wgp-all-btn {
    font-family: -apple-system, 'Montserrat', sans-serif;
    font-size: 12px;
    padding: 8px 14px;
    border: 1.5px solid var(--wgp-border);
    background: transparent;
    color: var(--wgp-muted);
    cursor: pointer;
    text-align: left;
    margin-bottom: 8px;
    transition: background var(--wgp-transition), color var(--wgp-transition),
                border-color var(--wgp-transition);
}

.wgp-all-btn.is-active {
    background: var(--wgp-chip-active);
    border-color: var(--wgp-chip-active);
    color: var(--wgp-chip-active-txt);
}

.wgp-filter-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 12px;
}

.wgp-filter-label {
    font-family: -apple-system, 'Montserrat', sans-serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    font-weight: 700;
    padding: 0 2px;
    margin-bottom: 4px;
}

.wgp-filter-btn {
    font-family: -apple-system, 'Montserrat', sans-serif;
    font-size: 13px;
    padding: 7px 12px;
    border: none;
    background: transparent;
    color: var(--wgp-text);
    cursor: pointer;
    text-align: left;
    transition: background var(--wgp-transition), color var(--wgp-transition);
}

.wgp-filter-btn:hover      { background: var(--wgp-accent-light); color: var(--wgp-accent); }
.wgp-filter-btn.is-active  { background: var(--wgp-accent); color: var(--wgp-bg); font-weight: 600; }

/* ── Main + grid ─────────────────────────────────────────────── */
.wgp-main { flex: 1; min-width: 0; }

.wgp-grid {
    display: grid;
    gap: var(--wgp-gap);
    list-style: none;
    padding: 0;
    margin: 0;
}

.wgp-grid--cols-1 { grid-template-columns: 1fr; }
.wgp-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.wgp-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.wgp-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .wgp-grid--cols-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
    .wgp-grid--cols-3,
    .wgp-grid--cols-4 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Mobile: single column, sidebar stacks above grid ────────── */
@media (max-width: 480px) {

    /* Every column count collapses to one */
    .wgp-grid--cols-1,
    .wgp-grid--cols-2,
    .wgp-grid--cols-3,
    .wgp-grid--cols-4 { grid-template-columns: 1fr; }

    /* Stack sidebar above the grid */
    .wgp-gallery__inner {
        flex-direction: column;
        gap: 16px;
    }

    /* Sidebar goes full width, loses sticky */
    .wgp-sidebar__panel {
        width: 100%;
        position: static;
        max-height: none;
        border-radius: var(--wgp-radius);
    }

    /* Controls scrolls freely at full height */
    .wgp-sidebar__controls {
        max-height: none;
        overflow-y: visible;
    }

    /* Filter buttons: larger tap targets on mobile */
    .wgp-filter-btn {
        padding: 10px 14px;
        font-size: 14px;
    }

    .wgp-all-btn {
        padding: 10px 14px;
        font-size: 14px;
    }

    /* Body: safe-area bottom padding */
    .wgp-sidebar__body {
        padding-bottom: calc( 16px + env(safe-area-inset-bottom, 0px) );
    }
}

/* ── Gallery Item ───────────────────────────────────────────── */
.wgp-item {
    background: var(--wgp-surface);
    border-radius: var(--wgp-radius);
    overflow: hidden;
    box-shadow: var(--wgp-shadow);
    transition: box-shadow var(--wgp-transition), transform var(--wgp-transition),
                opacity .35s ease;
    opacity: 1;
    transform: translateY(0);
    border: 1.5px solid #E9E8E8;
}

.wgp-item--entering { opacity: 0; transform: translateY(16px); }
.wgp-item[hidden]   { display: none; }

.wgp-item:hover {
    box-shadow: var(--wgp-shadow-hover);
    transform: translateY(-3px);
}

.wgp-item__link { display: block; text-decoration: none; color: inherit; }

/* Image */
.wgp-item__image-wrap {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    background: var(--wgp-chip-bg);
}

.wgp-item__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(.4,0,.2,1);
}

.wgp-item:hover .wgp-item__image { transform: scale(1.04); }

.wgp-item__count {
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(26,25,23,.65);
    color: #fff;
    font-family: -apple-system, 'Montserrat', sans-serif;
    font-size: 11px; font-weight: 600;
    padding: 3px 8px;
    border-radius: 100px;
    backdrop-filter: blur(4px);
}

.wgp-item__overlay {
    position: absolute;
    inset: 0;
    background: rgba(200,98,42,0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--wgp-transition);
}

.wgp-item:hover .wgp-item__overlay { background: rgba(200,98,42,.22); }

.wgp-icon-expand {
    width: 36px; height: 36px;
    stroke: #fff; stroke-width: 2; stroke-linecap: round; fill: none;
    opacity: 0; transform: scale(0.7);
    transition: opacity var(--wgp-transition), transform var(--wgp-transition);
    filter: drop-shadow(0 2px 4px rgba(0,0,0,.4));
}

.wgp-item:hover .wgp-icon-expand { opacity: 1; transform: scale(1); }

/* Meta / content */
.wgp-item__meta { padding: 12px 14px 14px; }

/* Formatted post content — clamp to 4 lines, preserve HTML formatting */
.wgp-item__content {
    font-size: 13px;
    line-height: 1.55;
    color: var(--wgp-muted);
    margin: 0 0 8px;
}
.wgp-item__content p {
    margin-bottom: 8px;
    font-size: 0.85rem;
}
.wgp-item__content > * { margin: 0; padding: 0; }
.wgp-item__content > * + * { margin-top: .4em; }

.wgp-item__tags { display: flex; flex-wrap: wrap; gap: 4px; }

.wgp-tag {
    font-family: -apple-system, 'Montserrat', sans-serif;
    font-size: 10.5px; letter-spacing: .04em;
    background: var(--wgp-accent-light);
    color: var(--wgp-accent);
    padding: 2px 8px;
    border-radius: 4px;
}

/* ── Footer ─────────────────────────────────────────────────── */
.wgp-footer {
    margin-top: 40px;
    display: flex; flex-direction: column; align-items: center; gap: 16px;
}

.wgp-load-more {
	font-family: 'Montserrat', sans-serif;
    font-size: 13px;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 13px 36px;
    border: 1.5px solid var(--wgp-accent);
    background: transparent;
    color: var(--wgp-accent);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background var(--wgp-transition), color var(--wgp-transition);
}

.wgp-load-more:hover:not(:disabled) { background: var(--wgp-text); color: var(--wgp-bg); }
.wgp-load-more:disabled { opacity: .5; cursor: not-allowed; }
.wgp-load-more[hidden] { display: none; }   /* beats display:flex at equal specificity */
.wgp-load-more__count { font-size: 11px; opacity: .65; }

.wgp-spinner { display: flex; gap: 6px; align-items: center; }
.wgp-spinner[hidden] { display: none; }
.wgp-spinner span {
    display: block; width: 7px; height: 7px;
    border-radius: 50%; background: var(--wgp-accent);
    animation: wgp-bounce 1.2s ease-in-out infinite;
}
.wgp-spinner span:nth-child(1) { animation-delay: 0s; }
.wgp-spinner span:nth-child(2) { animation-delay: .2s; }
.wgp-spinner span:nth-child(3) { animation-delay: .4s; }

@keyframes wgp-bounce {
    0%, 80%, 100% { transform: scale(0); opacity: .3; }
    40%            { transform: scale(1); opacity: 1; }
}

.wgp-no-items,
.wgp-no-results {
    text-align: center;
    padding: 48px 24px;
    font-style: italic;
    color: var(--wgp-muted);
    font-size: 16px;
}

.wgp-no-items[hidden],
.wgp-no-results[hidden] { display: none; }

.wgp-no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.wgp-no-results__message { margin: 0; }

.wgp-reset-filters {
    font-family: -apple-system, 'Montserrat', sans-serif;
    font-size: 13px;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 10px 28px;
    border: 1.5px solid var(--wgp-accent);
    background: transparent;
    color: var(--wgp-accent);
    border-radius: 100px;
    cursor: pointer;
    transition: background var(--wgp-transition), color var(--wgp-transition);
}

.wgp-reset-filters:hover {
    background: var(--wgp-accent);
    color: #fff;
}

/* ── Lightbox (iframe) ──────────────────────────────────────── */
.wgp-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.8);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    padding: 56px 24px 24px;  /* top padding clears the outer close button */
    box-sizing: border-box;
    z-index:999;
}

.wgp-lightbox.is-open {
    display: flex;
    animation: wgp-lb-fade-in .22s ease;
}

@keyframes wgp-lb-fade-in { from { opacity: 0; } to { opacity: 1; } }

body.wgp-lightbox-open { overflow: hidden; }

/* ── Shared close button base ────────────────────────────────── */
.wgp-lightbox__close {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    transition: background var(--wgp-transition), color var(--wgp-transition),
                transform var(--wgp-transition);
    font-family: -apple-system, 'Montserrat', sans-serif;
}

/* ── Outer close — sits above the frame in the white margin ──── */
.wgp-lightbox__close--outer {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wgp-chip-bg);
    color: var(--wgp-text);
    font-size: 16px;
}

.wgp-lightbox__close--outer:hover {
    background: var(--wgp-accent-light);
    color: var(--wgp-accent);
    transform: scale(1.08);
}

/* ── Inner close — overlaid on the top-right of the iframe ───── */
.wgp-lightbox__close--inner {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    padding: 8px 14px;
    border-radius: 100px;
    background: var(--wgp-text);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .04em;
    box-shadow: 0 2px 12px rgba(0,0,0,.18);
    /* Hidden on desktop — the outer button is sufficient */
    display: none;
}

.wgp-lightbox__close--inner:hover {
    background: var(--wgp-accent);
    transform: translateY(-1px);
}

.wgp-lightbox__close-label {
    font-size: 12px;
}

/* On mobile, hide the outer (may be off-screen when keyboard opens)
   and show the inner overlay button instead */
@media (max-width: 600px) {
    .wgp-lightbox {
        padding: 0;           /* iframe fills the full screen */
    }

    .wgp-lightbox__close--outer {
        display: none;
    }

    .wgp-lightbox__close--inner {
        display: flex;        /* visible overlay button on mobile */
    }

    .wgp-lightbox__frame-wrap {
        border-radius: 0;
        box-shadow: none;
        max-height: 100vh;
    }
}

.wgp-lightbox__frame-wrap {
    position: relative;
    width: 100%; max-width: 1100px;
    height: 100%; max-height: calc(100vh - 80px);
    background: var(--wgp-surface);
    border-radius: var(--wgp-radius);
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.12);
    animation: wgp-lb-in .28s cubic-bezier(.4,0,.2,1);
}

@keyframes wgp-lb-in {
    from { opacity: 0; transform: scale(.97) translateY(12px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

.wgp-lightbox__spinner {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--wgp-surface); z-index: 2;
}
.wgp-lightbox__spinner[hidden] { display: none; }
.wgp-lightbox__spinner span {
    display: block; width: 9px; height: 9px;
    border-radius: 50%; background: var(--wgp-accent);
    animation: wgp-bounce 1.2s ease-in-out infinite;
}
.wgp-lightbox__spinner span:nth-child(1) { animation-delay: 0s; }
.wgp-lightbox__spinner span:nth-child(2) { animation-delay: .2s; }
.wgp-lightbox__spinner span:nth-child(3) { animation-delay: .4s; }

.wgp-lightbox__iframe {
    display: block; width: 100%; height: 100%;
    border: none; opacity: 0;
    transition: opacity .25s ease;
}
.wgp-lightbox__iframe.is-loaded { opacity: 1; }
