/* =====================================================================================================
   book.css: Floor 4 · The Library (/learn/book/) and its twin Piso 4 · La biblioteca (/es/aprender/libro/).
   Mood: a calm, warm reading room in wood and brass. One chandelier, the book on a lectern.
   Every selector is scoped under body[data-floor="library"]. Tokens only; gold (--deco-*) is decor only.
   No 100vw: full-bleed layers use inset inside an overflow: clip parent (.scene, .rooftop).
   ===================================================================================================== */

/* ---- The reading room (page head + lectern) ---- */
body[data-floor="library"] .library-hall {
  /* warm lamp light pooled at the top, wood panelling fading to night */
  background:
    radial-gradient(60% 45% at 78% 8%, rgb(134 171 167 / 0.1), transparent 70%),
    radial-gradient(70% 55% at 50% 0%, var(--deco-wood), transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 119px, rgb(134 171 167 / 0.035) 119px 120px),
    linear-gradient(180deg, #0B1315, #05080A);
}
/* the scene already pads the block; the page head only keeps its bottom rhythm here */
body[data-floor="library"] .library-hall__head { padding-block: 0; }
body[data-floor="library"] .library-hall__head h1 { max-width: 14em; text-wrap: balance; }
body[data-floor="library"] .library-hall__head .lede { text-wrap: pretty; }

@media (min-width: 56rem) {
  body[data-floor="library"] .library-hall__grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--s-7);
  }
}

/* The stand: one chandelier hanging over the lectern. Decor never sits under text: it has its own column on wide
   screens, and stacks under the lede on phones. */
body[data-floor="library"] .library-stand {
  display: grid;
  justify-items: center;
  min-width: 0;
}
body[data-floor="library"] .library-stand__chandelier {
  width: clamp(6.5rem, 4rem + 7vw, 10rem);
  margin-block-end: calc(-1 * var(--s-3));
  z-index: 1;
}

/* The lectern art is drawn in a 480 x 560 box with an empty square cover slot at x 165, y 70, 150 x 150
   (left 34.375 %, top 12.5 %, width 31.25 %). The wrapper keeps that exact ratio, so the cover lines up at every
   width; the art is never letterboxed. */
body[data-floor="library"] .library-lectern {
  position: relative;
  width: min(100%, 26rem);
  aspect-ratio: 480 / 560;
  margin: 0;
}
body[data-floor="library"] .library-lectern::before {     /* the reading lamp's pool of light (decor) */
  content: "";
  position: absolute;
  inset: 2% 12% 52%;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(closest-side, var(--glow-gold), transparent 100%);
  opacity: 0.35;
}
body[data-floor="library"] .library-lectern__art {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}
body[data-floor="library"] .library-lectern__art img {
  display: block;
  width: 100%;
  height: 100%;
}
body[data-floor="library"] .library-lectern .cover {
  position: absolute;
  inset-inline-start: 34.375%;
  inset-block-start: 12.5%;
  z-index: 1;
  width: 31.25%;
  margin: 0;
}

@media (min-width: 56rem) {
  body[data-floor="library"] .library-lectern { width: min(100%, 34rem); }
}

/* ---- The reading table: why it led to the app + the facts card with the exit doors ---- */
body[data-floor="library"] .library-reading {
  background:
    radial-gradient(80% 60% at 20% 0%, rgb(17 27 29 / 0.55), transparent 70%),
    var(--noir-1);
}
body[data-floor="library"] .library-reading__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-6);
  align-items: start;
}
@media (min-width: 56rem) {
  body[data-floor="library"] .library-reading__grid {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: var(--s-8);
  }
}
body[data-floor="library"] .library-why { min-width: 0; max-width: var(--max-text); }
body[data-floor="library"] .library-why h2 { margin-block-end: var(--s-4); }
body[data-floor="library"] .library-why :is(p, si-p) {
  font-size: var(--t-title3);
  line-height: 1.65;
  color: var(--ink-1);
  text-wrap: pretty;
}

body[data-floor="library"] .library-facts { min-width: 0; }
body[data-floor="library"] .library-facts h2 {
  margin-block-end: var(--s-3);
  font-size: var(--t-title2);
  letter-spacing: 0.12em;
}
body[data-floor="library"] .library-facts .pairs { margin-block-end: var(--s-4); }
body[data-floor="library"] .library-facts__doors { margin-block-end: var(--s-3); }
body[data-floor="library"] .library-facts__tm { margin: 0; }

/* ---- The stairs up to the Penthouse ---- */
body[data-floor="library"] .library-up { border-block-start: 1px solid var(--deco-gold-faint); }
body[data-floor="library"] .library-up__link { gap: 0.75em; text-align: start; }
body[data-floor="library"] .library-up__code {
  display: inline-grid;
  place-items: center;
  min-width: 2rem;
  height: 2rem;
  padding-inline: 0.3rem;
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1.5px solid var(--deco-gold);
  border-radius: 999px;
}

/* ---- Preferences ---- */
@media (prefers-contrast: more) {
  body[data-floor="library"] .library-lectern::before { display: none; }
  body[data-floor="library"] .library-hall,
  body[data-floor="library"] .library-reading { background: var(--noir-0); }
}
@media (forced-colors: active) {
  body[data-floor="library"] .library-lectern::before { display: none; }
  body[data-floor="library"] .library-up__code { border-color: CanvasText; }
}

/* Lead the Way Fund, on the Library floor with the book. The case matches
   the SI Amero medallion: glass, plinth, cone, slow turn, scanlines. */
body[data-floor="library"] .library-fund { text-align: center; }
body[data-floor="library"] .ltwf-case {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  margin-block: var(--s-5);
  text-decoration: none;
}
body[data-floor="library"] .ltwf-stage {
  display: block;
  position: relative;
  width: min(22rem, 92vw);
  aspect-ratio: 4 / 5;
  flex: 0 0 auto;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(#0B1315, #020304);
  box-shadow: inset 0 0 0 2px rgb(232 255 252 / 0.35);
}
body[data-floor="library"] .ltwf-stage picture { display: contents; }
body[data-floor="library"] .ltwf-stage img,
body[data-floor="library"] .ltwf-stage canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
body[data-floor="library"] .ltwf-stage canvas {
  position: absolute;
  inset: 0;
}
body[data-floor="library"] .ltwf-stage.is-live img {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
body[data-floor="library"] .ltwf-case__name {
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}
@media (prefers-contrast: more) {
  body[data-floor="library"] .ltwf-stage canvas { display: none; }
  body[data-floor="library"] .ltwf-stage.is-live img {
    position: static;
    width: 100%;
    height: auto;
    clip: auto;
    overflow: visible;
  }
}
