/* Storybook film player. Fraunces (SIL OFL 1.1), bundled. */
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-latin-400-italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-latin-600-normal.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url(fonts/fraunces-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }
/* the other scripts: open Noto faces (SIL OFL 1.1), cut to the book's own characters by tools/fonts.py */
@font-face { font-family: "Noto Serif"; src: url(fonts/noto-serif.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Noto Serif"; src: url(fonts/noto-serif-italic.woff2) format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Noto Serif Devanagari"; src: url(fonts/noto-serif-devanagari.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Noto Serif Bengali"; src: url(fonts/noto-serif-bengali.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Noto Naskh Arabic"; src: url(fonts/noto-naskh-arabic.woff2) format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Noto Serif SC"; src: url(fonts/noto-serif-sc.woff2) format("woff2"); font-weight: 200 900; font-display: swap; }

:root {
  /* the table the book lies on; inside an ID app the shell's glass is the ground instead ([look] maps it to clear) */
  --sb-ground: radial-gradient(ellipse at 50% 38%, #6b4a2e 0%, #4a321f 45%, #2a1b10 100%) #3a2717;
  --sb-ink: #fff6e6;
  --sb-dim: #e9d6b6;
  --sb-panel: rgba(36, 23, 13, 0.62);
  --sb-gold: #f0c66e;
  --sb-caption-bg: rgba(250, 242, 226, 0.94);
  --sb-caption-ink: #3a2816;
  --sb-cap-size: clamp(17px, 1.55vw, 24px);
  --sb-btn: 52px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sb-caption-bg: rgba(250, 242, 226, 0.92); } }
:root[data-theme="dark"] { --sb-caption-bg: rgba(250, 242, 226, 0.92); }

* { box-sizing: border-box; }
html { background: var(--sb-ground); height: 100%; }
body { margin: 0; height: 100%; overflow: hidden; color: var(--sb-ink); background: transparent;
  font-family: "Fraunces", "Noto Serif", "Noto Serif Devanagari", "Noto Serif Bengali", "Noto Naskh Arabic", "Noto Serif SC", Georgia, "Times New Roman", serif; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }
body.large { --sb-cap-size: clamp(24px, 2.3vw, 34px); --sb-btn: 64px; }

#book { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: default; }
#book.grab { cursor: grab; } #book.grabbing { cursor: grabbing; }

#films { position: fixed; left: 0; top: 0; width: 2px; height: 2px; overflow: hidden; opacity: 0.01; pointer-events: none; }
#films video { width: 2px; height: 2px; }
/* John, 9 Oct 2026: nothing is ever drawn on the film. The films play on the book's pages (WebGL); their <video>
   elements are invisible and never have controls, and the browser's own overlays are switched off besides. */
video::-webkit-media-controls, video::-webkit-media-controls-panel, video::-webkit-media-controls-overlay-play-button,
video::-webkit-media-controls-start-playback-button, video::-webkit-media-controls-enclosure, video::-internal-media-controls-overlay-cast-button {
  display: none !important; -webkit-appearance: none; appearance: none; opacity: 0 !important; }

#captions { position: fixed; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; max-width: 92vw; }
#captions p { display: inline-block; margin: 0; padding: 0.42em 1.1em 0.5em; border-radius: 14px; background: var(--sb-caption-bg);
  color: var(--sb-caption-ink); font-size: var(--sb-cap-size); line-height: 1.38; box-shadow: 0 6px 22px rgba(0,0,0,.28);
  transition: opacity .45s ease; max-width: 100%; text-wrap: balance; }
#captions p:empty { display: none; }
#captions.fading p { opacity: 0; }
body.nocap #captions { display: none; }

/* the prompts sit in the slot BELOW the book (top set by resize(), like the captions), never on the pictures */
#hint, #tapplay, #theend { position: fixed; left: 50%; transform: translateX(-50%); top: calc(100vh - var(--sb-btn) * 1.2 - 96px); pointer-events: none; white-space: nowrap; }
#tapplay:not([hidden]) ~ #captions { display: none; }
#hint span { display: inline-block; padding: .5em 1.1em; border-radius: 999px; background: var(--sb-panel); color: var(--sb-ink);
  font-size: clamp(16px, 1.4vw, 22px); animation: breathe 2.6s ease-in-out infinite; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#tapplay { pointer-events: auto; }
#tapplay button, #theend button { font: 600 clamp(18px, 1.6vw, 26px) "Fraunces", Georgia, serif; padding: .6em 1.4em; border-radius: 999px; border: 0;
  background: var(--sb-gold); color: #3a2816; cursor: pointer; box-shadow: 0 8px 24px rgba(0,0,0,.35); }
@keyframes breathe { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { #hint span { animation: none; } }

#theend { pointer-events: auto; }
#theend:not([hidden]) { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; left: 12px; right: 12px; transform: none; }
/* the cover's shelf: the other book of the series and the note, under the "tap the book" prompt (never on the cover) */
#hint { left: 0; right: 0; transform: none; }   /* full width (pointer-events none), so the row can wrap at the screen, not at 50vw */
#hint:not([hidden]) { display: flex; flex-direction: column; align-items: center; gap: 6px; }
#hint .row { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; max-width: calc(100vw - 24px); }
#hint .shelf:not([hidden]) { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; pointer-events: auto; }
#hint.back .tapme { display: none; }
#hint .pill, #theend a { font: 600 clamp(15px, 1.3vw, 20px) "Fraunces", Georgia, serif; padding: .5em 1.15em; border-radius: 999px; border: 0;
  background: var(--sb-gold); color: #3a2816; cursor: pointer; text-decoration: none; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
#theend a { font-size: clamp(18px, 1.6vw, 26px); padding: .6em 1.4em; }
#theend #again:not(:only-child) { background: var(--sb-panel); color: var(--sb-ink); }
#hint .pill.quiet { background: var(--sb-panel); color: var(--sb-ink); box-shadow: none; }
#hint .why { pointer-events: auto; border: 0; background: none; color: var(--sb-dim); font: 400 clamp(13px, 1.1vw, 16px) "Fraunces", Georgia, serif;
  cursor: pointer; padding: 2px 6px; text-decoration: underline; text-decoration-color: rgba(255,240,215,.3); text-underline-offset: 3px; }
#hint .why { white-space: normal; max-width: calc(100vw - 32px); }
#hint .why b { color: var(--sb-ink); font-weight: 600; }
#hint .pill:focus-visible, #hint .why:focus-visible, #theend a:focus-visible { outline: 3px solid var(--sb-gold); outline-offset: 2px; }
#about { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  overflow: auto; padding: 16px 22px 18px; border-radius: 20px; background: rgba(36, 23, 13, 0.94); color: var(--sb-ink);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 16px 50px rgba(0,0,0,.5); z-index: 5;
  font: 400 17px/1.55 "Fraunces", Georgia, serif; }
#about header { display: flex; align-items: center; justify-content: space-between; }
#about h2 { margin: 0; font-weight: 600; font-size: 24px; color: var(--sb-gold); }
#about p { margin: .7em 0 0; }
@media (max-width: 480px) { #about { font-size: 15.5px; line-height: 1.5; padding: 12px 16px 14px; } #about h2 { font-size: 21px; } }
#about .sig { font-style: italic; color: var(--sb-dim); text-align: right; }

#bar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px; background: var(--sb-panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 8px 30px rgba(0,0,0,.35); transition: opacity .5s ease, transform .5s ease; max-width: calc(100vw - 32px); }
body.idle #bar { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
/* on a touch screen the bar never steps aside: it sits below the picture, and a tap must reach the language menu
   (12 Oct 2026, iOS Simulator walk: a tap on the hidden bar fell through) */
@media (hover: none) and (pointer: coarse) { body.idle #bar { opacity: 1; transform: translateX(-50%); pointer-events: auto; } }
body.sideways #captions { text-align: start; }
body.sideways { --sb-btn: 44px; }
body.sideways #volume, body.sideways .where, body.sideways #layout, body.sideways #large { display: none; }
body.sideways #bar { gap: 2px; padding: 4px 8px; bottom: 6px; }
body.sideways .pick { max-width: 130px; font-size: 13px; padding: 5px 20px 5px 9px; background-position: calc(100% - 12px) 55%, calc(100% - 7px) 55%; }
body.sideways #captions p { display: block; }
#bar .gap { width: 6px; }
.b { width: var(--sb-btn); height: var(--sb-btn); border-radius: 50%; border: 0; background: transparent; color: var(--sb-ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; flex-direction: column; padding: 0; position: relative; flex: none; }
.b:hover { background: rgba(255,240,215,.12); }
.b:focus-visible { outline: 3px solid var(--sb-gold); outline-offset: 2px; }
.b svg { width: 46%; height: 46%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.b.big { width: calc(var(--sb-btn) * 1.2); height: calc(var(--sb-btn) * 1.2); background: var(--sb-gold); color: #3a2816; }
.b.big:hover { background: #f7d58b; }
.b.big svg { width: 44%; height: 44%; stroke: none; }
#play .i-pause, #play.playing .i-play { display: none; } #play.playing .i-pause { display: block; }
#mute .i-mute, #mute.muted .i-vol { display: none; } #mute.muted .i-mute { display: block; }
.toggle[aria-pressed="false"] { color: var(--sb-dim); opacity: .62; }
.toggle[aria-pressed="true"] { color: var(--sb-gold); }
#auto .lbl { position: absolute; bottom: -2px; font-size: 9px; letter-spacing: .02em; white-space: nowrap; opacity: .9; }
#auto[aria-pressed="false"] .tick { display: none; }
.aa { font-weight: 700; font-size: calc(var(--sb-btn) * 0.36); }
.vol { display: inline-flex; align-items: center; }
#volume { width: 90px; accent-color: var(--sb-gold); }
.langs { display: inline-flex; gap: 6px; align-items: center; }
.langs[hidden] { display: none; }
.pick { appearance: none; -webkit-appearance: none; font: inherit; font-size: 15px; color: var(--sb-ink); background: rgba(255,240,215,.1);
  border: 1px solid rgba(240,198,110,.45); border-radius: 999px; padding: 7px 26px 7px 12px; max-width: 170px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--sb-gold) 50%), linear-gradient(135deg, var(--sb-gold) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.pick:focus-visible { outline: 3px solid var(--sb-gold); outline-offset: 2px; }
.pick option { color: #3a2816; background: #faf2e2; }
.pick[hidden] { display: none; }
body.large .pick { font-size: 19px; }
.where { color: var(--sb-dim); font-size: 15px; padding: 0 8px 0 4px; white-space: nowrap; font-variant-numeric: tabular-nums; }

#contents { position: fixed; left: 50%; bottom: calc(var(--sb-btn) + 40px); transform: translateX(-50%); width: min(1100px, calc(100vw - 32px));
  max-height: 62vh; overflow: auto; padding: 14px 18px 18px; border-radius: 20px; background: rgba(36, 23, 13, 0.86);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 16px 50px rgba(0,0,0,.5); }
#contents header { display: flex; align-items: center; justify-content: space-between; }
#contents h2 { margin: 0 0 10px; font-weight: 600; font-size: 22px; color: var(--sb-gold); }
#strip { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
#strip li button { width: 100%; border: 0; padding: 0; background: none; color: var(--sb-ink); cursor: pointer; text-align: left; font: inherit; }
#strip img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 8px; display: block; background: #5a4029; box-shadow: 0 3px 10px rgba(0,0,0,.4); }
#strip .cap { display: block; font-size: 13px; line-height: 1.3; margin-top: 5px; color: var(--sb-dim); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
#strip .n { color: var(--sb-gold); font-weight: 700; margin-right: 4px; }
#strip li.here img { outline: 3px solid var(--sb-gold); }
body.large #strip .cap { font-size: 17px; }

#err { position: fixed; inset: auto 16px 16px 16px; padding: 12px 16px; border-radius: 12px; background: #5b1d12; color: #fff; font: 15px system-ui, sans-serif; }

@media (max-width: 720px) {
  :root { --sb-btn: 44px; }
  #volume, .where, #layout, #large { display: none; }
  .pick { max-width: 104px; font-size: 13px; padding: 6px 20px 6px 9px; background-position: calc(100% - 12px) 55%, calc(100% - 7px) 55%; }
  #bar { gap: 2px; padding: 6px 8px; }
}
/* ?diag=1 only (tests on a real phone): what the film is doing, at the top of the page */
#diag { position: fixed; left: 8px; right: 8px; top: 8px; margin: 0; font: 10px/1.3 ui-monospace, Menlo, monospace; color: #f3e6cf; white-space: pre-wrap; pointer-events: none; z-index: 50; }
