/* room.css: the 3D library's frame. The canvas fills the space under the top bar; the app's own controls
   float over it: a title and hint, a caption naming whatever is under the pointer, the open bookcase's
   bar, and the pulled book's first page on antique paper. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

body.in-room main { max-width: none; padding: 0; }
.lib3d { position: relative; overflow: hidden; background: #0b0806; min-height: 320px; touch-action: none; user-select: none; -webkit-user-select: none; }
.lib3d-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.lib3d-hud { position: absolute; inset: 0; pointer-events: none; z-index: 2; color: #f3ead7; }
.lib3d-hud > * { pointer-events: auto; }
.lib3d-hud [hidden] { display: none !important; }

.lib3d-top { position: absolute; top: 12px; left: 16px; right: 16px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; pointer-events: none; }
.lib3d-top > * { pointer-events: auto; }
.lib3d-title { display: flex; flex-direction: column; gap: 2px; text-shadow: 0 1px 6px #000; }
.lib3d-title strong { font: 600 1.25rem/1.1 var(--head-font, Georgia, serif); letter-spacing: .02em; }
.lib3d-title span { font-size: .82rem; opacity: .85; }
.lib3d .btn { backdrop-filter: blur(6px); }
/* the goal: fill the library */
.lib3d-fill { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: .8rem; color: #f1dfae; }
.lib3d-fill b { display: block; width: 120px; height: 5px; border-radius: 3px; background: #ffffff26; overflow: hidden; box-shadow: inset 0 1px 2px #0008; }
.lib3d-fill i { display: block; height: 100%; background: linear-gradient(90deg, #8f6a2e, #f2dfa6); }

/* the museum label: names what you're pointing at */
.lib3d-caption {
  position: absolute; left: 50%; bottom: 18px; translate: -50% 0; max-width: min(92%, 560px); pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 18px 9px; text-align: center;
  background: linear-gradient(180deg, #f2dfa6, #c9a157 60%, #9a7434); color: #24180a;
  border: 1px solid #5d4519; border-radius: 4px; box-shadow: 0 6px 18px #000000b3, inset 0 1px 0 #ffffff80;
  font-family: var(--head-font, Georgia, serif);
}
.lib3d-caption strong { font-variant: small-caps; font-size: 1.05rem; letter-spacing: .03em; }
.lib3d-caption span { font-size: .82rem; opacity: .85; }

/* standing at a bookcase */
.lib3d-casebar {
  position: absolute; left: 16px; right: 16px; top: 64px; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px; background: #0f0b08cc; border: 1px solid #ffffff1f; backdrop-filter: blur(8px);
}
.lib3d-casebar .eyebrow { color: #d9b56a; }
.lib3d-casebar strong { font: 600 1.05rem var(--head-font, Georgia, serif); }
.lib3d-casebar .small { opacity: .8; }

/* the pulled book, opened to its first page */
.lib3d-page {
  position: absolute; right: 16px; bottom: 16px; width: min(380px, calc(100% - 32px)); padding: 18px 20px 16px;
  color: #2a1d10; border-radius: 3px 6px 6px 3px;
  background:
    radial-gradient(circle at 18% 22%, #b0884a14 0 2px, transparent 3px),
    radial-gradient(circle at 76% 64%, #9a6a3012 0 3px, transparent 4px),
    radial-gradient(120% 90% at 50% 40%, #f5ecd4 0%, #ead9b2 70%, #d9c08a 100%);
  box-shadow: inset 14px 0 18px -14px #5a3c1a8c, 0 14px 40px #000000c7, 0 0 0 1px #6b4f2a;
  font-family: var(--read-font, Georgia, serif);
}
.lib3d-page h3 { margin: 0 0 8px; font: 600 1.2rem/1.2 var(--head-font, Georgia, serif); color: #2a1d10; }
.lib3d-page h3::first-letter { color: #7a2a1c; font-size: 1.5em; }
.lib3d.is-green .lib3d-page h3::first-letter { color: #1f5a38; }
.lib3d-page p { margin: 0 0 10px; line-height: 1.5; }
.lib3d-page .small { color: #4f3b26; }
.lib3d-page .row { gap: 8px; flex-wrap: wrap; }

/* loading: a thin brass bar */
.lib3d-load { position: absolute; inset: 0; display: grid; place-content: center; gap: 10px; text-align: center; background: #0b0806; color: #e9d9b4;
  font: 1rem var(--head-font, Georgia, serif); letter-spacing: .04em; pointer-events: none; }
.lib3d-load b { display: block; width: 220px; height: 3px; background: #ffffff1a; border-radius: 2px; overflow: hidden; }
.lib3d-load i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8f6a2e, #f2dfa6); }
.lib3d-load.done { opacity: 0; visibility: hidden; }
@media (prefers-reduced-motion: no-preference) {
  .lib3d-load { transition: opacity .6s ease, visibility 0s linear .6s; }
  .lib3d-load i { transition: width .3s ease; }
}

@media (max-width: 640px) {
  .lib3d-title span { display: none; }
  .lib3d-casebar { top: 56px; left: 10px; right: 10px; padding: 8px 10px; }
  .lib3d-page { left: 10px; right: 10px; bottom: 10px; width: auto; }
  .lib3d-caption { bottom: 10px; }
  .lib3d-page:not([hidden]) ~ .lib3d-caption { display: none; }
}
