/* Carpetas por categoría (material de ayuda). Al pasar el cursor se abre y se asoman los libros. */
.carpetas { list-style: none; margin: 0 auto; padding: clamp(16px, 3vw, 32px) var(--gutter) 80px; max-width: 1180px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); gap: clamp(20px, 3vw, 36px); }
.carpeta {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  min-height: 330px; padding: 28px 20px 26px; border-radius: 22px; background: #fffdf8; border: 1px solid var(--filete);
  perspective: 1200px; isolation: isolate;
  transition: transform .7s cubic-bezier(.16, 1, .3, 1), box-shadow .7s cubic-bezier(.16, 1, .3, 1), border-color .4s;
}
.carpeta:hover, .carpeta.abierta { transform: scale(1.03) rotate(-1.2deg); box-shadow: 0 30px 50px -22px rgba(60, 45, 20, .45); border-color: var(--repisa); }
.carpeta-link { position: absolute; inset: 0; z-index: 5; border-radius: inherit; }
.carpeta-link:focus-visible { outline: 2px solid var(--tinta); outline-offset: 4px; }
.carpeta-brillo { position: absolute; inset: 0; z-index: -1; border-radius: inherit; opacity: 0; transition: opacity .7s;
  background: radial-gradient(circle at 50% 62%, var(--pasta) 0%, transparent 68%); }
.carpeta:hover .carpeta-brillo, .carpeta.abierta .carpeta-brillo { opacity: .14; }

/* Arte de la carpeta */
.carpeta-arte { position: relative; width: 210px; height: 180px; margin-bottom: 18px; display: grid; place-items: center; }
.c-atras, .c-frente, .c-reflejo { position: absolute; width: 140px; height: 102px; border-radius: 12px; transform-origin: bottom center;
  transition: transform .7s cubic-bezier(.16, 1, .3, 1); }
.c-atras { z-index: 1; background: linear-gradient(135deg, color-mix(in srgb, var(--pasta) 78%, #000), var(--pasta)); box-shadow: 0 4px 10px rgba(0,0,0,.12); }
.c-pestana { position: absolute; z-index: 1; width: 50px; height: 16px; border-radius: 7px 7px 0 0; top: calc(50% - 51px - 13px); left: calc(50% - 70px + 14px);
  background: color-mix(in srgb, var(--pasta) 78%, #000); transform-origin: bottom center; transition: transform .7s cubic-bezier(.16, 1, .3, 1); }
.c-frente { z-index: 30; top: calc(50% - 51px + 5px); border: 1px solid rgba(255,255,255,.18);
  background: linear-gradient(135deg, color-mix(in srgb, var(--pasta) 82%, #fff), var(--pasta)); box-shadow: 0 10px 22px -8px rgba(0,0,0,.35); }
.c-reflejo { z-index: 31; top: calc(50% - 51px + 5px); pointer-events: none; background: linear-gradient(135deg, rgba(255,255,255,.38) 0%, transparent 60%); }
.c-cv { position: absolute; z-index: 32; top: calc(50% + 20px); font-weight: 800; font-size: .8rem; letter-spacing: .06em; color: var(--tinta); opacity: .7;
  transform-origin: 50% -30px; transition: transform .7s cubic-bezier(.16, 1, .3, 1); }
.carpeta:hover .c-atras, .carpeta.abierta .c-atras { transform: rotateX(-20deg) scaleY(1.05); }
.carpeta:hover .c-pestana, .carpeta.abierta .c-pestana { transform: rotateX(-30deg) translateY(-3px); }
.carpeta:hover .c-frente, .carpeta:hover .c-reflejo, .carpeta.abierta .c-frente, .carpeta.abierta .c-reflejo { transform: rotateX(35deg) translateY(12px); }
.carpeta:hover .c-cv, .carpeta.abierta .c-cv { transform: rotateX(35deg) translateY(10px); }

/* Libros que se asoman */
.c-hojas { position: absolute; z-index: 20; top: 50%; left: 50%; width: 0; height: 0; }
.c-hoja { position: absolute; left: -33px; top: -46px; width: 66px; height: 92px; z-index: 10; display: block; border-radius: 7px; overflow: hidden;
  background: var(--pasta); color: var(--tinta); text-decoration: none; box-shadow: 0 8px 18px -6px rgba(0,0,0,.4);
  transform: translate(0, 0) rotate(0) scale(.4); opacity: 0;
  transition: transform .7s cubic-bezier(.16, 1, .3, 1), opacity .5s, box-shadow .4s; }
.c-hoja img { width: 100%; height: 100%; object-fit: cover; }
.c-hoja-t { position: absolute; inset: auto 6px 6px; font-size: 8.5px; line-height: 1.15; font-weight: 800; text-transform: uppercase; letter-spacing: -.01em;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.c-hoja.con-img .c-hoja-t { color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.c-hoja.con-img::after { content: ''; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.75), transparent 60%); }
.c-hoja.con-img .c-hoja-t { z-index: 1; }
.c-hoja::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: rgba(0,0,0,.18); z-index: 1; }
.carpeta:hover .c-hoja, .carpeta.abierta .c-hoja { opacity: 1; }
.c-hoja.d1 { transition-delay: 50ms; } .c-hoja.d2 { transition-delay: 100ms; } .c-hoja.d3 { transition-delay: 150ms; } .c-hoja.d4 { transition-delay: 200ms; }
.c-hojas .h1-0 { z-index: 10; } .c-hojas .d1 { z-index: 11; } .c-hojas .d2 { z-index: 12; } .c-hojas .d3 { z-index: 13; } .c-hojas .d4 { z-index: 14; }
.carpeta .c-hoja:hover, .carpeta .c-hoja:focus-visible { z-index: 40; box-shadow: 0 0 0 2px #fff, 0 18px 30px -8px rgba(0,0,0,.5); }
.carpeta.abierta .h1-0, .carpeta:hover .h1-0 { transform: translate(0px, -96px) rotate(0deg) scale(1); }
.carpeta.abierta .h2-0, .carpeta:hover .h2-0 { transform: translate(-85px, -84px) rotate(-25deg) scale(1); }
.carpeta.abierta .h2-1, .carpeta:hover .h2-1 { transform: translate(85px, -84px) rotate(25deg) scale(1); }
.carpeta.abierta .h3-0, .carpeta:hover .h3-0 { transform: translate(-85px, -84px) rotate(-25deg) scale(1); }
.carpeta.abierta .h3-1, .carpeta:hover .h3-1 { transform: translate(0px, -96px) rotate(0deg) scale(1); }
.carpeta.abierta .h3-2, .carpeta:hover .h3-2 { transform: translate(85px, -84px) rotate(25deg) scale(1); }
.carpeta.abierta .h4-0, .carpeta:hover .h4-0 { transform: translate(-85px, -84px) rotate(-25deg) scale(1); }
.carpeta.abierta .h4-1, .carpeta:hover .h4-1 { transform: translate(-28px, -92px) rotate(-8deg) scale(1); }
.carpeta.abierta .h4-2, .carpeta:hover .h4-2 { transform: translate(28px, -92px) rotate(8deg) scale(1); }
.carpeta.abierta .h4-3, .carpeta:hover .h4-3 { transform: translate(85px, -84px) rotate(25deg) scale(1); }
.carpeta.abierta .h5-0, .carpeta:hover .h5-0 { transform: translate(-85px, -84px) rotate(-25deg) scale(1); }
.carpeta.abierta .h5-1, .carpeta:hover .h5-1 { transform: translate(-42px, -90px) rotate(-12deg) scale(1); }
.carpeta.abierta .h5-2, .carpeta:hover .h5-2 { transform: translate(0px, -96px) rotate(0deg) scale(1); }
.carpeta.abierta .h5-3, .carpeta:hover .h5-3 { transform: translate(42px, -90px) rotate(12deg) scale(1); }
.carpeta.abierta .h5-4, .carpeta:hover .h5-4 { transform: translate(85px, -84px) rotate(25deg) scale(1); }
/* Al pasar sobre un libro, sube un poco */
.carpeta:hover .c-hoja:hover { translate: 0 -10px; scale: 1.15; }

/* Texto */
.carpeta-nombre { position: relative; z-index: 4; text-align: center; transition: transform .5s; }
.carpeta-nombre h2 { font-size: 1.25rem; margin: 0 0 .15em; }
.carpeta-nombre p { margin: 0; font-size: .9rem; color: var(--tinta-3); }
.carpeta:hover .carpeta-nombre { transform: translateY(2px); }
.carpeta-pista { position: absolute; z-index: 4; bottom: 10px; left: 0; right: 0; text-align: center; font-size: .7rem; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase; color: var(--tinta-3); opacity: .6; transition: opacity .4s, transform .4s; }
.carpeta:hover .carpeta-pista, .carpeta.abierta .carpeta-pista { opacity: 0; transform: translateY(8px); }

/* Encabezado de una carpeta abierta */
.cat-head { max-width: 1180px; margin: 0 auto; padding: clamp(24px, 5vw, 56px) var(--gutter) 0; }
.cat-head h1 { font-size: clamp(2.2rem, 7vw, 4.2rem); margin: 10px 0 .2em; }
.cat-head p { color: var(--tinta-2); margin: 0; }
.cat-volver { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; text-decoration: none; padding: 8px 14px 8px 10px;
  border-radius: 999px; margin-left: -10px; }
.cat-volver:hover { background: var(--papel-2); }
.cat-head + .librero { animation: entra .6s cubic-bezier(.16, 1, .3, 1) both; }
.carpetas > li { animation: entra .7s cubic-bezier(.16, 1, .3, 1) both; }
.carpetas > li:nth-child(2) { animation-delay: .08s; } .carpetas > li:nth-child(3) { animation-delay: .16s; }
.carpetas > li:nth-child(4) { animation-delay: .24s; } .carpetas > li:nth-child(n+5) { animation-delay: .3s; }
@keyframes entra { from { opacity: 0; transform: translateY(24px); } }

@media (prefers-reduced-motion: reduce) {
  .carpeta, .carpeta *, .carpetas > li, .cat-head + .librero { transition: none !important; animation: none !important; }
}
/* Solo el enlace de la carpeta y los libros reciben clics */
.carpeta-arte, .c-atras, .c-pestana, .c-frente, .c-reflejo, .c-cv, .carpeta-nombre, .carpeta-brillo, .carpeta-pista { pointer-events: none; }
.c-hoja { pointer-events: none; }
.carpeta:hover .c-hoja, .carpeta.abierta .c-hoja { pointer-events: auto; }

/* ---------- Visor de documentos (crece desde la carpeta) ---------- */
html.lb-sin-scroll { overflow: hidden; }
.c-hoja.oculta { opacity: 0 !important; }
.lb { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.lb[hidden] { display: none; }
.lb-fondo { position: absolute; inset: 0; background: rgba(244, 241, 234, .86); -webkit-backdrop-filter: blur(18px) saturate(1.1); backdrop-filter: blur(18px) saturate(1.1);
  opacity: 0; transition: opacity .6s cubic-bezier(.16, 1, .3, 1); }
.lb.visible .lb-fondo { opacity: 1; }
.lb.cerrando .lb-fondo { opacity: 0; transition-duration: .45s; }
.lb-panel { position: relative; z-index: 2; width: min(880px, 100%); border-radius: 24px; overflow: hidden; background: #fffdf8; border: 1px solid var(--filete);
  box-shadow: 0 40px 70px -24px rgba(60, 45, 20, .45); transform-origin: center center; will-change: transform; }
.lb-ventana { position: relative; aspect-ratio: 16 / 10; max-height: 68vh; width: 100%; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #fffdf8 0%, var(--papel-2) 75%); touch-action: pan-y; }
.lb-pista { display: flex; height: 100%; }
.lb-slide { flex: 0 0 100%; height: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; padding: clamp(18px, 4vw, 40px); }
.lb-portada { max-width: 72%; max-height: 100%; min-height: 0; width: auto; height: auto; object-fit: contain; border-radius: 4px; user-select: none;
  box-shadow: 0 2px 3px rgba(0,0,0,.12), 0 30px 50px -20px rgba(40, 30, 10, .55); }
.lb-libro { display: block; width: min(250px, 46%); }
.lb-pie { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 28px 24px; border-top: 1px solid var(--filete);
  opacity: 0; transform: translateY(30px); transition: opacity .45s ease-out, transform .6s cubic-bezier(.16, 1, .3, 1); }
.lb.listo .lb-pie { opacity: 1; transform: none; }
.lb-txt { min-width: 0; flex: 1; }
.lb-titulo { margin: 0; font-size: clamp(1.2rem, 3vw, 1.6rem); font-weight: 800; letter-spacing: -.02em; line-height: 1.15;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.lb-meta { margin: 4px 0 0; font-size: .9rem; color: var(--tinta-3); }
.lb-navinfo { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.lb-navinfo[hidden] { display: none; }
.lb-puntos { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--papel-2); }
.lb-punto { width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%; background: rgba(28, 29, 27, .25); cursor: pointer; transition: transform .4s, background .4s; }
.lb-punto.on { background: var(--tinta); transform: scale(1.5); }
.lb-cont { font-size: .75rem; font-weight: 700; letter-spacing: .14em; color: var(--tinta-3); }
.lb-abrir { flex: none; gap: 8px; }
.lb-abrir svg { width: 18px; height: 18px; }
.lb-btn { position: absolute; z-index: 3; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; cursor: pointer; color: var(--tinta);
  background: rgba(255, 253, 248, .85); border: 1px solid var(--filete); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  box-shadow: 0 12px 24px -10px rgba(60, 45, 20, .4); opacity: 0; transition: opacity .4s ease-out, transform .5s cubic-bezier(.16, 1, .3, 1), background .2s; }
.lb-btn svg { width: 22px; height: 22px; }
.lb-btn:hover { background: #fff; }
.lb-btn[hidden], .lb-btn:disabled { display: none; }
.lb-cerrar { top: 20px; right: 20px; transform: translateY(-24px); }
.lb-nav { top: 50%; margin-top: -24px; width: 48px; height: 48px; }
.lb-prev { left: 16px; transform: translateX(-12px); }
.lb-next { right: 16px; transform: translateX(12px); }
.lb.listo .lb-btn { opacity: 1; transform: none; }
.lb.listo .lb-nav:hover { transform: scale(1.08); }
@media (max-width: 760px) {
  .lb { padding: 12px; }
  .lb-ventana { aspect-ratio: 4 / 5; max-height: 60vh; }
  .lb-libro { width: 62%; }
  .lb-portada { max-width: 86%; }
  .lb-pie { flex-direction: column; align-items: stretch; padding: 18px 18px 20px; gap: 14px; }
  .lb-abrir { width: 100%; }
  .lb-nav { width: 42px; height: 42px; margin-top: -21px; }
  .lb-prev { left: 10px; } .lb-next { right: 10px; }
  .lb-cerrar { top: 14px; right: 14px; width: 46px; height: 46px; }
}
.cat-seccion { max-width: 1180px; margin: 0 auto; padding: 8px var(--gutter) 0; font-size: 1.3rem; }
.cat-seccion + .librero { padding-top: 24px; }
.cat-head + .carpetas { padding-top: clamp(24px, 4vw, 40px); }
