/* =====================
   SIDEBAR SHELL
   ===================== */

.lib-shell {
    display: flex;
    align-items: flex-start;
    width: 100%;
    max-width: 1560px;
    margin: 0 auto;
    text-align: left;
}

.lib-sidebar {
    position: sticky;
    top: 140px; /* below fixed site header (70px) + action bar (70px) */
    flex: 0 0 230px;
    height: calc(100vh - 242px);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: rgba(8, 8, 8, 0.82);
    border: 1px solid rgba(255, 191, 0, 0.12);
    border-radius: 14px;
    margin: 16px 0 16px 16px;
    padding: 12px 10px 16px;
    box-sizing: border-box;
}

.lib-filter-form {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Search pinned to the top of the rail, above the set selectors */
.lib-sidebar-head {
    padding: 2px 6px 14px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 191, 0, 0.08);
}

.lib-nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.lib-nav-group {
    margin-bottom: 6px;
}

.lib-nav-group-label {
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.58rem;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: rgba(240, 236, 230, 0.32);
    padding: 8px 12px 6px;
}

/* Set selectors styled as nav tabs. The checkbox is hidden; its label is the tab. */
.set-cb {
    display: none;
}

.lib-tab {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    box-sizing: border-box; /* label defaults to content-box; keep padding inside the 100% width */
    height: auto; /* override global button height */
    background: transparent;
    border: none;
    border-radius: 9px;
    padding: 10px 12px;
    color: rgba(240, 236, 230, 0.55);
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.78rem;
    letter-spacing: 1.5px;
    cursor: pointer;
    text-align: left;
    user-select: none;
    transition: background 0.2s, color 0.2s;
}

.lib-tab > i:first-child {
    width: 18px;
    text-align: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: color 0.2s;
}

.lib-tab > span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-tab-check {
    margin-left: auto;
    font-size: 0.6rem;
    opacity: 0;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.lib-tab:hover {
    color: rgba(240, 236, 230, 0.9);
    background: rgba(255, 255, 255, 0.04);
}

/* Per-set accent on the leading icon */
.lib-tab-dragons > i:first-child { color: #ff7043; }
.lib-tab-gemini  > i:first-child { color: #ab8ee8; }

/* Checked (active) state — set-flavoured tint + visible check */
.set-cb:checked + .lib-tab {
    color: #f4f0ea;
}

.set-cb:checked + .lib-tab .lib-tab-check {
    opacity: 1;
}

.set-cb:checked + .lib-tab-dragons {
    background: rgba(255, 112, 67, 0.16);
    box-shadow: inset 0 0 0 1px rgba(255, 112, 67, 0.4);
}

.set-cb:checked + .lib-tab-dragons .lib-tab-check { color: #ff7043; }

.set-cb:checked + .lib-tab-gemini {
    background: rgba(171, 142, 232, 0.16);
    box-shadow: inset 0 0 0 1px rgba(171, 142, 232, 0.4);
}

.set-cb:checked + .lib-tab-gemini .lib-tab-check { color: #ab8ee8; }

/* =====================
   SEARCH INPUT
   ===================== */

.lib-search-wrap {
    display: flex;
    gap: 0;
    width: 100%;
}

.lib-search-input {
    flex: 1;
    min-width: 0;
    background: rgba(8, 8, 8, 0.7);
    border: 1px solid rgba(255, 191, 0, 0.12);
    border-right: none;
    border-radius: 10px 0 0 10px;
    padding: 10px 14px;
    color: #f0ece6;
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.8rem;
    letter-spacing: 1px;
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.lib-search-input::placeholder {
    color: rgba(240, 236, 230, 0.3);
}

.lib-search-input:focus {
    border-color: rgba(255, 191, 0, 0.35);
}

.lib-search-btn {
    background: rgba(255, 191, 0, 0.15);
    border: 1px solid rgba(255, 191, 0, 0.12);
    border-radius: 0 10px 10px 0;
    padding: 10px 15px;
    color: #ffbf00;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 0.85rem;
    height: auto;
}

.lib-search-btn:hover {
    background: rgba(255, 191, 0, 0.25);
}

/* =====================
   CONTENT COLUMN + TOP BAR
   ===================== */

.lib-content-col {
    flex: 1;
    min-width: 0;
}

.lib-topbar {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 18px 24px 0;
    box-sizing: border-box;
}

.lib-results {
    font-family: 'HwyGothic', Arial, sans-serif;
    font-size: 0.68rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: rgba(240, 236, 230, 0.4);
    white-space: nowrap;
}

.lib-page {
    padding: 18px 14px 80px;
}

/* =====================
   CARD GRID
   ===================== */

.card-grid {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0 10px;
    margin: 0;
    justify-content: center;
    gap: 14px;
}

/* Staggered entrance — JS sets --i per tile (capped), no-JS falls back to 0. */
.card-grid li {
    animation: lib-card-in 0.45s ease both;
    animation-delay: calc(var(--i, 0) * 18ms);
}

@keyframes lib-card-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

/* Tile: 3D tilt driven by --rx/--ry (set by mousemove JS), with lift + zoom
   folded into the same transform so hover and tilt compose cleanly. */
.card-grid li a {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
    padding: 8px 8px 7px;
    margin: 0;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: linear-gradient(180deg, rgba(28, 24, 16, 0.65), rgba(10, 9, 7, 0.85));
    transform: perspective(700px)
               rotateX(var(--rx, 0deg))
               rotateY(var(--ry, 0deg))
               translateY(var(--lift, 0px))
               scale(var(--zoom, 1));
    transition: transform 0.18s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    will-change: transform;
}

.card-grid li a:hover {
    --lift: -8px;
    --zoom: 1.045;
    z-index: 2;
}

/* Set-flavored hover glows: DRAGONS burns ember, GEMINI shimmers violet. */
.card-grid li a.lib-set-dragons:hover {
    border-color: rgba(255, 112, 67, 0.5);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.6), 0 0 26px rgba(255, 112, 67, 0.22);
}

.card-grid li a.lib-set-gemini:hover {
    border-color: rgba(171, 142, 232, 0.5);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.6), 0 0 26px rgba(171, 142, 232, 0.25);
}

/* Glare that follows the cursor across the card face. */
.card-grid li a::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    background: radial-gradient(circle at var(--gx, 50%) var(--gy, 50%),
        rgba(255, 255, 255, 0.16), transparent 55%);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.card-grid li a:hover::after {
    opacity: 1;
}

.card-grid li img {
    width: 175px;
    height: 245px;
    border-radius: 8px;
    object-fit: cover;
    display: block;
}

.card-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 7px;
    font-size: 0.75rem;
    font-family: 'HwyGothic', Arial, sans-serif;
    letter-spacing: 0.5px;
    color: #e8e4de;
    max-width: 175px;
    text-align: center;
}

.card-num {
    background: rgba(255, 191, 0, 0.12);
    border: 1px solid rgba(255, 191, 0, 0.25);
    color: #ffbf00;
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 0.62rem;
    line-height: 1.4;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.card-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.card-grid li a:hover .card-name {
    color: #ffbf00;
}

/* =====================
   EMPTY STATE
   ===================== */

.library-empty {
    width: 100%;
    text-align: center;
    padding: 60px 20px 80px;
    color: rgba(240, 236, 230, 0.4);
    font-family: 'HwyGothic', Arial, sans-serif;
}

.library-empty i {
    font-size: 2.2rem;
    color: rgba(255, 191, 0, 0.3);
    margin-bottom: 12px;
    display: block;
}

.library-empty p {
    margin: 0;
    font-size: 0.9rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* =====================
   RESPONSIVE: sidebar becomes a wrapping chip bar
   ===================== */

@media only screen and (max-width: 1024px), only screen and (hover: none) {
    .lib-shell {
        flex-direction: column;
    }

    .lib-sidebar {
        position: static;
        flex: none;
        width: auto;
        height: auto;
        overflow: visible;
        margin: 12px 12px 0;
        padding: 12px 12px 14px;
    }

    .lib-filter-form {
        display: block;
    }

    .lib-sidebar-head {
        padding: 0 0 10px;
        margin-bottom: 10px;
    }

    .lib-nav {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 6px;
    }

    .lib-nav-group {
        display: contents;
    }

    .lib-nav-group-label {
        display: none;
    }

    .lib-tab {
        width: auto;
        flex: 0 0 auto;
        white-space: nowrap;
        border: 1px solid rgba(255, 191, 0, 0.18);
        border-radius: 999px;
        padding: 7px 14px;
    }

    .lib-tab > i:first-child {
        width: auto;
    }

    .lib-topbar {
        padding: 14px 12px 0;
        justify-content: center;
    }

    .lib-page {
        padding: 12px 0 60px;
    }
}

/* Narrow phones: 2-column card grid filling screen width */
@media only screen and (max-width: 767px), only screen and (hover: none) {
    .card-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 4px 12px 40px;
    }

    .card-grid li a {
        width: 100%;
        box-sizing: border-box;
    }

    .card-grid li img {
        width: 100%;
        height: auto;
        aspect-ratio: 5 / 7;
    }

    .card-label {
        max-width: 100%;
        font-size: 0.68rem;
        padding: 3px 8px;
    }
}
