/* =============================================================================
   Visual Hub — Frontend Styles
   Responsive masonry grid · hover overlay · Instagram-style lightbox
   ============================================================================= */

/* ---- Reset / scope -------------------------------------------------------- */
.vh-main,
.vh-wrap {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

/* ---- Filter bar ----------------------------------------------------------- */
.vh-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 16px;
    background: #fff;
    position: var(--vh-filter-pos, sticky);
    top: 0;
    z-index: 200;
    border-bottom: 1px solid rgba(0,0,0,0.07);
    justify-content: center;
}

.vh-filter-btn {
    padding: 5px 18px;
    border: 1.5px solid #ccc;
    background: transparent;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    letter-spacing: 0.02em;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
    line-height: 1.4;
}

.vh-filter-btn:hover {
    border-color: #555;
    background: #f4f4f4;
}

.vh-filter-btn.active,
.vh-filter-btn[aria-pressed="true"] {
    background: #111;
    color: #fff;
    border-color: #111;
}

/* ---- Masonry grid (JS shortest-column engine — see frontend.js) ---------- */
.vh-masonry {
    position: relative;
    min-height: 60px; /* prevent collapse before JS first run */
}

/* Tablet / mobile breakpoints are read by JS from CSS vars — no rules needed here */

/* ---- Card ----------------------------------------------------------------- */
.vh-card {
    position: absolute; /* JS masonry sets left/top/width */
    overflow: hidden;
    cursor: pointer;
    background: #111;
    display: block;
    outline: none;
    border-radius: var(--vh-radius, 0px);
    /* Smooth repositioning when filter changes column count */
    transition: opacity 0.2s ease;
}

.vh-card:focus-visible {
    box-shadow: inset 0 0 0 3px #4a90e2;
}

/* Images and videos fill card width; height is natural (preserves aspect ratio) */
.vh-card__img,
.vh-card__video {
    display: block;
    width: 100%;
    height: auto;
    object-fit: cover;
    transition: transform 0.35s ease;
}

.vh-card__placeholder {
    width: 100%;
    padding-bottom: 100%; /* 1:1 square */
    background: #333;
}

/* ---- Hover overlay -------------------------------------------------------- */
.vh-card__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, var(--vh-opa, 0.48));
    display: flex;
    align-items: var(--vh-title-align, flex-start);
    justify-content: center;
    padding: 14px 16px;
    opacity: 0;
    transition: opacity 0.22s ease;
    pointer-events: none;
}

.vh-card:hover .vh-card__overlay,
.vh-card:focus-visible .vh-card__overlay {
    opacity: 1;
}

.vh-card:hover .vh-card__img {
    transform: scale(1.04);
}

.vh-card__title {
    color: #fff;
    font-family: var(--vh-title-font, inherit);
    font-size: var(--vh-title-size, 0.9rem);
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    width: 100%;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}

/* ---- Non-interactive card variants --------------------------------------- */
.vh-card--no-hover {
    cursor: default;
}
.vh-card--no-hover .vh-card__overlay {
    display: none;
}
.vh-card--no-hover:hover .vh-card__img,
.vh-card--no-hover:focus-visible .vh-card__img {
    transform: none;
}
.vh-card--no-lightbox {
    cursor: default;
}

/* ---- Tag-filtered hidden state ------------------------------------------- */
.vh-card.vh-filtered-out {
    display: none;
}

/* ---- Filter animation (fade-in when a card is revealed by filtering) ------- */
.vh-card.vh-visible {
    animation: vhFadeIn 0.22s ease both;
}

@keyframes vhFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* =============================================================================
   Lightbox
   ============================================================================= */
.vh-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.vh-lightbox.is-open {
    display: flex;
}

/* Backdrop */
.vh-lightbox__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    cursor: pointer;
}

/* Inner panel — image left, text right */
.vh-lightbox__inner {
    position: relative;
    z-index: 1;
    display: flex;
    width: 92vw;
    max-width: 1140px;
    max-height: 92vh;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}

/* Close button */
.vh-lightbox__close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: rgba(0,0,0,0.45);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.4rem;
    line-height: 36px;
    text-align: center;
    cursor: pointer;
    color: #fff;
    z-index: 2;
    padding: 0;
    transition: background 0.18s;
}

.vh-lightbox__close:hover {
    background: rgba(0,0,0,0.75);
}

/* Media pane (left) */
.vh-lightbox__media {
    flex: 0 0 var(--vh-lb-media, 58%);
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 300px;
}

.vh-lightbox__media img,
.vh-lightbox__media video {
    width: 100%;
    height: 100%;
    max-height: 92vh;
    object-fit: contain;
    display: block;
}

/* Text pane (right) */
.vh-lightbox__body {
    flex: 1;
    padding: 44px 36px 32px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vh-lightbox__title {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0;
}

.vh-lightbox__content {
    font-size: 0.93rem;
    line-height: 1.75;
    color: #333;
    flex: 1;
}

.vh-lightbox__content p:first-child {
    margin-top: 0;
}

/* Tags row inside lightbox */
.vh-lightbox__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding-top: 16px;
    border-top: 1px solid #eee;
    margin-top: auto;
}

.vh-lightbox__tag {
    padding: 4px 14px;
    background: #f2f2f2;
    border: 1px solid #ddd;
    border-radius: 999px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.18s, color 0.18s;
    font-family: inherit;
}

.vh-lightbox__tag:hover {
    background: #111;
    color: #fff;
    border-color: #111;
}

/* ---- Responsive lightbox -------------------------------------------------- */
@media (max-width: 720px) {
    .vh-lightbox__inner {
        flex-direction: column;
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .vh-lightbox__media {
        flex: 0 0 45vh;
        min-height: 0;
    }

    .vh-lightbox__body {
        padding: 20px 18px 24px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
    }

    .vh-filter-bar {
        position: static; /* prevent overlap on small screens */
    }
}
