/* Libros: estantería 3D, filtros por nivel y fichas desplegables */

/* ---------- Filtros ---------- */
.shelf-section {
  position: relative; z-index: 1;
  max-width: 1200px; margin: 0 auto;
  padding: 0 40px;
}
.lib-filters {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 10px;
  margin-bottom: 56px;
}
.lib-filter {
  font-family: var(--font); font-size: .9rem; font-weight: 600; letter-spacing: .2px;
  color: #bdbdbd; background: rgba(255,255,255,.04);
  border: 1px solid #2a2a2a; border-radius: 100px;
  padding: 10px 22px; cursor: pointer;
  transition: color .25s, background .25s, border-color .25s, transform .25s;
}
.lib-filter:hover { color: #fff; border-color: rgba(247,147,26,.5); transform: translateY(-2px); }
.lib-filter:focus-visible, .shelf-book:focus-visible, .book-toggle:focus-visible {
  outline: 2px solid var(--btc-orange); outline-offset: 3px;
}
.lib-filter.active {
  color: #000; background: var(--btc-orange); border-color: var(--btc-orange);
  box-shadow: 0 6px 24px rgba(247,147,26,.28);
}

/* ---------- Estantería ---------- */
.shelf { position: relative; }
.shelf-row {
  display: flex; justify-content: center; align-items: flex-end; gap: 18px;
  perspective: 1100px;
  padding: 30px 8px 0;
}
.shelf-book {
  all: unset; box-sizing: border-box;
  position: relative; flex: 0 1 124px; min-width: 0;
  aspect-ratio: 2 / 3; cursor: pointer;
  transition: opacity .4s, filter .4s, transform .4s;
}
.shelf-cover {
  position: absolute; inset: 0; display: block;
  border-radius: 3px 8px 8px 3px; overflow: hidden;
  background: #1b1b1b;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0);
  transition: transform .5s cubic-bezier(.2,.7,.2,1), box-shadow .5s;
  box-shadow: 0 14px 22px -8px rgba(0,0,0,.85), 0 2px 4px rgba(0,0,0,.6);
  will-change: transform;
}
.shelf-book.tilting .shelf-cover {
  transition: transform .08s linear, box-shadow .3s;
  box-shadow: 0 30px 40px -12px rgba(0,0,0,.9), 0 0 0 1px rgba(247,147,26,.55), 0 0 36px rgba(247,147,26,.18);
}
.shelf-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* lomo y brillo */
.shelf-cover::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 9px; z-index: 2;
  background: linear-gradient(90deg, rgba(0,0,0,.55), rgba(255,255,255,.18) 45%, rgba(0,0,0,0));
}
.shelf-cover::after {
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  background: radial-gradient(circle at var(--gx, 30%) var(--gy, 20%), rgba(255,255,255,.28), transparent 55%);
  opacity: 0; transition: opacity .3s;
}
.shelf-book.tilting .shelf-cover::after { opacity: 1; }

/* etiqueta con el título */
.shelf-book::after {
  content: attr(data-title);
  position: absolute; left: 50%; bottom: calc(100% + 14px); transform: translate(-50%, 6px);
  width: max-content; max-width: 220px; text-align: center;
  font-family: var(--font); font-size: .78rem; font-weight: 600; line-height: 1.3;
  color: #fff; background: rgba(20,20,20,.96); border: 1px solid #333; border-radius: 8px;
  padding: 7px 11px; opacity: 0; pointer-events: none; z-index: 5;
  transition: opacity .2s, transform .2s;
}
.shelf-book.show-tip::after { opacity: 1; transform: translate(-50%, 0); }

.shelf-book.is-dim { opacity: .16; filter: grayscale(1) blur(1px); transform: scale(.94); pointer-events: none; }

/* balda */
.shelf-plank {
  position: relative; height: 18px; margin: 0 -10px;
  border-radius: 3px;
  background: linear-gradient(180deg, #3a2a18 0%, #20160c 55%, #120c06 100%);
  box-shadow: 0 1px 0 rgba(247,147,26,.35) inset, 0 22px 34px -6px rgba(0,0,0,.9), 0 40px 80px -20px rgba(247,147,26,.14);
}
.shelf-plank::after {
  content: ''; position: absolute; left: 4%; right: 4%; top: 100%; height: 40px;
  background: radial-gradient(ellipse at top, rgba(247,147,26,.10), transparent 70%);
  pointer-events: none;
}
.shelf-hint {
  text-align: center; margin: 44px 0 48px;
  font-size: .85rem; color: var(--text-dim); letter-spacing: .3px;
}

/* ---------- Fichas ---------- */
.books-section { padding-top: 0; }
.book-card {
  grid-template-columns: 96px 1fr; gap: 28px; padding: 24px 28px; margin-bottom: 16px;
  border-radius: 16px; scroll-margin-top: 110px; align-items: center;
}
.book-card .book-cover { width: 96px; height: 140px; border-radius: 3px 7px 7px 3px; box-shadow: 0 10px 20px -6px rgba(0,0,0,.8); }
.book-card .book-info { padding-top: 0; gap: 6px; }
.book-card .book-title { font-size: 1.45rem; letter-spacing: -.5px; }
.book-card .book-author { font-size: .95rem; }
.book-level {
  align-self: flex-start; font-size: .7rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  padding: 4px 11px; border-radius: 100px; border: 1px solid currentColor; margin-top: 4px;
}
.book-level.lvl-beg { color: #4ade80; }
.book-level.lvl-mid { color: #F7931A; }
.book-level.lvl-adv { color: #f87171; }
.book-toggle { display: none; }
.book-card[hidden] { display: none; }

.js .book-card { cursor: pointer; }
.js .book-toggle {
  order: 4; align-self: flex-start; margin-top: 10px;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font); font-size: .85rem; font-weight: 600;
  color: var(--btc-orange); background: none; border: 1px solid rgba(247,147,26,.4);
  border-radius: 100px; padding: 8px 16px; cursor: pointer;
  transition: background .25s, color .25s;
}
.js .book-toggle:hover { background: var(--btc-orange); color: #000; }
.js .book-toggle svg { transition: transform .35s; }
.js .book-card.open .book-toggle svg { transform: rotate(180deg); }

.js .book-more {
  order: 5; display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s cubic-bezier(.2,.7,.2,1);
}
.js .book-more-in { overflow: hidden; min-height: 0; opacity: 0; transition: opacity .35s; }
.js .book-card.open .book-more { grid-template-rows: 1fr; }
.js .book-card.open .book-more-in { opacity: 1; transition-delay: .1s; }
.js .book-card.open { border-color: rgba(247,147,26,.4); }
.js .book-card.open .book-more-in > .book-divider { margin: 14px 0 16px; }
.book-card.flash { animation: libFlash 1.4s ease-out; }
@keyframes libFlash {
  0% { box-shadow: 0 0 0 0 rgba(247,147,26,.7); }
  100% { box-shadow: 0 0 0 26px rgba(247,147,26,0); }
}

/* ---------- Móvil ---------- */
@media (max-width: 768px) {
  .shelf-section { padding: 0 0; }
  .lib-filters { padding: 0 20px; margin-bottom: 36px; gap: 8px; }
  .lib-filter { padding: 9px 16px; font-size: .85rem; }
  .shelf-row {
    justify-content: flex-start; overflow-x: auto; gap: 14px; padding: 24px 20px 6px;
    scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .shelf-row::-webkit-scrollbar { display: none; }
  .shelf-book { flex: 0 0 104px; scroll-snap-align: center; }
  .shelf-book::after { display: none; }
  .shelf-plank { margin: 0; border-radius: 0; }
  .shelf-hint { margin: 28px 20px 32px; }
  .book-card { grid-template-columns: 72px 1fr; gap: 16px; padding: 16px; }
  .book-card .book-cover { width: 72px; height: 106px; margin: 0; }
  .book-card .book-title { font-size: 1.1rem; }
  .book-card .book-number { font-size: .62rem; }
}

/* ---------- Cabecera propia: texto + abanico de portadas 3D ---------- */
html body .page-hero.lib-hero {
  min-height: 0; padding: 130px 40px 40px; max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 24px; align-items: center;
  text-align: left;
}
html body .page-hero.lib-hero::after { display: none; }
html body .lib-hero h1 { margin: 14px 0 22px; max-width: 12ch; }
html body .lib-hero p { margin: 0; max-width: 24em; font-size: 1.1rem; }
.lib-hero::before {
  content: ''; position: absolute; z-index: -1; right: -8%; top: 8%; width: 70%; height: 90%;
  background: radial-gradient(closest-side, rgba(247,147,26,.20), transparent 72%); pointer-events: none;
}
.lib-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 14px 30px; margin-top: 32px; }
.lib-stat { display: flex; align-items: baseline; gap: 8px; }
.lib-stat strong { font-family: 'JetBrains Mono', monospace; font-size: 2rem; font-weight: 600; color: var(--btc-orange); line-height: 1; }
.lib-stat span { font-size: .9rem; color: #bdbdbd; }
.lib-cta {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none;
  font-weight: 700; font-size: .95rem; color: #000; background: var(--btc-orange);
  padding: 13px 24px; border-radius: 100px; box-shadow: 0 8px 28px rgba(247,147,26,.3);
  transition: transform .25s, box-shadow .25s;
}
.lib-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 34px rgba(247,147,26,.45); }
.lib-cta svg { animation: libBob 1.8s ease-in-out infinite; }
.lib-cta:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@keyframes libBob { 50% { transform: translateY(3px); } }

.lib-fan { position: relative; height: 440px; perspective: 1200px; --mx: 0; --my: 0; }
.hf {
  position: absolute; left: 50%; bottom: 20px; width: 165px; aspect-ratio: 2 / 3;
  margin-left: -82px; transform-origin: 50% 100%;
  transform: translate(calc(var(--x) * 1px + var(--mx) * var(--d) * 1px), calc(var(--y) * 1px + var(--my) * var(--d) * .6px)) rotate(calc(var(--r) * 1deg));
  transition: transform .25s ease-out;
  z-index: var(--z);
}
.hf-in {
  display: block; width: 100%; height: 100%; border-radius: 3px 9px 9px 3px; overflow: hidden; position: relative;
  transform: rotateY(calc(var(--mx) * -14deg)) rotateX(calc(var(--my) * 10deg));
  box-shadow: 0 26px 40px -14px rgba(0,0,0,.95), 0 0 0 1px rgba(255,255,255,.07);
  animation: libFloat 6s ease-in-out infinite; animation-delay: calc(var(--z) * -1.1s);
  background: #1b1b1b;
}
.hf-in::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 9px; z-index: 2; background: linear-gradient(90deg, rgba(0,0,0,.55), rgba(255,255,255,.18) 45%, transparent); }
.hf-in::after { content: ''; position: absolute; inset: 0; z-index: 3; background: linear-gradient(135deg, rgba(255,255,255,.16), transparent 45%); }
.hf img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hf-1 { --x: -150; --y: 14; --r: -15; --z: 1; --d: -8; }
.hf-2 { --x: -78; --y: 4; --r: -7; --z: 2; --d: -4; }
.hf-3 { --x: 0; --y: -14; --r: 0; --z: 5; --d: 0; width: 195px; margin-left: -97px; }
.hf-4 { --x: 78; --y: 4; --r: 7; --z: 3; --d: 5; }
.hf-5 { --x: 150; --y: 14; --r: 15; --z: 2; --d: 9; }
@keyframes libFloat { 50% { translate: 0 -8px; } }

.shelf-title { text-align: center; font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 800; letter-spacing: -1px; margin: 40px 0 22px; }
.lib-filters { margin-bottom: 48px; }
.lib-count { font-family: 'JetBrains Mono', monospace; font-size: .72rem; margin-left: 8px; padding: 2px 7px; border-radius: 100px; background: rgba(255,255,255,.08); }
.lib-filter.active .lib-count { background: rgba(0,0,0,.18); }
.book-card { align-items: start; }
@media (max-width: 900px) {
  html body .page-hero.lib-hero { grid-template-columns: 1fr; padding: 110px 20px 24px; gap: 8px; text-align: center; }
  html body .lib-hero h1, html body .lib-hero p { margin-left: auto; margin-right: auto; }
  .lib-stats { justify-content: center; }
  .lib-fan { height: 330px; }
  .hf { width: 108px; margin-left: -54px; }
  .hf-3 { width: 132px; margin-left: -66px; }
  .hf-1 { --x: -92; } .hf-2 { --x: -48; } .hf-4 { --x: 48; } .hf-5 { --x: 92; }
  .shelf-title { margin-top: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .hf, .hf-in, .lib-cta, .lib-cta svg { animation: none !important; transition: none !important; }
  .hf-in { transform: none !important; }
  .shelf-cover, .shelf-book, .lib-filter, .book-more, .book-more-in, .book-toggle svg, .shelf-book::after { transition: none !important; }
  .shelf-cover { transform: none !important; }
  .book-card.flash { animation: none; outline: 2px solid var(--btc-orange); }
}

