/**
 * Página Biblioteca — alinhado a padrões públicos (não inventar do zero):
 * - Material Design 3 — Cards (variante outlined, hierarquia título / texto de apoio / trailing):
 *   https://m3.material.io/components/cards/guidelines
 * - UMN Libraries Design System — tipos Coleção + Guia (secção com resumo + acesso explícito):
 *   https://umnlibraries.github.io/design-system/content/tools/patterns.html
 * - Hubs de recursos: lista escaneável em coluna única em vez de grelha ornamental.
 */

.agni-library-page {
    --agni-lib-max: 42rem;
    --agni-lib-catalog-max: min(40rem, 100%);
}

.agni-library-hero {
    padding: clamp(1.5rem, 3.5vw, 2.5rem) 0 clamp(1.25rem, 2.5vw, 1.75rem);
    background: var(--color-bg, #fff);
    border-bottom: 1px solid var(--color-border, rgb(0 0 0 / 0.1));
}

.has-light-text .agni-library-hero {
    border-bottom-color: rgb(255 255 255 / 0.12);
}

.agni-library-hero-inner {
    max-width: min(var(--agni-lib-max), 100%);
    margin-inline: auto;
}

.agni-library-eyebrow {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.55));
}

.has-light-text .agni-library-eyebrow {
    color: rgb(255 255 255 / 0.65);
}

.agni-library-title {
    margin: 0 0 0.75rem;
    font-size: clamp(1.85rem, 4.5vw, 2.5rem);
    line-height: 1.12;
    letter-spacing: -0.03em;
    max-width: 22ch;
}

.agni-library-dek {
    margin: 0;
    max-width: 36rem;
    font-size: clamp(1.05rem, 2vw, 1.125rem);
    line-height: 1.65;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.68));
}

.has-light-text .agni-library-dek {
    color: rgb(255 255 255 / 0.75);
}

.agni-library-hero-cover {
    margin-top: clamp(1.25rem, 3vw, 2rem);
}

.agni-library-cover {
    margin: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--color-border, rgb(0 0 0 / 0.1));
}

.has-light-text .agni-library-cover {
    border-color: rgb(255 255 255 / 0.14);
}

.agni-library-cover img {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: middle;
}

.agni-library-cover-caption {
    margin: 0;
    padding: 0.65rem 1rem 0;
    font-size: 0.875rem;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.6));
}

.has-light-text .agni-library-cover-caption {
    color: rgb(255 255 255 / 0.65);
}

.agni-library-sheet {
    padding-block: clamp(1.75rem, 4vw, 2.75rem);
}

/* Medida de leitura própria da biblioteca (não herdar conflitos com outros layouts) */
body.page-template .agni-library-page .agni-library-body.gh-content {
    max-width: var(--agni-lib-max);
    margin-left: auto;
    margin-right: auto;
    font-size: 1.0625rem;
    line-height: 1.78;
}

body.page-template .agni-library-page .agni-library-body.gh-content > p {
    margin-bottom: 1.35em;
}

body.page-template .agni-library-page .agni-library-body.gh-content > h2,
body.page-template .agni-library-page .agni-library-body.gh-content > h3,
body.page-template .agni-library-page .agni-library-body.gh-content > h4 {
    margin-top: 2.15em;
    margin-bottom: 0.6em;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

body.page-template .agni-library-page .agni-library-body.gh-content > h2 {
    font-size: clamp(1.25rem, 2.5vw, 1.45rem);
    padding-bottom: 0.35em;
    border-bottom: 1px solid var(--color-border, rgb(0 0 0 / 0.1));
}

.has-light-text body.page-template .agni-library-page .agni-library-body.gh-content > h2 {
    border-bottom-color: rgb(255 255 255 / 0.14);
}

body.page-template .agni-library-page .agni-library-body.gh-content a:not(.kg-bookmark-container):not(.kg-file-card-container) {
    color: var(--agni-brand, #00608a);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

.has-light-text body.page-template .agni-library-page .agni-library-body.gh-content a:not(.kg-bookmark-container):not(.kg-file-card-container) {
    color: var(--agni-brand-2, #73b3f3);
}

body.page-template .agni-library-page .agni-library-body.gh-content .kg-width-wide,
body.page-template .agni-library-page .agni-library-body.gh-content .kg-width-full {
    max-width: none;
}

/* Recursos: cartões de marcador e ficheiro mais legíveis como itens de catálogo */
.agni-library-page .kg-bookmark-card {
    border-radius: 10px;
    border: 1px solid var(--color-border, rgb(0 0 0 / 0.1));
    background: var(--color-bg, #fff);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.has-light-text .agni-library-page .kg-bookmark-card {
    border-color: rgb(255 255 255 / 0.12);
    background: rgb(255 255 255 / 0.04);
}

@media (prefers-reduced-motion: no-preference) {
    .agni-library-page .kg-bookmark-card:hover {
        border-color: color-mix(in srgb, var(--agni-brand, #00608a) 35%, var(--color-border, rgb(0 0 0 / 0.1)));
        box-shadow: 0 6px 20px rgb(0 0 0 / 0.06);
    }

    .has-light-text .agni-library-page .kg-bookmark-card:hover {
        border-color: color-mix(in srgb, var(--agni-brand-2, #73b3f3) 40%, rgb(255 255 255 / 0.12));
        box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
    }
}

.agni-library-page .kg-file-card {
    border-radius: 10px;
    border: 1px solid var(--color-border, rgb(0 0 0 / 0.1));
    background: var(--color-bg, #fff);
}

.has-light-text .agni-library-page .kg-file-card {
    border-color: rgb(255 255 255 / 0.12);
    background: rgb(255 255 255 / 0.04);
}

@media (prefers-reduced-motion: no-preference) {
    .agni-library-page .kg-file-card:hover {
        border-color: color-mix(in srgb, var(--agni-brand, #00608a) 30%, var(--color-border, rgb(0 0 0 / 0.1)));
    }

    .has-light-text .agni-library-page .kg-file-card:hover {
        border-color: color-mix(in srgb, var(--agni-brand-2, #73b3f3) 35%, rgb(255 255 255 / 0.12));
    }
}

.agni-library-page .kg-bookmark-card a.kg-bookmark-container,
.agni-library-page .kg-file-card a.kg-file-card-container {
    border-radius: inherit;
}

/* ——— Catálogo: navegação textual + secções tipo «collection» ——— */

.agni-library-system {
    max-width: var(--agni-lib-catalog-max);
    margin-inline: auto;
    padding: clamp(1.25rem, 3vw, 1.75rem) 0 clamp(0.25rem, 1.5vw, 0.75rem);
    border-bottom: 1px solid var(--color-border, rgb(0 0 0 / 0.08));
}

.has-light-text .agni-library-system {
    border-bottom-color: rgb(255 255 255 / 0.12);
}

.agni-lib-collections-nav {
    margin-bottom: clamp(1.75rem, 3.5vw, 2.5rem);
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border, rgb(0 0 0 / 0.06));
}

.has-light-text .agni-lib-collections-nav {
    border-bottom-color: rgb(255 255 255 / 0.1);
}

.agni-lib-collections-label {
    display: block;
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.55));
}

.has-light-text .agni-lib-collections-label {
    color: rgb(255 255 255 / 0.65);
}

.agni-lib-collections-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.agni-lib-collections-list li {
    display: inline;
}

.agni-lib-collections-list li:not(:last-child)::after {
    content: "·";
    margin: 0 0.5rem;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.35));
}

.agni-lib-collections-list a {
    color: var(--agni-brand, #00608a);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

.has-light-text .agni-lib-collections-list a {
    color: var(--agni-brand-2, #73b3f3);
}

.agni-lib-collections-list a:focus-visible {
    outline: 2px solid var(--agni-brand, #00608a);
    outline-offset: 2px;
}

/* Secção = título + resumo (padrão hub / coleção) */
.agni-lib-collection-section {
    margin-bottom: clamp(2rem, 4vw, 2.5rem);
}

.agni-lib-collection-section:last-child {
    margin-bottom: 0;
}

.agni-lib-collection-head {
    margin-bottom: 1rem;
}

.agni-lib-collection-title {
    margin: 0 0 0.4rem;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.agni-lib-collection-summary {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.68));
}

.has-light-text .agni-lib-collection-summary {
    color: rgb(255 255 255 / 0.74);
}

.agni-lib-collection {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.agni-lib-collection-item {
    margin: 0;
}

/* Cartão outlined, linha horizontal (MD3 + lista escaneável) */
.agni-lib-card {
    margin: 0;
}

.agni-lib-card-link {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 1rem;
    min-height: 5.5rem;
    padding: 0.875rem 1rem;
    text-decoration: none;
    color: inherit;
    background: var(--color-bg, #fff);
    border: 1px solid var(--color-border, rgb(0 0 0 / 0.12));
    border-radius: 12px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.has-light-text .agni-lib-card-link {
    background: rgb(255 255 255 / 0.03);
    border-color: rgb(255 255 255 / 0.14);
}

@media (prefers-reduced-motion: no-preference) {
    .agni-lib-card-link:hover {
        border-color: color-mix(in srgb, var(--agni-brand, #00608a) 28%, var(--color-border, rgb(0 0 0 / 0.12)));
        background: color-mix(in srgb, var(--agni-brand, #00608a) 4%, var(--color-bg, #fff));
    }

    .has-light-text .agni-lib-card-link:hover {
        border-color: color-mix(in srgb, var(--agni-brand-2, #73b3f3) 35%, rgb(255 255 255 / 0.14));
        background: rgb(255 255 255 / 0.06);
    }
}

.agni-lib-card-link:focus-visible {
    outline: 2px solid var(--agni-brand, #00608a);
    outline-offset: 2px;
}

.agni-lib-card-media {
    flex: 0 0 5.5rem;
    width: 5.5rem;
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-border, rgb(0 0 0 / 0.06));
    align-self: center;
}

.has-light-text .agni-lib-card-media {
    background: rgb(255 255 255 / 0.08);
}

.agni-lib-card-img {
    width: 100%;
    aspect-ratio: 16 / 10;
    height: auto;
    object-fit: cover;
    display: block;
}

.agni-lib-card-media-fallback {
    width: 100%;
    aspect-ratio: 16 / 10;
    min-height: 3.25rem;
    background: linear-gradient(
        135deg,
        rgb(0 0 0 / 0.04),
        rgb(0 0 0 / 0.08)
    );
}

.has-light-text .agni-lib-card-media-fallback {
    background: linear-gradient(135deg, rgb(255 255 255 / 0.06), rgb(255 255 255 / 0.1));
}

.agni-lib-card-body {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    min-width: 0;
}

.agni-lib-card-text {
    flex: 1;
    min-width: 0;
}

.agni-lib-card-eyebrow {
    display: block;
    margin: 0 0 0.2rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.55));
}

.has-light-text .agni-lib-card-eyebrow {
    color: rgb(255 255 255 / 0.6);
}

.agni-lib-card-title {
    margin: 0 0 0.25rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.02em;
}

.agni-lib-card-supporting {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.65));
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.has-light-text .agni-lib-card-supporting {
    color: rgb(255 255 255 / 0.7);
}

.agni-lib-card-trailing {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    font-size: 0.8125rem;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.55));
}

.has-light-text .agni-lib-card-trailing {
    color: rgb(255 255 255 / 0.6);
}

.agni-lib-card-meta {
    font-size: 0.8125rem;
}

.agni-lib-card-cta {
    font-weight: 600;
    color: var(--agni-brand, #00608a);
    white-space: nowrap;
}

.has-light-text .agni-lib-card-cta {
    color: var(--agni-brand-2, #73b3f3);
}

@media (max-width: 520px) {
    .agni-lib-card-link {
        flex-direction: column;
        align-items: stretch;
    }

    .agni-lib-card-media {
        width: 100%;
        flex-basis: auto;
    }

    .agni-lib-card-body {
        flex-direction: column;
        align-items: stretch;
    }

    .agni-lib-card-trailing {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* Guia editorial (bloco Koenig) */
.agni-library-editorial-head {
    margin-bottom: clamp(1.25rem, 3vw, 1.75rem);
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--color-border, rgb(0 0 0 / 0.12));
}

.has-light-text .agni-library-editorial-head {
    border-bottom-color: rgb(255 255 255 / 0.14);
}

.agni-library-section-title {
    margin: 0 0 0.4rem;
    font-size: clamp(1.05rem, 2vw, 1.2rem);
    letter-spacing: -0.02em;
}

.agni-library-section-lead {
    margin: 0;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--color-secondary-text, rgb(0 0 0 / 0.65));
}

.has-light-text .agni-library-section-lead {
    color: rgb(255 255 255 / 0.72);
}
