/* Smart Gallery — Frontend */
*, *::before, *::after { box-sizing: border-box; }

.sg-gallery {
    --accent: #1b9be0;
    --radius: 8px;
    --gap:    8px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    margin: 0;
}

/* ── HERO ──────────────────────────────────── */
.sg-hero {
    position: relative;
    min-height: 320px;
    display: flex; align-items: center; justify-content: center;
    background: #1a1a2e; overflow: hidden; margin-bottom: 28px;
}
.sg-hero__bg {
    position: absolute; inset: 0;
    background-size: cover; background-position: center;
    filter: brightness(.5);
}
.sg-hero__content {
    position: relative; z-index: 1;
    text-align: center; padding: 40px 24px;
    width: 100%; max-width: 760px; margin: 0 auto;
}
.sg-hero__title {
    color: #fff; font-size: clamp(20px, 4vw, 34px);
    font-weight: 700; margin: 0 0 22px;
    text-shadow: 0 1px 6px rgba(0,0,0,.4);
}

/* Search bar */
.sg-hero__searchbar {
    display: flex; background: #fff; border-radius: 6px;
    overflow: hidden; box-shadow: 0 4px 20px rgba(0,0,0,.25);
    margin-bottom: 14px;
}
.sg-hero__searchbar svg {
    width: 18px; height: 18px; margin: auto 0 auto 14px;
    color: #aaa; flex-shrink: 0;
}
.sg-search-input {
    flex: 1; border: none; outline: none;
    padding: 13px 16px; font-size: 15px; color: #333; background: transparent;
}
.sg-search-input::placeholder { color: #aaa; }

/* Tag filter pills */
.sg-hero__pills {
    display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
}
.sg-pill-btn {
    background: rgba(255,255,255,.15); color: rgba(255,255,255,.85);
    border: 1.5px solid rgba(255,255,255,.25); border-radius: 20px;
    padding: 5px 14px; font-size: 12.5px; cursor: pointer;
    transition: all .15s; backdrop-filter: blur(4px);
    font-weight: 400;
}
.sg-pill-btn:hover {
    background: rgba(255,255,255,.28);
    color: #fff;
    border-color: rgba(255,255,255,.5);
}
.sg-pill-btn--active {
    background: #fff;
    color: #1a1a2e;
    border-color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

/* Clear All button */
.sg-clear-tags {
    background: rgba(231, 76, 60, .85);
    color: #fff;
    border: 1.5px solid rgba(231,76,60,.6);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    backdrop-filter: blur(4px);
}
.sg-clear-tags:hover {
    background: rgba(231,76,60,1);
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

/* ── MASONRY ───────────────────────────────── */
.sg-pub-wrap { width: 100%; padding: 0 0 48px; }

.sg-masonry { columns: 4; column-gap: var(--gap); }
.sg-cols-1 { columns: 1; }
.sg-cols-2 { columns: 2; }
.sg-cols-3 { columns: 3; }
.sg-cols-4 { columns: 4; }
.sg-cols-5 { columns: 5; }
.sg-cols-6 { columns: 6; }

@media (max-width: 1100px) { .sg-cols-5, .sg-cols-6 { columns: 4; } }
@media (max-width: 860px)  { .sg-cols-4, .sg-cols-5, .sg-cols-6 { columns: 3; } }
@media (max-width: 580px)  { .sg-masonry { columns: 2 !important; } }
@media (max-width: 380px)  { .sg-masonry { columns: 1 !important; } }

.sg-pub-item {
    break-inside: avoid; margin-bottom: var(--gap);
    border-radius: var(--radius); overflow: hidden;
}
.sg-pub-item.sg-hidden { display: none; }

.sg-pub-item__btn {
    all: unset; display: block; width: 100%;
    cursor: pointer; position: relative;
    border-radius: var(--radius); overflow: hidden;
}
.sg-pub-item__btn img {
    display: block; width: 100%; height: auto;
    transition: transform .35s ease;
}
.sg-pub-item__btn:hover img { transform: scale(1.04); }
.sg-pub-item__btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.sg-pub-item__overlay {
    position: absolute; inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,.55) 0%, transparent 55%);
    display: flex; flex-direction: column; justify-content: flex-end;
    padding: 10px 12px; opacity: 0; transition: opacity .22s;
    border-radius: var(--radius);
}
.sg-pub-item__btn:hover .sg-pub-item__overlay,
.sg-pub-item__btn:focus-visible .sg-pub-item__overlay { opacity: 1; }

.sg-pub-item__title {
    color: #fff; font-size: 13px; font-weight: 600;
    margin: 0 0 2px; text-shadow: 0 1px 3px rgba(0,0,0,.5);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sg-pub-item__loc {
    color: rgba(255,255,255,.82); font-size: 11px; margin: 0;
    display: flex; align-items: center; gap: 3px;
}
.sg-pub-item__loc svg { width: 11px; height: 11px; flex-shrink: 0; }

.sg-no-results { text-align: center; padding: 50px; color: #999; font-size: 15px; }

/* ── LIGHTBOX ──────────────────────────────── */
.sg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(8,8,14,.93);
    align-items: center;
    justify-content: center;
    /* Push down from top so it never overlaps the nav */
    padding-top: 80px;
    padding-bottom: 20px;
}
@keyframes sg-fade { from { opacity: 0; } to { opacity: 1; } }

.sg-lb-inner {
    /* Total width = image + 260px sidebar, never exceed 92vw */
    max-width: 92vw;
    max-height: calc(100vh - 100px);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
}
.sg-lb-figure {
    display: flex; margin: 0; background: #fff;
    border-radius: 10px; overflow: hidden;
    max-height: calc(100vh - 100px);
    width: 100%;
    /* Prevent children from blowing out the container */
    min-width: 0;
}
.sg-lb-img {
    display: block;
    /* Image takes remaining space after sidebar */
    flex: 1 1 auto;
    min-width: 0;
    max-height: calc(100vh - 100px);
    width: 100%;
    object-fit: contain;
    background: #fff;
}
.sg-lb-caption {
    /* Fixed 260px sidebar — never shrinks, never grows */
    width: 260px;
    min-width: 260px;
    max-width: 260px;
    flex: 0 0 260px;
    padding: 16px 18px;
    overflow-y: auto;
    max-height: calc(100vh - 100px);
    display: block;
    background: #fff;
    /* Clip any overflow */
    overflow-x: hidden;
}
.sg-lb-title { font-size: 15px; font-weight: 700; color: #111; margin: 0 0 8px; }
.sg-lb-desc  { font-size: 13px; color: #555; margin: 0 0 12px; line-height: 1.6; }
.sg-lb-meta  { margin: 0 0 12px; border-top: 1px solid #eee; padding-top: 12px; }
.sg-lb-row   { display: flex; flex-direction: column; margin-bottom: 8px; }
.sg-lb-row dt { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #bbb; font-weight: 700; }
.sg-lb-row dd { font-size: 12.5px; color: #333; margin: 2px 0 0; }
.sg-lb-tags  { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 4px; }
.sg-lb-tag   { font-size: 11.5px; background: #f0f8fe; color: var(--accent); padding: 2px 8px; border-radius: 4px; border: 1px solid #d4eaf8; }

.sg-lb-close, .sg-lb-prev, .sg-lb-next {
    position: fixed; background: rgba(255,255,255,.14); border: none;
    color: #fff; cursor: pointer; border-radius: 50%;
    transition: background .14s; z-index: 100000;
    display: flex; align-items: center; justify-content: center; line-height: 1;
}
.sg-lb-close { top: 14px; right: 18px; width: 36px; height: 36px; font-size: 22px; }
.sg-lb-prev, .sg-lb-next { top: 50%; transform: translateY(-50%); width: 46px; height: 46px; font-size: 30px; }
.sg-lb-prev { left: 10px; }
.sg-lb-next { right: 10px; }
.sg-lb-close:hover, .sg-lb-prev:hover, .sg-lb-next:hover { background: rgba(255,255,255,.28); }

@media (max-width: 680px) {
    .sg-lb-figure   { flex-direction: column; }
    .sg-lb-img      { max-width: 92vw; max-height: 50vh; }
    .sg-lb-caption  { width: 100%; max-height: 38vh; }
}
