#library {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: clamp(76px, 8vw, 112px) 0;
    background:
        radial-gradient(circle at 90% 8%, rgba(36, 103, 214, 0.22), transparent 30%),
        radial-gradient(circle at 8% 100%, rgba(217, 169, 54, 0.12), transparent 33%),
        var(--navy-950, #071426);
    color: #ffffff;
}

#library::before {
    position: absolute;
    z-index: -1;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 54px 54px;
    content: "";
    mask-image: linear-gradient(to bottom, #000, transparent 88%);
    pointer-events: none;
}

.library-heading {
    display: grid;
    grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.88fr);
    align-items: end;
    gap: clamp(34px, 6vw, 86px);
    margin-bottom: 40px;
}

.library-kicker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--gold-400, #e9bf58);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1em;
    line-height: 1.4;
    text-transform: uppercase;
}

.library-kicker::before {
    width: 28px;
    height: 2px;
    background: currentColor;
    content: "";
}

.library-heading h2 {
    max-width: 730px;
    margin: 0;
    color: #ffffff;
    font-family: Cambria, Georgia, "Times New Roman", serif;
    font-size: clamp(34px, 4vw, 50px);
    letter-spacing: -0.025em;
    line-height: 1.12;
}

.library-heading-copy > p {
    margin: 0 0 19px;
    color: #bdcadd;
    font-size: 16px;
    line-height: 1.75;
}

.library-heading-copy > a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--gold-400, #e9bf58);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
}

.library-heading-copy > a:hover {
    color: #ffe293;
}

.library-heading-copy > a svg {
    width: 17px;
    height: 17px;
    transition: transform 180ms ease;
}

.library-heading-copy > a:hover svg {
    transform: translateX(3px);
}

.library-index {
    display: grid;
    grid-template-columns: auto repeat(3, minmax(0, 1fr));
    align-items: stretch;
    gap: 10px;
    margin-bottom: 22px;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md, 20px);
    background: rgba(255, 255, 255, 0.065);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.library-index-label {
    display: inline-flex;
    align-items: center;
    padding: 10px 17px;
    color: #93a6bf;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.library-index a {
    display: flex;
    min-width: 0;
    min-height: 58px;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.055);
    color: #ffffff;
    text-decoration: none;
    transition: border-color 180ms ease, background-color 180ms ease, transform 180ms ease;
}

.library-index a:hover {
    border-color: rgba(233, 191, 88, 0.42);
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.library-index a span {
    flex: 0 0 auto;
    color: var(--gold-400, #e9bf58);
    font-family: Cambria, Georgia, "Times New Roman", serif;
    font-size: 18px;
    font-weight: 700;
}

.library-index a strong {
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.library-shelves {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.library-shelf {
    min-width: 0;
    padding: 28px;
    scroll-margin-top: 112px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: var(--radius-md, 20px);
    background: rgba(255, 255, 255, 0.97);
    color: var(--slate-900, #172033);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
    transition: box-shadow 180ms ease, transform 180ms ease;
}

.library-shelf:hover {
    box-shadow: 0 30px 74px rgba(0, 0, 0, 0.26);
    transform: translateY(-4px);
}

.library-shelf:target {
    outline: 3px solid var(--gold-400, #e9bf58);
    outline-offset: 4px;
}

.library-shelf-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--slate-200, #e2e8f0);
}

.library-shelf-icon {
    display: inline-flex;
    width: 51px;
    height: 51px;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
}

.library-shelf-icon svg {
    width: 26px;
    height: 26px;
}

.library-shelf-math .library-shelf-icon {
    background: #fff4d5;
    color: #9a7217;
}

.library-shelf-english .library-shelf-icon {
    background: #e5f7ef;
    color: #087a4f;
}

.library-shelf-it .library-shelf-icon {
    background: var(--blue-100, #eaf2ff);
    color: var(--blue-600, #2467d6);
}

.library-shelf-header span:not(.library-shelf-icon) {
    display: block;
    margin-bottom: 2px;
    color: var(--slate-500, #758197);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.library-shelf-header h3 {
    margin: 0;
    color: var(--navy-900, #0b1f3a);
    font-family: Cambria, Georgia, "Times New Roman", serif;
    font-size: clamp(22px, 2vw, 26px);
    line-height: 1.25;
}

.library-shelf-intro {
    min-height: 72px;
    margin: 19px 0 20px;
    color: var(--slate-600, #5d6b80);
    font-size: 13px;
    line-height: 1.7;
}

.library-resource-list {
    display: grid;
    gap: 9px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.library-resource-list li {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 13px;
    border: 1px solid var(--slate-200, #e2e8f0);
    border-radius: 13px;
    background: #f8fafc;
    transition: border-color 180ms ease, background-color 180ms ease;
}

.library-resource-list li:hover {
    border-color: rgba(36, 103, 214, 0.26);
    background: #ffffff;
}

.library-resource-symbol {
    display: inline-flex;
    width: 38px;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--slate-100, #f0f4f8);
    color: var(--navy-700, #1b4675);
    font-family: Cambria, Georgia, "Times New Roman", serif;
    font-size: 11px;
    font-style: normal;
    font-weight: 800;
}

.library-resource-list strong,
.library-resource-list small {
    display: block;
}

.library-resource-list strong {
    margin-bottom: 2px;
    color: var(--navy-900, #0b1f3a);
    font-size: 13px;
    line-height: 1.35;
}

.library-resource-list small {
    color: var(--slate-500, #758197);
    font-size: 10.5px;
    line-height: 1.5;
}

.library-resource-list em {
    padding: 4px 7px;
    border-radius: 999px;
    background: #eef3f9;
    color: var(--slate-600, #5d6b80);
    font-size: 9px;
    font-style: normal;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.library-note {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 17px;
    margin-top: 22px;
    padding: 21px 24px;
    border: 1px solid rgba(233, 191, 88, 0.28);
    border-radius: var(--radius-md, 20px);
    background: rgba(233, 191, 88, 0.08);
}

.library-note-icon {
    display: inline-flex;
    width: 43px;
    height: 43px;
    align-items: center;
    justify-content: center;
    border-radius: 13px;
    background: rgba(233, 191, 88, 0.13);
    color: var(--gold-400, #e9bf58);
}

.library-note-icon svg {
    width: 23px;
    height: 23px;
}

.library-note strong {
    display: block;
    margin-bottom: 2px;
    color: #ffffff;
    font-size: 14px;
}

.library-note p {
    margin: 0;
    color: #afbed1;
    font-size: 12px;
    line-height: 1.6;
}

.library-note > a {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    padding: 9px 15px;
    border: 1px solid rgba(233, 191, 88, 0.45);
    border-radius: 10px;
    color: var(--gold-400, #e9bf58);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    transition: background-color 180ms ease, color 180ms ease;
}

.library-note > a:hover {
    background: var(--gold-400, #e9bf58);
    color: var(--navy-950, #071426);
}

@media (max-width: 1100px) {
    .library-shelves {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .library-shelf:last-child {
        grid-column: 1 / -1;
    }

    .library-shelf-intro {
        min-height: auto;
    }
}

@media (max-width: 900px) {
    .library-heading {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .library-heading-copy {
        max-width: 720px;
    }

    .library-index {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .library-index-label {
        grid-column: 1 / -1;
        padding: 4px 8px 2px;
    }
}

@media (max-width: 720px) {
    #library {
        padding: 68px 0;
    }

    .library-index {
        grid-template-columns: 1fr;
    }

    .library-index-label {
        grid-column: auto;
    }

    .library-index a strong {
        white-space: normal;
    }

    .library-shelves {
        grid-template-columns: 1fr;
    }

    .library-shelf:last-child {
        grid-column: auto;
    }

    .library-note {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .library-note > a {
        grid-column: 1 / -1;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .library-heading {
        margin-bottom: 30px;
    }

    .library-shelf {
        padding: 22px 19px;
        border-radius: 17px;
    }

    .library-resource-list li {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .library-resource-list em {
        grid-column: 2;
        justify-self: start;
    }

    .library-note {
        padding: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .library-heading-copy > a svg,
    .library-index a,
    .library-shelf,
    .library-resource-list li,
    .library-note > a {
        transition: none;
    }

    .library-heading-copy > a:hover svg,
    .library-index a:hover,
    .library-shelf:hover {
        transform: none;
    }
}
