/*
 * Jaminan lintas tema untuk halaman OPAC:
 * kolom kiri (Total katalog s.d. Kota terbit) tetap sticky di semua tema,
 * termasuk tema ekstensi yang berkas CSS-nya berada di luar repo.
 * Dimuat setelah CSS tema sehingga nilainya bisa ditimpa per tema.
 */
.opac-content-grid {
    --opac-sticky-top: 88px;
    --opac-sticky-gap: 16px;
    display: grid !important;
    grid-template-columns: 250px minmax(0, 1fr) !important;
    gap: 16px !important;
    align-items: start !important;
}

/* Specificity dibuat lebih tinggi dari CSS tema (termasuk tema ekstensi)
   agar kolom kiri tetap sticky di semua tema. */
html body[data-theme] .opac-content-grid > .opac-filter-sidebar,
html body[data-theme] .opac-content-grid > aside:first-child,
html body[data-theme] .opac-filter-sidebar {
    position: -webkit-sticky !important;
    position: sticky !important;
    top: var(--opac-sticky-top) !important;
    align-self: start !important;
    height: auto !important;
    max-height: calc(100vh - var(--opac-sticky-top) - var(--opac-sticky-gap)) !important;
    max-height: calc(100dvh - var(--opac-sticky-top) - var(--opac-sticky-gap)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: contain;
    scrollbar-width: thin;
    z-index: 2;
}

/* Leluhur yang menjadi kontainer gulir mematikan position: sticky.
   Kelas ini dipasang oleh assets/js/pages/opac/index.js saat terdeteksi. */
.opac-sticky-unlock {
    overflow: visible !important;
}

.opac-filter-sidebar {
    min-width: 0;
}

/* Peramban tanpa position: sticky — kolom tetap tampil utuh */
@supports not (position: sticky) {
    html body[data-theme] .opac-content-grid > .opac-filter-sidebar,
    html body[data-theme] .opac-content-grid > aside:first-child,
    html body[data-theme] .opac-filter-sidebar {
        position: static !important;
        max-height: none !important;
        overflow: visible !important;
    }
}

/* Layar kecil: kolom kiri ditumpuk, tidak sticky */
@media (max-width: 991.98px) {
    .opac-content-grid {
        grid-template-columns: 1fr !important;
    }

    html body[data-theme] .opac-content-grid > .opac-filter-sidebar,
    html body[data-theme] .opac-content-grid > aside:first-child,
    html body[data-theme] .opac-filter-sidebar {
        position: static !important;
        max-height: none !important;
        overflow: visible !important;
    }
}