/* Kouzan Gyousho, brushed by Kouzan Aoyagi. https://opentype.jp/kouzangyousho.htm */
@font-face {
  font-family: "Book Gyosho";
  src: url("book-kouzan-gyosho.woff2") format("woff2");
  font-weight: 400;
  size-adjust: 108%;
  font-display: swap;
}

@font-face {
  font-family: "Book Kouzan";
  src: url("book-kouzan-manuscript.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Manuscript Kana";
  src: url("book-manuscript-kana.woff2") format("woff2");
  font-display: swap;
}

.policy-dialog:has([data-policy-page="history"]:not([hidden])) {
  width: min(100% - 1rem, 67rem);
}
.history-book {
  --book-w: min(100%, clamp(43rem, 118svh, 65rem));
  --cover-offset: 50%;
  --paper-clearance: clamp(.7rem, min(3.4vw, 2svh), 1.15rem);
  --book-script: "Manuscript Kana", "Book Kouzan", "Book Gyosho", "Yu Mincho", serif;
  --book-text: Georgia, var(--book-script);
  --paper: #d9c5a3;
  --binding-ink: #251d1c;
  width: var(--book-w);
  container-type: inline-size;
  margin: 0 auto;
  padding: var(--paper-clearance) .4rem .75rem;
  color: var(--binding-ink);
  font-family: var(--book-text);
  font-synthesis: none;
}
.history-book [hidden] { display: none !important; }
.book-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.book-stage {
  position: relative;
  isolation: isolate;
  width: 100%;
  aspect-ratio: 1.44;
  min-height: var(--min-book-height, 0px);
}
.book-gathering, .book-spread, .book-cover {
  position: absolute;
  inset: 0;
}
.book-gathering {
  box-shadow: 0 1px #aa9575, 0 3px #655343, 0 4px #bcaa8e, 0 6px #57432f, 0 .8rem 1.7rem #0006;
}
.book-spread { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
.book-leaf {
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--paper) url("history-book-paper.webp") center / 100% 100%;
}

.book-gathering { cursor: pointer; }
@media (hover: hover) and (min-width: 701px) {
  .book-gathering .book-left { cursor: w-resize; }
  .book-gathering .book-right { cursor: e-resize; }
}
.book-right { grid-area: 1 / 2; }
.book-left { grid-area: 1 / 1; }
.book-stock {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.book-left > .book-stock { transform: scaleX(-1); }
.book-leaf::after {
  content: "";
  position: absolute;
  inset-block: 0;
  width: 2%;
  pointer-events: none;
}
.book-right::after { left: 0; background: linear-gradient(90deg, #392a1c36, transparent); }
.book-left::after { right: 0; background: linear-gradient(270deg, #392a1c36, transparent); }
.book-ink {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}
.book-transcript:not(.book-sr) {
  position: absolute;
  inset: 6%;
  overflow: auto;
  font: 1rem/1.55 var(--book-text);
}
.book-transcript:lang(ja):not(.book-sr) { writing-mode: vertical-rl; text-orientation: upright; }
.book-client-plate {
  position: absolute;
  inset: 6% 8% 6% 7%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: .6rem;
}
.book-gathering .book-client-plate { pointer-events: none; }
.book-client-plate > img { min-height: 0; width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.book-client-plate figcaption img { display: block; width: 92%; height: auto; margin: 0 auto; }
.book-cover {
  inset: 0 auto 0 0;
  z-index: 2;
  width: 50%;
  container-type: inline-size;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--binding-ink);
  transform-origin: right center;
  transform: translateX(var(--cover-offset));
  transform-style: preserve-3d;
}
.book-cover > img {
  width: 100%;
  height: 100%;
  box-shadow: .1rem .3rem .7rem #0007;
}
.book-slip {
  position: absolute;
  inset: 3.1% auto auto 3.9%;
  width: 12.8%;
  height: 62.6%;
  background: #d6c4a4 url("history-book-paper.webp") 60% 44% / 900% 160%;
  backface-visibility: hidden;
}
.book-slip img {
  position: absolute;
  top: 8%;
  left: 13%;
  width: 74%;
  height: 66%;
  object-fit: contain;
  object-position: center top;
}
.book-open-label {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  padding: .8rem 0 .55rem;
  color: var(--ink);
  text-align: center;
  font: 400 1rem/1.5 var(--book-text);
  text-decoration: underline;
  text-underline-offset: .3em;
}
.history-book:not(.is-open) { padding-bottom: calc(.75rem + var(--paper-clearance) + 48px); }
.history-book.is-open .book-open-label { visibility: hidden; }
.book-turn-scene, .book-opening {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.book-turn-scene > .book-leaf, .book-opening-stack, .book-paper-probe {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
}
.book-turn-scene > .book-right { left: 50%; }
.history-book.is-opening :is(.book-gathering, .book-stage > .book-cover) { visibility: hidden; }
.book-opening-stack { box-shadow: 0 2px #aa9575, 0 4px #665342, 0 5px #b7a58b; }
.book-opening-stack > .book-leaf, .book-paper-probe > .book-leaf { width: 100%; height: 100%; }
.book-paper-probe { visibility: hidden; pointer-events: none; }
.book-paper-probe > .book-cover { width: 100%; transform: none; }
.book-paper-canvas {
  position: absolute;
  left: 0;
  top: -4%;
  width: 100%;
  height: 108%;
  pointer-events: none;
}
.book-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: .65rem;
  min-height: 48px;
  margin-top: var(--paper-clearance);
  color: var(--ink);
  font-size: .93rem;
}
.book-controls button { min-height: 44px; border: 0; background: transparent; padding: .4rem; }
.book-controls button:disabled { opacity: .35; }
.book-controls [data-book-next] { justify-self: start; }
.book-controls [data-book-prev] { justify-self: end; }
@media (max-width: 700px) {
  .history-book { --book-w: min(100%, 26rem); --cover-offset: 0%; }
  .book-stage { aspect-ratio: .72; }
  .book-spread { display: block; }
  .book-spread .book-leaf { position: absolute; inset: 0; }
  .book-spread .book-left, .history-book.is-left .book-spread .book-right { display: none; }
  .history-book.is-left .book-spread .book-left { display: block; }
  .book-leaf::after { display: none; }
  .book-cover, .book-turn-scene > .book-leaf, .book-paper-probe, .book-opening-stack { width: 100%; }
  .book-turn-scene > .book-right { left: 0; }
}
