/* =========================================================
   LIBRARY NAVIGATION
   Standalone blocks — no .library-nav-sticky wrapper
   ========================================================= */

/* Search block */
.library-nav-search,
.library-nav-filters-wrap {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.library-nav-search {
    padding: 28px 12px 8px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    background: var(--bs-body-bg);
    position: relative;
    margin-top: -20px;
    z-index: 1;
}

/* Filters wrapper */
.library-nav-filters-wrap {
    padding: 0 12px 10px;
    overflow: visible;
}


/* =========================================================
   SEARCH AREA
   Full width
   ========================================================= */

.library-nav-search {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}


/* Search form */
#library_search_form {
    width: 100%;
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
}


/* Search input wrapper */
.library-search-input-wrap {
    position: relative;
    width: 100%;
}


/* Search input */
.library-nav-search input#library_search_input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;

    border-radius: 999px;

    /* Extra right space for search icon */
    padding: 8px 44px 8px 14px;

    font-size: 14px;
    box-shadow: none;
}


/* =========================================================
   SEARCH ICON
   Search button is inside the search field
   ========================================================= */

.library-search-submit {
    position: absolute;

    top: 50%;
    right: 6px;

    transform: translateY(-50%);

    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;
    background: transparent;

    border-radius: 50%;

    cursor: pointer;

    z-index: 2;
}


/* Icon */
.library-search-submit i {
    font-size: 15px;
    line-height: 1;
}


/* =========================================================
   FILTERS
   Desktop = use the full available width
   Mobile = horizontally scroll if necessary
   ========================================================= */

.library-nav-filters {
    display: flex;
    align-items: center;

    gap: 10px;

    width: 100%;
    max-width: 100%;
    min-width: 0;

    padding-top: 10px;

    box-sizing: border-box;

    /* Prevent the entire page from becoming wider */
    overflow-x: auto;
    overflow-y: hidden;

    white-space: nowrap;

    scrollbar-width: none;
    -ms-overflow-style: none;

    flex-wrap: nowrap;
}

.library-nav-filters::-webkit-scrollbar {
    display: none;
}


/* =========================================================
   FILTER CONTROLS
   Desktop controls grow and fill the available space
   ========================================================= */

.library-nav-filters .form-select,
.library-nav-filters input {
    min-height: 38px;
    height: 38px;

    padding: 6px 14px;

    font-size: 13px;

    border-radius: 999px;

    box-shadow: none;

    box-sizing: border-box;
}


/* Institution */
#library_filter_institution {
    flex: 1 1 0;
    width: 0;
    min-width: 150px;
}


/* Program */
.library-nav-filters .position-relative:has(#library_filter_program) {
    flex: 1 1 0;
    width: 0;
    min-width: 150px;
}


/* Course */
.library-nav-filters .position-relative:has(#library_filter_course) {
    flex: 1 1 0;
    width: 0;
    min-width: 150px;
}


/* Material type */
#library_filter_material_type {
    flex: 1 1 0;
    width: 0;
    min-width: 150px;
}


/* Program / Course inputs */
#library_filter_program,
#library_filter_course {
    width: 100% !important;
    min-width: 0;
}


/* =========================================================
   DROPDOWN LISTS
   ========================================================= */

#library_filter_program_list,
#library_filter_course_list {
    max-width: calc(100vw - 24px);
}


/* =========================================================
   NAV LINKS
   True top-level sticky tabs
   ========================================================= */

.library-nav-tabs {
    display: flex;
    align-items: center;

    width: 100%;
    max-width: 100%;
    min-width: 0;

    gap: 8px;

    padding: 8px 12px 12px;

    box-sizing: border-box;

    overflow-x: auto;
    overflow-y: hidden;

    white-space: nowrap;

    -webkit-overflow-scrolling: touch;

    scrollbar-width: none;
    -ms-overflow-style: none;

    flex-wrap: nowrap;

    /* True top-level sticky navigation */
    position: sticky;
    top: 0;
    z-index: 60;

    /* Opaque background so content does not show through */
    background: var(--bs-body-bg);
}

.library-nav-tabs::-webkit-scrollbar {
    display: none;
}


/* =========================================================
   NAV BUTTONS
   Default / mobile behavior
   ========================================================= */

.library-nav-tabs .btn {
    flex: 0 0 auto;

    padding: 6px 14px;

    font-size: 13px;
    border-radius: 999px;

    white-space: nowrap;
    text-align: center;
}


/* Normal category buttons */
.library-nav-tabs .btn-gray {
    border: 0;
}


/* Active button */
.library-nav-tabs .btn-primary {
    border: 0;
}


/* Add button */
.library-nav-tabs .library-nav-add {
    flex: 0 0 auto;

    padding: 6px 14px;

    font-size: 13px;

    white-space: nowrap;
    text-align: center;
}


/* =========================================================
   DESKTOP
   Filters + navigation expand to full available width
   ========================================================= */

@media (min-width: 992px) {

    /* -----------------------------------------------------
       Search
       ----------------------------------------------------- */

    .library-nav-search {
        width: 100%;

        padding-left: 12px;
        padding-right: 12px;
    }


    /* -----------------------------------------------------
       Filters
       ----------------------------------------------------- */

    .library-nav-filters {
        width: 100%;
        max-width: 100%;

        /*
         * Allow all four filters to use the available width.
         */
        overflow-x: visible;
        overflow-y: visible;

        white-space: normal;

        flex-wrap: nowrap;
    }


    /* -----------------------------------------------------
       Navigation links
       ----------------------------------------------------- */

    .library-nav-tabs {
        width: 100%;
        max-width: 100%;

        padding-left: 12px;
        padding-right: 12px;

        /*
         * No horizontal scrolling on desktop.
         */
        overflow-x: visible;
        overflow-y: visible;

        white-space: normal;

        flex-wrap: nowrap;

        position: sticky;
        top: 0;
        z-index: 60;
        background: var(--bs-body-bg);
    }


    /* -----------------------------------------------------
       Make every navigation button share the width
       ----------------------------------------------------- */

    .library-nav-tabs .btn,
    .library-nav-tabs .library-nav-add {
        flex: 1 1 0;

        width: auto;
        min-width: 0;

        padding-left: 10px;
        padding-right: 10px;

        text-align: center;
    }

}


/* =========================================================
   MOBILE
   Keep page fixed to viewport
   ========================================================= */

@media (max-width: 991.98px) {

    html,
    body {
        max-width: 100%;
        overflow-x: visible;
    }


    .library-nav-search {
        max-width: 100vw;
    }


    #library_search_form {
        max-width: 100%;
    }


    /* -----------------------------------------------------
       Mobile filters
       ----------------------------------------------------- */

    .library-nav-filters {
        max-width: 100%;

        overflow-x: auto;
        overflow-y: visible;

        white-space: nowrap;

        flex-wrap: nowrap;
    }




    /*
     * Keep mobile filters at a comfortable width
     * instead of shrinking them too much.
     */

    #library_filter_institution,
    #library_filter_material_type,
    .library-nav-filters .position-relative:has(#library_filter_program),
    .library-nav-filters .position-relative:has(#library_filter_course) {

        flex: 0 0 auto;

        width: auto;

        min-width: 150px;
    }


    #library_filter_program,
    #library_filter_course {
        width: 100% !important;
    }


    /* -----------------------------------------------------
       Mobile navigation
       ----------------------------------------------------- */

    .library-nav-tabs {
        max-width: 100%;

        overflow-x: auto;
        overflow-y: hidden;

        white-space: nowrap;

        flex-wrap: nowrap;

        position: sticky;
        top: 0;
        z-index: 60;
        background: var(--bs-body-bg);
    }


    /*
     * On mobile the buttons return to their natural size.
     * User can swipe across them.
     */

    .library-nav-tabs .btn,
    .library-nav-tabs .library-nav-add {
        flex: 0 0 auto;

        width: auto;

        min-width: max-content;

        padding-left: 14px;
        padding-right: 14px;
    }

}


/* =========================================================
   LIBRARY TRENDING
   Full width + transparent background
   ========================================================= */

.library-trending-strip {
    width: 100%;
    max-width: 100%;
    margin-bottom: 10px;
    margin-top: 10px;

    padding: 12px;

    box-sizing: border-box;

    background-color: transparent;

    overflow: hidden;
}


/* =========================================================
   TRENDING HEADER
   ========================================================= */

.library-trending-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    width: 100%;
    max-width: 100%;
}


/* "See All" — pill, no underline */
.library-trending-seeall {
    text-decoration: none !important;
    border: 1px solid var(--bs-border-color);
    color: var(--bs-body-color);
    background: transparent;
    padding: 4px 14px;
}

.library-trending-seeall:hover {
    text-decoration: none !important;
    background: var(--bs-tertiary-bg, rgba(0, 0, 0, 0.04));
}


/* =========================================================
   TRENDING ITEMS
   ========================================================= */

.library-trending-items {
    display: flex;
    align-items: stretch;

    width: 100%;
    max-width: 100%;
    min-width: 0;

    gap: 10px;

    overflow-x: auto;
    overflow-y: hidden;

    padding-bottom: 4px;

    box-sizing: border-box;

    scrollbar-width: none;
    -ms-overflow-style: none;

    -webkit-overflow-scrolling: touch;
}

.library-trending-items::-webkit-scrollbar {
    display: none;
}


/* =========================================================
   TRENDING CARD
   Default/mobile size
   ========================================================= */

.library-thumb-card {
    flex: 0 0 150px;

    width: 150px;
    min-width: 150px;
    max-width: 150px;

    box-sizing: border-box;

    color: inherit;
}


/* =========================================================
   THUMBNAIL
   Soft tinted background instead of a flat border
   ========================================================= */

.library-thumb-icon {
    position: relative;

    width: 100%;
    height: 100px;

    box-sizing: border-box;

    border-radius: 0.6rem;

    background: color-mix(in srgb, var(--bs-primary) 8%, transparent);
    border: none;

    color: var(--bs-primary);
}

.library-thumb-icon svg {
    width: 36px;
    height: 36px;
}


/* Extension badge — small pill instead of loose muted text */
.library-thumb-icon .library-thumb-ext {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);

    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;

    color: var(--bs-primary);
    background: var(--bs-body-bg);

    border-radius: 999px;
    padding: 1px 8px;
}


/* =========================================================
   TRENDING TITLE — centered
   ========================================================= */

.library-thumb-card .text-truncate {
    display: block;

    width: 100%;
    max-width: 100%;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    text-align: center;
}


/* =========================================================
   LOCKED BADGE
   ========================================================= */

.library-thumb-card .badge {
    display: inline-block;
    margin-top: 2px;
}


/* =========================================================
   DESKTOP
   Cards expand across available width
   ========================================================= */

@media (min-width: 992px) {

    .library-trending-strip {
        width: 100%;
        max-width: 100%;

        padding-left: 12px;
        padding-right: 12px;
    }


    .library-trending-items {
        width: 100%;
        max-width: 100%;

        overflow-x: visible;

        flex-wrap: nowrap;
    }


    /*
     * IMPORTANT:
     * Cards now share the full desktop width.
     */

    .library-thumb-card {
        flex: 1 1 0;

        width: auto;
        min-width: 0;
        max-width: none;

        box-sizing: border-box;
    }


    .library-thumb-icon {
        width: 100%;
        height: 120px;
    }

}


/* =========================================================
   MOBILE
   Cards remain swipeable
   ========================================================= */

@media (max-width: 991.98px) {

    .library-trending-strip {
        width: 100%;
        max-width: 100vw;

        overflow: hidden;
    }


    .library-trending-items {
        width: 100%;
        max-width: 100%;

        overflow-x: auto;
        overflow-y: hidden;

        flex-wrap: nowrap;
    }


    .library-thumb-card {
        flex: 0 0 150px;

        width: 150px;
        min-width: 150px;
        max-width: 150px;
    }

}


/* =========================================================
   EXTRA SAFETY
   ========================================================= */

.library-trending-strip *,
.library-trending-strip *::before,
.library-trending-strip *::after {
    box-sizing: border-box;
}


/* =========================================================
   LIBRARY HERO
   ========================================================= */

.library-hero {
    width: 100%;
    height: 530px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    display: flex;
    align-items: flex-end;
}

.library-hero-overlay {
    width: 100%;
    padding: 20px 16px 30px;
    background: linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0));
    color: #fff;
}

.library-hero-title {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.library-hero-subtitle {
    font-size: 1.1rem;
    margin: 4px 0 0;
    opacity: 0.9;
}

@media (max-width: 576px) {
    .library-hero {
        height: 410px;
    }

    .library-hero-title {
        font-size: 1.9rem;
    }
}


/* =========================================================
   STICKER
   ========================================================= */

.sticker12 {
    z-index: 200 !important;
    background-color: transparent;
}


/* =========================================================
   LIBRARY POST CARD
   ========================================================= */

.library-post-wrap {
    margin: 0.75rem 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
    overflow: visible;
}

.library-card {
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.library-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.library-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--bs-body-color);

    flex: 1 1 auto;
    min-width: 0;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-card-title-muted {
    color: var(--bs-secondary-color);
    font-weight: 500;
}

.library-card-badges {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.library-card-badge {
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;

    color: var(--bs-primary);
    border: 1px solid var(--bs-primary);

    border-radius: 4px;

    padding: 0.15rem 0.65rem;

    white-space: nowrap;
}


/* Downloaded badge */
.library-card-badge-downloaded {
    color: #fff;
    background-color: #198754;
    border-color: #198754;
}


.library-card-rows {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.library-card-row {
    display: flex;
    gap: 0.5rem;
    font-size: 0.82rem;
}

.library-card-label {
    width: 90px;
    flex-shrink: 0;
    color: var(--bs-secondary-color);
}

.library-card-value {
    color: var(--bs-body-color);
}

.library-card-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
    font-size: 0.8rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--bs-border-color);
}

.library-card-link {
    color: var(--bs-primary);
    font-weight: 500;
    text-decoration: none;
}

.library-card-link:hover {
    text-decoration: underline;
}

.library-card-link-danger {
    color: var(--bs-danger);
}

.library-card-status {
    color: var(--bs-secondary-color);
}


/* =========================================================
   DESCRIPTION
   ========================================================= */

.library-card-description {
    margin: 0;
    font-size: 0.82rem;
    color: var(--bs-body-color);
    line-height: 1.4;
}

.library-card-row-description {
    margin-top: 0.35rem;
}

.library-card-description-block {
    margin-top: 0.5rem;
}

.library-card-description-block .library-card-label {
    display: block;
    width: auto;
    margin-bottom: 0.2rem;
}


/* =========================================================
   MOBILE LIBRARY CARD
   ========================================================= */

@media (max-width: 576px) {

    .library-post-wrap {
        margin: 0.6rem 0.75rem;
    }

    .library-card {
        padding: 0.7rem 0.85rem;
    }

    .library-card-label {
        width: 76px;
    }

}




#library_filter_program_list,
#library_filter_course_list {
    max-height: 240px;
    overflow-y: auto;
}


