/* Thư viện: bốn quyển đứng trên một thanh nhôm định hình */
.library { overflow-x: clip; background: var(--paper); color: var(--graphite); min-height: 100vh; display: flex; flex-direction: column; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .library { background: #f4f5f6; color: var(--graphite); color-scheme: light; } }
.lib-head { padding: 28px clamp(20px, 5vw, 72px) 0; display: flex; align-items: center; justify-content: space-between; }
.lib-brand { height: 48px; display: flex; align-items: center; }
.lib-brand img { height: 48px; width: auto; }
.wordmark { font-weight: 700; font-stretch: 112%; letter-spacing: .14em; font-size: 13px; color: var(--navy); }

.lib-main { flex: 1; padding: 0 clamp(20px, 5vw, 72px); }
.hero { padding: clamp(40px, 9vh, 104px) 0 clamp(36px, 7vh, 80px); max-width: 1440px; margin: 0 auto; }
.hero-title { margin: 0; line-height: .92; color: var(--navy); }
.hero-title .t1 { display: block; white-space: nowrap; font-weight: 800; font-stretch: 125%; font-size: min(168px, calc((100vw - 2 * clamp(20px, 5vw, 72px)) / 5.9)); letter-spacing: -.01em; }
.hero-title .t2 { display: block; font-weight: 300; font-stretch: 72%; font-size: clamp(30px, 5.6vw, 86px); letter-spacing: .02em; color: var(--graphite-2); margin-top: .12em; }
.hero-tag { margin: 22px 0 0; font-size: clamp(15px, 1.4vw, 19px); color: var(--ink-soft); font-stretch: 100%; letter-spacing: .01em; }

.shelf-wrap { max-width: 1440px; margin: 0 auto; padding-bottom: 72px; }
.shelf { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--books, 5), minmax(0, 1fr)); gap: clamp(18px, 2.4vw, 40px); position: relative; }
/* thanh nhôm: dải kim loại mảnh chạy dưới chân các quyển */
.shelf::before { content: ""; position: absolute; left: calc(-1 * clamp(8px, 1.5vw, 24px)); right: calc(-1 * clamp(8px, 1.5vw, 24px)); top: var(--shelf-y, 0); height: 10px;
  background: linear-gradient(180deg, #f6f7f8 0%, #c3c8cd 35%, #9aa1a8 60%, #d4d8dc 100%); border-radius: 1px; box-shadow: 0 10px 18px -10px rgba(22,35,51,.5); z-index: 0; }
.shelf::after { content: ""; position: absolute; left: calc(-1 * clamp(8px, 1.5vw, 24px)); right: calc(-1 * clamp(8px, 1.5vw, 24px)); top: calc(var(--shelf-y, 0) + 10px); height: 4px; background: #7d858d; opacity: .5; }

.book-slot { position: relative; z-index: 1; }
.book-link { display: block; text-decoration: none; color: inherit; border-radius: 2px; }
.book { position: relative; aspect-ratio: 210 / 297; transition: transform .45s var(--ease); transform-origin: 50% 100%; }
.book .cover { position: absolute; inset: 0; border-radius: 1px 3px 3px 1px; overflow: hidden; background: var(--mist);
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 18px 24px -14px rgba(22,35,51,.55), 0 2px 4px rgba(22,35,51,.18); }
/* gáy sách */
.book .cover::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5.5%; z-index: 3;
  background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(255,255,255,.10) 55%, rgba(0,0,0,.08)); }
/* mép giấy bên phải */
.book::after { content: ""; position: absolute; top: 1.4%; bottom: 1.4%; right: -5px; width: 5px; border-radius: 0 2px 2px 0;
  background: repeating-linear-gradient(90deg, #fbfbfb 0 1px, #dfe2e5 1px 2px); box-shadow: 1px 0 2px rgba(0,0,0,.15); }
.book .cover img { width: 100%; height: 100%; object-fit: cover; }
@media (hover: hover) {
  .book-link:hover .book, .book-link:focus-visible .book { transform: translateY(-14px); }
  .book-link:hover .book .cover { box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 34px 34px -18px rgba(22,35,51,.5), 0 4px 10px rgba(22,35,51,.18); }
}
.book-link:active .book { transform: translateY(-4px) scale(.99); }

/* Bìa mẫu (khi admin chưa tải bìa thật) */
.ph { position: absolute; inset: 0; display: flex; flex-direction: column; padding: 11% 10% 9% 15%; color: #fff; }
.ph svg.motif { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .9; }
.ph .ph-code { position: relative; font-size: clamp(9px, .9vw, 13px); letter-spacing: .08em; font-weight: 500; opacity: .8; }
.ph .ph-name { position: relative; margin-top: auto; font-size: clamp(18px, 2.5vw, 38px); font-weight: 700; font-stretch: 118%; line-height: 1; letter-spacing: -.005em; }
.ph .ph-sub { position: relative; font-size: clamp(9px, .85vw, 12px); margin-top: .7em; opacity: .75; font-stretch: 90%; }
.ph .ph-brand { position: relative; margin-top: 12%; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ph .ph-brand .wm { font-size: clamp(8px, .75vw, 11px); font-weight: 700; letter-spacing: .16em; font-stretch: 112%; }
.ph .ph-brand img { height: clamp(12px, 1.4vw, 20px); width: auto; }
.ph .sample { font-size: clamp(7px, .62vw, 9.5px); letter-spacing: .04em; padding: 2px 6px; border: 1px solid currentColor; border-radius: 2px; opacity: .8; white-space: nowrap; }
.ph.t-solution { background: #162333; }
.ph.t-premium { background: #23272b; }
.ph.t-premium .ph-name { color: #e3e5e8; }
.ph.t-nstandard { background: #c9ced3; color: #162333; }
.ph.t-profiles { background: #f7f8f9; color: #23272b; }

.caption { padding-top: 26px; display: grid; gap: 2px; }
.caption .c-code { font-size: 12px; color: var(--ink-soft); letter-spacing: .04em; }
.caption .c-title { font-size: clamp(15px, 1.3vw, 19px); font-weight: 600; font-stretch: 104%; color: var(--navy); }
.caption .c-desc { font-size: 13.5px; color: var(--ink-soft); line-height: 1.45; margin-top: 6px; max-width: 34ch; }
.caption .c-meta { font-size: 12px; color: var(--ink-soft); margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.caption .c-meta .state-off { color: #8a5a1f; }

.skel .cover { background: linear-gradient(100deg, #e3e6e9 30%, #eef0f2 50%, #e3e6e9 70%); background-size: 300% 100%; animation: sk 1.4s infinite linear; }
.skel .caption span { display: block; height: 12px; background: #e3e6e9; border-radius: 2px; width: 50%; margin-top: 8px; }
.skel .caption span + span { width: 80%; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -50% 0; } }

.lib-error { padding: 32px 0; color: var(--ink-soft); }
.lib-foot { padding: 28px clamp(20px, 5vw, 72px) calc(28px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid #dfe2e5; color: var(--ink-soft); font-size: 13px; }
.lib-foot p { max-width: 1440px; margin: 0 auto; }

/* Mobile: 2 cột, mỗi hàng có thanh nhôm riêng; mô tả ẩn để bìa đủ lớn */
@media (max-width: 760px) {
  .lib-head { padding-top: 18px; }
  .hero { padding: 34px 0 30px; }
  .hero-tag { margin-top: 14px; }
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; row-gap: 34px; }
  .shelf::before, .shelf::after { display: none; }
  .book-slot::before { content: ""; position: absolute; left: -9px; right: -9px; /* nằm trong lề 20px của trang */ top: var(--slot-shelf-y, 0); height: 7px; z-index: 0;
    background: linear-gradient(180deg, #f6f7f8 0%, #c3c8cd 35%, #9aa1a8 60%, #d4d8dc 100%); box-shadow: 0 8px 12px -8px rgba(22,35,51,.5); }
  .book-slot .book { z-index: 1; }
  .caption { padding-top: 18px; }
  .caption .c-desc { display: none; }
  .ph { padding: 12% 9% 10% 14%; }
  .ph .ph-name { font-size: clamp(17px, 5.4vw, 26px); }
  .ph .ph-code, .ph .ph-sub { font-size: 10px; }
  .ph .ph-brand .wm { font-size: 8.5px; }
  .ph .sample { font-size: 8px; padding: 1px 4px; }
}
@media (min-width: 761px) and (max-width: 1100px) {
  .shelf { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 40px; }
  .shelf::before, .shelf::after { display: none; }
  .book-slot::before { content: ""; position: absolute; left: -11px; right: -11px; top: var(--slot-shelf-y, 0); height: 8px; z-index: 0;
    background: linear-gradient(180deg, #f6f7f8 0%, #c3c8cd 35%, #9aa1a8 60%, #d4d8dc 100%); box-shadow: 0 8px 12px -8px rgba(22,35,51,.5); }
  .book-slot .book { z-index: 1; }
  .caption .c-desc { font-size: 12.5px; }
}

/* Trọn bộ: một link, một QR cho cả bộ */
.set-strip { max-width: 1440px; margin: 0 auto 72px; display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 28px; align-items: center;
  padding: 26px 28px; background: #fff; border: 1px solid #dfe2e5; border-radius: 6px; }
.set-qr { background: #fff; }
.set-qr svg { width: 100%; height: auto; }
.set-body h2 { margin: 0 0 6px; font-size: 20px; font-weight: 700; font-stretch: 108%; color: var(--navy); }
.set-body p { margin: 0 0 16px; color: var(--ink-soft); font-size: 14.5px; max-width: 62ch; }
.set-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.set-strip .btn { white-space: normal; text-align: center; background: #fff; color: var(--graphite); border-color: #cfd3d7; }
.set-strip .btn-solid { background: var(--navy); color: #fff; border-color: var(--navy); }
.set-note { margin: 12px 0 0 !important; font-size: 13px !important; }
@media (max-width: 760px) {
  .lib-brand, .lib-brand img { height: 38px; }
  .set-strip { grid-template-columns: 96px minmax(0, 1fr); gap: 16px; padding: 18px; margin-bottom: 48px; }
  .set-body h2 { font-size: 17px; }
  .set-body p { font-size: 13.5px; }
  .set-actions { grid-column: 1 / -1; }
}
