/* ==========================================================================
   Project library - filters, grid and lightbox
   ========================================================================== */

.library-head {
    padding-block: clamp(2.5rem, 6vw, 4.5rem) clamp(1.5rem, 3vw, 2.5rem);
}

.library-head h1 { margin: 1.25rem 0 1.5rem; }

/* ------------------------------------------------------------------ filters */

.filters {
    position: sticky;
    top: var(--header-h);
    z-index: 40;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding-block: 1.1rem;
    background: rgba(250, 247, 241, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line-soft);
}

.filter-btn {
    padding: 0.55rem 1.15rem;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.3s var(--ease), border-color 0.3s var(--ease), background 0.3s var(--ease);
}

.filter-btn:hover { color: var(--ink); border-color: var(--ink); }

.filter-btn[aria-selected="true"] {
    color: var(--paper);
    background: var(--ink);
    border-color: var(--ink);
}

.filter-count {
    margin-left: auto;
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-faint);
}

/* --------------------------------------------------------------------- grid */

.library-section { padding-block: clamp(2.5rem, 5vw, 4rem); }

.library-section + .library-section { padding-top: 0; }

.library-section-head {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.library-section-head h2 { font-size: clamp(1.5rem, 2.6vw, 2.1rem); }
.library-section-head p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.project-grid {
    display: grid;
    gap: clamp(1.1rem, 2.5vw, 1.9rem);
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
}

.empty-state {
    padding: clamp(2.5rem, 6vw, 4rem);
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: 2px;
    color: var(--text-muted);
}

/* ----------------------------------------------------------------- lightbox */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    background: rgba(16, 14, 10, 0.94);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s var(--ease), visibility 0.35s;
}

@supports (backdrop-filter: blur(1px)) {
    .lightbox { background: rgba(16, 14, 10, 0.86); backdrop-filter: blur(16px); }
}

.lightbox.is-open { opacity: 1; visibility: visible; }

.lightbox-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem clamp(1rem, 4vw, 2.5rem);
    border-bottom: 1px solid var(--line-dark);
    flex: none;
}

.lightbox-bar .meta { min-width: 0; }

.lightbox-bar h2 {
    font-size: clamp(1rem, 2.2vw, 1.4rem);
    color: var(--on-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lightbox-bar .counter {
    margin: 0.2rem 0 0;
    font-size: 0.68rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--on-dark-muted);
}

.icon-btn {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 2.6rem;
    height: 2.6rem;
    color: var(--on-dark);
    background: transparent;
    border: 1px solid var(--line-dark);
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.3s var(--ease), border-color 0.3s var(--ease), background 0.3s var(--ease);
}
.icon-btn svg { width: 1.1rem; height: 1.1rem; }
.icon-btn:hover:not(:disabled) { color: var(--ink); background: var(--on-dark); border-color: var(--on-dark); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.lightbox-close { margin-left: auto; }

.lightbox-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: grid;
    place-items: center;
    padding: clamp(0.75rem, 2.5vw, 1.75rem);
}

.lightbox-stage img,
.lightbox-stage video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}

.lightbox-stage img {
    opacity: 0;
    transition: opacity 0.35s var(--ease);
}
.lightbox-stage img.is-loaded { opacity: 1; }

.stage-spinner {
    position: absolute;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--line-dark);
    border-top-color: var(--gold-bright);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
.stage-spinner[hidden] { display: none; }

@keyframes spin { to { transform: rotate(360deg); } }

/* edge navigation zones on larger screens */
.stage-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    width: clamp(3rem, 12vw, 8rem);
    display: none;
    place-items: center;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--on-dark);
    opacity: 0;
    transition: opacity 0.3s var(--ease);
}
.stage-nav svg { width: 2rem; height: 2rem; }
.stage-nav--prev { left: 0; }
.stage-nav--next { right: 0; }
.stage-nav:disabled { cursor: default; }
.lightbox-stage:hover .stage-nav:not(:disabled) { opacity: 0.75; }
.stage-nav:hover:not(:disabled) { opacity: 1 !important; }

@media (min-width: 48rem) and (hover: hover) {
    .stage-nav { display: grid; }
}

/* filmstrip */
.filmstrip {
    flex: none;
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
    overflow-x: auto;
    border-top: 1px solid var(--line-dark);
    scrollbar-width: thin;
    scrollbar-color: rgba(244, 239, 230, 0.25) transparent;
}

.filmstrip::-webkit-scrollbar { height: 5px; }
.filmstrip::-webkit-scrollbar-thumb { background: rgba(244, 239, 230, 0.25); border-radius: 999px; }

.thumb {
    flex: none;
    position: relative;
    width: 4.5rem;
    aspect-ratio: 4 / 3;
    padding: 0;
    background: rgba(244, 239, 230, 0.08);
    border: 1px solid transparent;
    border-radius: 2px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s var(--ease), border-color 0.3s var(--ease);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb:hover { opacity: 0.85; }
.thumb[aria-current="true"] { opacity: 1; border-color: var(--gold-bright); }

.thumb-video {
    display: grid;
    place-items: center;
    color: var(--gold-bright);
    height: 100%;
}
.thumb-video svg { width: 1.1rem; height: 1.1rem; }

@media (max-width: 47.99rem) {
    .thumb { width: 3.5rem; }
}
