/*
  Author home coming-soon page (r4: restyled to match the Dragon Tamers book page;
  r5: the two books, each a small cover and title that opens that book on the series site).
  Same world as the series page: the dark quiet surface, the parchment paper, Cinzel (self-hosted, OFL),
  the same colours and the same credit footer. The page is the book's "About the Author" spread:
  her portrait on the left page in a simple printed frame, the words on the right page.
  Phones (under 720 px) show one page, the portrait above the words.
  Scripts: site-config.js only maps the two site addresses for local testing; portrait.js (r10) starts the
  portrait's draw-in when its frame is on screen. Load moment: the book settles, then the portrait draws
  itself in: outlines first, then the shading (about 3.5 s, opacity, transform and one SVG stroke only).
  Without the script the portrait simply fades in. Base styles are the finished frame; reduced motion
  shows it at once.
  r10: the portrait is a hand-drawn version of the author's photo, ink on nothing, so the page's own
  paper is its background (no fill behind it, in the frame or the image). The series line under the books.
*/

@font-face {
  font-family: "Cinzel";
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url("fonts/cinzel-latin.woff2") format("woff2");
}

:root {
  --night: #0b0907;
  --ink: #1a1206;
  --parchment: #f0e6cc;
  --quiet: #a99d86;
  --gold: #d4a043;
  --gold-text: #e2b866;
  /* on paper */
  --p-ink: #2a1c0f;
  --p-soft: #54412b;
  --p-gold: #765010;
  --p-rust: #84340f;
  --paper: #efe4c8;
  --paper-edge: #cdbd98;
  --board: #101011;        /* r11: the book is black leather, so its boards are black too */
  --board-hi: #2a2a2c;
  --font: "Cinzel", Georgia, "Times New Roman", serif;
  /* One page of the book; the spread is twice this. The same size rule as the series page, so the
     book does not change size when a reader moves between the two sites. */
  --page-w: max(min(calc(100vw - 28px), calc((100vh - 114px) / 1.649), 480px), min(280px, calc(100vw - 28px)));
  --page-w: max(min(calc(100vw - 28px), calc((100svh - 114px) / 1.649), 480px), min(280px, calc(100vw - 28px)));
  --page-h: calc(var(--page-w) * 1.499);
  --book-w: var(--page-w);
  --inset: max(4px, calc(var(--page-w) * 0.018));
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .26 0 0 0 0 .14 0 0 0 1.1 -.42'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --gutter-r: linear-gradient(to right, rgba(58, 38, 18, 0.30), rgba(58, 38, 18, 0.10) calc(var(--page-w) * 0.05), rgba(58, 38, 18, 0) calc(var(--page-w) * 0.13));
  --gutter-l: linear-gradient(to left, rgba(58, 38, 18, 0.30), rgba(58, 38, 18, 0.10) calc(var(--page-w) * 0.05), rgba(58, 38, 18, 0) calc(var(--page-w) * 0.13));
  --outer-r: linear-gradient(to left, rgba(58, 38, 18, 0.12), rgba(58, 38, 18, 0) calc(var(--page-w) * 0.05));
  --outer-l: linear-gradient(to right, rgba(58, 38, 18, 0.12), rgba(58, 38, 18, 0) calc(var(--page-w) * 0.05));
  color-scheme: dark;
}
@media (min-width: 720px) {
  :root {
    --page-w: max(min(calc((100vw - 64px) / 2), calc((100vh - 114px) / 1.649), 740px), 300px);
    --page-w: max(min(calc((100vw - 64px) / 2), calc((100svh - 114px) / 1.649), 740px), 300px);
    --book-w: calc(var(--page-w) * 2);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse 60% 55% at 50% 45%, rgba(212, 160, 67, 0.09), transparent 72%),
    radial-gradient(circle at 88% 8%, rgba(123, 184, 200, 0.06), transparent 32%),
    var(--night);
  color: var(--parchment);
  font-family: var(--font);
  font-size: 18px;
  line-height: 1.5;
  text-rendering: optimizeLegibility;
}

/* Faint grain on the surface: one small static tile, never animated. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .94 0 0 0 0 .82 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--parchment);
  outline-offset: 4px;
  border-radius: 4px;
}

main {
  position: relative;
  flex: 1;
  display: grid;
  place-content: center;
  padding: clamp(8px, 2svh, 24px) 0 clamp(8px, 2svh, 24px);
}

/* r11: the same frame as the Dragon Tamers page: a control row as wide as the open book (Skip / Replay
   at its right edge), then the stage with the book. */
.scene {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
}
.scene__bar {
  position: relative;
  z-index: 3;
  width: var(--book-w);
  max-width: calc(100vw - 28px);
  min-height: 32px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.bk-control {
  min-height: 32px;
  min-width: 64px;
  padding: 4px 14px;
  border: 1px solid rgba(226, 184, 102, 0.55);
  border-radius: 999px;
  background: rgba(11, 9, 7, 0.6);
  color: var(--gold-text);
  font: 600 0.8rem/1 var(--font);
  letter-spacing: 0.12em;
  cursor: pointer;
}
.bk-control:hover { background: rgba(226, 184, 102, 0.14); color: var(--parchment); }
.bk-control[hidden] { display: none; }
.stage {
  display: grid;
  justify-content: center;
  width: 100vw;
  max-width: 100%;
  min-width: 0;
  overflow-x: clip;        /* the cover swinging open and the cord falling never cause sideways scroll */
}
.book-wrap { position: relative; width: var(--book-w); }

/* ---- The open book: boards, then paper pages ---- */
.book {
  position: relative;
  width: var(--book-w);
  padding: var(--inset);
  border-radius: 6px;
  background: linear-gradient(160deg, var(--board-hi), var(--board) 55%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 calc(var(--page-w) * 0.07) calc(var(--page-w) * 0.12) calc(var(--page-w) * -0.03) rgba(0, 0, 0, 0.78),
    0 3px 10px rgba(0, 0, 0, 0.45);
}
.book__leaves {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: calc(var(--page-h) - 2 * var(--inset));
}
.page {
  position: relative;
  min-width: 0;
  display: grid;
  align-items: center;
  background-color: var(--paper);
  background-size: auto, auto, 220px 220px;
  color: var(--p-ink);
}
.page--left {
  justify-items: center;
  background-image: var(--gutter-l), var(--outer-l), var(--noise);
  box-shadow: -1px 0 0 var(--paper-edge), -2px 0 0 var(--paper), -3px 0 0 var(--paper-edge);
}
.page--right {
  container-type: inline-size;
  padding: calc(var(--page-w) * 0.07) calc(var(--page-w) * 0.075);
  background-image: var(--gutter-r), var(--outer-r), var(--noise);
  box-shadow: 1px 0 0 var(--paper-edge), 2px 0 0 var(--paper), 3px 0 0 var(--paper-edge);
  text-align: center;
}

/* ---- Her portrait, drawn on the page inside a thin gold rule (the same 4:5 frame, size and place as
   before). r10: the drawing is ink on nothing, so nothing is painted behind it: no tint in the frame and
   no fill or keyline on the image. The paper seen around her is the page itself (PHOTO_SWAP.md). ---- */
.portrait {
  position: relative;
  width: 58%;
  margin: 0;
  padding: calc(var(--page-w) * 0.022);
  border: 1px solid rgba(118, 80, 16, 0.7);
}
.portrait picture { display: block; }
.portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;            /* a picture of another shape is cropped to the frame, never stretched */
  object-position: 50% 22%;
}
/* The outlines layer, over the image in the same box. Only painted while the portrait is being drawn. */
.portrait__lines {
  display: none;
  position: absolute;
  inset: calc(var(--page-w) * 0.022);
  width: calc(100% - 2 * var(--page-w) * 0.022);
  height: calc(100% - 2 * var(--page-w) * 0.022);
  pointer-events: none;
}
.portrait__pen {
  fill: none;
  stroke: #fff;                 /* in the mask: where the pen has been, the outlines show */
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1;
}
.portrait__pen--outline { stroke-width: 96; }
.portrait__pen--inside { stroke-width: 125; }

/* ---- The words. Sizes follow the page width (container query units) with readable floors. ---- */
.words {
  display: grid;
  justify-items: center;
  gap: clamp(6px, 2.6cqi, 22px);
}

.kicker {
  margin: 0;
  font-weight: 600;
  font-size: clamp(12px, 3.3cqi, 22px);
  letter-spacing: 0.18em;
  padding-left: 0.18em;           /* optical centring against the trailing tracking */
  color: var(--p-gold);
}

h1 {
  margin: 0;
  font-weight: 700;
  font-size: clamp(28px, 12cqi, 92px);
  line-height: 1.02;
  letter-spacing: 0.06em;
  padding-left: 0.06em;
  color: var(--p-ink);
}

.role {
  margin: 0;
  font-weight: 600;
  font-size: clamp(13px, 4cqi, 28px);
  line-height: 1.35;
  letter-spacing: 0.05em;
  color: var(--p-ink);
}
.keep { white-space: nowrap; }

.ornament {
  width: 46cqi;
  height: auto;
  aspect-ratio: 320 / 34;
  color: var(--p-gold);
  opacity: 0.85;
}
.ornament path { fill: none; stroke: currentColor; stroke-width: 1.6; }

.soon {
  margin: 0;
  font-weight: 700;
  white-space: nowrap;
  font-size: clamp(15px, 6.6cqi, 46px);
  line-height: 1.1;
  letter-spacing: 0.1em;
  padding-left: 0.1em;
  color: var(--p-rust);
}

.page :focus-visible { outline-color: var(--p-ink); }

/* ---- The two books (r5). Each entry: a small cover and the title, one link that opens that book
   on the series site; under it, a quiet link to the book on Amazon. ---- */
.books {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(8px, 4cqi, 30px);
  width: 100%;
  max-width: 78cqi;
  margin: 0.2em 0 0;
  padding: 0;
  list-style: none;
}
.bookcard {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: clamp(2px, 1cqi, 8px);
  min-width: 0;
}
.bookcard__open {
  display: grid;
  justify-items: center;
  gap: clamp(4px, 1.6cqi, 12px);
  padding: 3px;
  border-radius: 4px;
  color: var(--p-ink);
  text-decoration: none;
}
.bookcard__open img {
  display: block;
  width: clamp(54px, 21cqi, 150px);
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 1px 3px 3px 1px;
  box-shadow: 0 0 0 1px rgba(42, 28, 15, 0.55), 0 calc(var(--page-w) * 0.012) calc(var(--page-w) * 0.035) rgba(58, 38, 18, 0.32);
  transition: transform 160ms ease;
}
.bookcard__open:hover img { transform: translateY(-2px); }
.bookcard__label {
  display: grid;
  justify-items: center;
  font-weight: 700;
  font-size: clamp(12px, 3.4cqi, 22px);
  line-height: 1.25;
  letter-spacing: 0.06em;
}
.bookcard__num {
  font-weight: 600;
  font-size: clamp(12px, 2.8cqi, 18px);
  letter-spacing: 0.16em;
  padding-left: 0.16em;
  color: var(--p-gold);
}
.bookcard__label cite {
  font-style: normal;
  text-decoration: underline;
  text-decoration-color: rgba(118, 80, 16, 0.6);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.bookcard__buy {
  display: inline-block;
  min-height: 24px;
  padding: 2px 4px;
  font-weight: 600;
  font-size: clamp(12px, 2.9cqi, 18px);
  line-height: 1.7;
  letter-spacing: 0.05em;
  color: var(--p-soft);
  text-decoration: underline;
  text-decoration-color: rgba(118, 80, 16, 0.6);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.bookcard__buy:hover { color: var(--p-ink); }

/* ---- Phones: one page, the portrait above the words. The page grows with its content. ---- */
@media (max-width: 719.98px) {
  .book { border-radius: 2px 6px 6px 2px; }
  .book__leaves {
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    background-color: var(--paper);
    background-image: var(--gutter-r), var(--outer-r), var(--noise);
    background-size: auto, auto, 220px 220px;
    box-shadow: 1px 0 0 var(--paper-edge), 2px 0 0 var(--paper), 3px 0 0 var(--paper-edge);
  }
  .page--left,
  .page--right { background: none; box-shadow: none; }
  .page--left { padding-top: calc(var(--page-w) * 0.07); }
  .page--right { padding-top: calc(var(--page-w) * 0.05); padding-bottom: calc(var(--page-w) * 0.07); }
  .portrait { width: 44%; }
  .words { gap: clamp(5px, 2.2cqi, 14px); }
  h1 { font-size: clamp(26px, 10.4cqi, 60px); }
  .ornament { width: 40cqi; }
}
/* ---- The series line (r10): plain words under the two books. Not a link. ---- */
.series-note {
  margin: 0.15em 0 0;
  max-width: 82cqi;
  font-weight: 600;
  font-size: clamp(12px, 3cqi, 19px);
  line-height: 1.5;
  letter-spacing: 0.05em;
  color: var(--p-ink);
  text-wrap: balance;
}
.series-note cite { font-style: normal; font-weight: 700; }

/* ---- Contact the author (r19): a button drawn in pencil on the page, under her portrait. Nothing is painted
   behind it: the paper shows through. The sketched box is an inline drawing in index.html (two passes of the
   pencil and a little hatching), in graphite; the words are the page's own lettering in the same grey.
   The portrait keeps its exact place: the left page is three rows (room, the portrait, room) and the button
   stands at the top of the lower room. On a phone the rooms close up and it is simply the next thing down. ---- */
.page--left { grid-template-rows: 1fr auto 1fr; }
.portrait { grid-row: 2; }
.contact-btn {
  grid-row: 3;
  align-self: start;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: calc(var(--page-w) * 0.05);
  padding: 0.7em 1.4em;
  white-space: nowrap;
  border-radius: 3px;
  color: #45413b;
  font-weight: 700;
  font-size: clamp(12px, calc(var(--page-w) * 0.029), 20px);
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-decoration: none;
  box-shadow: 0 0 0 0 rgba(58, 54, 48, 0);
  transition: transform 180ms ease, box-shadow 180ms ease;
}
.contact-btn__sketch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.contact-btn__line {
  fill: none;
  stroke: #57534c;
  stroke-width: 1.35;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.contact-btn__line--second { stroke-width: 0.8; opacity: 0.7; }
.contact-btn__line--hatch { stroke-width: 0.75; opacity: 0.6; }
.contact-btn__label { position: relative; }
/* Pointed at, or reached by keyboard: it lifts a little off the page, and a soft graphite shadow shows under it.
   Still pencil on paper: no fill. Pressed, it settles back. (A shadow is only ever painted outside the box.) */
.contact-btn:focus-visible {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 9px 12px -6px rgba(58, 54, 48, 0.55);
  outline: 2px solid #45413b;
  outline-offset: 5px;
}
@media (hover: hover) {
  .contact-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 9px 12px -6px rgba(58, 54, 48, 0.55);
  }
}
.contact-btn:active { transform: none; box-shadow: 0 3px 5px -4px rgba(58, 54, 48, 0.5); }
@media (prefers-reduced-motion: reduce) {
  .contact-btn, .contact-btn:hover, .contact-btn:focus-visible, .contact-btn:active { transform: none; transition: box-shadow 180ms ease; }
}
@media (max-width: 719.98px) {
  .contact-btn { margin-top: calc(var(--page-w) * 0.045); }
}

@container (max-width: 270px) {
  .bookcard__label, .bookcard__buy, .series-note { letter-spacing: 0.02em; }
}

/* ---- Designer credit (the same line and colours as the series page) ---- */
.credit {
  position: relative;
  padding: 18px 20px 14px;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--quiet);
}
.credit p { margin: 0; }
.credit a {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 3px;
  color: var(--gold-text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}
.credit a:hover { color: var(--parchment); }

/* ---- Load moment (about 1.5 s, once; opacity and transform only) ---- */
@media (prefers-reduced-motion: no-preference) {
  .book { animation: ah-settle 1.1s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
  .portrait img { animation: ah-portrait 1s 0.5s ease-out both; }
}
@keyframes ah-settle {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
@keyframes ah-portrait {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---- The portrait draws itself in (r10; started by portrait.js when the frame is on screen).
   0.30 - 1.55 s  the pen travels her outline          (.portrait__pen--outline)
   1.40 - 2.65 s  the pen crosses the drawing          (.portrait__pen--inside)
   2.35 - 3.45 s  the shading fades in                 (the finished drawing)
   2.90 - 3.50 s  the outlines layer hands over to it  (pd-lines-out; its end marks the drawing done)
   "pd" is set on <html> by portrait.js only when motion is allowed, so reduced motion never gets here. ---- */
@media (prefers-reduced-motion: no-preference) {
  .pd .portrait img { animation: none; opacity: 0; }
  .pd .portrait.is-drawing .portrait__lines { display: block; animation: pd-lines-out 0.6s 2.9s ease-in both; }
  .pd .portrait.is-drawing .portrait__pen--outline { animation: pd-pen 1.25s 0.3s cubic-bezier(0.45, 0.05, 0.35, 1) both; }
  .pd .portrait.is-drawing .portrait__pen--inside { animation: pd-pen 1.25s 1.4s cubic-bezier(0.4, 0.1, 0.5, 1) both; }
  .pd .portrait.is-drawing img { animation: pd-shade 1.1s 2.35s ease-out both; }
  .pd .portrait.is-drawn img { animation: none; opacity: 1; }
}
@keyframes pd-pen {
  from { stroke-dashoffset: 1; }
  to   { stroke-dashoffset: 0; }
}
@keyframes pd-shade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pd-lines-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}


/* =====================  r11: the page opens like a black leather book  =====================
   Base styles above ARE the finished open spread. Without JavaScript, under reduced motion, after Skip
   and after the sequence ends, the page shows that still state and none of the rules below apply.
   The opening plays only while assets/book.js keeps "ob-play" on <html>:
     ob-wait   the closed book is being drawn; nothing is shown yet (a moment)
     ob-hold   the closed book, held at the first frame, while the cord unwinds and falls (book.js)
     then      the cover swings open and the paper leaves flip: the same mechanics, curves and shading
               as the Dragon Tamers book (dragon-tamers/assets/book-open.css), renamed "ob".
   Only transform, opacity, visibility and clip-path animate. The cord is one small SVG moved by book.js.
   The blackletter face is UnifrakturCook Bold (SIL Open Font License 1.1, fonts/at-blackletter-OFL.txt),
   cut down to Latin letters and renamed "AT Blackletter" as that licence asks of changed copies. */
@font-face {
  font-family: "AT Blackletter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/at-blackletter-latin.woff2") format("woff2");
}

.book {
  /* Timeline of the opening, in seconds (book.js reads these). The cord comes first: its times are in book.js. */
  --ob-t-open: 0.1s;      /* after the cord has gone: pause before the cover moves */
  --ob-d-open: 1.3s;      /* cover swing */
  --ob-t-leaves: 1.0s;    /* first paper leaf starts */
  --ob-step: 0.34s;       /* gap between leaves */
  --ob-d-leaf: 0.95s;     /* one leaf turn (the last one takes 1.2x) */
  --ob-t-ink: 2.9s;       /* written by book.js: every leaf has landed */
  --ob-t-reveal: 1.76s;   /* written by book.js: the last leaf lifts */
  --ob-tilt-x: 18deg;     /* how the closed book leans before it opens */
  --ob-tilt-y: -22deg;
  --ob-thick: calc(var(--page-w) * 0.1);
  --ob-closed-x: calc(var(--page-w) * -0.5);
  --ob-leaf-w: calc(var(--page-w) - var(--inset));
  --ob-letters: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='264'%3E%3Cpath fill='%233a2814' fill-opacity='.17' d='M0 4h36v7h-36zM43 4h41v7h-41zM90 4h20v7h-20zM116 4h39v7h-39zM161 4h48v7h-48zM216 4h18v7h-18zM240 4h43v7h-43zM292 4h20v7h-20zM319 4h21v7h-21zM0 26h19v7h-19zM25 26h30v7h-30zM61 26h52v7h-52zM122 26h19v7h-19zM148 26h18v7h-18zM173 26h34v7h-34zM216 26h25v7h-25zM247 26h52v7h-52zM307 26h51v7h-51zM0 48h22v7h-22zM29 48h39v7h-39zM74 48h51v7h-51zM131 48h52v7h-52zM189 48h55v7h-55zM251 48h47v7h-47zM307 48h36v7h-36zM0 70h53v7h-53zM62 70h39v7h-39zM109 70h31v7h-31zM147 70h31v7h-31zM184 70h52v7h-52zM244 70h49v7h-49zM302 70h37v7h-37zM0 92h34v7h-34zM40 92h23v7h-23zM72 92h26v7h-26zM106 92h25v7h-25zM140 92h42v7h-42zM188 92h20v7h-20zM216 92h37v7h-37zM261 92h54v7h-54zM324 92h36v7h-36zM0 114h21v7h-21zM29 114h46v7h-46zM81 114h19v7h-19zM28 136h52v7h-52zM89 136h34v7h-34zM132 136h38v7h-38zM176 136h45v7h-45zM229 136h26v7h-26zM261 136h47v7h-47zM314 136h29v7h-29zM0 158h24v7h-24zM31 158h41v7h-41zM81 158h47v7h-47zM134 158h26v7h-26zM169 158h41v7h-41zM218 158h24v7h-24zM251 158h51v7h-51zM310 158h42v7h-42zM0 180h40v7h-40zM47 180h25v7h-25zM78 180h27v7h-27zM112 180h30v7h-30zM149 180h16v7h-16zM174 180h53v7h-53zM234 180h32v7h-32zM274 180h16v7h-16zM297 180h42v7h-42zM0 202h55v7h-55zM63 202h24v7h-24zM93 202h45v7h-45zM147 202h41v7h-41zM197 202h41v7h-41zM244 202h46v7h-46zM299 202h19v7h-19zM325 202h20v7h-20zM0 224h44v7h-44zM51 224h23v7h-23zM82 224h54v7h-54zM142 224h22v7h-22zM170 224h52v7h-52zM229 224h50v7h-50zM285 224h39v7h-39zM330 224h20v7h-20zM0 246h40v7h-40zM47 246h56v7h-56zM111 246h38v7h-38zM157 246h31v7h-31z'/%3E%3C/svg%3E");
}
.book__leaves { position: relative; }
.ob { display: none; position: absolute; inset: 0; pointer-events: none; }
.ob-on .book { animation: none; }          /* the old load moment gives way to the opening */

.ob-play .book-wrap {
  perspective: calc(var(--page-w) * 7);
  perspective-origin: 50% 35%;
}
.ob-wait .book-wrap { opacity: 0; }
/* (r14) The closed book slides in on arrival and slides away on the way to a book's page: the same travel,
   easing and times as the book swap on the Dragon Tamers pages (their site.css: dt-slide-in, dt-slide-out).
   .stage clips sideways, so a book off the side never causes sideways scroll. */
.ob-arrive .book-wrap { animation: ob-slide-in 0.65s 0.12s cubic-bezier(0.15, 0.6, 0.25, 1) both; }
.ob-away .book-wrap { animation: ob-slide-out 0.55s cubic-bezier(0.55, 0, 0.85, 0.5) both; pointer-events: none; }
@keyframes ob-slide-in {
  from { transform: translateX(calc(50vw + var(--page-w) * 1.1)); }
  to   { transform: none; }
}
@keyframes ob-slide-out {
  from { transform: none; }
  to   { transform: translateX(calc(-50vw - var(--page-w) * 1.1)); }
}
@media (prefers-reduced-motion: reduce) {
  .ob-arrive .book-wrap, .ob-away .book-wrap { animation: none; }
}
.ob-play .book-wrap { transition: opacity 0.3s ease-out; }
.ob-play .book {
  background: none;
  box-shadow: none;
  cursor: pointer;
  animation: ob-settle 1.3s calc(var(--ob-t-open) - 0.1s) cubic-bezier(0.45, 0, 0.2, 1) both;
}
.ob-play :is(.book, .ob, .ob__turn, .ob__leaf, .ob__seg) { transform-style: preserve-3d; }
.ob-play .ob { display: block; }

/* Under the pages: the shadow on the surface and the two boards (the left ones wait for the cover). */
.ob__shadow, .ob__board { position: absolute; top: 0; bottom: 0; width: 50%; }
.ob__shadow {
  box-shadow:
    0 calc(var(--page-w) * 0.07) calc(var(--page-w) * 0.12) calc(var(--page-w) * -0.03) rgba(0, 0, 0, 0.78),
    0 3px 10px rgba(0, 0, 0, 0.45);
}
.ob__shadow--left { left: 0; border-radius: 6px 0 0 6px; }
.ob__shadow--right { right: 0; border-radius: 0 6px 6px 0; }
.ob__board {
  background: linear-gradient(160deg, var(--board-hi), var(--board) 55%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.ob__board--left { left: 0; border-radius: 6px 2px 2px 6px; }
.ob__board--right { right: 0; border-radius: 2px 6px 6px 2px; }
.ob-play .ob__shadow--left { animation: ob-fade 0.6s calc(var(--ob-t-open) + var(--ob-d-open) * 0.55) ease-out both; }
.ob-play .ob__board--left,
.ob-play .page--left { animation: ob-show 1ms calc(var(--ob-t-open) + var(--ob-d-open)) both; }
/* The still right-hand page is covered until the last leaf lifts. */
.ob-play .page--right { animation: ob-show 1ms var(--ob-t-reveal) both; }

/* Edges of the closed book block, seen while it leans. */
.ob__edge { position: absolute; }
.ob__edge--fore {
  top: var(--inset);
  bottom: var(--inset);
  left: calc(100% - 1px);
  width: var(--ob-thick);
  transform-origin: 0 50%;
  transform: rotateY(90deg);
  background:
    linear-gradient(to right, transparent 82%, var(--board) 82%),
    repeating-linear-gradient(to right, var(--paper) 0 1.5px, var(--paper-edge) 1.5px 2.5px);
}
.ob__edge--foot {
  left: 50%;
  width: calc(50% - var(--inset));
  top: calc(100% - 1px);
  height: var(--ob-thick);
  transform-origin: 50% 0;
  transform: rotateX(-90deg);
  background:
    linear-gradient(to bottom, transparent 82%, var(--board) 82%),
    repeating-linear-gradient(to bottom, #e6d9b9 0 1.5px, #bfae88 1.5px 2.5px);
}
.ob-play .ob__edge { animation: ob-gone 1ms var(--ob-t-ink) forwards; }

/* Leaves sit over the right-hand board and turn on the spine. */
.ob__turn { position: absolute; top: 0; bottom: 0; left: 50%; width: 50%; }
.ob__leaf { position: absolute; transform-origin: 0 50%; }
.ob__leaf--cover { inset: 0; }
.ob__leaf--paper { top: var(--inset); bottom: var(--inset); left: 0; right: var(--inset); }
.ob__face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.ob__face--back { transform: rotateY(180deg); }
/* Shading that deepens as a face turns away from the light. */
.ob__face::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.ob__face--front::after { background: rgba(34, 20, 8, 0.34); }
.ob__face--back::after  { background: rgba(34, 20, 8, 0.26); }

/* ---- The cover: black leather, drawn on a canvas by book.js. Until it is drawn, plain black board. ---- */
.ob__leaf--cover .ob__face--front {
  isolation: isolate;
  border-radius: 3px 9px 9px 3px;
  background: linear-gradient(150deg, #1c1c1e, #0b0b0c 60%);
}
.ob__leather {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.ob__leaf--cover .ob__face--front::before {   /* the hinge groove along the spine */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.07) 2.2%, rgba(0, 0, 0, 0.2) 3.6%, transparent 7%);
}
/* The cord (r12): thin dark leather, tied to the back board at the fore-edge. One SVG over the right-hand
   board (the closed cover's place), in the cover's own units (1000 x 1499); its shape is set by book.js.
   It belongs to the book, not the cover, so it stays when the cover opens and hangs beside the open book.
   It lies outside the book's edge there; .stage clips anything past the screen's edge. */
.ob__cord {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 2;
  width: 50%;
  height: var(--page-h);
  overflow: visible;
  pointer-events: none;
}
.ob-play .ob__cord { transform: translateZ(4px); }      /* just over the closed cover; the opening cover passes in front */
@media (max-width: 719.98px) {
  .ob__cord { left: 0; width: 100%; }
}
.ob__cord path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ob__cord-shadow { stroke: rgba(0, 0, 0, 0.7); stroke-width: 14; }
.ob__cord .ob__cord-body { fill: #2e2620; stroke: #2e2620; stroke-width: 0.8; }   /* a ribbon: one continuous shape, no joints */
.ob__cord-end { fill: #2e2620; }
.ob__cord-light { stroke: rgba(255, 238, 214, 0.42); stroke-width: 3; }  /* placed on the lit side by book.js */
.ob__cord-dark { stroke: #000; stroke-width: 11.5; }                      /* the cap's shadow, where the cord runs in under it */
/* The clasp: a polished silver button on the right edge, drawn on its own canvas, over the cord. */
.ob__clasp {
  position: absolute;
  z-index: 3;
  left: 77.2%;
  top: 50.7%;
  width: 20%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow:
    calc(var(--page-w) * 0.005) calc(var(--page-w) * 0.010) calc(var(--page-w) * 0.014) rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(0, 0, 0, 0.5);
}
.ob__leaf--cover .ob__face--front::after {
  z-index: 4;
  border-radius: inherit;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.3));
}
.ob__leaf--cover .ob__face--back {
  border-radius: 6px 2px 2px 6px;
  background: linear-gradient(200deg, var(--board-hi), var(--board) 55%);
}
.ob__leaf--cover .ob__face--back::before {     /* pasted-down endpaper */
  content: "";
  position: absolute;
  top: var(--inset);
  bottom: var(--inset);
  left: var(--inset);
  right: 0;
  background: var(--gutter-l), var(--noise) 0 0 / 220px 220px, #e2d3ae;
}

/* Paper leaf: three hinged segments give the page a believable curl. */
.ob__seg { position: absolute; top: 0; bottom: 0; transform-origin: 0 50%; }
.ob__seg--a { left: 0; width: 50%; --x: 0; --bx: 0.5; }
.ob__seg--b { left: calc(100% - 1px); width: calc(56% + 1px); --x: 0.5; --bx: 0.22; }
.ob__seg--c { left: calc(100% - 1px); width: calc(78.5714% + 1px); --x: 0.78; --bx: 0; }
.ob__leaf--paper .ob__face {
  background-color: var(--paper);
  background-image: var(--noise);
  background-size: 220px 220px;
}
.ob__leaf--paper .ob__face--front { background-position: calc(var(--ob-leaf-w) * var(--x) * -1) 0; }
.ob__leaf--paper .ob__face--back  { background-position: calc(var(--ob-leaf-w) * var(--bx) * -1) 0; }
.ob__seg--a > .ob__face--front {
  background-image: var(--gutter-r), var(--noise);
  background-size: auto, 220px 220px;
  background-position: 0 0, 0 0;
}
.ob__seg--a > .ob__face--back {
  background-image: var(--gutter-l), var(--noise);
  background-size: auto, 220px 220px;
  background-position: 0 0, calc(var(--ob-leaf-w) * -0.5) 0;
}
.ob__seg--c > .ob__face--front {
  background-image: var(--outer-r), var(--noise);
  background-size: auto, 220px 220px;
  background-position: 0 0, calc(var(--ob-leaf-w) * -0.78) 0;
}
.ob__seg--c > .ob__face--back {
  background-image: var(--outer-l), var(--noise);
  background-size: auto, 220px 220px;
  background-position: 0 0, 0 0;
}
/* Faint lettering on some leaves: two blocks of word-shaped strokes. */
.ob__leaf--lettered .ob__face--front::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--ob-letters), var(--ob-letters);
  background-repeat: no-repeat;
  background-size: calc(var(--ob-leaf-w) * 0.74) auto;
  background-position:
    calc(var(--ob-leaf-w) * (0.14 - var(--x))) calc(var(--page-h) * 0.11),
    calc(var(--ob-leaf-w) * (0.14 - var(--x))) calc(var(--page-h) * 0.11 + var(--ob-leaf-w) * 0.57);
}

/* Timing: each leaf carries --ob-delay, --ob-dur, --ob-zr (resting on the right), --ob-zl (landed on the
   left), and --ob-show / --ob-hide, the time it can actually be seen. */
.ob-play .ob__leaf {
  animation:
    ob-turn var(--ob-dur, 1s) var(--ob-delay, 1s) cubic-bezier(0.55, 0.05, 0.35, 1) both,
    ob-show 1ms var(--ob-show, 0s) both,
    ob-gone 1ms var(--ob-hide, 99s) forwards;
}
.ob-play .ob__leaf--cover {
  --ob-show: -1s;   /* the cover is there from the first frame, also while the opening is held */
  --ob-dur: var(--ob-d-open);
  --ob-delay: var(--ob-t-open);
  animation-timing-function: cubic-bezier(0.6, 0.02, 0.3, 1), linear, linear;
}
.ob-play .ob__seg--b { animation: ob-curl-b var(--ob-dur) var(--ob-delay) linear both; }
.ob-play .ob__seg--c { animation: ob-curl-c var(--ob-dur) var(--ob-delay) linear both; }
.ob-play .ob__face--front::after { animation: ob-shade-front var(--ob-dur) var(--ob-delay) cubic-bezier(0.55, 0.05, 0.35, 1) both; }
.ob-play .ob__face--back::after  { animation: ob-shade-back  var(--ob-dur) var(--ob-delay) cubic-bezier(0.55, 0.05, 0.35, 1) both; }
/* Every leaf has landed: hand over to the still pages underneath. */
.ob-play .ob__turn { animation: ob-gone 1ms var(--ob-t-ink) forwards; }

@keyframes ob-settle {
  from { transform: translateX(var(--ob-closed-x)) rotateX(var(--ob-tilt-x)) rotateY(var(--ob-tilt-y)); }
  to   { transform: translateX(0) rotateX(0deg) rotateY(0deg); }
}
@keyframes ob-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ob-turn {
  from { transform: translateZ(var(--ob-zr, 1px)) rotateY(0deg); }
  to   { transform: translateZ(var(--ob-zl, 1px)) rotateY(-180deg); }
}
@keyframes ob-curl-b {
  0%   { transform: rotateY(0deg); }
  25%  { transform: rotateY(-9deg); }
  55%  { transform: rotateY(-3deg); }
  80%  { transform: rotateY(7deg); }
  100% { transform: rotateY(0deg); }
}
@keyframes ob-curl-c {
  0%   { transform: rotateY(0deg); }
  25%  { transform: rotateY(-13deg); }
  55%  { transform: rotateY(-4deg); }
  80%  { transform: rotateY(9deg); }
  100% { transform: rotateY(0deg); }
}
@keyframes ob-shade-front {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 1; }
}
@keyframes ob-shade-back {
  0%, 50% { opacity: 1; }
  100%    { opacity: 0; }
}
@keyframes ob-show { from { visibility: hidden; } to { visibility: visible; } }
/* A hide must be hidden at both ends (and fill forwards only), or a 1 ms step could stay visible. */
@keyframes ob-gone { from, to { visibility: hidden; } }

/* Held at the first frame: the closed book, while the cord unwinds and falls. */
.ob-hold .book,
.ob-hold .book *,
.ob-hold .book *::before,
.ob-hold .book *::after { animation-play-state: paused !important; }

/* ---- Phones: the closed book is one board, the size of the page; the cover swings away to the left.
   The page is taller than the cover: the paper is cut to the cover's height while the book opens,
   then grows to its full height (clip-path only; the layout never changes). ---- */
@media (max-width: 719.98px) {
  .book { --ob-tilt-x: 12deg; --ob-tilt-y: -14deg; --ob-closed-x: 0px; }
  .ob-play .book { transform-origin: 50% calc(var(--page-h) * 0.5); }
  .ob-play .book-wrap { perspective-origin: 50% calc(var(--page-h) * 0.35); }
  .ob__shadow--left, .ob__board--left { display: none; }
  .ob__shadow--right, .ob__board--right { width: 100%; }
  .ob__turn { left: 0; width: 100%; bottom: auto; height: var(--page-h); }
  .ob__edge--fore { bottom: auto; height: calc(var(--page-h) - 2 * var(--inset)); }
  .ob__edge--foot { left: 0; width: calc(100% - var(--inset)); top: calc(var(--page-h) - 1px); }
  .ob-play .page--left,
  .ob-play .page--right { animation: ob-show 1ms var(--ob-t-reveal) both; }
  .ob-play .ob__shadow--right,
  .ob-play .ob__board--right { animation: ob-grow 0.7s var(--ob-t-ink) cubic-bezier(0.3, 0.6, 0.3, 1) both; }
  .ob-play .book__leaves {
    animation:
      ob-show 1ms var(--ob-t-reveal) both,
      ob-grow-page 0.7s var(--ob-t-ink) cubic-bezier(0.3, 0.6, 0.3, 1) both;
  }
}
@keyframes ob-grow-page {
  from { clip-path: inset(-40px -40px calc(100% - var(--page-h) + 2 * var(--inset)) -40px); }
  to   { clip-path: inset(-40px -40px -80px -40px); }
}
@keyframes ob-grow {
  from { clip-path: inset(-40px -40px calc(100% - var(--page-h)) -40px); }
  to   { clip-path: inset(-40px -40px -80px -40px); }
}

/* Belt and braces: book.js never adds these classes under reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .ob-play .ob { display: none; }
  .ob-wait .book-wrap { opacity: 1; }
  .ob-play .book {
    background: linear-gradient(160deg, var(--board-hi), var(--board) 55%);
    cursor: auto;
  }
  .ob-play .book,
  .ob-play .book *,
  .ob-play .book *::before,
  .ob-play .book *::after { animation: none !important; }
}
