/* All composition coordinates are in the original 550 × 400 stage. */ :root {
  color-scheme: light;
  font-family: Georgia, 'Times New Roman', serif;
}
* {
  box-sizing: border-box;
}
/* Browser surround only. Page colours belong to .page rules below. */
body {
  margin: 0;
  overflow: hidden;
  background: #635b52;
}
button, input {
  font: inherit;
}
button {
  cursor: pointer;
  color: inherit;
}
button:focus-visible, input:focus-visible, .interaction:focus-visible {
  outline: 2px solid #80582d;
  outline-offset: 4px;
}
button:disabled {
  opacity: .25;
  cursor: default;
}
[hidden] {
  display: none !important;
}
/* Fixed page frame; JS scales it to fit. Shadow falls onto the browser surround. */
#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 550px;
  height: 400px;
  overflow: hidden;
  background: #80582d;
  box-shadow: 0 2px 8px rgb(0 0 0 / 12%);
  transform-origin: center;
}
#page-content, .page {
  position: absolute;
  inset: 0;
}
/* Composite each physical sheet as one layer, including its moving artwork.
   This keeps parent opacity applied to transformed children on iPad/WebKit. */
.page {
  background: #C07002;
  isolation: isolate;
  transform: translateZ(0);
}
/* Keep translucent moving sheets composited between page turns on tablets. */
.page-translucent { will-change: opacity, transform; }
/* A lifted sheet briefly drifts left, revealing the next sheet beneath it. */
.page.page-leaving {
  z-index: 2;
  pointer-events: none;
  animation:
    sheet-drift-left 800ms cubic-bezier(.55, .05, .9, .45) forwards,
    sheet-fade 500ms ease-in forwards;
  will-change: transform, opacity;
}
.page.page-entering-backward {
  z-index: 2;
  pointer-events: none;
  animation:
    sheet-return-from-left 400ms cubic-bezier(.1, .55, .45, .95) both,
    sheet-appear 120ms ease-out 280ms both;
  will-change: transform, opacity;
}
@keyframes sheet-drift-left {
  to { transform: translate3d(-40px, 0, 0); }
}
@keyframes sheet-return-from-left {
  from { transform: translate3d(-40px, 0, 0); }
  to { transform: translate3d(0, 0, 0); }
}
@keyframes sheet-fade {
  to { opacity: 0; }
}
@keyframes sheet-appear {
  from { opacity: 0; }
  to { opacity: var(--sheet-opacity, 1); }
}
@media (prefers-reduced-motion: reduce) {
  .page.page-leaving { animation-duration: 1ms; }
  .page.page-entering-backward {
    animation-duration: 1ms, 1ms;
    animation-delay: 0s, 0s;
  }
}
.background {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* Physical sheet opacities. Keep these on :root so gm.js can read them when
   rendering and revealing the following sheet in the stack. */
:root {
  --orange-silk-sheet-opacity: .85;
  /* Gold handmade paper: 80% opacity, 20% transparency. */
  --gold-handmade-sheet-opacity: .80;
  /* Yellow handmade paper: 80% opacity, 20% transparency. */
  --yellow-handmade-sheet-opacity: .95;
  /* Fibre sheet: 50% opacity = 50% transparency. */
  --fibre-sheet-opacity: .70;
  /* Shared normal opacity for Refrain and plain white tracing-paper sheets. */
  --tracing-paper-sheet-opacity: .80;
  /* Glassine after Refrain: 15% opacity, blended over the next painting. */
  --glassine-after-refrain-opacity: .40;
  /*--glassine-after-refrain-blend-mode: multiply;*/
}
.image-contained .background {
  object-fit: contain;
  object-position: center;
}
.prototype-note {
  position: absolute;
  left: 25px;
  top: 13px;
  margin: 0;
  font: 7px Arial, sans-serif;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #716d62;
  pointer-events: none;
}
.interaction {
  position: absolute;
  padding: 0;
  border: 0;
  background: transparent;
}
/* Separate wrappers keep reading zoom and random movement independent. */
.zoom-layer {
  position: absolute;
  inset: 0;
  transform: scale(1);
  transition: transform 450ms ease;
}
.motion-layer {
  position: absolute;
  inset: 0;
  transform-origin: center;
}
.artwork {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
/* Reference placement: author at 26% across / 58% down; title starts near 40% across. */
.interaction-cover {
  left: 143px;
  top: 232px;
  width: 385px;
  height: auto;
  aspect-ratio: 1148.72 / 146.17;
}
/* Overscan keeps the moving texture covering the stage at every motion extreme. */
.interaction-sailcloth { inset: -12px; }
.interaction-sailcloth .artwork { object-fit: cover; }
/* Contained silk sheets share the cloth motion, with room for drift and rotation. */
.image-contained .interaction-sailcloth { inset: -12px; }
.image-contained .interaction-sailcloth .artwork {
  object-fit: contain;
  object-position: center;
}
#stage:has(.page-current.page-sailcloth) .prototype-note { display: none; }
.interaction-text { height: auto; }
.page-refrain {
  background: #fff;
}
.painting-backdrop {
  position: absolute;
  left: 86px;
  top: 96px;
  width: 378px;
  aspect-ratio: 4000 / 2039;
  pointer-events: none;
}

  .refrain-white-overlay {
  position: absolute;
  inset: 0;
  background: rgb(255 255 255 / var(--tracing-paper-sheet-opacity));
  transition: background-color 450ms ease;
  pointer-events: none;
}
.page-refrain:has(.interaction-text.is-interacting) /* White sheet between painting and text: 90% normally, 95% during reading zoom. */
.refrain-white-overlay {
  background: rgb(255 255 255 / 95%);
}
.interaction-text .zoom-layer {
  transform-origin: top left;
}
.page-text {
  background: #f2e1c6;
}
.page-text.page-refrain {
  background: #fff;
}
#stage:has(.page-current.page-text) .prototype-note {
  display: none;
}
.interaction-garofalo {
  left: 86px;
  top: 96px;
  width: 378px;
  height: auto;
  aspect-ratio: 4000 / 2039;
}
#page-content {
  touch-action: none;
}
/* Fixed page frame; JS scales it to fit. Shadow falls onto the browser surround. */
#stage { touch-action: none; }
/* Appended to body, outside the scaled page. JS sets width/left to match zoomed text;
   top/bottom reach the window edges for scrolling. */
.reading-hit-area {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 2;
  cursor: pointer;
  touch-action: none;
}
.interaction-text { cursor: pointer; }
/* Animate zoom changes like roll-off; keep wheel, edge and drag scrolling immediate. */
.interaction-text.is-reading:not(.is-zooming) .zoom-layer { transition: none; }
/* Central zoom control shown by nav reveal; its arrival flash is touch-only in JS. */
#zoom-control {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 28px;
  height: 28px;
  padding: 2px;
  border: 0;
  background: transparent;
  z-index: 3;
}
#zoom-control img { width: 100%; height: 100%; pointer-events: none; }
#stage:has(.page-text) .navigation-revealed /* Central zoom control shown by nav reveal; its arrival flash is touch-only in JS. */
#zoom-control { display: block; }
#stage:has(.page-text) #zoom-control.is-arrival-hint {
  display: block;
  animation: zoom-arrival 900ms ease-in-out;
}
@keyframes zoom-arrival {
  0%, 100% { opacity: 0; }
  20%, 65% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #stage:has(.page-text) #zoom-control.is-arrival-hint { animation: none; }
}
.page-garofalo {
  background: #fff;
}
/* Colophon, Nietzche, Dedication and every Garofalo BW sheet. */
.page-colophon,
.page-nietzche,
.page-dedication,
.page-garofalo-bw {
  background: #f2ece6;
}
#stage:has(.page-garofalo) .prototype-note {
  display: none;
}
.interaction-garofalo .artwork {
  object-fit: contain;
}
.painting-full .painting-backdrop,
.painting-full .interaction-garofalo {
  inset: -6px;
  width: auto;
  height: auto;
  aspect-ratio: auto;
}
.painting-full .painting-backdrop .artwork,
.painting-full .interaction-garofalo .artwork { object-fit: cover; }
/* Hit rectangles move with the painting. Highlight colour is separate from geometry;
   head circles are drawn by ::before below. Onlookers uses rectangular hover highlights without previews. */
/* Shared controls for Garofalo and Onlookers highlights. */
.hotspots {
  --hotspot-colour: 200 200 200;
  --hotspot-opacity: .40;
  --hotspot-fade-duration: 250ms;
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hotspot {
  position: absolute;
  padding: 0;
  border: .7px solid transparent;
  background: transparent;
  pointer-events: auto;
}
.hotspots:not(.hotspots-silent).is-previewing .hotspot::before,
html:not(.touch-input) .hotspots .hotspot:hover::before,
.hotspots .hotspot:focus-visible::before {
  opacity: var(--hotspot-opacity);
}
.hotspot:focus-visible {
  outline: none;
}
/* Large invisible navigation target; the small arrow appears on hover or nav reveal. */
.arrow {
  position: absolute;
  top: 145px;
  border: 0;
  background: transparent;
  padding: 0;
  width: 58px;
  height: 110px;
  display: grid;
  place-items: center;
  color: #A89C8E;
}
.arrow-icon {
  opacity: 0;
  width: 20px;
  height: 20px;
  object-fit: contain;
  pointer-events: none;
}
html:not(.touch-input) .arrow:hover .arrow-icon,
html:not(.touch-input) .arrow:focus-visible .arrow-icon,
.navigation-revealed .arrow-icon {
  opacity: 1;
}
.arrow:focus-visible {
  outline: none;
}
.arrow:disabled {
  visibility: hidden;
}
.previous {
  left: 0;
}
.next {
  right: 0;
}
.square {
  width: 8px;
  height: 8px;
  padding: 0;
  border: .6px solid #A89C8E;
  background: transparent;
  color: #A89C8E;
}
.square:hover, .square:focus-visible, .square.is-icon-open {
  background: #A89C8E;
  outline: none;
}
/* Revealed icons sit left of the group. The transparent bridge below keeps them reachable. */
.menu-icon {
  position: absolute;
  right: 28px;
  top: 2px;
  width: 28px;
  height: 16px;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
}
.square.is-icon-open /* Revealed icons sit left of the group. The transparent bridge below keeps them reachable. */
.menu-icon {
  opacity: 1;
  pointer-events: auto;
  z-index: 1;
}
.menu:has(.is-icon-open)::before {
  content: '';
  position: absolute;
  right: 20px;
  top: 0;
  width: 36px;
  height: 20px;
}
/* Bottom-left page scrubber: closed square expands into a horizontal slider. */
.ticker {
  position: absolute;
  left: 19px;
  bottom: 18px;
  width: 20px;
  height: 20px;
  border: .6px solid #A89C8E;
  color: #A89C8E;
  background: transparent;
  transition: width 280ms ease;
}
.ticker.is-open {
  width: 120px;
}
.scrubber-toggle {
  position: absolute;
  inset: 0 auto 0 0;
  width: 19px;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
}
.ticker.is-open .scrubber-toggle {
  pointer-events: none;
}
.ticker:has(:focus-visible) {
  border-color: #80582d;
}
/* Visible 2 x 2 menu. The ::after rules below extend hit areas into the gaps. */
.menu {
  position: absolute;
  right: 19px;
  bottom: 18px;
  display: grid;
  width: 20px;
  height: 20px;
  grid-template-columns: repeat(2, 8px);
  grid-template-rows: repeat(2, 8px);
  gap: 4px;
}
#scrubber-panel {
  position: absolute;
  inset: 0;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  transition: opacity 150ms ease, visibility 0s linear 280ms;
}
.ticker.is-open #scrubber-panel {
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}
#scrubber {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  left: 9px;
  top: 0;
  width: calc(100% - 18px);
  height: 18px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}
#scrubber::-webkit-slider-runnable-track {
  height: .6px;
  background: #A89C8E;
}
#scrubber::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 8px;
  height: 8px;
  margin-top: -3.7px;
  border: 0;
  border-radius: 0;
  background: #A89C8E;
}
#scrubber::-moz-range-track {
  height: .6px;
  background: #A89C8E;
}
#scrubber::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border: 0;
  border-radius: 0;
  background: #A89C8E;
}
#scrubber:focus-visible, .scrubber-toggle:focus-visible {
  outline: none;
}
#opening {
  position: absolute;
  inset: 0;
  background: #ece9df;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#opening p {
  font-size: 28px;
}
#resume {
  border: 1px solid #74776b;
  padding: 9px 20px;
  background: transparent;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
/* Phone-only recommendation. JS detects a coarse pointer and phone-sized screen. */
#phone-advisory {
  position: fixed;
  left: var(--phone-centre-x, 50%);
  top: var(--phone-centre-y, 50%);
  z-index: 20;
  width: min(330px, calc(var(--phone-width, 100vw) - 28px));
  padding: 12px 14px;
  border: 1px solid rgb(255 255 255 / 28%);
  background: rgb(63 58 52 / 94%);
  box-shadow: 0 3px 12px rgb(0 0 0 / 18%);
  color: #f6f3ec;
  font: 14px/1.35 Arial, sans-serif;
  text-align: center;
  transform: translate(-50%, -50%);
}
html.phone-view,
html.phone-view body {
  min-height: 100%;
}
html.phone-view body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: #ece9df url('../assets/cover-image.svg') center / cover no-repeat;
}
html.phone-view #stage {
  display: none;
}
#phone-advisory p {
  margin: 0 0 9px;
}
#share-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border: 1px solid rgb(255 255 255 / 55%);
  border-radius: 2px;
  background: transparent;
  color: inherit;
  font: inherit;
}
#share-link img {
  width: 17px;
  height: 17px;
}
#share-link:focus-visible {
  outline-color: #f6f3ec;
}
@media (prefers-reduced-motion: reduce) {
  .zoom-layer, .hotspots, .ticker, #scrubber-panel, /* White sheet between painting and text: 90% normally, 95% during reading zoom. */
.refrain-white-overlay {
    transition: none;
  }
}


.hotspots-silent .hotspot:not(:focus-visible) { border-color: transparent; }

#fullscreen, #fullscreen:hover, #fullscreen:focus-visible, #fullscreen.is-icon-open {
  border: 0;
  background: transparent;
}
.fullscreen-square { display: block; width: 100%; height: 100%; pointer-events: none; }
#fullscreen:hover .fullscreen-square, #fullscreen:focus-visible .fullscreen-square,
#fullscreen.is-icon-open .fullscreen-square { filter: brightness(1.3); }
html:not(.touch-input) #fullscreen /* Revealed icons sit left of the group. The transparent bridge below keeps them reachable. */
.menu-icon { display: none; }
/* Expand targets by 2 stage pixels on each side, meeting halfway across each gap. */
.menu > .square::after {
  content: '';
  position: absolute;
  left: -2px;
  top: -2px;
  width: 12px;
  height: 12px;
}
.menu > .square:nth-child(even)::after { left: 10px; }
.menu > .square:nth-child(n + 3)::after { top: 10px; }
.fullscreen-square { transition: transform 160ms ease; transform-origin: center; }
html:not(.touch-input) #fullscreen:hover .fullscreen-square { transform: scale(1.15); }
@media (prefers-reduced-motion: reduce) {
  .fullscreen-square { transition: none; }
}

/* Fade a separate visual layer so click targets keep their original geometry.
   Garofalo heads are circles; other targets, including Onlookers, are rectangles. */
.hotspot::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgb(var(--hotspot-colour));
  opacity: 0;
  transition: opacity var(--hotspot-fade-duration) ease-in-out;
  pointer-events: none;
}
.hotspot-head::before {
  bottom: auto;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
}
@media (prefers-reduced-motion: reduce) {
  .hotspot::before { transition: none; }
}

.page-glassine-after-refrain {
  mix-blend-mode: var(--glassine-after-refrain-blend-mode);
}

/* Colour reproduction: reference proportions on a white sheet.
   Shadow lengths use the book's 550 x 400 stage coordinates. */
.page-saint-nicholas-colour {
  --painting-width: 90%;
  --painting-centre-y: 47%;
}
.page-saint-nicholas-colour .background {
  inset: auto;
  left: 50%;
  top: var(--painting-centre-y);
  width: var(--painting-width);
  height: auto;
  transform: translate(-50%, -50%);
}

/* Shared shadow for every Garofalo BW image and the St Nicholas colour image.
   Values use the book's 550 x 400 stage coordinates. */
img[src$="/Garofalo-BW.webp"],
.page-saint-nicholas-colour .background {
  --painting-shadow: 0 2px 3px rgb(0 0 0 / 23%);
  filter: drop-shadow(var(--painting-shadow));
}

/* Onlookers names: font size is in the 550 x 400 stage's CSS pixels. */
.hotspots-silent {
  --onlooker-name-size: 5px;
  --onlooker-name-tracking: 0.9em;
    em; /* 150% of the font size. */
}
.onlooker-name {
  position: absolute;
  top: 8px;
  left: 0;
  width: 100%;
  z-index: 1;
  color: #fff;
  font-family: 'EB Garamond', Georgia, serif;
  font-size: var(--onlooker-name-size);
  letter-spacing: var(--onlooker-name-tracking);
  opacity: 0;
  transition: opacity var(--hotspot-fade-duration) ease-in-out;
  font-weight: 400;
  line-height: 1.2;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
}

html:not(.touch-input) .hotspot:hover .onlooker-name {
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .onlooker-name { transition: none; }
}

/* Tablet menu: one four-square toggle, with controls opening above it. */
.tablet-menu { display: none; }
html.tablet-controls .menu { display: none; }
html.tablet-controls .tablet-menu {
  display: block; position: absolute; right: 19px; bottom: 18px;
  width: 20px; height: 20px; z-index: 4;
}
#tablet-menu-toggle {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px;
  width: 20px; height: 20px; padding: 0; border: 0; background: transparent;
}
#tablet-menu-toggle::after { content: ''; position: absolute; inset: -4px; }
#tablet-menu-toggle span {
  border: .6px solid #A89C8E;
  background: transparent;
  border-radius: .5px;
}
.tablet-menu.is-open #tablet-menu-toggle span { background: #A89C8E; }
.tablet-menu-panel {
  position: absolute; bottom: 24px; right: 0; display: flex;
  flex-direction: column; gap: 3px;
  opacity: 0; transform: translateY(8px); visibility: hidden; pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease, visibility 0s linear 220ms;
}
.tablet-menu.is-open .tablet-menu-panel {
  opacity: 1; transform: translateY(0); visibility: visible; pointer-events: auto;
  transition-delay: 0s;
}
.tablet-menu-panel button {
  display: grid; place-items: center; width: 20px; height: 20px;
  padding: 2px; border: .8px solid #A89C8E; background: transparent;
}
.tablet-menu-panel img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .tablet-menu-panel { transition: none; } }

/* A transparent bridge keeps the hover menu open between the toggle and panel. */
.tablet-menu-panel::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 4px; }
#tablet-menu-toggle:focus:not(:focus-visible) { outline: none; }
.tablet-menu-panel button { color: #A89C8E; }
/* External SVG images also work when the book is opened directly from disk. */
.tablet-menu-panel button { position: relative; }
.tablet-menu-panel .menu-line-icon { display: block; }
.tablet-menu-panel .menu-hover-icon { display: none; }
@media (hover: hover) and (pointer: fine) {
  .tablet-menu-panel button:hover {
    background: #A89C8E;
    color: #f2e1c6;
    border-color: transparent;
  }
  .tablet-menu-panel button:hover .menu-line-icon { display: none; }
  .tablet-menu-panel button:hover .menu-hover-icon { display: block; }
  #tablet-menu-toggle:hover span { background: #A89C8E; }
}

/* Tablet names sit over clothing, one-third of the page height from the bottom. */
@media (any-pointer: coarse) {
  .onlooker-name {
    top: auto;
    bottom: 33.333%;
  }
}
/* Tablet arrival: names only, 300ms in, 4.4s hold, 300ms out. */
.hotspots-silent.is-name-preview .onlooker-name {
  animation: onlooker-name-preview 5s ease-in-out both;
}
@keyframes onlooker-name-preview {
  0%, 100% { opacity: 0; }
  6%, 94% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .hotspots-silent.is-name-preview .onlooker-name {
    animation-name: onlooker-name-preview-still;
    animation-timing-function: steps(1, end);
  }
}
@keyframes onlooker-name-preview-still {
  from { opacity: 1; }
  to { opacity: 0; }
}
