/* book.css — Book mode chrome (P1). Overlays sit over #canvas-viewport; only
   the arrows capture clicks so the canvas stays fully interactive. A bottom
   navigator (#book-nav) replaces the flat spread strip in book mode. */

#book-chrome {
  position: absolute;
  inset: 0;
  pointer-events: none;   /* canvas interactive; arrows opt back in */
  z-index: 6;
}

/* Obvious turn arrows — a clear button box with a chevron on each edge. */
#book-chrome .book-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;   /* icon glyph, not text — outside the type scale deliberately */
  line-height: 1;
  color: var(--gold, #C4943A);
  background: rgba(20, 14, 6, 0.72);
  border: 1px solid rgba(var(--gold-rgb, 196, 148, 58), 0.55);
  border-radius: var(--radius, 4px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.12s ease;
}
#book-chrome .book-arrow:hover { background: rgba(var(--gold-rgb, 196, 148, 58), 0.28); }
#book-chrome .book-arrow:active { transform: translateY(-50%) scale(0.94); }
#book-chrome .book-arrow-left  { left: 14px; }
#book-chrome .book-arrow-right { right: 14px; }

/* Soft page-turn overlay (P2) — a snapshot of the outgoing opening curling
   around the spine while the canvas loads the next opening beneath. */
.book-turn-host {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 7;
  overflow: hidden;
  perspective: 1600px;
}
.book-turn-leaf {
  position: absolute;
  inset: 0;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  transform-origin: 50% 50%;
  backface-visibility: hidden;
  will-change: transform, opacity;
  box-shadow: 0 0 40px rgba(0,0,0,0.4);
}

/* Spine shadow at the gutter — visual only. */
#book-chrome .book-spine {
  position: absolute;
  top: 0; bottom: 0; left: 50%;
  width: 40px;
  transform: translateX(-20px);
  pointer-events: none;
  background: linear-gradient(90deg,
    rgba(0,0,0,0) 0%, rgba(0,0,0,0.22) 45%, rgba(0,0,0,0.30) 50%,
    rgba(0,0,0,0.22) 55%, rgba(0,0,0,0) 100%);
}

/* Page numbers in the outer margins. Fixed ink, not a theme token: they sit
   over the paper (always light, in every theme), so a dark ink is the one
   choice that stays legible everywhere — the old --text-secondary measured
   2.3:1 on the paper and 1.4:1 when it strayed onto the desk (18 Jul 2026). */
#book-chrome .book-pagenum {
  position: absolute;
  bottom: 3%;
  font-size: var(--fs-body, 12px);
  color: #4A3A26;                 /* ≈9.6:1 on the paper */
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#book-chrome .book-pagenum-left  { left: 8%; }
#book-chrome .book-pagenum-right { right: 8%; text-align: right; }

/* Opening title, top-centre. Fixed dark pill + fixed warm-white text, NOT
   theme tokens: the pill floats over the desk, whose colour varies by theme —
   the old translucent wash blended with the tan desk to 1.27:1, which is why
   the page number was near-invisible (18 Jul 2026). ≈13:1 as set here. */
#book-chrome .book-counter {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-body, 12px);
  letter-spacing: 0.04em;
  color: #EDE0C8;
  background: rgba(30, 20, 9, 0.92);
  border: 1px solid rgba(196, 148, 58, 0.35);
  padding: 3px 12px;
  border-radius: 10px;
  pointer-events: none;
  white-space: nowrap;
}
#book-chrome.book-closed .book-counter { color: var(--gold, #C4943A); }

/* In book view: hide the single/spread toggle (book view has openings, not a
   single-page mode). The window tool IS available in book mode as of P3 — it now
   cuts leaf-model windows (mirrored through the sheet, position-resolved
   reveals) rather than the flat "reveal next spread" hole. */
body.book-mode #btn-toggle-spread { display: none; }

/* Prominent topbar toggle active state. */
#btn-book-view.view-active {
  color: var(--gold, #C4943A);
  box-shadow: inset 0 0 0 1px rgba(196, 148, 58, 0.55);
  border-radius: 6px;
}

/* ── Bottom opening-navigator (replaces the flat strip in book mode) ── */
#book-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-3, 12px);
  height: 84px;
  padding: var(--sp-2, 8px) var(--sp-3, 12px);
  background: var(--bg-panel, #1a1206);
  border-top: 1px solid var(--border, #423122);
  box-sizing: border-box;
}
#book-nav .book-nav-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
/* Neutral at rest — gold is a state, not trim (accent discipline, 18 Jul 2026) */
#book-nav .book-nav-btn,
#book-nav .book-nav-count {
  background: var(--bg-input, #1B140C);
  color: var(--text-secondary, #b8a878);
  border: 1px solid var(--border-light, #6A503A);
  border-radius: var(--radius, 4px);
  padding: 6px 10px;
  font-size: var(--fs-body, 12px);
  cursor: pointer;
  white-space: nowrap;
}
#book-nav .book-nav-btn:hover,
#book-nav .book-nav-count:hover { color: var(--gold, #C4943A); border-color: var(--gold-dim, #6E5942); background: var(--hover-tint, rgba(255,255,255,0.05)); }
#book-nav .book-nav-count { font-variant-numeric: tabular-nums; }

#book-nav .book-nav-track {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  flex: 1;
  height: 100%;
  padding: 2px;
}
#book-nav .book-nav-item {
  flex: 0 0 auto;
  width: 88px;    /* spread-shaped for two-page openings (18 Jul 2026) */
  height: 62px;
  border: 1px solid var(--border, #423122);
  border-radius: var(--radius, 4px);
  background: var(--bg-surface, #221706);
  color: var(--text-secondary, #b8a878);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
}
#book-nav .book-nav-item:hover { border-color: var(--border-light, #6A503A); }
#book-nav .book-nav-item.cover { width: 46px; background: var(--bg-panel-alt, #2b2010); border-style: dashed; }
#book-nav .book-nav-item.active { border-color: var(--gold, #C4943A); box-shadow: 0 0 0 1px var(--gold, #C4943A); }
/* contain, not cover — show the whole spread accurately, letterboxed if the
   page ratio differs, rather than cropping content off the tile edges */
#book-nav .book-nav-item img { width: 100%; height: 100%; object-fit: contain; }
#book-nav .book-nav-item .book-nav-label { font-size: var(--fs-hint, 11.5px); }
