/* The captions share a grid cell so the paper stays at the same height as pages turn. */
.book-captions {
  display: grid;
  align-items: center;
  max-width: min(90%, 47rem);
  margin-inline: auto;
}
.book-captions .hero-desc { grid-area: 1 / 1; text-wrap: balance; }
.book-captions [aria-hidden="true"] { visibility: hidden; }
.caption-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6em;
  margin-bottom: .18em;
  color: var(--ink);
  font: 650 clamp(1.08rem, 1.55vw, 1.4rem)/1.4 var(--serif);
  letter-spacing: .07em;
}
.caption-title::before, .caption-title::after {
  content: "";
  width: 1.4em;
  height: 1px;
  background: var(--caption-rule, #b39155);
}
#caption-students { --caption-rule: #859765; }
#caption-adults { --caption-rule: #b48776; }
@media (max-width: 700px) {
  .book-captions { max-width: 100%; }
}
#interactive-book {
  --book-ink: #253d2a;
  --book-gold: #9b7848;
  --book-serif: var(--serif, "Yu Mincho", "Hiragino Mincho ProN", serif);
  --sign-width: clamp(108px, 17.4cqw, 184px);
  container-type: inline-size;
  position: relative;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  color: var(--book-ink);
}
#interactive-book *,
#interactive-book *::before,
#interactive-book *::after { box-sizing: border-box; }
#interactive-book button {
  appearance: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.book-theater { position: relative; width: 100%; }
.paper-stage {
  --tilt-x: 0;
  --tilt-y: 0;
  --scene-pose: rotateX(calc(var(--tilt-y) * -1.35deg)) rotateY(calc(var(--tilt-x) * .7deg));
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 1024 / 367;
  perspective: clamp(650px, 104cqw, 1200px);
  perspective-origin: 50% 80%;
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  outline-offset: 3px;
}
.paper-stage[data-gesture="drag"],
.paper-stage[data-gesture="drag"] .object-hit { cursor: grabbing; }
.paper-stage:focus-visible {
  outline: 2px dashed #687b4c;
  border-radius: 14px;
}
#interactive-book :is(.paper-base, .paper-scenery, .paper-object, .paper-fallback) {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  pointer-events: none;
  -webkit-user-drag: none;
}
.paper-base {
  z-index: 0;
  filter: drop-shadow(0 2px 1px #55431e3d) drop-shadow(0 7px 5px #77542b30);
}
.paper-scenery {
  z-index: 1;
  transform-origin: 50% 79%;
  transform: var(--scene-pose);
  transition: transform .18s ease-out;
}
.paper-object {
  --object-lift: 0px;
  --object-scale: 1;
  --object-roll: 0deg;
  --object-shadow: transparent;
  --object-pose: translate3d(calc(var(--tilt-x) * 1.5px), calc(var(--object-lift) + var(--tilt-y) * .8px), 0)
    rotate(var(--object-roll)) scale(var(--object-scale));
  z-index: 2;
  transform: var(--object-pose);
  filter: drop-shadow(1px 3px 2px var(--object-shadow));
  transition: transform .36s cubic-bezier(.2,.8,.23,1), filter .3s ease;
}
.paper-object[data-object="kids"] { transform-origin: 23.4% 75.8%; --selected-roll: -2deg; }
.paper-object[data-object="students"] { transform-origin: 41% 73%; --selected-roll: -3.8deg; }
.paper-object[data-object="adults"] { transform-origin: 77.3% 75.5%; --selected-roll: 1.7deg; }
.paper-fallback { z-index: 3; }
@media (hover: hover) {
  .paper-stage:has(.object-hit[data-chapter="kids"]:hover) [data-object="kids"],
  .paper-stage:has(.object-hit[data-chapter="students"]:hover) [data-object="students"],
  .paper-stage:has(.object-hit[data-chapter="adults"]:hover) [data-object="adults"] {
    --object-lift: clamp(-7px, -.55cqw, -3px);
    --object-scale: 1.055;
    --object-roll: var(--selected-roll);
    --object-shadow: #70512b6b;
  }
}
.paper-stage:has(.object-hit[data-chapter="kids"]:focus-visible) [data-object="kids"],
.paper-stage:has(.object-hit[data-chapter="students"]:focus-visible) [data-object="students"],
.paper-stage:has(.object-hit[data-chapter="adults"]:focus-visible) [data-object="adults"] {
  --object-lift: -4px;
  --object-scale: 1.06;
  --object-roll: var(--selected-roll);
  --object-shadow: #70512b6b;
}

/* The rendered paper pieces supply the scenery throughout a turn and on
   every illustrated chapter. Only the open contents spread uses HTML signs. */
.paper-stage[data-mechanism] :is(.paper-scenery,.paper-object,.object-label,.paper-fallback),
.paper-stage[data-mechanism="cover"] .paper-base { opacity: 0; }
.paper-stage[data-gesture="closed"] { cursor: pointer; }
.paper-stage .object-hit:disabled { pointer-events: none; visibility: hidden; }

/* Each botanical sign and the illustration above it share one hit target. */
#interactive-book .object-hit {
  --sign-lift: 0px;
  --sign-shadow: #583e2138;
  position: absolute;
  z-index: 7;
  top: var(--sign-top);
  bottom: 12%;
  left: var(--hit-center);
  width: var(--hit-width, 28%);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  transform: translateX(-50%);
  border: 0;
  border-radius: 0;
  background: transparent;
  outline: 0;
  touch-action: pan-y pinch-zoom;
}
.object-hit[data-chapter="kids"] {
  --sign-ratio: 238 / 139;
  --sign-top: 7.5%;
  --paper-tab: #a18e50;
  --hit-center: 20.5%;
  --hit-width: 28%;
  --sign-art: url("/assets/paper-sign-kids.webp");
}
.object-hit[data-chapter="students"] {
  --sign-ratio: 241 / 123;
  --sign-top: 5.9%;
  --paper-tab: #879371;
  --hit-center: 49%;
  --hit-width: 27%;
  --sign-art: url("/assets/paper-sign-students.webp");
}
.object-hit[data-chapter="adults"] {
  --sign-ratio: 241 / 133;
  --sign-top: 8.4%;
  --paper-tab: #b6876d;
  --hit-center: 78.5%;
  --hit-width: 29%;
  --sign-art: url("/assets/paper-sign-adults.webp");
}
.sign-carrier {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transform-origin: 50% 88%;
}
.object-label {
  position: absolute;
  top: 0;
  left: 50%;
  width: var(--sign-width);
  aspect-ratio: var(--sign-ratio);
  transform: translate(-50%, var(--sign-lift));
  transform-origin: center 94%;
  text-align: center;
  white-space: nowrap;
  color: #26351e;
  background: var(--sign-art) center / 100% 100% no-repeat;
  filter: drop-shadow(0px 2px 1px var(--sign-shadow));
  transition: transform .24s ease, filter .24s ease;
}
.object-label::before, .object-label::after {
  content: "";
  position: absolute;
  top: 94%;
  width: 5%;
  height: 9%;
  background: linear-gradient(110deg, #eee1b7 18%, var(--paper-tab) 73%);
  clip-path: polygon(0 0, 65% 0, 100% 100%, 20% 86%);
}
.object-label::before { left: 27%; }
.object-label::after { right: 27%; transform: scaleX(-1); }
.object-label strong, .object-label small {
  position: absolute;
  left: 9%;
  width: 82%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--book-serif);
  line-height: 1;
}
.object-label strong {
  top: 13%;
  height: 41%;
  font-size: clamp(17px, 2.52cqw, 30px);
  font-weight: 700;
  letter-spacing: .055em;
}
.object-label small {
  top: 60%;
  height: 21%;
  font-size: clamp(10px, 1.29cqw, 14px);
  font-weight: 650;
  letter-spacing: .018em;
}
.object-hit:focus-visible .object-label {
  outline: 2px solid #526f45;
  outline-offset: 3px;
  border-radius: 15% / 23%;
}
@media (hover: hover) {
  .object-hit:hover .object-label {
    --sign-lift: -4px;
    --sign-shadow: #54371569;
  }
}
.book-controls {
  position: relative;
  margin: 0 auto;
  padding-inline: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 44px;
  color: #4e5946;
}
#interactive-book .book-controls button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  min-width: 44px;
  min-height: 44px;
  padding: 0 9px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  color: #516044;
}
.book-controls :is(.book-prev,.book-next)::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid #b9ac8c;
  border-radius: 50%;
  background: #fffaf0a6;
  transition: border-color .15s, background .15s;
}
.book-controls :is(.book-prev,.book-next) svg {
  position: relative;
  width: 15px;
  height: 15px;
}
.book-actions, .chapter-tabs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chapter-tabs { gap: 2px; }
#interactive-book .chapter-tabs .chapter-tab {
  position: relative;
  padding-inline: .48rem;
  font: 600 .93rem/1.4 var(--book-serif);
}
.chapter-tab::after {
  content: "";
  position: absolute;
  right: .42rem;
  left: .42rem;
  bottom: 5px;
  height: 2px;
  border-radius: 50%;
  background: transparent;
}
.chapter-tab[aria-current="page"]::after { background: #947540; }
#interactive-book .chapter-tabs .chapter-tab:hover { color: #374722; }
.book-instruction {
  font-family: var(--book-serif);
  font-size: clamp(12px, .82rem, 14px);
  line-height: 1.4;
  font-weight: 550;
  letter-spacing: .055em;
}
#interactive-book .book-controls :is(.book-replay,.book-reset) {
  margin-left: 4px;
  padding-inline: 9px;
  font-size: .75rem;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: #a5a18a;
}
#interactive-book .book-controls .book-replay { color: #526448; }
#interactive-book .book-controls .book-replay:disabled { opacity: .46; cursor: default; }
.book-controls button:is(:hover,:focus-visible)::before { background: #f7edd6; border-color: #827449; }
#interactive-book :is(.book-controls button,.preview-link):focus-visible {
  outline: 2px solid #526f45;
  outline-offset: 2px;
}
#interactive-book [hidden] { display: none !important; }
.book-preview {
  width: min(640px, 94%);
  margin: 10px auto 0;
  padding: 15px 6px;
  border-block: 1px solid #cbbc9a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 28px;
  text-align: left;
}
.book-preview > div { min-width: 0; }
.preview-kind {
  display: block;
  margin-bottom: .2rem;
  color: #76613d;
  font-size: .73rem;
  line-height: 1.45;
  font-weight: 650;
}
.preview-title {
  display: block;
  font: 650 clamp(1rem, 2.1cqw, 1.34rem)/1.45 var(--book-serif);
  color: var(--book-ink);
}
.preview-excerpt { margin: 3px 0 0; font-size: .88rem; line-height: 1.65; color: #515a48; }
.preview-actions {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.preview-category {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding-inline: 5px;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: #999079;
  color: #57604c;
  font-size: .78rem;
}
.preview-link {
  display: inline-flex;
  flex: none;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding-inline: 14px;
  border: 1px solid #acb198;
  border-radius: 3px;
  background: #fffaf0a6;
  color: #355338;
  font-size: .88rem;
  font-weight: 650;
  text-underline-offset: 4px;
}
.preview-link::after {
  content: "";
  width: .48em;
  height: .48em;
  border: solid currentColor;
  border-width: 1.5px 1.5px 0 0;
  transform: rotate(45deg);
}
.preview-link:hover { text-decoration: underline; }

@container (max-width: 620px) {
  .book-theater {
    --sign-width: clamp(82px, 24.5cqw, 140px);
  }
  .object-hit[data-chapter="kids"] { --hit-center: 19%; --hit-width: 30%; --sign-top: -1.5%; }
  .object-hit[data-chapter="students"] { --hit-center: 50%; --hit-width: 30%; --sign-top: -3.2%; }
  .object-hit[data-chapter="adults"] { --hit-center: 81%; --hit-width: 30%; --sign-top: -.5%; }
  .object-label strong { font-size: clamp(15px, 4.3cqw, 23px); }
  .object-label small { font-size: clamp(10px, 2.64cqw, 13px); }
  .book-controls { gap: 3px; }
  .book-instruction { font-size: .75rem; letter-spacing: .01em; }
  .book-preview { width: 91%; gap: 3px; display: grid; }
  .preview-actions { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: 8px; padding-top: 4px; }
}
@container (max-width: 365px) {
  .book-controls { column-gap: 0; }
  #interactive-book .book-controls :is(.book-replay,.book-reset) { margin-left: 0; padding-inline: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .paper-stage :is(.paper-scenery,.paper-object,.object-label) { animation: none !important; transition: none !important; }
  .paper-stage .paper-scenery { transform: none; }
  .paper-stage .paper-object { --object-pose: none; }
}
