/* Content library — poster shelf, filters, detail dialog.
   Leans on base.css / components.css for colours and the container. */

.lib-hero {
  position: relative; overflow: hidden;
  padding: 5.5rem 0 2rem;
  background: var(--bg, #0a0a0f);
  text-align: center;
}
.lib-hero::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(700px 380px at 12% -5%,  rgba(255, 92, 200, .16), transparent 65%),
    radial-gradient(700px 380px at 88% 5%,   rgba(59, 200, 255, .16), transparent 65%),
    radial-gradient(900px 460px at 50% -15%, rgba(124, 92, 231, .28), transparent 70%);
}
.lib-hero > .container { position: relative; z-index: 1; }
.lib-hero-sub { color: var(--text-muted, #9a9ab0); max-width: 40rem; margin: 0 auto; }

.lib-hero-title {
  margin: .5rem 0 .75rem;
  background: linear-gradient(100deg, #ff5cc8, #a78bfa 45%, #3bc8ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 24px rgba(124, 92, 231, .35));
}

/* ── Tabs & chips ── */
.lib-tabs { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1rem; }
.lib-tab {
  padding: .6rem 1.3rem; border-radius: 999px; cursor: pointer; font: inherit;
  font-size: .92rem; font-weight: 700; color: #b9b9cc;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1);
  transition: all .18s;
}
.lib-tab:hover { color: #fff; border-color: rgba(167, 139, 250, .5); }
.lib-tab.active {
  background: linear-gradient(135deg, #ff5cc8, #a78bfa 55%, #3bc8ff);
  color: #fff; border-color: transparent;
  box-shadow: 0 8px 22px -8px rgba(167, 139, 250, .7);
}

.lib-filters {
  display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center;
  margin-bottom: 1.1rem;
}
.lib-chip {
  padding: .34rem .7rem; border-radius: 8px; cursor: pointer; font: inherit;
  font-size: .78rem; color: #a9a9be;
  background: rgba(255, 255, 255, .035); border: 1px solid rgba(255, 255, 255, .08);
}
.lib-chip:hover { color: #fff; }
.lib-chip.active { background: rgba(108, 92, 231, .22); border-color: #6c5ce7; color: #fff; }
.lib-chip i { font-style: normal; opacity: .5; font-size: .72rem; margin-left: .15rem; }

/* ── Toolbar ── */
.lib-toolbar {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 1rem; margin-bottom: 1.1rem;
}
.lib-sort {
  padding: .45rem .8rem; border-radius: 8px; font: inherit; font-size: .82rem;
  color: #d5d5e2; background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12); cursor: pointer;
}

/* ── Grid — 3D poster cards ── */
.lib-grid {
  display: grid; gap: 1.75rem 1.5rem;
  grid-template-columns: repeat(4, 1fr);
  perspective: 1200px;
}
.lib-card {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; text-align: left; color: inherit;
}
.lib-poster {
  position: relative; aspect-ratio: 2 / 3; border-radius: 16px; overflow: hidden;
  background: linear-gradient(160deg, #1c1c2a, #100f18);
  border: 1px solid rgba(255, 255, 255, .08);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .06) inset,
    0 18px 32px -14px rgba(0, 0, 0, .65);
  transform: translateZ(0) rotateX(0) rotateY(0) scale(1);
  transition: transform .28s cubic-bezier(.2,.8,.2,1), box-shadow .28s, border-color .28s;
  transform-style: preserve-3d;
}
.lib-card:hover .lib-poster,
.lib-card:focus-visible .lib-poster {
  transform: translateY(-8px) scale(1.035) rotateX(3deg) rotateY(-3deg);
  border-color: rgba(167, 139, 250, .6);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .08) inset,
    0 30px 50px -16px rgba(124, 92, 231, .45),
    0 10px 24px -8px rgba(0, 0, 0, .6);
}
.lib-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-poster::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, .55) 100%);
  pointer-events: none;
}
.lib-rating {
  position: absolute; left: .5rem; bottom: .5rem; z-index: 1;
  padding: .18rem .5rem; border-radius: 7px;
  font-size: .74rem; font-weight: 800; color: #ffd75e;
  background: rgba(0, 0, 0, .78); backdrop-filter: blur(3px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}
.lib-card-title {
  margin-top: .6rem; font-size: .9rem; font-weight: 700; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lib-card-meta { font-size: .76rem; color: #8484a0; margin-top: .15rem; }

.lib-skel { pointer-events: none; }
.lib-skel .lib-poster { animation: libpulse 1.3s ease-in-out infinite; box-shadow: none; }
@keyframes libpulse { 0%, 100% { opacity: .45 } 50% { opacity: .8 } }

.lib-empty { grid-column: 1 / -1; text-align: center; color: #75758c; padding: 3rem 1rem; }

/* ── Pager — real pages, not an endless single load ── */
.lib-pager { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin: 2.5rem 0 1rem; }
.lib-page {
  min-width: 2.3rem; padding: .45rem .65rem; border-radius: 9px; cursor: pointer;
  font: inherit; font-size: .84rem; font-weight: 600; color: #b9b9cc;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1);
  transition: all .15s;
}
.lib-page:hover { color: #fff; border-color: rgba(167, 139, 250, .5); }
.lib-page.active {
  background: linear-gradient(135deg, #a78bfa, #6c5ce7); color: #fff; border-color: transparent;
  box-shadow: 0 6px 16px -6px rgba(124, 92, 231, .7);
}
.lib-gap { color: #55556a; padding: 0 .15rem; align-self: center; }

/* ── Detail dialog ── */
.lib-modal { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.lib-modal[hidden] { display: none; }
.lib-modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .82); backdrop-filter: blur(4px); }
.lib-modal-card {
  position: relative; width: min(46rem, 100%); max-height: 88vh; overflow-y: auto;
  border-radius: 16px; padding: 1.5rem;
  background: #12121a; border: 1px solid rgba(255, 255, 255, .1);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6);
}
.lib-modal-close {
  position: absolute; top: .6rem; right: .75rem; width: 2rem; height: 2rem;
  border: 0; border-radius: 50%; cursor: pointer; font-size: 1.3rem; line-height: 1;
  color: #c9c9d8; background: rgba(255, 255, 255, .07);
}
.lib-detail { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.lib-detail-poster {
  width: 11rem; border-radius: 12px; flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, .08); background: #15151f;
}
.lib-detail-text { flex: 1; min-width: 15rem; }
.lib-detail-text h3 { margin: 0 0 .35rem; font-size: 1.35rem; }
.lib-detail-meta { font-size: .8rem; color: #8f8fa6; margin-bottom: .9rem; }
.lib-detail-plot { font-size: .9rem; line-height: 1.65; color: #c4c4d4; margin: 0 0 1rem; }
.lib-detail-line { font-size: .8rem; color: #8f8fa6; margin: .2rem 0; }
.lib-watch { display: inline-block; margin-top: 1rem; }
.lib-detail-note { font-size: .74rem; color: #6b6b80; margin: .5rem 0 0; }

/* ── Mobile ── */
@media (max-width: 900px) {
  .lib-grid { grid-template-columns: repeat(3, 1fr); gap: 1.25rem 1rem; }
}

@media (max-width: 640px) {
  .lib-hero { padding: 4.5rem 0 1.5rem; }
  .lib-hero-sub { font-size: .92rem; padding: 0 .5rem; }
  .lib-tab { padding: .5rem 1rem; font-size: .84rem; }
  .lib-toolbar { justify-content: center; }

  /* A wall of genre chips ate half the screen before any poster showed up —
     one scrollable strip instead of eight rows of wrapped buttons. */
  .lib-filters {
    flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto;
    margin: 0 -1rem 1rem; padding: 0 1rem .3rem;
    scrollbar-width: none;
  }
  .lib-filters::-webkit-scrollbar { display: none; }
  .lib-chip { flex: none; }
  .lib-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem .8rem; }
  .lib-poster { border-radius: 12px; }
  .lib-card:hover .lib-poster, .lib-card:focus-visible .lib-poster { transform: translateY(-4px) scale(1.02); }
  .lib-card-title { font-size: .82rem; }
  .lib-detail-poster { width: 8rem; margin: 0 auto; }
  .lib-modal-card { padding: 1.1rem; }
}

@media (max-width: 380px) {
  .lib-grid { gap: .8rem .6rem; }
}
