@import url('paper-curl.css');
:root {
  --paper: #f9fbf3;
  --ink: #192b46;
  --muted: #495e74;
  --line: #afc1cf;
  --green: #244b96;
  --accent: #ad3851;
  --rule: #629bc528;
  --margin: #ed80919c;
  --cover: #294d99 url('notebook-cover.jpg') repeat 50% 0 / 192px;
}
html { min-height: 100%; background: #d8e4e8; }
body.notebook {
  min-height: 100vh; color: var(--ink);
  background: radial-gradient(#9db3c333 .8px,transparent 1px) 0 0 / 5px 5px, #dee8e9;
  --section: #244b96; --tab: #c2dbff;
}
.notebook[data-stage="2"] { --section: #704477; --tab: #e9c5e7; }
.notebook[data-stage="3"] { --section: #216565; --tab: #aee4d1; }
.notebook main {
  max-width: 440px; width: 100%; margin: 9px auto 20px;
  padding: max(5px,env(safe-area-inset-top)) max(6px,env(safe-area-inset-right)) max(11px,env(safe-area-inset-bottom)) max(6px,env(safe-area-inset-left));
  background: var(--cover); border-radius: 6px 11px 8px 6px;
  box-shadow: 0 2px 3px #152c4729, 0 10px 32px #16305642;
}
.notebook .episode-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  position: relative; min-height: 62px; padding: 6px 5px 14px;
}
/* This zero-height seam shares the edge of the page, including during turns. */
.notebook-binding {
  position: relative; flex: 0 0 0; height: 0; z-index: 4; pointer-events: none;
}
.notebook-binding::before {
  content: ''; position: absolute; inset: -8px 4px auto; height: 20px;
  background: url('tactile/notebook-binding.svg') left top / 28px 20px space no-repeat;
}

.episode-strip img {
  display: block; width: 117px; height: auto; padding: 0 7px 2px;
  border: 1px solid #d4dfde; border-radius: 3px; background: #f8faf1;
  box-shadow: 1px 2px #152e65; transform: rotate(-1.4deg);
}
.edition-label {
  display: flex; align-items: center; position: relative; min-width: 0;
  border-radius: 3px 4px 1px 1px; background: var(--tab); border-bottom: 2px solid var(--section);
}
.edition-label::after {
  content: ''; position: absolute; right: 8px; top: 40%; width: 5px; height: 5px;
  border: solid var(--ink); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); pointer-events: none;
}
.edition-label select {
  appearance: none; max-width: 100%; min-height: 34px; padding: 3px 22px 3px 9px;
  background: transparent; border: 0; border-radius: 0; color: var(--ink);
  font: bold italic 15px/1.2 Georgia,serif; cursor: pointer;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.reader-nav {
  display: flex; align-items: center; gap: 2px; padding: 0 4px; background: var(--paper);
  border-radius: 2px 5px 0 0; border-bottom: 1px solid var(--line);
}
.reader-nav button {
  min-height: 40px; padding: 4px 7px; border: 0; color: var(--ink); background: transparent; font: 13px Arial,sans-serif;
}
.reader-nav #case-prev, .reader-nav #case-forward { min-width: 33px; font-size: 24px; }
#case-position { padding: 3px 6px; font: bold 12px 'Courier New',monospace; color: var(--section); border-bottom: 2px solid var(--section); }
#theme-play { margin-left: auto; }
#case-sound[aria-pressed="true"]::before { content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 5px 2px 0; border-radius: 50%; background: #298375; }
#audio-status:not(:empty) { display: block; padding: 4px; background: var(--paper); font: 12px Arial,sans-serif; }

.notebook .paper, .dispatch-card {
  background-color: var(--paper);
  background-image: linear-gradient(90deg, transparent 4px,var(--margin) 4px 5px,transparent 5px),
    repeating-linear-gradient(0deg,transparent 0 23px,var(--rule) 23px 24px);
  color: var(--ink); border: 0; border-radius: 0 0 3px 2px;
  box-shadow: 0 2px #b5c8cc, 0 3px #f3f7ed, 0 4px #8fa9af;
}
.notebook .paper { padding: 9px 7px 9px 9px; position: relative; }
.notebook #levels, .notebook #heading, .notebook #type, .notebook .letterhead { display: none !important; }
.notebook #story {
  font: bold 5.52cqw/1.3 'Courier New',Courier,monospace; color: var(--ink); margin: 0 auto 10px;
}
.notebook #story .line { height: 1.3em; line-height: 1.3; }
#story:focus { outline: none; }
.notebook button:focus-visible, .edition-label select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.notebook #message:empty { display: none; }
.notebook #message { min-height: 0; padding: 4px 1px; }
#radio-log, #verse-log { font: 14px/1.5 Georgia,serif; border-block: 1px solid var(--line); margin: 9px 0; padding: 5px 0; }
#radio-log summary, #verse-log summary { cursor: pointer; }
#radio-log ol { padding-left: 2em; font: 13px/1.5 monospace; }
#verse-log pre { white-space: pre-wrap; font: italic 15px/1.5 Georgia,serif; }

.notebook[data-stage="1"] #story {
  border-block: 2px solid var(--section);
  background: repeating-linear-gradient(0deg,transparent 0 calc(1.3em - 1px),#79a2cb2b calc(1.3em - 1px) 1.3em), #f1f7fc;
}
.notebook #story .glyph { color: var(--green); border-color: #5675a1; }
.notebook #story .picked { color: #40283a; background: #ffe38a; }
.notebook #sub { align-items: center; gap: 7px; }
.notebook #sub input { width: 3ch; min-width: 38px; border: 1px solid var(--green); background: #fffef8; color: var(--ink); }
.notebook #sub button, .notebook #play .actions button, .notebook #play>button {
  background: #f5f8fa; border: 1px solid var(--line); border-radius: 2px; color: var(--ink); min-height: 36px;
}
.notebook #sub button { background: var(--section); border-color: var(--section); color: white; }
.notebook .actions { gap: 6px; }

.notebook[data-stage="2"] .paper { padding: 9px 7px 9px 8px; }
/* The hit areas stay square while the paper faces can lift and tilt. */
.notebook #story.cut-page {
  --seam: 4px;
  width: 100%; display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: var(--seam);
  margin: 0 auto 10px; padding: 3px; font-size: calc(5.52cqw - 2.8px);
  background: #97948b; box-shadow: 0 0 0 1px #77756f;
}
.notebook[data-stage="2"] .paper::before,
.notebook[data-stage="2"] .paper::after {
  content: ''; position: absolute; z-index: 1; pointer-events: none;
  top: 4px; left: 2px; width: 22px; height: 8px; transform: rotate(-21deg);
  background: repeating-linear-gradient(90deg,#edc957ae 0 3px,#efd978ac 3px 5px);
}
.notebook[data-stage="2"] .paper::after { left: auto; right: 3px; transform: rotate(24deg); }
.notebook #story.cut-page button {
  width: 100%; min-width: 0; outline: 0; clip-path: none; color: #26272a; background: transparent;
  border: 0; box-shadow: none; animation: none; filter: drop-shadow(.5px 1.3px .6px #25242360);
}
.shred {
  display: block; position: relative; isolation: isolate; text-align: center;
  line-height: 1.25; padding: 5px 0; transform: rotate(var(--rest-angle));
}
.shred::before {
  content: ''; position: absolute; inset: -1px; z-index: -1; pointer-events: none;
  border-image: var(--newsprint) 42 24 36 24 fill / 8px 5px 7px 5px / 0 stretch;
  transform: scale(var(--paper-x,1),var(--paper-y,1)); filter: brightness(1.13) saturate(.45);
}
.cut-page button.dragging .shred { transform: none; }
.notebook #story.cut-page button.dragging { z-index: 4; filter: drop-shadow(2px 4px 2px #251d2380); }
.notebook #story.cut-page button[aria-pressed=true] .shred,
.notebook #story.cut-page button.dragging .shred { color: #753349; text-decoration: underline; text-decoration-color: #88465766; }
.notebook #story.cut-page button.drop-target .shred,
.notebook #story.cut-page button:focus-visible .shred { outline: 2px dashed #963b49; outline-offset: -3px; }
.notebook #story.cut-page .lock-pick .shred { outline:2px dashed #77562c; outline-offset:-2px; }
.notebook [data-clip] { --clip-ink:#73522b; --clip-paper:#f3ddad; }
.notebook [data-clip="B"] { --clip-ink:#286661; --clip-paper:#c6e2d9; }
.locked-slip { position:relative; overflow:visible; }
.locked-slip::after {
  content:attr(data-clip); position:absolute; top:-3px; right:4px;
  min-width:12px; text-align:center; padding:0 2px; color:var(--clip-ink);
  background:linear-gradient(155deg,#fff9,transparent 65%),color-mix(in srgb,var(--clip-paper) 70%,transparent);
  border-block:1px solid #89836665; transform:rotate(5deg);
  font:bold 9px/10px 'Courier New',monospace; pointer-events:none;
}
.notebook #play .actions select { min-width:0; min-height:38px; border:1px solid var(--line); border-radius:2px; padding:4px; color:var(--ink); background:#f5f8fa; font:inherit; font-size:12px; }
.seam-tape {
  position:absolute; z-index:1; pointer-events:none;
  width:clamp(27px,45%,46px); height:clamp(8px,.58em,13px);
  background:linear-gradient(109deg,transparent 24%,#fff8 29%,#fff1 34%,transparent 41%),
    linear-gradient(3deg,#b3a97a38,#fff9d74f 53%,#f5f1df80 70%,#d5cfa43b);
  border-top:1px solid #fffc; border-bottom:1px solid #837d5c75;
  clip-path:polygon(3% 0,100% 0,96% 19%,100% 39%,96% 62%,100% 83%,97% 100%,0 100%,4% 78%,0 57%,4% 35%,0 16%);
}
.tape-left {
  left:calc(var(--seam) / -2); top:39%; transform:translate(-50%,-50%) rotate(-7deg);
}
.tape-top {
  left:62%; top:calc(var(--seam) / -2); transform:translate(-50%,-50%) rotate(77deg);
}
.notebook #play #lock-slips[aria-pressed="true"] { background:#f1e4c6; border-color:#85642e; }
.notebook.proof-workbench #story.overprinted {
  width: 100%; margin: 0 auto 7px; outline: 1px solid #98b2be;
  background: linear-gradient(153deg,transparent 86.4%,#8096b220 86.6%,transparent 86.9%),
    linear-gradient(to bottom,transparent 95%,#638eae22 95%) 0 0 / 100% 5%, #f4f9fa;
}
.notebook.proof-workbench #story.patch-over { outline: 2px solid var(--section); }
.notebook #story .loose-impression { box-shadow: inset 0 0 0 1px #5685a87d; background: #b9e6f025; }
.notebook .flying-impression { outline: 2px solid #285e9a; background: #d5edf349; box-shadow: 0 3px 7px #20375635; }
.notebook.proof-workbench .pool-rail {
  grid-template-columns: 25px minmax(0,1fr) 25px; gap: 2px; align-items: center;
  border-block: 1px solid #95b9b8; background: #cee9df; padding: 3px 0;
}
.notebook .pool-rail:has(#proofs:empty) { min-height: 52px; border: 1px dashed var(--section); }
.notebook .pool-rail.return-target { outline: 2px solid var(--section); outline-offset: 1px; background: #c0e4d2; }
.notebook .pool-rail>button { color: var(--section); }
.notebook #proofs button canvas { width: 100%; height: auto; max-height: none; aspect-ratio: auto; margin: 0; }
.notebook #proofs .pool-card>button:first-child {
  padding: 2px; border: 1px solid #92acba; border-top: 3px solid #658c96; color: var(--ink);
  background: linear-gradient(135deg,#efaf8b 0 6px,transparent 6.5px) top left / 10px 10px no-repeat, #fcfdf5;
  box-shadow: 0 1px 1px #718a991f;
}
.notebook #proofs .pool-reject { background: var(--paper); }
.notebook #proof-footer { margin: 7px 0 0; }
.notebook #proof-footer #read-proof {
  min-height: 43px; width: 100%; border: 1px solid var(--section); border-radius: 2px; background: var(--section);
  color: white; font: bold 16px 'Courier New',monospace; text-decoration: none;
}
.briefing-open .notebook-puzzle { display: none; }
#briefing { padding: 3px 1px 5px; outline: none; }
.dispatch-card { position: relative; padding: 19px 20px 20px; border-top: 5px solid var(--tab); }
.dispatch-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.dispatch-header img { width: 36px; height: auto; }
#brief-count { color: var(--section); font: bold 11px/1.5 'Courier New',monospace; text-transform: uppercase; letter-spacing: .08em; }
#brief-name { font: bold italic 34px/1.06 Georgia,serif; color: var(--ink); letter-spacing: -.04em; margin: 16px 0 12px; }
#brief-rule, #brief-note { font: 17px/1.45 Georgia,serif; margin: 10px 0; }
#brief-note { color: var(--muted); font-style: italic; }
#brief-note:empty { display: none; }
.dispatch-actions { display: flex; align-items: center; gap: 12px; margin-top: 15px; padding-top: 10px; border-top: 1px solid var(--line); }
.dispatch-actions button { min-height: 42px; border-radius: 2px; font: bold 14px Georgia,serif; padding: 7px 12px; }
#brief-start { background: var(--section); color: white; border: 1px solid var(--section); }
#brief-sound { margin-left: auto; background: transparent; color: var(--section); border-color: transparent; }
@media (max-width: 460px) {
  .notebook main { margin: 0 auto 10px; }
}
@media (max-width: 355px) {
  .episode-strip img { width: 90px; }
  .edition-label select { font-size: 13px; }
}
@media (max-height: 740px) {
  .notebook .episode-strip { min-height: 51px; padding-block: 3px 12px; }
  .reader-nav button { min-height: 36px; }
  .notebook.proof-workbench .paper { padding-block: 5px; }
  .notebook #proof-footer { margin-top: 5px; }
}

/* All page faces meet the same row of spiral rings. */
.notebook-leaf {
  --corner-inset:12px;
  --corner-width:48px;
  min-height: min(820px,calc(100svh - 97px)); position: relative; padding-bottom: 40px;
  border-radius: 2px 4px 3px 2px; isolation: isolate;
  background: repeating-linear-gradient(0deg,transparent 0 23px,var(--rule) 23px 24px),var(--paper);
  box-shadow: 0 2px #afbdba,0 4px var(--paper);
}
#briefing[data-stage="1"] { --tab:#c2dbff; --section:#244b96; }
#briefing[data-stage="2"] { --tab:#e9c5e7; --section:#704477; }
#briefing[data-stage="3"] { --tab:#aee4d1; --section:#216565; }
.notebook .page-corner {
  position:absolute; z-index:4; right:var(--corner-inset); bottom:0; width:var(--corner-width); height:44px;
  border:0; padding:0; background:transparent; cursor:grab; touch-action:none;
}
.page-corner::after {
  content:''; position:absolute; bottom:0; right:calc(0px - var(--corner-inset)); width:40px; height:40px;
  background:linear-gradient(135deg,transparent 45%,#aaa99a 49%,#ede9d8 55%,#d7d2c0 73%,#869481 96%);
  filter:drop-shadow(1px -1px 1px #423f3626);
}
.page-corner:active { cursor:grabbing; }
.page-corner.back-corner { top:0; bottom:auto; }
.page-corner.back-corner::after { top:3px; bottom:auto; height:27px; transform:scaleY(-1); opacity:.65; }
.notebook .reader-nav { padding-right:calc(var(--corner-width) + var(--corner-inset)); }
#opening-cover .cover-actions { padding-right:calc(var(--corner-width) + var(--corner-inset) - 15px); }
.cover-open .page-corner.back-corner, .quiz-open .page-corner,
body[data-stage="3"]:not(.cover-open,.briefing-open,.episode-read) .page-corner:not(.back-corner) { display:none; }
body[data-stage="3"]:not(.cover-open,.briefing-open,.episode-read) .notebook-leaf { padding-bottom: 40px; }
.quiz-open .notebook-puzzle { display:none; }
.turn-reveal {
  position:fixed; inset:0; z-index:20; overflow:hidden; pointer-events:none;
}
.turn-scene { position:absolute; inset:0 0 auto; width:100%; margin:0; }
.turn-moving { visibility:hidden; }
.turn-scene:not(.turn-moving) .notebook-binding { visibility:hidden; }
.turn-moving .episode-strip, .turn-moving #cipher-desk, .turn-moving .notebook-binding { visibility:visible; }
.notebook .turn-hinge {
  flex:none; padding-bottom:0; overflow:hidden; border-radius:0; box-shadow:none;
}
.turn-scene .page-corner, .notebook-leaf[data-turning] .page-corner { opacity:0; }
.quiz-page {
  padding:16px 14px 12px 17px; color:var(--ink);
  background:repeating-linear-gradient(0deg,transparent 0 23px,var(--rule) 23px 24px),var(--paper);
}
.quiz-page h1 { font:bold italic 29px/1.03 Georgia,serif; margin:5px 0 18px; letter-spacing:-.04em; }
.quiz-page h2 { font:bold 20px/1.17 Georgia,serif; letter-spacing:-.025em; margin:6px 0 15px; color:var(--ink); }
.review-title,.review-count { font:bold 12px/1.4 'Courier New',monospace; color:var(--section); margin:3px 0; }
.quiz-page button { font:600 14px/1.25 Georgia,serif; min-height:40px; padding:7px 10px; border-radius:2px; }
.quiz-page>button { margin:5px 7px 3px 0; }
.quiz-page>button:first-of-type { color:var(--paper); background:var(--section); border-color:var(--section); }
.reading-notes { padding:8px 0 1px; border-block:1px solid var(--line); }
.reading-notes nav { display:flex; gap:4px; }
.reading-notes nav button { flex:1; font:600 12px/1.15 'Courier New',monospace; padding:4px; }
.reading-notes nav button[aria-current] { background:var(--tab); border-color:var(--section); }
.reading-notes p { font:17px/1.48 Georgia,serif; margin:12px 0; }
.verse-note { white-space:pre-wrap; }
.review-options { display:grid; gap:5px; margin-top:13px; }
.review-options button { text-align:left; background:var(--paper); }
.review-options button.right-answer { opacity:1; background:var(--tab); border:2px solid var(--section); }
.review-options button.wrong-answer { border:2px dashed var(--accent); }
.review-feedback,.review-answer { font:16px/1.4 Georgia,serif; }
.review-answer { border-top:1px solid var(--line); padding:8px 0; }
.review-answer p { margin:2px 0; }
