/*!
 * biblioteca.css — Biblioteca Virtual UC
 *
 * Sistema de diseño propio y autocontenido: sin peticiones externas, sin
 * frameworks. Sustituye por completo a style.css (tema "university") y a
 * Bootstrap — esta es la unica hoja de estilos del sitio.
 *
 * Tipografia: Nexa (aportada por la Universidad), convertida a WOFF2 y
 * servida desde ../fonts/nexa/. Ancla de color: el navy del logotipo de la UC.
 */

/* ---------------------------------------------------------------------- */
/* Tipografia — Nexa, autoalojada                                          */
/* ---------------------------------------------------------------------- */

@font-face {
    font-family: "Nexa";
    src: url("../fonts/nexa/NexaBook.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Nexa";
    src: url("../fonts/nexa/NexaBold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "Nexa";
    src: url("../fonts/nexa/NexaBlack.woff2") format("woff2");
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

/* ---------------------------------------------------------------------- */
/* Tokens                                                                   */
/* ---------------------------------------------------------------------- */

:root {
    --ink: #0e2536;
    --ink-2: #143349;
    --ink-3: #1d4560;
    --paper: #ffffff;
    --paper-2: #f3f6f7;
    --teal: #1e8c86;
    --teal-dark: #166b66;
    --teal-glow: rgba(30, 140, 134, 0.25);
    /* Dos variantes del mismo ocre: un solo hex no cumple 4.5:1 sobre blanco
       y sobre navy a la vez.
       --gold-on-dark se mide contra --ink-3 (#1d4560), el extremo CLARO del
       degradado del hero, no contra --ink: ahi es donde el contraste es
       peor. #d99a4e daba 4.19:1 y no llegaba a AA. */
    --gold: #8a5420;
    --gold-on-dark: #e3ab63;
    --line: #d8e1e4;
    --text: #1c2b34;
    --text-soft: #4b5c66;
    --text-on-ink: #eef3f5;
    --text-on-ink-soft: #a9c0cb;

    --font-sans: "Nexa", "Century Gothic", Futura, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    --radius: 8px;
    --radius-lg: 14px;
    --shadow-card: 0 1px 2px rgba(14, 37, 54, 0.06), 0 1px 1px rgba(14, 37, 54, 0.04);
    --shadow-card-hover: 0 10px 28px rgba(14, 37, 54, 0.14), 0 3px 6px rgba(14, 37, 54, 0.08);

    --header-h: 60px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    color-scheme: light;
}

/* ---------------------------------------------------------------------- */
/* Reset                                                                    */
/* ---------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    /* deja libre el header fijo + la barra de filtros pegajosa */
    scroll-padding-top: calc(var(--header-h) + 78px);
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--text);
    font-family: var(--font-sans);
    font-weight: 400;
    font-size: 16.5px;
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

a { color: var(--teal-dark); text-underline-offset: 2px; }
a:hover { color: var(--ink); }

h1, h2, h3, h4 {
    font-weight: 700;
    color: var(--ink);
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin: 0 0 0.5em;
}

p { margin: 0 0 1em; }

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.skip-link {
    position: absolute;
    left: 0.5rem;
    top: -4rem;
    z-index: 100;
    background: var(--paper);
    color: var(--ink);
    padding: 0.7rem 1.1rem;
    border-radius: var(--radius);
    font-weight: 700;
    box-shadow: var(--shadow-card-hover);
    transition: top 0.18s var(--ease-out);
}

.skip-link:focus {
    top: 0.5rem;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 3px solid var(--teal);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ---------------------------------------------------------------------- */
/* Animaciones base                                                         */
/* ---------------------------------------------------------------------- */

@keyframes rise {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
}

@keyframes fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes drift-up {
    from { transform: translateY(0); }
    to   { transform: translateY(-50%); }
}

@keyframes drift-down {
    from { transform: translateY(-50%); }
    to   { transform: translateY(0); }
}

@keyframes pop-count {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.14); }
    100% { transform: scale(1); }
}

/* Entrada escalonada del hero */
.anim-rise { animation: rise 0.7s var(--ease-out) both; }

.anim-rise-1 { animation-delay: 0.05s; }
.anim-rise-2 { animation-delay: 0.15s; }
.anim-rise-3 { animation-delay: 0.25s; }
.anim-rise-4 { animation-delay: 0.35s; }
.anim-rise-5 { animation-delay: 0.45s; }

/* Revelado al hacer scroll (lo activa biblioteca.js) */
/* Condicionado a .js, que un script inline del <head> anade. Si
   biblioteca.js no carga (404, proxy, bloqueador), la clase nunca llega y
   el contenido se queda visible en vez de desaparecer: las 12 secciones del
   directorio usan .reveal, o sea el catalogo entero. */
.js .reveal {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.js .reveal.is-in {
    opacity: 1;
    transform: none;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
    /* Misma especificidad que `.js .reveal`, o este override no gana. */
    .js .reveal { opacity: 1; transform: none; }
    .hero__marquee-track { animation: none !important; }
}

/* ---------------------------------------------------------------------- */
/* Header                                                                   */
/* ---------------------------------------------------------------------- */

.site-header {
    background: var(--ink);
    height: var(--header-h);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}

.site-header .container {
    display: flex;
    align-items: center;
    width: 100%;
}

.site-header__brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--text-on-ink);
    text-decoration: none;
}

.site-header__brand img {
    height: 32px;
    width: 32px;
    border-radius: 5px;
}

.site-header__brand span {
    font-weight: 700;
    font-size: 1.02rem;
}

.site-header__brand:hover { color: #fff; }

/* ---------------------------------------------------------------------- */
/* Hero                                                                     */
/* ---------------------------------------------------------------------- */

.hero {
    position: relative;
    background: linear-gradient(158deg, var(--ink) 0%, var(--ink-2) 55%, var(--ink-3) 100%);
    color: var(--text-on-ink);
    padding: 3.75rem 0 3.25rem;
    overflow: hidden;
}

.hero .container {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 2.5rem;
    align-items: center;
    position: relative;
    z-index: 2;
}

.hero__eyebrow {
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold-on-dark);
    margin-bottom: 1rem;
}

.hero h1 {
    color: #fff;
    font-weight: 900;
    font-size: clamp(2.1rem, 1.3rem + 3.1vw, 3.5rem);
    line-height: 1.04;
    letter-spacing: -0.025em;
    max-width: 15ch;
    margin-bottom: 0.7rem;
}

.hero__lead {
    color: var(--text-on-ink-soft);
    font-size: 1.08rem;
    max-width: 40ch;
    margin-bottom: 1.65rem;
}

/* --- Marquesina de logos: el material real del sujeto ------------------- */

.hero__marquee {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
    height: 360px;
    overflow: hidden;
    /* fundido amplio arriba y abajo: disimula los mosaicos cortados por el
       borde, que es lo que delata una marquesina */
    -webkit-mask-image: linear-gradient(180deg, transparent 2%, #000 26%, #000 74%, transparent 98%);
    mask-image: linear-gradient(180deg, transparent 2%, #000 26%, #000 74%, transparent 98%);
}

.hero__marquee-col { overflow: hidden; }

.hero__marquee-track {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    animation: drift-up 46s linear infinite;
}

.hero__marquee-col:nth-child(2) .hero__marquee-track {
    animation-name: drift-down;
    animation-duration: 58s;
}

.hero__marquee:hover .hero__marquee-track { animation-play-state: paused; }

.hero__chip {
    background: rgba(255, 255, 255, 0.9);
    border-radius: var(--radius);
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 0.9rem;
    flex-shrink: 0;
}

.hero__chip img {
    /* alto uniforme: los logos originales van de 35px a 300px de alto y sin
       esto la columna queda desigual */
    max-height: 34px;
    max-width: 84%;
    width: auto;
    object-fit: contain;
}

/* ---------------------------------------------------------------------- */
/* Buscador                                                                 */
/* ---------------------------------------------------------------------- */

.search {
    position: relative;
    max-width: 30rem;
}

.search__input {
    width: 100%;
    font: inherit;
    font-size: 1rem;
    padding: 0.9rem 2.6rem 0.9rem 2.85rem;
    border-radius: var(--radius);
    border: 2px solid transparent;
    background: rgba(255, 255, 255, 0.97);
    color: var(--text);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.search__input::placeholder { color: var(--text-soft); }
.search__input::-webkit-search-cancel-button { display: none; }

.search__input:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 4px var(--teal-glow);
    outline: none;
}

.search__icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.15rem;
    height: 1.15rem;
    stroke: var(--text-soft);
    fill: none;
    stroke-width: 2;
    pointer-events: none;
}

.search__clear {
    position: absolute;
    right: 0.55rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.9rem;
    height: 1.9rem;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-soft);
    font-family: inherit;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
}

.search__clear:hover { background: var(--paper-2); color: var(--ink); }
.search.has-value .search__clear { display: flex; }

.hero__stats {
    margin-top: 1rem;
    font-size: 0.88rem;
    color: var(--text-on-ink-soft);
}

.hero__stats strong {
    color: var(--gold-on-dark);
    font-weight: 700;
    display: inline-block;
}

.hero__stats strong.is-pop { animation: pop-count 0.4s var(--ease-out); }

/* ---------------------------------------------------------------------- */
/* Cómo empezar                                                             */
/* ---------------------------------------------------------------------- */

.start {
    background: var(--paper-2);
    border-bottom: 1px solid var(--line);
    padding: 3.25rem 0;
}

/* Mientras hay un filtro activo, la introduccion estorba: se aparta para que
   los resultados suban hasta el tope y la barra de filtros pueda fijarse. */
body.is-filtering .start { display: none; }

.start .container {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 3rem;
}

.start h2 { font-size: 1.45rem; margin-bottom: 0.7rem; }
.start__intro p { color: var(--text-soft); font-size: 1.04rem; }

.start__steps {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: step;
}

.start__steps li {
    counter-increment: step;
    position: relative;
    padding-left: 2.6rem;
    margin-bottom: 1.05rem;
}

.start__steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.1rem;
    width: 1.7rem;
    height: 1.7rem;
    border-radius: 50%;
    background: var(--ink);
    color: var(--text-on-ink);
    font-size: 0.82rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.start__steps strong { color: var(--ink); font-weight: 700; }

/* ---------------------------------------------------------------------- */
/* Barra de filtros pegajosa — mantiene el buscador a la vista              */
/* ---------------------------------------------------------------------- */

.toolbar {
    position: sticky;
    top: var(--header-h);
    z-index: 30;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    padding: 0.7rem 0;
}

.toolbar .container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toolbar .search {
    flex: 0 0 20rem;
    max-width: 20rem;
}

.toolbar .search__input {
    background: var(--paper-2);
    border-color: var(--line);
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    font-size: 0.94rem;
}

.toolbar__chips {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
    flex: 1 1 auto;
    /* fundido a la derecha: indica que la fila sigue, en vez de cortar un
       chip a la mitad contra el contador */
    -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent);
    mask-image: linear-gradient(90deg, #000 92%, transparent);
}

.toolbar__chips::-webkit-scrollbar { display: none; }

.chip {
    flex-shrink: 0;
    /* 44px es el objetivo tactil recomendado; el padding solo daba ~29px. */
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--text-soft);
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.chip:hover {
    border-color: var(--teal);
    color: var(--teal-dark);
    transform: translateY(-1px);
}

.chip[aria-pressed="true"] {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.toolbar__count {
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-soft);
    white-space: nowrap;
}

/* ---------------------------------------------------------------------- */
/* Directorio                                                               */
/* ---------------------------------------------------------------------- */

.directory { padding: 2.5rem 0 4rem; }

.directory__group { margin-bottom: 2.75rem; }

.directory__group-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--gold);
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.65rem;
    margin-bottom: 1.75rem;
}

.directory__section { margin-bottom: 2.25rem; }
.directory__section:last-child { margin-bottom: 0; }

.directory__section-title {
    /* 1.32rem frente a los 1.04rem del nombre de tarjeta: 1.27:1. Con 1.22rem
       el salto era de 1.19:1 y los dos niveles se leian como el mismo, que es
       justo lo que la tarjeta dejo de resolver al bajar de h3 a h4. */
    font-size: 1.32rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 1.1rem;
}

.db-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.15rem;
}

.db-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--paper);
    box-shadow: var(--shadow-card);
    transition: box-shadow 0.22s var(--ease-out), transform 0.22s var(--ease-out), border-color 0.22s ease;
}

.db-card:has(a:hover),
.db-card:has(a:focus-visible) {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-4px);
    border-color: rgba(30, 140, 134, 0.4);
}

/* Respaldo donde :has() no exista: el nombre se subraya igual */
.db-card a:hover .db-card__name,
.db-card a:focus-visible .db-card__name {
    text-decoration: underline;
    text-decoration-color: var(--teal);
}

.db-card a {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1.15rem 1.15rem 1rem;
    text-decoration: none;
    color: inherit;
}

.db-card__logo-box {
    height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.9rem;
}

.db-card__logo-box img {
    max-height: 62px;
    max-width: 100%;
    object-fit: contain;
    transition: transform 0.25s var(--ease-out);
}

.db-card a:hover .db-card__logo-box img { transform: scale(1.06); }

.db-card__eyebrow {
    /* 0.72rem = 11.52px. Por debajo de 11px el texto en mayusculas con
       letter-spacing deja de ser comodo de leer. */
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 0.35rem;
}

.db-card__name {
    font-weight: 700;
    font-size: 1.04rem;
    color: var(--ink);
    margin-bottom: 0.35rem;
    line-height: 1.25;
}

.db-card__desc {
    font-size: 0.87rem;
    color: var(--text-soft);
    margin-bottom: 0.9rem;
    flex-grow: 1;
}

.db-card__cta {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--teal-dark);
    border-top: 1px solid var(--line);
    padding-top: 0.7rem;
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.db-card__cta svg {
    width: 0.85rem;
    height: 0.85rem;
    transition: transform 0.25s var(--ease-out);
}

.db-card a:hover .db-card__cta svg { transform: translate(2px, -2px); }

/* Filtrado */
.db-card.is-hidden,
.directory__section.is-hidden,
.directory__group.is-hidden { display: none; }

/* Las tarjetas que sobreviven al filtro entran con un fundido corto */
.db-card.is-match { animation: fade 0.28s var(--ease-out) both; }

.directory__empty {
    display: none;
    text-align: center;
    color: var(--text-soft);
    padding: 3rem 1rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius-lg);
}

.directory__empty.is-visible { display: block; animation: fade 0.3s var(--ease-out) both; }

.directory__empty strong { color: var(--ink); }

/* ---------------------------------------------------------------------- */
/* Pie                                                                      */
/* ---------------------------------------------------------------------- */

.site-footer {
    background: var(--ink);
    color: var(--text-on-ink-soft);
    padding: 1.85rem 0;
    font-size: 0.9rem;
}

.site-footer .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-footer__links {
    display: flex;
    align-items: center;
    gap: 1.4rem;
}

.site-footer a { color: var(--text-on-ink-soft); text-decoration: none; }
.site-footer a:hover { color: #fff; }

.site-footer__social svg {
    width: 1.15rem;
    height: 1.15rem;
    fill: currentColor;
    transition: transform 0.2s var(--ease-out);
}

.site-footer__social:hover svg { transform: translateY(-2px); }

.back-to-top {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------------------------------------------------------------------- */
/* Responsive                                                               */
/* ---------------------------------------------------------------------- */

@media (max-width: 1040px) {
    .db-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
    .hero .container { grid-template-columns: 1fr; }
    .hero__marquee { display: none; }
    .hero h1 { max-width: 100%; }
    .start .container { grid-template-columns: 1fr; gap: 2rem; }
    .db-grid { grid-template-columns: repeat(2, 1fr); }
    .toolbar .container { flex-wrap: wrap; }
    .toolbar .search { flex: 1 1 100%; max-width: 100%; }
    .toolbar__count { order: 3; }
}

@media (max-width: 560px) {
    body { font-size: 16px; }
    .hero { padding: 2.5rem 0 2.25rem; }
    .db-grid { grid-template-columns: 1fr; }
    .site-footer .container { flex-direction: column; align-items: flex-start; }
}
