/* The Player's Guide as a book (guide.html, assets/js/book.js). */

.guide-head .wrap { padding-top: clamp(24px, 4vw, 44px); padding-bottom: clamp(18px, 3vw, 28px); }
.guide-head h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); }
.guide-head-row { display: grid; gap: 16px; align-items: end; }
@media (min-width: 900px) { .guide-head-row { grid-template-columns: 1fr auto; } }

.book-app { padding: 14px 0 40px; background: radial-gradient(ellipse at 50% 0%, var(--night-4) 0%, var(--night) 70%); }
.book-app:fullscreen { background: var(--night); padding: 10px 0; overflow: auto; }
.book-app:fullscreen .wrap { max-width: none; }

.bk-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between;
  padding: 8px; background: var(--night-2); border: 1px solid var(--line); border-radius: var(--radius);
}
.bk-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bk-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--night-3); color: var(--text); cursor: pointer;
  font: 600 0.92rem/1.2 var(--font-head); letter-spacing: 0.03em; white-space: nowrap;
}
.bk-btn:hover { border-color: var(--accent-text); color: var(--accent-text); }
.bk-btn[aria-expanded="true"] { background: var(--gold); color: var(--on-gold); border-color: var(--gold); }
.bk-btn:disabled { opacity: 0.4; cursor: default; border-color: var(--line); color: var(--text-dim); }
.bk-btn.icon { width: 40px; padding: 0; justify-content: center; }
.bk-btn.small { min-height: 34px; padding: 6px 12px; font-size: 0.86rem; }
.bk-btn svg { width: 20px; height: 20px; flex: 0 0 auto; }
.bk-goto { display: flex; align-items: center; gap: 6px; color: var(--text-dim); font: 600 0.9rem/1 var(--font-head); }
.bk-goto input {
  width: 4.2em; min-height: 38px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--night);
  color: var(--text); font: 700 1rem/1 var(--font-head); text-align: center;
}
.bk-goto input::-webkit-inner-spin-button { opacity: 0.4; }
@media (max-width: 640px) {
  .bk-toolbar { display: grid; grid-template-columns: auto auto; justify-content: space-between; gap: 8px; }
  .bk-toolbar > .bk-group:first-child { grid-column: 1; grid-row: 1; }
  .bk-toolbar > .bk-group:last-child { grid-column: 2; grid-row: 1; }
  .bk-toolbar > .bk-nav { grid-column: 1 / -1; grid-row: 2; justify-content: center; flex-wrap: nowrap; }
  #bk-first, #bk-last { display: none; }
  .bk-btn span { display: none; }
  .bk-btn:not(.icon):not(.small) { width: 40px; padding: 0; justify-content: center; }
  .bk-goto label { display: none; }
}

.bk-body { position: relative; display: flex; gap: 14px; margin-top: 12px; }
.bk-panel {
  flex: 0 0 320px; max-height: var(--book-h, 70vh); display: flex; flex-direction: column; background: var(--night-2);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.bk-panel[hidden] { display: none; }
.bk-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--line); }
.bk-panel-head h2 { font-size: 1.05rem; margin: 0; letter-spacing: 0.06em; text-transform: uppercase; }
.bk-toc, .bk-search { overflow-y: auto; padding: 8px 6px 14px; flex: 1; min-height: 0; }
.bk-toc[hidden], .bk-search[hidden] { display: none; }
.toc-list { list-style: none; margin: 0; padding: 0; }
.toc-list li { margin: 0; }
.toc-list a {
  display: flex; gap: 10px; justify-content: space-between; padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--text-dim); font-size: 0.9rem; line-height: 1.3;
}
.toc-list li.ch a { color: var(--strong); font: 700 0.95rem/1.3 var(--font-head); margin-top: 6px; }
.toc-list li.sec a { padding-left: 22px; }
.toc-list a:hover, .toc-list a:focus-visible { background: var(--night-3); color: var(--accent-text); }
.toc-list a.here { color: var(--accent-text); background: rgba(var(--accent-rgb), 0.08); }
.toc-list .p { color: var(--text-faint); font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.bk-search form { display: flex; gap: 6px; padding: 4px 6px 10px; }
.bk-search input {
  flex: 1; min-width: 0; min-height: 38px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--night); color: var(--text);
  padding: 6px 12px; font: inherit; font-size: 0.95rem;
}
.bk-hitnav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px 8px; color: var(--text-dim); font-size: 0.88rem; }
.bk-hitnav[hidden] { display: none; }
.bk-search-status { padding: 0 10px; margin: 0 0 8px; color: var(--text-dim); font-size: 0.88rem; }
.bk-results { list-style: none; margin: 0; padding: 0; }
.bk-results li { margin: 0; }
.bk-results button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 6px; color: var(--text-dim);
  padding: 8px 10px; cursor: pointer; font: inherit; font-size: 0.88rem; line-height: 1.4;
}
.bk-results button:hover, .bk-results button:focus-visible { background: var(--night-3); }
.bk-results button.here { background: rgba(var(--accent-rgb), 0.1); }
.bk-results b { display: block; color: var(--strong); font: 700 0.9rem/1.3 var(--font-head); margin-bottom: 2px; }
.bk-results b span { color: var(--text-faint); font-weight: 600; }
.bk-results mark { background: rgba(var(--accent-rgb), 0.85); color: var(--on-gold); border-radius: 2px; padding: 0 1px; }
@media (max-width: 1023px) {
  .bk-panel { position: absolute; z-index: 20; left: 0; top: 0; width: min(360px, 100%); box-shadow: var(--shadow); max-height: var(--book-h, 70vh); }
}

/* ---------------------------------------------------------------- the book */
.bk-stage { position: relative; flex: 1; min-width: 0; display: flex; justify-content: center; align-items: flex-start; }
.book {
  position: relative; display: flex; perspective: 2600px; transition: transform 0.45s ease;
  width: var(--book-w, 800px); height: var(--book-h, 520px); user-select: none; -webkit-user-select: none; touch-action: pan-y;
}
.book.cover-only { transform: translateX(-25%); }
.book.single { perspective: 1800px; }
.bk-slot { position: relative; flex: 1; height: 100%; }
.book.single .bk-slot.left { display: none; }
.bk-page {
  position: absolute; inset: 0; background: #faf6ec; overflow: hidden; box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}
.bk-page img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: fill; }
.bk-page .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #9a927e; font: 600 1rem var(--font-head); }
/* the spine: shading on the inside edge of each page */
.bk-slot.left .bk-page::after, .bk-slot.right .bk-page::after, .bk-flip .face::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none;
}
.bk-slot.left .bk-page::after, .bk-flip .face.back::after { right: 0; background: linear-gradient(to left, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0)); }
.bk-slot.right .bk-page::after, .bk-flip .face.front::after { left: 0; background: linear-gradient(to right, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0)); }
.book.single .bk-slot.right .bk-page::after { display: none; }
.bk-slot.left .bk-page { border-radius: 4px 0 0 4px; }
.bk-slot.right .bk-page { border-radius: 0 4px 4px 0; }
.book.single .bk-slot.right .bk-page { border-radius: 4px; }

/* page edges: thin stacks of paper on the outside of the book */
.book:not(.single) .bk-slot.left.has-page::before, .book:not(.single) .bk-slot.right.has-page::before {
  content: ""; position: absolute; top: 3px; bottom: 3px; width: 6px; z-index: -1;
  background: repeating-linear-gradient(90deg, #e9e3d3 0 1px, #cfc8b6 1px 2px);
}
.book:not(.single) .bk-slot.left.has-page::before { left: -5px; border-radius: 3px 0 0 3px; }
.book:not(.single) .bk-slot.right.has-page::before { right: -5px; border-radius: 0 3px 3px 0; }

/* the turning leaf */
.bk-flip { position: absolute; top: 0; height: 100%; z-index: 5; transform-style: preserve-3d; }
.bk-flip .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; background: #faf6ec; overflow: hidden; }
.bk-flip .face img { width: 100%; height: 100%; display: block; }
.bk-flip .face.back { transform: rotateY(180deg); }
.bk-flip .shade { position: absolute; inset: 0; pointer-events: none; background: #000; opacity: 0; }

/* click zones on the page edges, and the zoom cursor in the middle */
.bk-hot { position: absolute; top: 0; bottom: 0; width: 16%; z-index: 4; cursor: pointer; background: transparent; border: 0; padding: 0; }
.bk-hot.prev { left: 0; cursor: w-resize; }
.bk-hot.next { right: 0; cursor: e-resize; }
.bk-hot:hover { background: linear-gradient(to var(--dir, right), rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.06)); }
.bk-hot.prev:hover { --dir: left; }
.bk-page { cursor: zoom-in; }

/* the lines of the printed contents page */
.bk-link { position: absolute; z-index: 3; background: transparent; border: 0; padding: 0; cursor: pointer; border-radius: 2px; }
.bk-link:hover { background: rgba(227, 115, 28, 0.14); box-shadow: inset 0 -2px 0 rgba(227, 115, 28, 0.7); }

/* search highlights */
.bk-hl { position: absolute; background: rgba(255, 205, 40, 0.42); border-radius: 2px; box-shadow: 0 0 0 1px rgba(214, 150, 0, 0.55); pointer-events: none; mix-blend-mode: multiply; }
.bk-hl.on { background: rgba(255, 170, 0, 0.6); box-shadow: 0 0 0 2px rgba(214, 90, 0, 0.9); animation: bk-pulse 1.2s ease 2; }
@keyframes bk-pulse { 50% { box-shadow: 0 0 0 5px rgba(255, 170, 0, 0.35); } }
.bk-num { position: absolute; bottom: -26px; font: 600 0.8rem/1 var(--font-head); color: var(--text-faint); letter-spacing: 0.05em; }
.bk-slot.left .bk-num { left: 4px; }
.bk-slot.right .bk-num { right: 4px; }
.bk-status { text-align: center; color: var(--text-dim); margin: 34px 0 0; font: 600 0.95rem/1.4 var(--font-head); letter-spacing: 0.03em; }

/* ---------------------------------------------------------------- zoomed page */
.bk-zoom { position: fixed; inset: 0; z-index: 600; background: #070b14; display: flex; flex-direction: column; }
.bk-zoom[hidden] { display: none; }
.bk-zoom-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px var(--gutter); border-bottom: 1px solid var(--line); color: var(--text-dim); font: 600 0.95rem/1.2 var(--font-head); }
.bk-zoom-scroll { flex: 1; overflow: auto; padding: 16px; outline: none; }
.bk-zoom-scroll .zpage { position: relative; margin: 0 auto; background: #faf6ec; box-shadow: var(--shadow); }
.bk-zoom-scroll .zpage img { display: block; width: 100%; height: auto; }

@media (prefers-reduced-motion: reduce) {
  .book { transition: none; }
}
