/* ==========================================================================
   IIEDM · Estilos base: reset ligero y aspecto de los elementos HTML.
   Solo usa las variables de tokens.css (nunca colores ni tamaños sueltos).
   ========================================================================== */

@layer base {
    /* ---- Reset ligero ---- */
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    * {
        margin: 0;
    }

    html {
        /* La web es clara: los campos y barras del navegador no se oscurecen
           aunque el sistema esté en modo oscuro. */
        color-scheme: light;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
        scroll-padding-top: calc(var(--alto-cabecera) + var(--e-2));
        scrollbar-color: rgba(43, 22, 48, .35) var(--fondo);
    }

    @media (prefers-reduced-motion: no-preference) {
        html {
            scroll-behavior: smooth;
        }
    }

    body {
        min-height: 100vh;
        background: var(--fondo);
        color: var(--c-texto);
        font-family: var(--f-texto);
        font-size: var(--t-cuerpo);
        font-weight: 400;
        line-height: var(--interlineado);
        /* Nunca negrita ni cursiva «de imitación»: solo las que traen las fuentes. */
        font-synthesis: none;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        caret-color: var(--acento);
        accent-color: var(--acento);
    }

    img,
    picture,
    svg,
    video {
        display: block;
        max-width: 100%;
    }

    img,
    video {
        height: auto;
    }

    input,
    button,
    textarea,
    select {
        font: inherit;
        color: inherit;
    }

    /* Palabras largas («psicoprofilaxis») no rompen el ancho del móvil. */
    p,
    li,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        overflow-wrap: break-word;
    }

    p {
        text-wrap: pretty;
    }

    ul[class],
    ol[class] {
        list-style: none;
        padding: 0;
    }

    table {
        border-collapse: collapse;
        font-variant-numeric: tabular-nums lining-nums;
    }

    /* ---- Títulos: Fraunces, pesos ligeros y tracking negativo ---- */
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        color: var(--c-titulo);
        font-family: var(--f-titulos);
        font-optical-sizing: auto;
        font-weight: 350;
        line-height: 1.1;
        letter-spacing: -0.02em;
        text-wrap: balance;
    }

    h1 {
        font-size: var(--t-titulo-pagina);
        font-weight: 320;
        line-height: 1.05;
        letter-spacing: -0.03em;
    }

    h2 {
        font-size: var(--t-h2);
        font-weight: 330;
        letter-spacing: -0.025em;
    }

    h3 {
        font-size: var(--t-h3);
        font-weight: 380;
        line-height: 1.15;
    }

    h4,
    h5,
    h6 {
        font-size: var(--t-h4);
        font-weight: 420;
        line-height: 1.2;
        letter-spacing: -0.01em;
    }

    /* Palabras clave de los títulos: cursiva en el color de énfasis
       (acento sobre claro, rubor sobre oscuro). */
    :is(h1, h2, h3, h4, h5, h6, .titulo-hero) :is(em, i) {
        font-family: inherit;
        font-size: inherit;
        font-style: italic;
        font-weight: inherit;
        line-height: inherit;
        color: var(--c-enfasis);
    }

    /* Cursiva dentro del texto: Figtree no tiene cursiva (no se descarga), así
       que se usa la cursiva de Fraunces, que ya está en la página por los
       títulos. Al 106,25 % su «x» mide lo mismo que la de Figtree (0,47 frente
       a 0,50 del cuerpo), y con line-height: 1 no separa las líneas. */
    :is(em, i, cite, dfn) {
        font-family: var(--f-titulos);
        font-size: 1.0625em;
        font-style: italic;
        font-weight: 400;
        line-height: 1;
    }

    strong,
    b {
        font-weight: 600;
        color: var(--c-titulo);
    }

    small {
        font-size: var(--t-pequeno);
    }

    /* ---- Enlaces ---- */
    a {
        color: var(--c-enlace);
        text-decoration-line: underline;
        text-decoration-thickness: 1px;
        text-underline-offset: 0.22em;
        transition:
            color var(--dur-rapida) var(--curva),
            text-decoration-thickness var(--dur-rapida) var(--curva);
    }

    a:hover {
        color: var(--c-enlace-hover);
        text-decoration-thickness: 2px;
    }

    /* ---- Foco visible: solo al navegar con teclado ---- */
    :focus-visible {
        outline: 2px solid var(--c-foco);
        outline-offset: 3px;
    }

    :focus:not(:focus-visible) {
        outline: none;
    }

    /* ---- Selección de texto: rubor con tinta (9,28:1) ---- */
    ::selection {
        background: var(--rubor);
        color: var(--tinta);
    }

    /* ---- Movimiento reducido: sin animaciones ni transiciones ---- */
    @media (prefers-reduced-motion: reduce) {
        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
            scroll-behavior: auto !important;
        }
    }
}
