/* ───────── 책장 (js/bookshelf.js · 3D 장면은 js/scene/shelf3d.js) ─────────
   입장 창(#modal, 20)보다 위 · 토스트(30)보다 아래 */
.bs {
  --serif: "Nanum Myeongjo", "AppleMyungjo", "Batang", "Noto Serif KR", serif;
  position: fixed; inset: 0; z-index: 25; overflow: hidden; color: #f6ecdc; background: #1c1512;
  animation: bs-in .3s ease-out;
}
@keyframes bs-in { from { opacity: 0; } }
.bs-3d { position: absolute; inset: 0; }
.bs-3d canvas { display: block; width: 100%; height: 100%; }
/* 위에 얹는 화면: 빈 곳은 3D 장면이 마우스를 받는다 */
.bs-ui { position: absolute; inset: 0; pointer-events: none; }
.bs-ui > * { pointer-events: auto; }

.bs-top { position: absolute; left: 0; right: 0; top: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 12px 16px; pointer-events: none !important; }
.bs-top > * { pointer-events: auto; }
.bs-top > :last-child { justify-self: end; }
.bs-back { justify-self: start; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(20, 12, 8, 0.6); color: inherit; border-radius: 999px; padding: 7px 14px; cursor: pointer; font-size: 14px; white-space: nowrap; backdrop-filter: blur(6px); }
.bs-back:hover { background: rgba(20, 12, 8, 0.85); }
.bs-title { display: flex; align-items: baseline; gap: 8px; padding: 6px 16px; border-radius: 999px; background: rgba(20, 12, 8, 0.55); backdrop-filter: blur(6px); white-space: nowrap; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; }
.bs-title b { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.bs-title span { color: #cdb99d; font-size: 13px; font-weight: 500; }

.bs-empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(360px, 80%); margin: 0; padding: 14px 18px; border-radius: 12px; text-align: center; font-size: 14px; line-height: 1.6; background: rgba(20, 12, 8, 0.78); color: #f0e2cb; word-break: keep-all; pointer-events: none !important; }
.bs-tip { position: fixed; z-index: 26; display: grid; gap: 2px; max-width: 260px; padding: 7px 10px; border-radius: 8px; background: rgba(20, 12, 8, 0.88); border: 1px solid rgba(255, 255, 255, 0.1); font-size: 13px; pointer-events: none; word-break: keep-all; }
.bs-tip b { font-family: var(--serif); }
.bs-tip span { color: #cdb99d; font-size: 12px; }
/* 화면 읽기 · 키보드용 책 목록 (눈에는 안 보임) */
.bs-a11y { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; list-style: none; }

/* 책 꽂기 패널 (방장) */
.bs-findpanel {
  position: absolute; right: 16px; top: 64px; bottom: 16px; width: 344px; overflow-y: auto;
  padding: 16px; border-radius: 14px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.bs-findpanel.enter { animation: bs-slide .25s ease-out; }
@keyframes bs-slide { from { transform: translateX(30px); opacity: 0; } }
.bs-findpanel h3 { margin-bottom: 4px; }
.bs-find-form { display: flex; gap: 6px; margin: 12px 0 8px; }
.bs-find-form button { flex: none; }
.bs-results ul { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 6px; }
.bs-result { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.bs-result-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.bs-result-text b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bs-result-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bs-thumb { flex: none; width: 40px; height: 58px; border-radius: 2px; object-fit: cover; background: #ddd; box-shadow: 1px 2px 4px rgba(0, 0, 0, 0.4); }
.bs-thumb.blank { display: grid; place-items: center; background: #5b3a29; color: #f6ecd9; font-family: var(--serif); font-weight: 700; }
.bs-on { flex: none; color: var(--ok); }
.bs-addform { flex-basis: 100%; display: grid; gap: 6px; margin-top: 2px; }
.bs-addform input { padding: 7px 10px; font-size: 13px; }
.bs-addform-row { display: flex; justify-content: flex-end; gap: 6px; }
.bs-more { width: 100%; margin-top: 4px; border-style: dashed; }

/* 책 정보 (눈앞에 든 책 옆) */
.bs-info {
  position: absolute; right: max(72px, 6vw); top: 50%; transform: translateY(-50%); width: min(420px, 40vw); max-height: calc(100% - 140px); overflow-y: auto;
  padding: 24px 26px; border-radius: 14px; background: rgba(24, 17, 13, 0.82); border: 1px solid rgba(255, 255, 255, 0.08); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(10px); animation: bs-info-in .5s ease-out .35s both; word-break: keep-all;
}
@keyframes bs-info-in { from { opacity: 0; translate: 16px 0; } }
.bs-info h2 { font-family: var(--serif); font-size: 25px; line-height: 1.35; margin-bottom: 8px; }
.bs-by { margin: 0 0 4px; color: #e8d6b9; font-size: 14px; }
.bs-pub { margin: 0 0 16px; font-size: 13px; color: #b9a690; }
.bs-contents { margin: 0 0 16px; font-family: var(--serif); font-size: 14.5px; line-height: 1.85; color: #eadfcd; white-space: pre-line; }
.bs-contents.none { color: var(--muted); font-family: inherit; }
.bs-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: 12.5px; }
.bs-meta dt { color: var(--muted); }
.bs-meta dd { margin: 0; }
.bs-hint { margin: 0 0 14px; font-size: 12px; color: var(--muted); }
.bs-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bs-navs { pointer-events: none !important; position: absolute; inset: 0; }
.bs-nav { pointer-events: auto; position: absolute; top: 50%; transform: translateY(-50%); display: grid; place-items: center; padding: 0; width: 44px; height: 64px; border: none; border-radius: 12px; background: rgba(20, 12, 8, 0.55); color: inherit; cursor: pointer; }
/* 화살표: 글자(‹ ›)는 기준선 때문에 가운데에 안 오므로 테두리 두 변으로 그린다. 꺾인 쪽으로 쏠려 보이지 않게 반대로 조금 옮긴다 */
.bs-nav::before { content: ''; width: 12px; height: 12px; border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; border-radius: 1px; }
.bs-nav.prev::before { transform: translateX(2.5px) rotate(45deg); }
.bs-nav.next::before { transform: translateX(-2.5px) rotate(-135deg); }
.bs-nav.prev { left: 12px; }
.bs-nav.next { right: 12px; }
.bs-nav:hover:not(:disabled) { background: rgba(20, 12, 8, 0.85); }
.bs-nav:disabled { opacity: 0.25; cursor: default; }

/* 좁은 화면: 꽂기 패널은 아래에서 · 책은 위, 정보는 아래 */
@media (max-width: 760px), (max-height: 500px) {
  .bs-top { padding: 8px 10px; }
  .bs-title { max-width: 60vw; padding: 6px 12px; }
  .bs-title b { font-size: 15px; }
  .bs-findpanel { left: 8px; right: 8px; width: auto; top: 42%; bottom: 8px; }
  .bs-findpanel.enter { animation-name: bs-sheet; }
  @keyframes bs-sheet { from { transform: translateY(30px); opacity: 0; } }
  .bs-info { left: 10px; right: 10px; top: auto; bottom: 10px; transform: none; width: auto; max-height: 44%; padding: 16px 18px; animation-name: bs-info-up; }
  @keyframes bs-info-up { from { opacity: 0; translate: 0 16px; } }
  .bs-info h2 { font-size: 20px; }
  .bs-nav { top: 30%; width: 36px; height: 52px; }
  .bs-nav::before { width: 10px; height: 10px; }
  .bs-nav.prev { left: 6px; }
  .bs-nav.next { right: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .bs, .bs * { animation: none !important; transition: none !important; }
}
