/* ==== Watson's notebook opens like a volume of the time (markup: journalBook in view.js; durations JOURNAL_FIRST_MS and
   JOURNAL_AGAIN_MS, played once per opening by entrance()). The first time, on one timeline of 1.7 s:
     0–14 %  the closed book is laid on the table (it comes up from below, tilted, its shadow growing);
    12–30 %  the brass clasp lets go and the leather strap folds back over the fore-edge;
    26–60 %  the cover swings open on the spine: green morocco with gilt rules and monogram, a gleam running over it, the board's
             edge seen as it stands upright, and inside a marbled endpaper with Watson's bookplate;
    56–92 %  three leaves turn after it, shaded as they rise;
    82–100 % the ink comes up on the pages from left to right and the ribbons rise from behind the top edge with a small swing.
   Later openings only swing the cover (0.6 s). Every piece shares the negative delay --enter-at, so a repaint resumes it. Loaded after kit.css. ==== */
.journal-stage{--cover:clamp(26px,3vw,40px);--gap:clamp(30px,3.4vw,46px);position:relative;isolation:isolate;perspective:2800px;container-type:inline-size}
.journal-open{--jb-ms:1700ms}
.journal-reopen{--jb-ms:600ms}
.journal-book{position:absolute;inset:0;z-index:4;pointer-events:none;visibility:hidden;transform-style:preserve-3d}
:is(.journal-open,.journal-reopen) .journal-book{animation:jb-show var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-show{0%,84%{visibility:visible}85%,100%{visibility:hidden}}
/* Lying flat, the pieces would share one plane and the browser would draw them in page order. Each holds a few pixels of
   depth that a half turn reverses: the closed cover is above the leaves, the open one under them, the last leaf on top. */
.journal-reopen .journal-book{animation-name:jb-show-again}
@keyframes jb-show-again{0%,69%{visibility:visible}70%,100%{visibility:hidden}}

/* The page block under the closed cover: a few millimetres of paper show at the fore-edge and the tail, sprinkled red as the
   edges of stationers' notebooks were. It goes as the cover lifts: the leaves and the pages take its place. */
.jb-block{position:absolute;top:calc(var(--cover) * .4);bottom:-6px;left:50%;right:-6px;border-radius:0 8px 8px 0;background:radial-gradient(circle at 20% 30%,#8e2a1f 0 1px,transparent 1.6px) 0 0/9px 7px,radial-gradient(circle at 60% 70%,#9c3324 0 .8px,transparent 1.4px) 3px 2px/11px 9px,repeating-linear-gradient(0deg,#efe3c4 0 1px,#cdbb92 1px 2px);box-shadow:0 16px 34px #000b,0 3px 6px #0008}

/* The cover: a board with three faces. */
.journal-cover{position:absolute;top:0;bottom:0;left:50%;right:0;transform-origin:left center;transform-style:preserve-3d;transform:translateZ(3px)}
.jc-front,.jc-back{position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;overflow:hidden}
.jc-front{border-radius:3px 12px 12px 3px;border:var(--cover) solid transparent;border-image:url('../assets/ui/kit/ui-v2-taccuino-copertina.webp') 80 / var(--cover) / 0 stretch;background:radial-gradient(ellipse at 30% 22%,#ffffff12,transparent 55%),url('../assets/ui/kit/ui-v2-taccuino-cuoio.webp') center/cover,#183c2c;background-origin:border-box;box-shadow:0 18px 40px #000c,inset 6px 0 10px #0006}
/* Two gilt rules close to the edge and a blind-tooled one inside them, as on a binder's cover. */
.jc-front::before{content:'';position:absolute;inset:4%;border:1.5px solid #c9a55acc;outline:1px solid #c9a55a88;outline-offset:-6px;border-radius:2px}
.jc-front::after{content:'';position:absolute;inset:9%;border:1px solid #00000066;box-shadow:0 1px 0 #ffffff14,inset 0 1px 0 #ffffff10;border-radius:2px}
.jc-title{position:absolute;inset:0;z-index:1;display:grid;place-content:center;justify-items:center;gap:.2em;font-family:var(--kit-display);color:#d9b560}
.jc-title :is(i,b,small){background:linear-gradient(180deg,#f8e3a2 0%,#d8b25c 42%,#8b6322 54%,#e7c46c 72%,#b98c3c 100%);-webkit-background-clip:text;background-clip:text;color:transparent;filter:drop-shadow(0 1px 0 #000a) drop-shadow(0 -1px 0 #ffffff22)}
/* A gilt ornament above the monogram: a short double rule with a lozenge, drawn, so no font is needed for it. */
.jc-title i{position:relative;width:clamp(60px,12cqw,140px);height:7px;border-block:1px solid #d6b060;background:none;filter:none}
.jc-title i::after{content:'';position:absolute;left:50%;top:50%;width:7px;height:7px;translate:-50% -50%;rotate:45deg;background:linear-gradient(135deg,#f8e3a2,#8b6322)}
.jc-title b{font:italic 600 clamp(44px,9cqw,104px)/1 var(--kit-display)}
.jc-title small{font:italic 500 clamp(12px,1.9cqw,20px)/1 var(--kit-display);letter-spacing:.12em}
/* A gleam of the lamp running over the leather while the cover turns. */
.jc-sheen{position:absolute;inset:calc(var(--cover) * -1);z-index:2;background:linear-gradient(105deg,transparent 38%,#fff6d826 48%,#ffffff10 52%,transparent 62%) 120% 0/260% 100% no-repeat}
/* Inside: the leather turned over the edges of the board, a marbled endpaper, and Watson's bookplate pasted a little askew. */
.jc-back{transform:rotateY(180deg);border-radius:12px 3px 3px 12px;border:calc(var(--cover) * .55) solid #163828;background:url('../assets/ui/kit/ui-v2-taccuino-guardia.webp') center/cover,#2c3c56;box-shadow:inset 0 0 0 1px #c9a55a55,inset -10px 0 18px #0008,inset 0 0 30px #0006}
.jc-plate{position:absolute;left:50%;top:50%;display:grid;justify-items:center;gap:.25em;width:min(52%,240px);padding:.9em .8em;translate:-50% -50%;rotate:-1.5deg;background:url('../assets/ui/kit/ui-v2-carta.webp') center/100% 100% no-repeat,#efe4c8;border:1px solid #6b4a24;outline:1px solid #6b4a2477;outline-offset:-6px;box-shadow:0 2px 4px #0007;color:#3a2414;text-align:center}
.jc-plate small{font:italic clamp(10px,1.3cqw,14px)/1.2 var(--kit-text);color:#6b4a24}
.jc-plate b{font:600 clamp(14px,2.2cqw,24px)/1.15 var(--kit-display);color:#2c1a0c}
/* The board's edge: seen only while the cover stands upright. */
.jc-edge{position:absolute;top:0;bottom:0;right:0;width:7px;transform-origin:right center;transform:rotateY(-90deg);background:linear-gradient(90deg,#0d2318,#1f4532 50%,#0d2318);border-radius:2px}

/* The strap: a leather tab from the back board over the fore-edge, held on the cover by a brass clasp. */
.jb-strap{backface-visibility:hidden;-webkit-backface-visibility:hidden;position:absolute;top:43%;height:13%;right:-1.2%;width:19%;transform-origin:right center;transform:translateZ(4px);border-radius:7px 0 0 7px;background:url('../assets/ui/kit/ui-v2-taccuino-cuoio.webp') center/600px,#1d4030;box-shadow:0 3px 8px #000b,inset 0 0 0 1px #0b2016}
.jb-strap::before{content:'';position:absolute;inset:4px 0 4px 4px;border:1px dashed #c9a55a66;border-right:0;border-radius:5px 0 0 5px}
.jb-clasp{position:absolute;left:10%;top:50%;width:clamp(16px,3cqw,30px);aspect-ratio:1;translate:0 -50%;border-radius:50%;background:radial-gradient(circle at 34% 30%,#fff3c0 0 8%,#e2b356 30%,#93651f 68%,#4d320d 100%);box-shadow:0 2px 4px #000c,inset 0 -2px 3px #0006,0 0 0 2px #3a260a66}

/* The leaves: paper, gutter shadow on the spine side, turned on the spine like the cover. */
.jb-leaf{--z:calc(2px - var(--n) * .5px);position:absolute;top:var(--cover);bottom:var(--cover);left:calc(50% + var(--gap) / 2);right:var(--cover);transform-origin:calc(var(--gap) / -2) 50%;transform-style:preserve-3d;transform:translateZ(var(--z))}
.jb-leaf::before,.jb-leaf::after{content:'';position:absolute;inset:0;backface-visibility:hidden;-webkit-backface-visibility:hidden;background:url('../assets/ui/kit/ui-v2-carta.webp') center/100% 100% no-repeat,#ecdcb8}
.jb-leaf::before{box-shadow:inset 18px 0 22px -14px #5a3a1a77}
.jb-leaf::after{transform:rotateY(180deg);box-shadow:inset 18px 0 22px -14px #5a3a1a77}

/* ---- The first opening ---- */
.journal-open .journal-stage{animation:jb-arrive var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-arrive{0%{opacity:0;transform:perspective(1400px) translateY(34px) rotateX(12deg) scale(.94);animation-timing-function:cubic-bezier(.2,.7,.25,1)}14%,100%{opacity:1;transform:none}}
/* The open volume under it: only its right half (under the closed cover) until the cover lands on the left. */
.journal-open .notebook{animation:jb-notebook var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-notebook{0%,56%{clip-path:inset(0 0 0 50%)}57%,100%{clip-path:inset(-60px)}}
.journal-open .jb-block{animation:jb-block var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-block{0%,30%{opacity:1}44%,100%{opacity:0}}
.journal-open .jb-strap{animation:jb-strap var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-strap{0%,16%{transform:translateZ(4px);opacity:1;animation-timing-function:cubic-bezier(.5,0,.6,1)}29%{transform:translateZ(4px) rotateY(165deg);opacity:1}30%,100%{transform:translateZ(4px) rotateY(165deg);opacity:0}}
.journal-open .jb-clasp{animation:jb-clasp var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-clasp{0%,11%{scale:1;filter:none}14%{scale:1.22;filter:brightness(1.35)}17%,100%{scale:1;filter:none}}
.journal-open .journal-cover{animation:jb-cover var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-cover{0%,26%{transform:rotateY(0deg) translateZ(3px);animation-timing-function:cubic-bezier(.45,.05,.4,1)}55%{transform:rotateY(-176deg) translateZ(3px);animation-timing-function:ease-out}58%,100%{transform:rotateY(-180deg) translateZ(3px)}}
.journal-open .jc-sheen{animation:jb-sheen var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-sheen{0%,24%{background-position:120% 0;animation-timing-function:ease-in-out}46%,100%{background-position:-20% 0}}
.journal-open .jb-leaf{animation:jb-leaf calc(var(--jb-ms) * .17) linear calc(var(--enter-at,0ms) + var(--jb-ms) * (.52 + var(--n) * .07)) both}
@keyframes jb-leaf{0%{transform:rotateY(0deg) translateZ(var(--z));filter:none;animation-timing-function:cubic-bezier(.4,0,.6,1)}50%{transform:rotateY(-90deg) skewY(-2.5deg) translateZ(var(--z));filter:brightness(.78);animation-timing-function:cubic-bezier(.3,0,.4,1)}100%{transform:rotateY(-180deg) translateZ(var(--z));filter:none}}
/* The ink comes up across each page, as if drying. */
:is(.journal-open,.journal-reopen) .notebook-page>*{-webkit-mask-image:linear-gradient(90deg,#000 42%,transparent 58%);mask-image:linear-gradient(90deg,#000 42%,transparent 58%);-webkit-mask-size:260% 100%;mask-size:260% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}
.journal-open .notebook-page>*{animation:jb-ink var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-ink{0%,84%{-webkit-mask-position:100% 0;mask-position:100% 0;animation-timing-function:ease-out}100%{-webkit-mask-position:0 0;mask-position:0 0}}
/* The ribbons come up from behind the top edge, each with a little swing on its own beat. */
.journal-open .bookmark{transform-origin:50% 100%;animation:jb-ribbon var(--jb-ms) linear var(--enter-at,0ms) both}
.journal-open .bookmark:nth-child(2){--swing:-1}
.journal-open .bookmark:nth-child(3){--swing:.8}
@keyframes jb-ribbon{0%,80%{opacity:0;translate:0 60%;rotate:0deg;animation-timing-function:cubic-bezier(.2,.8,.3,1)}88%{opacity:1;translate:0 0;rotate:calc(var(--swing,1) * 5deg)}94%{rotate:calc(var(--swing,1) * -2.5deg)}100%{opacity:1;translate:0 0;rotate:0deg}}

/* ---- Later openings: the closed cover swings open at once, and the ink comes up ---- */
.journal-reopen :is(.jb-leaf,.jb-strap,.jb-block){display:none}
.journal-reopen .journal-stage{animation:jb-return var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-return{0%{opacity:0;transform:translateY(10px) scale(.98);animation-timing-function:ease-out}22%,100%{opacity:1;transform:none}}
.journal-reopen .notebook{animation:jb-notebook-again var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-notebook-again{0%,50%{clip-path:inset(0 0 0 50%)}51%,100%{clip-path:inset(-60px)}}
.journal-reopen .journal-cover{animation:jb-cover-again var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-cover-again{0%,8%{transform:rotateY(0deg) translateZ(3px);animation-timing-function:cubic-bezier(.45,.05,.4,1)}66%,100%{transform:rotateY(-180deg) translateZ(3px)}}
.journal-reopen .jc-sheen{animation:jb-sheen-again var(--jb-ms) linear var(--enter-at,0ms) both}
/* With no leaves to turn, the inside of the cover fades as it lands: the left page shows, as if the cover went under it. */
.journal-reopen .jc-back{animation:jb-back-again var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-back-again{0%,54%{opacity:1}68%,100%{opacity:0}}
@keyframes jb-sheen-again{0%,8%{background-position:120% 0}50%,100%{background-position:-20% 0}}
.journal-reopen .notebook-page>*{animation:jb-ink-again var(--jb-ms) linear var(--enter-at,0ms) both}
@keyframes jb-ink-again{0%,52%{-webkit-mask-position:100% 0;mask-position:100% 0;animation-timing-function:ease-out}100%{-webkit-mask-position:0 0;mask-position:0 0}}

/* Small screens: the thinner leather of the phone layout (kit.css), a closer eye. */
@media (max-height:560px) and (min-aspect-ratio:1/1){
  .journal-stage{--cover:18px;--gap:22px;perspective:1600px}
  /* The ribbons stand in a row inside the cover here (kit.css): the pages, and so the leaves, start below it. */
  .jb-leaf{top:calc(var(--cover) + 46px)}
  .jc-plate{padding:.6em .5em}
}
/* A narrow upright screen shows the notebook as one column (kit.css): there is no spine to turn on, so it only arrives. */
@media (max-width:900px) and (min-height:561px){
  .journal-book{display:none}
  :is(.journal-open,.journal-reopen) .notebook{animation:none}
}
@media (prefers-reduced-motion:reduce){
  .journal-book{display:none}
  :is(.journal-open,.journal-reopen) :is(.journal-stage,.notebook,.notebook-page>*,.bookmark){animation:none}
  :is(.journal-open,.journal-reopen) .notebook-page>*{-webkit-mask-image:none;mask-image:none}
}

/* A struck claim of Ferguson in the notebook, above Holmes's reading. */
.journal-was{font-style:italic;color:#6e5a48}
.journal-was s{text-decoration-color:#b3241bb0;text-decoration-thickness:1.5px}
.journal-was span{font-style:normal;font-size:.9em}
