/* Estilos compartidos de las páginas internas — Matemáticas para Todos */
:root {
    --ink: #0B2545;          /* azul tinta: textos y footer */
    --brand: #0066CC;        /* azul de marca */
    --brand-deep: #003D7A;   /* azul profundo del hero */
    --sky: #4DB3FF;          /* acento claro */
    --paper: #F3F6FA;        /* fondo de secciones alternas */
    --line: #DCE3EC;         /* bordes finos */
    --text: #22313F;
    --muted: #5B6B7B;
    --white: #FFFFFF;
    --nav-h: 72px;
    --radius: 10px;
    --font-head: 'Sora', 'Segoe UI', system-ui, sans-serif;
    --font-body: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 12px); }

body {
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.65;
    color: var(--text);
    background: var(--white);
    -webkit-font-smoothing: antialiased;
}

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

:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; border-radius: 4px; }

.wrap { width: min(1180px, 100% - 2.5rem); margin-inline: auto; }

/* ============ NAVEGACIÓN ============ */
.site-nav {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--nav-h);
    z-index: 100;
    transition: background-color .3s ease, box-shadow .3s ease, color .3s ease;
    color: var(--white);
}

.site-nav.scrolled {
    background: rgba(255, 255, 255, .97);
    backdrop-filter: saturate(160%) blur(10px);
    box-shadow: 0 1px 0 var(--line), 0 6px 24px rgba(11, 37, 69, .06);
    color: var(--ink);
}

.nav-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    text-decoration: none;
    min-width: 0;
}

.brand img { height: 44px; width: auto; object-fit: contain; }

.brand-mark {
    width: 38px; height: 38px;
    flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 9px;
    background: var(--white);
    color: var(--brand);
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 1.3rem;
    transition: background-color .3s ease, color .3s ease;
}

.site-nav.scrolled .brand-mark { background: var(--brand); color: var(--white); }

.brand-name {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.08rem;
    letter-spacing: -.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: .25rem;
    list-style: none;
}

.nav-links > li { position: relative; }

.nav-link {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .55rem .9rem;
    font: 500 .98rem var(--font-body);
    color: inherit;
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
    position: relative;
    opacity: .88;
    transition: opacity .2s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    left: .9rem; right: .9rem; bottom: .25rem;
    height: 2px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .25s ease;
}

.nav-link:hover, .nav-link.is-active { opacity: 1; }
.nav-link:hover::after, .nav-link.is-active::after { transform: scaleX(1); }
.site-nav.scrolled .nav-link.is-active { color: var(--brand); }

.chev { width: 10px; height: 10px; transition: transform .25s ease; }
.has-menu.open .chev { transform: rotate(180deg); }

/* Panel desplegable de enlaces */
.menu-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 360px;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--white);
    color: var(--text);
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(11, 37, 69, .18), 0 0 0 1px var(--line);
    padding: .5rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
}

.menu-panel::before { /* puente para que el hover no se pierda */
    content: '';
    position: absolute;
    inset: -12px 0 auto 0;
    height: 12px;
}

.has-menu.open .menu-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.menu-panel a {
    display: block;
    padding: .7rem .85rem;
    border-radius: 8px;
    text-decoration: none;
    transition: background-color .15s ease;
}

.menu-panel a:hover, .menu-panel a:focus-visible { background: var(--paper); }

.menu-panel strong {
    display: block;
    font-weight: 600;
    color: var(--ink);
    font-size: .98rem;
}

.menu-panel small {
    display: block;
    color: var(--muted);
    font-size: .86rem;
    line-height: 1.4;
    margin-top: .1rem;
}

.nav-cta {
    display: inline-flex;
    align-items: center;
    padding: .6rem 1.15rem;
    border-radius: 8px;
    font: 600 .95rem var(--font-body);
    text-decoration: none;
    background: var(--white);
    color: var(--brand);
    white-space: nowrap;
    transition: background-color .2s ease, color .2s ease;
}

.site-nav.scrolled .nav-cta { background: var(--brand); color: var(--white); }
.site-nav.scrolled .nav-cta:hover { background: var(--brand-deep); }

.menu-toggle {
    display: none;
    width: 44px; height: 44px;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    border-radius: 8px;
    position: relative;
}

.menu-toggle span {
    position: absolute;
    left: 11px; right: 11px;
    height: 2px;
    background: currentColor;
    border-radius: 2px;
}

.menu-toggle span:nth-child(1) { top: 15px; }
.menu-toggle span:nth-child(2) { top: 21px; }
.menu-toggle span:nth-child(3) { top: 27px; }

/* Cajón lateral para celulares */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 37, 69, .45);
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s ease, visibility .3s;
    z-index: 190;
}

.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(86vw, 360px);
    background: var(--white);
    color: var(--text);
    z-index: 200;
    transform: translateX(100%);
    transition: transform .32s cubic-bezier(.2, .8, .2, 1), visibility .32s;
    display: flex;
    flex-direction: column;
    visibility: hidden;
}

body.drawer-open .drawer {
    transform: translateX(0);
    visibility: visible;
    box-shadow: -10px 0 40px rgba(11, 37, 69, .2);
}
body.drawer-open .drawer-backdrop { opacity: 1; visibility: visible; }

.drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}

.drawer-close {
    width: 40px; height: 40px;
    border: 0;
    background: var(--paper);
    border-radius: 8px;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--ink);
    cursor: pointer;
}

.drawer-body { overflow-y: auto; padding: .5rem 0 1.5rem; flex: 1; }

.drawer-link, .drawer-acc {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.5rem;
    font: 500 1.08rem var(--font-body);
    color: var(--ink);
    text-decoration: none;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    text-align: left;
}

.drawer-link.is-active { color: var(--brand); font-weight: 600; }

.drawer-sub {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .3s ease;
    background: var(--paper);
}

.drawer-sub > div { overflow: hidden; }
.drawer-acc[aria-expanded="true"] + .drawer-sub { grid-template-rows: 1fr; }
.drawer-acc[aria-expanded="true"] .chev { transform: rotate(180deg); }

.drawer-sub a {
    display: block;
    padding: .8rem 1.5rem .8rem 2.25rem;
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.drawer-sub strong { display: block; font-weight: 600; color: var(--ink); }
.drawer-sub small { color: var(--muted); font-size: .88rem; }

.drawer-foot { padding: 1.25rem 1.5rem; border-top: 1px solid var(--line); }

.drawer-foot .btn { width: 100%; justify-content: center; }

/* ============ BOTONES ============ */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    padding: .95rem 1.75rem;
    border-radius: 999px;
    font: 600 1rem var(--font-body);
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    overflow: hidden;
    transition: transform .25s ease, box-shadow .25s ease, background-color .25s ease, color .25s ease, border-color .25s ease;
}

.btn svg { width: 18px; height: 18px; transition: transform .25s ease; }
.btn:hover svg { transform: translateX(4px); }

.btn-light { background: var(--white); color: var(--brand); box-shadow: 0 10px 30px rgba(0, 25, 60, .25); }
.btn-light:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(0, 25, 60, .35); }

.btn-light::after { /* destello que cruza el botón */
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -60%;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgba(0, 102, 204, .18), transparent);
    transform: skewX(-20deg);
    animation: shine 4s ease-in-out infinite 2.5s;
}

@keyframes shine { 0%, 60% { left: -60%; } 100% { left: 130%; } }

.btn-ghost { border-color: rgba(255, 255, 255, .55); color: var(--white); backdrop-filter: blur(4px); }
.btn-ghost:hover { background: rgba(255, 255, 255, .14); border-color: var(--white); transform: translateY(-2px); }

.btn-primary { background: var(--brand); color: var(--white); box-shadow: 0 10px 26px rgba(0, 102, 204, .28); }
.btn-primary:hover { background: var(--brand-deep); transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0, 61, 122, .32); }

/* ============ SECCIONES ============ */
.section { position: relative; padding: clamp(4.5rem, 9vw, 7rem) 0; }
.section-alt { background: var(--paper); }

.section-head {
    text-align: center;
    max-width: 680px;
    margin: 0 auto 3.5rem;
}

.section-symbol {
    display: inline-grid;
    place-items: center;
    width: 52px; height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand), var(--brand-deep));
    color: #fff;
    font-family: var(--font-head);
    font-size: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 10px 24px rgba(0, 102, 204, .3);
}

.section-head h2 {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: clamp(1.9rem, 3.8vw, 2.75rem);
    line-height: 1.12;
    letter-spacing: -.025em;
    color: var(--ink);
}

.section-head .bar {
    width: 0;
    height: 4px;
    border-radius: 4px;
    margin: 1.1rem auto 1.1rem;
    background: linear-gradient(90deg, var(--brand), var(--sky));
    transition: width .9s cubic-bezier(.2, .8, .2, 1) .3s;
}

.section-head.in .bar { width: 72px; }

.section-head p { color: var(--muted); font-size: 1.1rem; }

.section-cta { text-align: center; margin-top: 3.25rem; }

.empty {
    padding: 2.5rem;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
}

/* Aparición al hacer scroll */
.js [data-reveal] {
    opacity: 0;
    transform: translateY(36px);
    transition: opacity .8s cubic-bezier(.2, .8, .2, 1), transform .8s cubic-bezier(.2, .8, .2, 1);
    transition-delay: calc(var(--d, 0) * 110ms);
}

.js [data-reveal].in { opacity: 1; transform: none; }

/* ---------- Libros ---------- */
.libros-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(1.5rem, 4vw, 3.5rem);
    max-width: 1040px;
    margin: 0 auto;
}

.libro { display: flex; flex-direction: column; align-items: center; text-align: center; }

.cover-stage { perspective: 900px; width: 100%; margin-bottom: 1.5rem; }

.cover {
    position: relative;
    aspect-ratio: 3 / 4;
    border-radius: 4px 12px 12px 4px;
    overflow: hidden;
    background: linear-gradient(150deg, var(--brand), var(--brand-deep));
    box-shadow: 0 2px 4px rgba(11, 37, 69, .1), 0 20px 40px rgba(11, 37, 69, .18);
    transform-style: preserve-3d;
    transition: transform .5s cubic-bezier(.2, .8, .2, 1), box-shadow .5s ease;
    will-change: transform;
}

.cover::before { /* lomo */
    content: '';
    position: absolute;
    inset: 0 auto 0 0;
    width: 14px;
    background: linear-gradient(to right, rgba(0, 0, 0, .25), rgba(255, 255, 255, .14) 60%, transparent);
    z-index: 3;
}

.cover .glare { /* reflejo que sigue al cursor */
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: radial-gradient(circle at var(--gx, 50%) var(--gy, 0%), rgba(255, 255, 255, .35), transparent 55%);
    opacity: 0;
    transition: opacity .4s ease;
}

.libro:hover .cover { box-shadow: 0 4px 8px rgba(11, 37, 69, .1), 0 30px 60px rgba(11, 37, 69, .28); }
.libro:hover .cover .glare { opacity: 1; }

.cover img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; }

.cover-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    text-align: left;
    padding: 1.5rem 1.5rem 1.75rem 2rem;
    color: var(--white);
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.3rem;
    line-height: 1.2;
}

.cover-fallback span { font-size: 3.5rem; opacity: .35; margin-bottom: auto; }

.libro h3 {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.2rem;
    line-height: 1.3;
    color: var(--ink);
    margin-bottom: .45rem;
}

.libro p {
    color: var(--muted);
    font-size: .98rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 1rem;
    max-width: 34ch;
}

.text-link {
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-weight: 600;
    color: var(--brand);
    text-decoration: none;
    position: relative;
    padding-bottom: 3px;
}

.text-link::after {
    content: '';
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 2px;
    background: currentColor;
    transform: scaleX(.3);
    transform-origin: left;
    transition: transform .3s ease;
}

.text-link:hover::after, a:hover > .text-link::after { transform: scaleX(1); }

/* ---------- Blog ---------- */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.post {
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-radius: 18px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 1px 0 var(--line), 0 10px 30px rgba(11, 37, 69, .06);
    transition: transform .4s cubic-bezier(.2, .8, .2, 1), box-shadow .4s ease;
}

.post:hover { transform: translateY(-8px); box-shadow: 0 1px 0 var(--line), 0 24px 50px rgba(11, 37, 69, .14); }

.post .thumb {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: linear-gradient(135deg, var(--brand), var(--brand-deep));
}

.post .thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .7s cubic-bezier(.2, .8, .2, 1); }
.post:hover .thumb img { transform: scale(1.08); }

.thumb-symbol {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: rgba(255, 255, 255, .35);
    font-family: var(--font-head);
    font-size: 4.5rem;
    transition: transform .7s cubic-bezier(.2, .8, .2, 1);
}

.post:hover .thumb-symbol { transform: scale(1.15) rotate(-8deg); }

.post .body { display: flex; flex-direction: column; flex: 1; padding: 1.4rem 1.4rem 1.6rem; }

.post-date { font-size: .88rem; color: var(--brand); font-weight: 600; margin-bottom: .45rem; }

.post h3 {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.32;
    color: var(--ink);
    margin-bottom: .5rem;
}

.post p {
    color: var(--muted);
    font-size: .95rem;
    margin-bottom: 1.1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post .text-link { align-self: flex-start; }

/* ---------- Herramientas ---------- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.tool {
    --angle: 0deg;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2.25rem 1.5rem 2rem;
    border-radius: 18px;
    text-decoration: none;
    background: var(--white);
    border: 1px solid var(--line);
    transition: transform .4s cubic-bezier(.2, .8, .2, 1), box-shadow .4s ease, border-color .4s ease;
}

.tool:hover {
    transform: translateY(-8px);
    border-color: transparent;
    box-shadow: 0 0 0 2px var(--brand), 0 24px 50px rgba(0, 102, 204, .16);
}

.tool-icon {
    position: relative;
    width: 76px; height: 76px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #E6F2FF, #CFE5FB);
    font-size: 2.1rem;
    margin-bottom: 1.4rem;
    transition: transform .5s cubic-bezier(.2, .8, .2, 1);
}

.tool-icon::after { /* anillo que gira al pasar el cursor */
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px dashed rgba(0, 102, 204, .45);
    opacity: 0;
    transition: opacity .3s ease;
}

.tool:hover .tool-icon { transform: scale(1.08); }
.tool:hover .tool-icon::after { opacity: 1; animation: spin 6s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.tool-icon img { width: 40px; height: 40px; object-fit: contain; }

.tool h3 {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1.12rem;
    color: var(--ink);
    margin-bottom: .45rem;
}

.tool p { color: var(--muted); font-size: .96rem; flex: 1; margin-bottom: 1.25rem; }

/* ============ FOOTER ============ */
.site-footer {
    background: var(--ink);
    color: rgba(255, 255, 255, .78);
    padding: 4rem 0 2rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 2.5rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.footer-brand .brand { color: var(--white); margin-bottom: 1rem; }
.footer-brand .brand-mark { background: var(--brand); color: var(--white); }
.footer-brand p { max-width: 36ch; }

.site-footer h4 {
    font-family: var(--font-head);
    font-weight: 600;
    font-size: 1rem;
    color: var(--white);
    margin-bottom: 1rem;
}

.site-footer ul { list-style: none; }
.site-footer li + li { margin-top: .55rem; }
.site-footer ul a { text-decoration: none; transition: color .2s ease; }
.site-footer ul a:hover { color: var(--white); }

.footer-bottom {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 1.5rem;
    font-size: .92rem;
}


/* ============ ENCABEZADO DE PÁGINAS INTERNAS ============ */
.page-hero {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    text-align: center;
    color: var(--white);
    padding: calc(var(--nav-h) + 3.5rem) 0 clamp(5.5rem, 10vw, 8rem);
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
}

.page-hero canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.page-hero .aurora {
    position: absolute;
    width: 40vw; height: 40vw;
    border-radius: 50%;
    background: #2F9BFF;
    filter: blur(80px);
    opacity: .45;
    top: -20vw; left: 10vw;
    z-index: 0;
    pointer-events: none;
    animation: drift 20s ease-in-out infinite alternate;
}

@keyframes drift { to { transform: translate(30vw, 6vw) scale(1.2); } }

.page-hero .wrap { position: relative; z-index: 2; }

.crumbs {
    display: flex;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: .5rem;
    font-size: .92rem;
    padding: .4rem 1rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    backdrop-filter: blur(6px);
    margin-bottom: 1.5rem;
    animation: fadeUp .7s ease both .1s;
}

.crumbs a { color: rgba(255, 255, 255, .85); text-decoration: none; }
.crumbs a:hover { color: #fff; text-decoration: underline; }
.crumbs span[aria-current] { color: #fff; font-weight: 600; }

.page-symbol {
    display: inline-grid;
    place-items: center;
    width: 64px; height: 64px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .14);
    border: 1px solid rgba(255, 255, 255, .25);
    font-family: var(--font-head);
    font-size: 2rem;
    margin: 0 auto 1.25rem;
    animation: popIn .8s cubic-bezier(.2, .8, .2, 1) both .2s;
}

.page-hero h1 {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: clamp(2.1rem, 5.2vw, 3.6rem);
    line-height: 1.08;
    letter-spacing: -.025em;
    max-width: 22ch;
    margin: 0 auto 1rem;
    text-wrap: balance;
    text-shadow: 0 6px 30px rgba(0, 25, 60, .3);
    animation: blurIn .9s cubic-bezier(.2, .8, .2, 1) both .3s;
}

.page-hero .lead {
    font-size: clamp(1.05rem, 1.8vw, 1.25rem);
    max-width: 52ch;
    margin: 0 auto;
    opacity: .9;
    animation: fadeUp .8s ease both .5s;
}

.page-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .6rem;
    margin-top: 1.5rem;
    animation: fadeUp .8s ease both .6s;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    font-size: .92rem;
    font-weight: 500;
}

.chip svg { width: 16px; height: 16px; }

.page-wave {
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    width: 100%;
    height: clamp(40px, 6vw, 90px);
    z-index: 2;
    display: block;
}

@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes blurIn { from { opacity: 0; filter: blur(12px); transform: translateY(30px); } to { opacity: 1; filter: none; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.5) rotate(-20deg); } to { opacity: 1; transform: none; } }

/* ============ BARRA DE BÚSQUEDA ============ */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.search {
    position: relative;
    flex: 1;
    max-width: 440px;
}

.search svg {
    position: absolute;
    left: 16px; top: 50%;
    width: 18px; height: 18px;
    transform: translateY(-50%);
    color: #8796A8;
    pointer-events: none;
}

.search input {
    width: 100%;
    height: 50px;
    padding: 0 1rem 0 2.9rem;
    font: 400 1rem var(--font-body);
    color: var(--text);
    background: var(--white);
    border: 1.5px solid var(--line);
    border-radius: 999px;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.search input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(0, 102, 204, .12);
}

.count { color: var(--muted); font-size: .98rem; }
.count strong { color: var(--ink); }

.no-results {
    display: none;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}

.no-results.show { display: block; }
.no-results strong { display: block; color: var(--ink); font-size: 1.15rem; margin-bottom: .3rem; }

.is-hidden { display: none !important; }

.back-row { text-align: center; margin-top: 3.5rem; }

.btn-outline { border-color: var(--line); color: var(--ink); background: var(--white); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-2px); }
.btn-outline svg { transform: rotate(180deg); }
.btn-outline:hover svg { transform: rotate(180deg) translateX(4px); }

.page-section { padding: clamp(3rem, 6vw, 4.5rem) 0 clamp(4rem, 8vw, 6rem); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
    .blog-grid, .tools-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .nav-links, .nav-cta { display: none; }
    .menu-toggle { display: block; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
    :root { --nav-h: 64px; }
    .brand-name { font-size: .98rem; }

    .toolbar { flex-direction: column; align-items: stretch; }
    .search { max-width: none; }

    .libros-grid { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
    .blog-grid { grid-template-columns: 1fr; }
    .tools-grid { grid-template-columns: 1fr; gap: 1rem; }

    .libro h3 { font-size: 1.02rem; }
    .libro p { -webkit-line-clamp: 2; font-size: .92rem; }
    .cover-fallback { font-size: 1rem; padding: 1rem 1rem 1.1rem 1.4rem; }
    .cover-fallback span { font-size: 2.4rem; }

    .post { flex-direction: row; border-radius: 14px; }
    .post .thumb { aspect-ratio: auto; width: 34%; flex-shrink: 0; }
    .thumb-symbol { font-size: 2.6rem; }
    .post .body { padding: 1rem 1.1rem 1.1rem; }
    .post p { -webkit-line-clamp: 2; margin-bottom: .6rem; }

    .tool { flex-direction: row; text-align: left; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
    .tool-icon { width: 56px; height: 56px; font-size: 1.6rem; margin: 0; flex-shrink: 0; }
    .tool p { margin: 0; }
    .tool .text-link { display: none; }

    .footer-grid { grid-template-columns: 1fr; }
    .footer-bottom { flex-direction: column; }
}

@media (hover: none) {
    .post:hover, .tool:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0s !important;
        transition-duration: .01ms !important;
        transition-delay: 0s !important;
    }
    .aurora { display: none; }
}

/* ============ EXTRAS DE LISTADOS ============ */
.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;
}

.page-section.section-alt { background: var(--paper); }

.blog-grid-page { grid-template-columns: repeat(3, 1fr); gap: 1.75rem; }

.post-featured { grid-column: 1 / -1; flex-direction: row; }
.post-featured .thumb { width: 55%; aspect-ratio: auto; min-height: 340px; flex-shrink: 0; }
.post-featured .body { padding: clamp(1.75rem, 3vw, 2.75rem); justify-content: center; }
.post-featured h3 { font-size: clamp(1.4rem, 2.4vw, 2rem); line-height: 1.2; margin-bottom: .8rem; }
.post-featured p { font-size: 1.05rem; -webkit-line-clamp: 4; }
.post-featured .thumb-symbol { font-size: 8rem; }

.badge {
    align-self: flex-start;
    display: inline-block;
    padding: .3rem .75rem;
    border-radius: 999px;
    background: #E6F2FF;
    color: var(--brand);
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: .9rem;
}

@media (max-width: 1100px) {
    .blog-grid-page { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .blog-grid-page { grid-template-columns: 1fr; gap: 1rem; }
    .post-featured { flex-direction: column; }
    .post-featured .thumb { width: 100%; min-height: 0; aspect-ratio: 16 / 9; }
    .post-featured .body { padding: 1.4rem; }
    .post-featured .thumb-symbol { font-size: 5rem; }
}

/* Libros centrados aunque la última fila esté incompleta */
.page-section .libros-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    --g: clamp(1.5rem, 4vw, 3.5rem);
    gap: var(--g);
}

.page-section .libros-grid > .libro { width: calc((100% - 2 * var(--g)) / 3); }

@media (max-width: 768px) {
    .page-section .libros-grid { --g: 1.25rem; }
    .page-section .libros-grid > .libro { width: calc((100% - var(--g)) / 2); }
}


/* Menú compacto en pantallas medianas (evita que se parta en dos líneas) */
.nav-link { white-space: nowrap; }

@media (min-width: 901px) and (max-width: 1140px) {
    .nav-cta { display: none; }
    .nav-link { padding: .55rem .7rem; }
    .nav-link::after { left: .7rem; right: .7rem; }
}
