/* Paged militia scrapbook: the existing taped-photo spread stays intact. */
.militia-book {
  --book-paper-light: #eee9d5;
  --book-paper-mid: #dad5bb;
  --book-paper-dark: #c8c3a7;
  --book-paper-edge: #797d60;
  --book-pencil: #62654c;
  --book-tab: #df733b;
  --book-tab-ink: #f5e8ce;
  min-width: 0;
}
.militia-book .scrapbook-wrap {
  perspective: 1600px;
  perspective-origin: 50% 50%;
}
.militia-book .scrapbook-board {
  grid-auto-rows: 241px;
}
.militia-book .scrapbook-wrap > .scrapbook-star {
  opacity: 1;
  transition: opacity 180ms ease-out;
}
.militia-book .scrapbook-wrap.book-is-turning > .scrapbook-star {
  opacity: 0;
  visibility: hidden;
  transition: none;
}
.book-edge {
  position: absolute;
  z-index: 20;
  top: 50%;
  width: 44px;
  height: 156px;
  padding: 0 5px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: transparent;
  color: #f9f3df;
  isolation: isolate;
  border-radius: 3px;
  transition: transform .2s ease, opacity .2s ease;
}
.book-edge::before {
  content: '';
  position: absolute;
  inset: 0 5px;
  z-index: -1;
  background: linear-gradient(90deg, #333e2de8, #596345f5 50%, #3a452ee8);
  border: 1px solid #7a8663;
  box-shadow: 2px 3px #28362155, inset 0 1px #ffffff35;
  border-radius: 2px 6px 6px 2px;
}
.book-edge-prev { left: -16px; }
.book-edge-next { right: -16px; }
.book-edge-prev::before { border-radius: 6px 2px 2px 6px; }
.book-edge-arrow { font: 500 37px/.8 var(--display); }
.book-edge-label {
  font: 700 6px/1.5 var(--mono);
  letter-spacing: 1px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}
.book-edge:hover:not(:disabled) { transform: translateY(-50%) scale(1.04); }
.book-edge:focus-visible { outline: 3px solid #173746; outline-offset: 4px; }
.book-edge:disabled { cursor: default; opacity: .36; }
.book-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 12px 0;
  font: 700 8px/1.6 var(--mono);
  letter-spacing: 1px;
  color: #4f624a;
  text-align: center;
}
.book-pagination strong { font-weight: 700; }
.book-pagination small { font: 6px/1.7 var(--mono); letter-spacing: .6px; opacity: .74; }
.book-page-dots { display: inline-flex; align-items: center; gap: 7px; }
.book-page-dot { width: 5px; height: 5px; border: 1px solid currentColor; border-radius: 50%; opacity: .5; }
.book-page-dot.active { background: currentColor; opacity: 1; }

/* Quiet, noninteractive photo spaces reserve the next page for future artists. */
.book-placeholder {
  position: relative;
  width: 100%;
  max-width: 390px;
  min-width: 0;
  min-height: 225px;
  justify-self: center;
  transform: rotate(-4deg);
  color: var(--book-pencil);
  pointer-events: none;
}
.book-placeholder:nth-child(2n) { transform: rotate(3deg); margin-top: 15px; }
.book-placeholder:nth-child(3) { transform: rotate(-6deg); margin-left: 8px; }
.book-placeholder:nth-child(4) { transform: rotate(-2deg); margin-top: 16px; }
.book-placeholder-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  width: 100%;
  height: 200px;
  padding: 24px;
  border: 1px dashed #8d92706b;
  background: linear-gradient(130deg, #ffffff15, #8d896614);
  box-shadow: inset 0 0 0 7px #fff1;
  transform: rotate(1deg);
}
.book-placeholder-frame::before,
.book-placeholder-frame::after {
  content: '';
  position: absolute;
  width: 59px;
  height: 23px;
  background: #aaa78c26;
  border: 1px solid #bbb89840;
  top: -10px;
  left: 12px;
  transform: rotate(-19deg);
  clip-path: polygon(0 5%, 98% 0, 100% 90%, 4% 100%);
}
.book-placeholder-frame::after { top: auto; left: auto; bottom: -9px; right: 7px; transform: rotate(15deg); }
.book-placeholder-label { font: 700 10px/1.6 var(--mono); letter-spacing: 1.1px; text-align: center; opacity: .68; }
.book-placeholder-frame small { font: 7px/1.7 var(--mono); letter-spacing: .7px; text-align: center; opacity: .48; }
.book-placeholder > small { display: block; font: 6px/1.7 var(--mono); letter-spacing: .5px; margin-top: 10px; padding-left: 9px; opacity: .55; }
.militia-book .artist-card .artist-tag-long { font-size: 54px; letter-spacing: -4px; transform: rotate(-13deg) skew(-9deg); }
.militia-book .artist-tag-long::after { width: 109px; }

/* A real two-sided leaf rotates across the spine; JS owns timing and cancellation. */
.book-turning-leaf {
  position: absolute;
  z-index: 15;
  top: 0;
  right: 0;
  bottom: 0;
  width: 50%;
  transform-origin: left center;
  transform-style: preserve-3d;
  pointer-events: none;
  will-change: transform;
}
.book-turning-leaf.book-turn-prev { left: 0; right: auto; transform-origin: right center; }
.book-receiving-page {
  position: absolute;
  z-index: 14;
  inset: 0 auto 0 0;
  width: 50%;
  pointer-events: none;
  background: radial-gradient(#4a4b2a12 .7px, transparent .7px), linear-gradient(90deg, var(--book-paper-mid), var(--book-paper-light) 12%, var(--book-paper-light) 88%, var(--book-paper-dark));
  background-size: 4px 4px, 100% 100%;
  border-radius: 3px 0 0 2px;
}
.book-receiving-prev { left: auto; right: 0; border-radius: 0 8px 5px 0; }
.book-leaf-front,
.book-leaf-back {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: radial-gradient(#4a4b2a12 .7px, transparent .7px), linear-gradient(90deg, var(--book-paper-mid), var(--book-paper-light) 12%, var(--book-paper-light) 88%, var(--book-paper-dark));
  background-size: 4px 4px, 100% 100%;
  border: 1px solid var(--book-paper-edge);
  box-shadow: 4px 5px 16px #342b2333;
}
.book-leaf-front { transform: translateZ(.15px); border: 0; border-radius: 0 8px 5px 0; }
.book-leaf-back { transform: rotateY(180deg) translateZ(.15px); border-radius: 5px 0 0 8px; }
.book-turn-prev .book-leaf-front { border-radius: 3px 0 0 2px; }
.book-turn-prev .book-leaf-back { border-radius: 0 3px 2px 0; }
.book-leaf-back::before {
  content: 'MILITIA ARCHIVE';
  position: absolute;
  top: 34px;
  left: 21px;
  right: 21px;
  font: 700 7px/1.5 var(--mono);
  letter-spacing: 2px;
  color: var(--book-pencil);
  opacity: .6;
}
.book-leaf-front::after,
.book-leaf-back::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, #34261b26, transparent 13%, transparent 88%, #34261b17);
  box-shadow: inset 0 0 16px #6a614320;
}
.book-leaf-board {
  position: absolute !important;
  top: 0;
  left: -100%;
  width: 200%;
  height: 100%;
  margin: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.book-turn-prev .book-leaf-board { left: 0; }
.book-leaf-back .book-leaf-board { left: 0; }
.book-turn-prev .book-leaf-back .book-leaf-board { left: -100%; }
.book-leaf-board .artist-card { transition: none !important; }

body[data-site-theme="halloween"] .militia-book {
  --book-paper-light: #d3c8b8;
  --book-paper-mid: #aa9789;
  --book-paper-dark: #a29283;
  --book-paper-edge: #72505b;
  --book-pencil: #643b45;
  --book-tab: #b01931;
  --book-tab-ink: #f5d7cd;
}
body[data-site-theme="halloween"] .book-edge { color: #f4d8d0; }
body[data-site-theme="halloween"] .book-edge::before { background: linear-gradient(90deg, #310f21, #861d39 53%, #3f1026); border-color: #ab4860; box-shadow: 2px 3px #08040c88, inset 0 1px #d4778a55; }
body[data-site-theme="halloween"] .book-edge:focus-visible { outline-color: var(--haunt-acid); }
body[data-site-theme="halloween"] .book-pagination { color: #cfa3b6; }
body[data-site-theme="halloween"] .book-placeholder-frame { border-color: #6d3d5366; background: linear-gradient(130deg, #d3bbac10, #5624380d); box-shadow: inset 0 0 0 7px #44203906; }
body[data-site-theme="halloween"] .book-placeholder-frame::before,
body[data-site-theme="halloween"] .book-placeholder-frame::after { background: #856a7920; border-color: #6a495330; }
body[data-site-theme="halloween"] .book-leaf-front,
body[data-site-theme="halloween"] .book-leaf-back { box-shadow: 4px 5px 16px #1c071b55; }

@media (max-width: 1000px) {
  .militia-book .scrapbook-board { grid-auto-rows: 224px; }
  .book-placeholder { min-height: 208px; }
  .book-placeholder-frame { height: 180px; }
}
@media (max-width: 760px) {
  .militia-book .scrapbook-board { grid-auto-rows: 213px; }
  .book-placeholder { min-height: 197px; }
  .book-placeholder-frame { height: 170px; padding: 16px; }
  .book-placeholder-label { font-size: 8px; letter-spacing: .6px; }
  .book-placeholder-frame small { font-size: 6px; }
  .militia-book .artist-tag-long { font-size: 45px; letter-spacing: -3px; }
  .militia-book .artist-tag-long::after { width: 89px; }
  .book-edge { height: 138px; }
  .book-pagination { font-size: 7px; }
}
@media (max-width: 600px) {
  .militia-book .scrapbook-board { grid-auto-rows: 229px; }
  .book-placeholder { max-width: 310px; min-height: 226px; }
  .book-placeholder-frame { height: 205px; }
  .book-placeholder:nth-child(2n),
  .book-placeholder:nth-child(4) { margin-top: 3px; }
  .book-placeholder:nth-child(3) { margin-left: 0; }
  .book-placeholder-label { font-size: 9px; }
  .book-edge { height: 156px; }
  .militia-book .artist-tag-long { font-size: 54px; letter-spacing: -4px; }
  .militia-book .artist-tag-long::after { width: 109px; }
  .book-pagination { gap: 8px; padding-top: 18px; letter-spacing: .7px; }
  .book-pagination small { font-size: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .book-edge { transition: none; }
  .militia-book .scrapbook-wrap > .scrapbook-star { transition: none; }
  .book-turning-leaf { display: none !important; will-change: auto; }
  .book-receiving-page { display: none !important; }
}
