/* ==========================================================================
   The Journal (js/journal.js). Every rule is scoped to .jr / .jp / .jf, so nothing
   here touches the desktop. Sizes inside a page are in cqw (% of the page width),
   so a page looks the same at every size, only larger or smaller. --k (set by
   js/journal.js) enlarges the handwriting a little on small pages so it stays readable.
   ========================================================================== */

.jr {
  --ink: #1b1b21;   /* black ballpoint: not quite pure black, a touch cool */
  --leather-grain: 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='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .35 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");

  position: fixed; inset: 0; z-index: 2000;
  overflow-x: hidden; overflow-y: auto;
  opacity: 0;
  transition: opacity 0.22s ease;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.jr[hidden] { display: none; }
.jr.is-open { opacity: 1; }

/* the desktop stays visible behind, slightly dimmed. (No blur: blurring the whole
   screen behind a turning page halves the frame rate.) */
.jr__backdrop {
  position: fixed; inset: 0;
  background: rgba(22, 10, 6, 0.64);
}

.jr__stage {
  position: relative;
  display: flex;
  min-height: 100%;
  padding: 64px 24px 88px;
}
.jr__frame {
  margin: auto; /* centred, and still scrollable if the window is shorter than the book */
  padding: var(--m);
  transform: translateY(16px) scale(0.97);
  opacity: 0;
  transition: transform 0.34s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
}
.jr.is-open .jr__frame { transform: none; opacity: 1; }

/* ---------- The book ---------- */

.jr__book {
  --spine: 50%;
  position: relative;
  width: calc(2 * var(--pw));
  height: var(--ph);
  perspective: calc(var(--pw) * 5);
  user-select: none; -webkit-user-select: none;
  touch-action: pan-y; /* vertical scrolling stays; horizontal swipes turn pages */
  cursor: grab;
}
.jr__book[data-mode="single"] { --spine: 0px; width: var(--pw); }
.jr.is-dragging .jr__book { cursor: grabbing; }

/* one sheet: front and back, rotating around the spine */
.jr__leaf {
  position: absolute; top: 0; left: var(--spine);
  width: var(--pw); height: var(--ph);
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  will-change: transform;
}
.jr__leaf--board {
  top: calc(-1 * var(--m));
  width: calc(var(--pw) + var(--m));
  height: calc(var(--ph) + 2 * var(--m));
}
.jr__face {
  position: absolute; inset: 0;
  overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  container-type: inline-size;
}
.jr__face--back { transform: rotateY(180deg); }

/* the leather board under single pages (phones), with a strip of spine on the left */
.jr__board {
  position: absolute;
  left: calc(-1 * var(--m)); top: calc(-1 * var(--m));
  width: calc(var(--pw) + 2 * var(--m)); height: calc(var(--ph) + 2 * var(--m));
  border-radius: 3px 6px 6px 3px;
  /* the real interior leather (from the photo of the open journal), shaded towards the spine */
  background: linear-gradient(90deg, rgba(20, 4, 9, 0.55) 0, rgba(20, 4, 9, 0.15) 4%, rgba(20, 4, 9, 0) 30%, rgba(20, 4, 9, 0.12) 100%),
    url("/assets/journal/leather-inside.jpg") center / cover;
  z-index: 0; /* the tucked-away flap sits behind it */
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.35);
}

/* page edges: a few sheets' thickness along the outer edges of the top page */
.jr__leaf:not(.jr__leaf--board) .jr__face.is-right { box-shadow: 1px 0 0 #e6e2d8, 2px 1px 0 #d3cdbf, 3px 1px 0 #ebe7de, 4px 2px 0 #c9c2b2, 5px 2px 3px rgba(0, 0, 0, 0.25); overflow: visible; }
.jr__leaf:not(.jr__leaf--board) .jr__face.is-left { box-shadow: -1px 0 0 #e6e2d8, -2px 1px 0 #d3cdbf, -3px 1px 0 #ebe7de, -4px 2px 0 #c9c2b2, -5px 2px 3px rgba(0, 0, 0, 0.25); overflow: visible; }
.jr__face > .jp { overflow: hidden; }

/* shading on a turning page: darker towards the spine, a sheen across the curve.
   js/journal.js only changes their opacity, so turning never repaints the paper. */
.jr__shade, .jr__sheen { position: absolute; inset: 0; pointer-events: none; opacity: 0; will-change: opacity; }
.jr__face--front > .jr__shade { background: linear-gradient(90deg, rgba(30, 18, 8, 0.55) 0%, rgba(30, 18, 8, 0.12) 45%, rgba(30, 18, 8, 0.3) 100%); }
.jr__face--back > .jr__shade { background: linear-gradient(270deg, rgba(30, 18, 8, 0.55) 0%, rgba(30, 18, 8, 0.12) 45%, rgba(30, 18, 8, 0.3) 100%); }
.jr__face--front > .jr__sheen { background: linear-gradient(90deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.22) 62%, rgba(255, 255, 255, 0) 80%); }
.jr__face--back > .jr__sheen { background: linear-gradient(270deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.22) 62%, rgba(255, 255, 255, 0) 80%); }

/* corner fold (paper pages): shading along the fold, and the shadow on the page beneath;
   js/journal.js → renderFold sets their gradients each frame */
.jr__fold { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.jr__fcast { position: absolute; top: 0; left: 0; width: var(--pw); height: var(--ph); pointer-events: none; opacity: 0; }

/* shadow the turning page throws on the page beneath */
.jr__cast { position: absolute; top: 0; left: 0; width: var(--pw); height: 100%; pointer-events: none; opacity: 0; will-change: transform, opacity; }
.jr__cast[data-dir="right"] { transform-origin: 0 50%; }
.jr__cast[data-dir="left"] { transform-origin: 100% 50%; }
.jr__cast[data-dir="right"] { background: linear-gradient(90deg, rgba(25, 14, 6, 0.42), rgba(25, 14, 6, 0)); }
.jr__cast[data-dir="left"] { background: linear-gradient(270deg, rgba(25, 14, 6, 0.42), rgba(25, 14, 6, 0)); }

/* ---------- Covers and endpapers ---------- */

.jf { position: absolute; inset: 0; }
/* the cover is a photo of the real journal; the leather beneath blends its soft cut-out edges */
/* the cover is the photo itself: no box, a shadow that follows the journal's own shape */
.jf--cover picture, .jf--cover img { display: block; width: 100%; height: 100%; }
.jf--cover img { object-fit: fill; pointer-events: none; -webkit-user-drag: none; filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.42)); }
.jf--leather {
  border-radius: 4px;
  background:
    var(--leather-grain),
    radial-gradient(ellipse 80% 70% at 30% 20%, rgba(255, 190, 170, 0.12), rgba(255, 190, 170, 0) 70%),
    linear-gradient(160deg, #66253a 0%, #55202f 55%, #431724 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), inset 0 0 calc(var(--m) * 2) rgba(0, 0, 0, 0.35), 0 18px 40px rgba(0, 0, 0, 0.45);
}
.jf--leather::before { /* blind-pressed border */
  content: ""; position: absolute; inset: 7%;
  border: 1px solid rgba(0, 0, 0, 0.3);
  box-shadow: 1px 1px 0 rgba(255, 200, 190, 0.12);
  border-radius: 2px;
}
/* inside of a cover: leather turned over the edges, zebra-print paper glued on top */
.jf--endpaper {
  border-radius: 4px;
  /* the leather turn-in round the zebra paper: the real interior leather */
  background: url("/assets/journal/leather-inside.jpg") center / cover;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.jf__paper {
  position: absolute;
  inset: calc(var(--m) * 0.55);
  background: url("/assets/journal/endpaper-zebra.jpg") center / cover no-repeat;
  background-image: image-set(url("/assets/journal/endpaper-zebra.avif") type("image/avif"), url("/assets/journal/endpaper-zebra.jpg") type("image/jpeg"));
  box-shadow: inset 0 0 calc(var(--m) * 1.5) rgba(0, 0, 0, 0.45);
}
.is-left .jf__paper { right: 0; }   /* glued right up to the spine */
.is-right .jf__paper { left: 0; }

/* ---------- The wrap: flap + elastic band over the closed cover (js/journal.js → setWrap) ---------- */

.jc {
  position: absolute;
  top: calc(-1 * var(--m)); left: var(--spine);
  width: calc(var(--pw) + var(--m)); height: calc(var(--ph) + 2 * var(--m));
  perspective: calc(var(--pw) * 5);
  pointer-events: none; /* clicks reach the book underneath */
}
.jc picture, .jc img { display: block; width: 100%; height: 100%; }
.jc img { object-fit: fill; -webkit-user-drag: none; }
.jc__flap, .jc__face, .jc__band, .jc__seam, .jc__shadow, .jc__shade { position: absolute; inset: 0; }
.jc__seam { will-change: opacity; }
/* hinged at the fore-edge (the right edge of the photo's book) */
.jc__flap { transform-origin: 98.3% 50%; transform-style: preserve-3d; will-change: transform; }
.jc__face { backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.jc__face--in { transform: rotateY(180deg); }
/* shading and the flap's shadow on the cover: masked to the flap's shape, only opacity animates */
.jc__shade, .jc__shadow { -webkit-mask-size: 100% 100%; mask-size: 100% 100%; opacity: 0; will-change: opacity; }
.jc__shade { background: #1a0509; }
.jc__shadow { background: linear-gradient(270deg, rgba(25, 5, 12, 0.6), rgba(25, 5, 12, 0.18) 55%, rgba(25, 5, 12, 0)); }
.jc__band { will-change: transform, opacity; }

/* ---------- Paper ---------- */

.jp {
  position: absolute; inset: 0;
  color: var(--ink);
  /* Shreyasi's chosen handwriting: Zeyada (the closest font), written a little wider and
     looser, in black ballpoint (the #jp-ballpoint filter below, from journal.js).
     --hand scales every size up, as Zeyada runs smaller than a typical script. */
  --hand: 1.15;
  font: 400 calc(4.3cqw * var(--k, 1) * var(--hand, 1))/1.5 "Zeyada", "Segoe Script", "Bradley Hand", cursive;
  letter-spacing: 0.03em; word-spacing: 0.2em;
  -webkit-text-stroke: 0.012em currentColor;   /* a ballpoint line, a touch firmer than the font */
  /* bleached handmade paper: a real scan (fibres, flecks, gentle cockling), each page from its own
     part of the sheet; just a whisper of age at the edges */
  background:
    radial-gradient(circle at var(--fx1, 30%) var(--fy1, 70%), rgba(150, 115, 60, 0.035) 0, rgba(150, 115, 60, 0) var(--fs1, 8%)),
    radial-gradient(ellipse 80% 75% at 50% 50%, rgba(140, 120, 90, 0) 60%, rgba(140, 120, 90, 0.1) 100%),
    url("/assets/journal/paper-handmade.jpg") var(--ppx, 50%) var(--ppy, 50%) / 125% auto,
    #f4f2ea;
  background-image:
    radial-gradient(circle at var(--fx1, 30%) var(--fy1, 70%), rgba(150, 115, 60, 0.035) 0, rgba(150, 115, 60, 0) var(--fs1, 8%)),
    radial-gradient(ellipse 80% 75% at 50% 50%, rgba(140, 120, 90, 0) 60%, rgba(140, 120, 90, 0.1) 100%),
    image-set(url("/assets/journal/paper-handmade.avif") type("image/avif"), url("/assets/journal/paper-handmade.jpg") type("image/jpeg"));
}
/* the gutter: paper curving into the spine */
.jp::before { content: ""; position: absolute; top: 0; bottom: 0; width: 16%; pointer-events: none; }
.is-right > .jp::before { left: 0; background: linear-gradient(90deg, rgba(60, 48, 34, 0.24), rgba(60, 48, 34, 0.06) 35%, rgba(60, 48, 34, 0)); }
.is-left > .jp::before { right: 0; background: linear-gradient(270deg, rgba(60, 48, 34, 0.24), rgba(60, 48, 34, 0.06) 35%, rgba(60, 48, 34, 0)); }
.jp--reverse, .jp--blank { font-size: 0; }

.jp__body {
  position: absolute;
  top: 10cqw; bottom: 13cqw; left: 12cqw; right: 9cqw;
  display: flex; flex-direction: column;
  transform: rotate(var(--tilt, 0deg));
}
.is-left > .jp > .jp__body { left: 9cqw; right: 12cqw; }

.jp-date { margin: 0 0 2cqw; align-self: flex-end; font-size: calc(3.7cqw * var(--k, 1) * var(--hand, 1)); opacity: 0.85; }
.jp-title { margin: 0 0 3cqw; font-size: calc(7.2cqw * var(--k, 1) * var(--hand, 1)); font-weight: 400; line-height: 1.15; }
.jp-text p { margin: 0 0 2.6cqw; }
.jp-text p:last-child { margin-bottom: 0; }
.jp b { font-weight: 400; text-shadow: 0.02em 0 0 currentColor, -0.02em 0 0 currentColor; }

.jp-fig { margin: 0; }
.jp-fig img {
  display: block; width: 100%; height: auto;
  mix-blend-mode: multiply; /* scanned drawings on white paper sit into the page */
  pointer-events: none; -webkit-user-drag: none;
}
.jp-fig figcaption { margin-top: 2.4cqw; font-size: calc(3.8cqw * var(--k, 1) * var(--hand, 1)); line-height: 1.35; transform: rotate(-1.2deg); }

.jp-note { position: absolute; margin: 0; font-size: calc(3.5cqw * var(--k, 1) * var(--hand, 1) * var(--s, 1)); line-height: 1.3; transform: rotate(var(--r, 0deg)); }
/* a photo of a page, filling this page edge to edge (journal.js: "pasted") */
.jp-full { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; -webkit-user-drag: none; }
.jp-gutter { position: absolute; top: 0; bottom: 0; width: 16%; pointer-events: none; }
.is-right > .jp > .jp-gutter { left: 0; background: linear-gradient(90deg, rgba(60, 48, 34, 0.24), rgba(60, 48, 34, 0.06) 35%, rgba(60, 48, 34, 0)); }
.is-left > .jp > .jp-gutter { right: 0; background: linear-gradient(270deg, rgba(60, 48, 34, 0.24), rgba(60, 48, 34, 0.06) 35%, rgba(60, 48, 34, 0)); }
/* pen line art over the whole page (journal.js: page.art) */
.jp-art { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.jp-doodle { position: absolute; height: auto; transform: rotate(var(--r, 0deg)); mix-blend-mode: multiply; pointer-events: none; -webkit-user-drag: none; }
.jp-num { position: absolute; bottom: 5cqw; font-size: calc(3.6cqw * var(--k, 1) * var(--hand, 1)); opacity: 0.8; }
.is-right > .jp > .jp-num { right: 7.5cqw; }
.is-left > .jp > .jp-num { left: 7.5cqw; }

/* placeholder pages: marked in red pencil so they can't be mistaken for real work */
.jp-stamp {
  position: absolute; bottom: 4.6cqw; left: 50%;
  padding: 0.4cqw 1.6cqw;
  border: 1.5px solid currentColor; border-radius: 1cqw;
  color: rgba(160, 32, 26, 0.72);
  font-size: calc(3.1cqw * var(--k, 1) * var(--hand, 1)); line-height: 1.2; letter-spacing: 0.06em;
  transform: translateX(-50%) rotate(-4deg);
}

/* pencil marks inside text */
.jp-strike {
  text-decoration: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'%3E%3Cpath d='M0 11 C18 7 32 14 50 9 S82 13 100 8 M1 13 C26 10 58 15 99 10' stroke='%231b1b21' stroke-width='1.7' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") 0 58% / 100% 0.6em no-repeat;
}
.jp-under {
  text-decoration: none;
  padding-bottom: 0.12em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 10' preserveAspectRatio='none'%3E%3Cpath d='M1 6 C25 3 55 8 99 4' stroke='%231b1b21' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") 0 100% / 100% 0.32em no-repeat;
}

/* ---------- Page layouts (each page composes differently) ---------- */

/* title page */
.jp--title .jp__body { justify-content: center; text-align: center; }
.jp--title .jp-title { margin: 0 0 1cqw; font-size: calc(12cqw * var(--k, 1) * var(--hand, 1)); }
.jp--title .jp-title::after {
  content: ""; display: block; height: 3cqw; margin: 1cqw auto 4cqw; width: 62%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6 C30 2 60 9 98 4 M8 8 C40 5 70 9 92 6' stroke='%231b1b21' stroke-width='1.3' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.jp--title .jp-text p { margin: 0 0 1cqw; font-size: calc(5.2cqw * var(--k, 1) * var(--hand, 1)); }
.jp--title .jp-text p + p { font-size: calc(4.2cqw * var(--k, 1) * var(--hand, 1)); opacity: 0.85; }
.jp--title .jp-note { text-align: center; }

/* a full-page drawing with a caption */
.jp--drawing .jp-fig { margin: auto 0; }
.jp--drawing .jp-fig figcaption { text-align: center; padding: 0 4cqw; }

/* text-led entry */
.jp--entry .jp-title { margin-bottom: 4cqw; }
.jp--entry .jp-text { font-size: calc(4.5cqw * var(--k, 1) * var(--hand, 1)); line-height: 1.6; }

/* a sketch with notes scattered around it */
.jp--sketch-notes .jp-fig { width: 54%; margin: auto; }

/* sketch taped in beside a paragraph */
.jp--mixed .jp__body { display: block; }
.jp--mixed .jp-fig { float: right; width: 44%; margin: 3cqw -2cqw 3cqw 4cqw; transform: rotate(3deg); position: relative; }
.jp--mixed .jp-fig img { background: rgba(255, 252, 244, 0.55); padding: 3cqw; box-shadow: 0 0.6cqw 1.4cqw rgba(60, 40, 20, 0.18); }
.jp--mixed .jp-fig figcaption { text-align: center; font-size: calc(3.4cqw * var(--k, 1) * var(--hand, 1)); }
.jp--mixed .jp-text { font-size: calc(4.4cqw * var(--k, 1) * var(--hand, 1)); line-height: 1.65; }
.jp-fig.has-tape::before, .jp-fig.has-tape::after {
  content: ""; position: absolute; z-index: 1;
  width: 34%; height: 7cqw;
  background: rgba(238, 230, 205, 0.62);
  box-shadow: 0 0.3cqw 0.8cqw rgba(60, 40, 20, 0.15);
}
.jp-fig.has-tape::before { top: -3cqw; left: -8%; transform: rotate(-32deg); }
.jp-fig.has-tape::after { top: -3cqw; right: -8%; transform: rotate(28deg); }

/* ---------- photo page: a real print taped in, ballpoint writing and an arrow under it ---------- */
/* The print keeps every texture of the original photo (dust, fading, grain). On top: the
   gloss of a photo print catching the light, a faint edge, and a shadow that deepens at the
   untaped corners, which lift off the page a little. */
.jp-photo { position: absolute; margin: 0; left: 28%; top: 12%; width: 46%; transform: rotate(-1deg); }
.jp-photo img {
  display: block; width: 100%; height: auto;
  box-shadow:
    0 0.12cqw 0.22cqw rgba(30, 20, 10, 0.32),            /* where it touches the paper */
    0 0.7cqw 1.5cqw -0.3cqw rgba(30, 20, 10, 0.26),       /* soft fall-off */
    1.1cqw 1.5cqw 2cqw -1.3cqw rgba(30, 20, 10, 0.34),    /* bottom-right corner lifting */
    -0.9cqw -0.9cqw 1.6cqw -1.3cqw rgba(30, 20, 10, 0.16); /* top-left corner lifting */
  pointer-events: none; -webkit-user-drag: none;
}
.jp-photo__gloss {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0) 28%, rgba(255, 255, 255, 0.15) 43%, rgba(255, 255, 255, 0.05) 52%, rgba(255, 255, 255, 0) 63%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.95' numOctaves='3' seed='6' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .22 -.04'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  box-shadow: inset 0 0 0 0.12cqw rgba(255, 255, 255, 0.3), inset 0 0 1.6cqw rgba(40, 25, 10, 0.12);
  mix-blend-mode: screen;
}
/* Washi tape: translucent pink paper (it lightens and tints what's under it, as real washi
   does), with long fibres, a lip print, a slight sheen, a crease, ragged torn ends and a
   faint shadow. Two crossed strips at the top-right and bottom-left corners; where they
   overlap the tape is doubled and deeper. */
.jp-washi {
  --washi-base: rgba(243, 126, 157, 0.46);   /* translucent pink */
  --washi-print: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8C4.5 5.2 6.6 5 8 6.4 9.4 5 11.5 5.2 13 8 11 11.2 5 11.2 3 8Z' fill='%23cf1d48' fill-opacity='.72'/%3E%3Cpath d='M3.6 8C6 8.9 10 8.9 12.4 8' stroke='%239c0f2e' stroke-opacity='.55' stroke-width='.5' fill='none'/%3E%3C/svg%3E");   /* a lip print */
  position: absolute; z-index: 1; width: 20cqw; height: 6cqw;
  filter: drop-shadow(0 0.14cqw 0.2cqw rgba(70, 20, 35, 0.2));
}
.jp-washi__paper {
  position: absolute; inset: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0) 24%, rgba(255, 255, 255, 0) 76%, rgba(120, 20, 50, 0.14)),   /* sheen + edge */
    linear-gradient(96deg, transparent 37%, rgba(255, 255, 255, 0.24) 39.5%, transparent 42%, transparent 69%, rgba(130, 20, 50, 0.12) 71%, transparent 73.5%),   /* a crease */
    var(--washi-print) repeat-x 0 50% / 6cqw 6cqw,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.5 .09' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .55 0 0 0 0 .07 0 0 0 0 .22 0 0 0 .7 -.22'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 22cqw 8cqw,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7 .14' numOctaves='3' seed='8' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .8 -.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E") 0 0 / 22cqw 8cqw,
    var(--washi-base);
  clip-path: polygon(0% 9%, 1.6% 2%, 3.2% 0%, 96.4% 0%, 98.6% 6%, 100% 15%, 98.2% 24%, 99.6% 33%, 97.6% 43%, 99.8% 52%, 98.3% 61%, 100% 71%, 98% 80%, 99.4% 91%, 96.8% 100%, 3.6% 100%, 1.2% 93%, 0.3% 84%, 2.4% 75%, 0.2% 66%, 2% 57%, 0% 47%, 2.6% 38%, 0.4% 28%, 2.2% 18%);
}
.jp-washi--tr { left: 100%; top: 0; transform: translate(-56%, -60%) rotate(31deg); }
.jp-washi--tr2 { left: 100%; top: 0; width: 13cqw; transform: translate(-4%, 6%) rotate(27deg); }
.jp-washi--bl { left: 0; top: 100%; transform: translate(-44%, -40%) rotate(29deg); }
.jp-washi--bl2 { left: 0; top: 100%; width: 13cqw; transform: translate(-98%, -112%) rotate(32deg); }
/* ---------- sketch pages: a drawing straight on the page ---------- */
/* The drawing's own paper was lifted to white (tools/lift_drawing.swift), so multiplying it
   onto the journal's paper leaves just the charcoal, sitting in the paper's grain. */
.jp-sketch { position: absolute; margin: 0; transform: rotate(var(--r, 0deg)); mix-blend-mode: multiply; }
.jp-sketch img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.jp-sketch--fade-bottom img {
  -webkit-mask-image: linear-gradient(#000 78%, transparent 99%);
  mask-image: linear-gradient(#000 78%, transparent 99%);
}
/* soft: every edge blurs very slightly into the page, so a drawing with hard rectangular
   edges (charcoal filled to a frame) sits in the paper rather than on it */
.jp-sketch--fade-soft img {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 3.5%, #000 96.5%, transparent 100%), linear-gradient(to right, transparent 0, #000 2.2%, #000 97.8%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, transparent 0, #000 3.5%, #000 96.5%, transparent 100%), linear-gradient(to right, transparent 0, #000 2.2%, #000 97.8%, transparent 100%);
  mask-composite: intersect;
}
.jp-sketch--fade-soft { filter: blur(0.15px); }
/* a drawing whose paper didn't lift cleanly to white: every edge softens into the page,
   the bottom most of all */
.jp-sketch--fade-edges img {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 4%, #000 74%, transparent 99%), linear-gradient(to right, transparent 0, #000 5%, #000 95%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, transparent 0, #000 4%, #000 74%, transparent 99%), linear-gradient(to right, transparent 0, #000 5%, #000 95%, transparent 100%);
  mask-composite: intersect;
}
/* a drawing cut off by its paper's top and left edges: those edges fade out, so drawn
   strands (journal-content.js: art) can carry it on without a straight line showing */
.jp-sketch--fade-top-left img {
  -webkit-mask-image: linear-gradient(to bottom, transparent 1%, #000 9%), linear-gradient(to right, transparent 1%, #000 8%);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to bottom, transparent 1%, #000 9%), linear-gradient(to right, transparent 1%, #000 8%);
  mask-composite: intersect;
}
/* pencil strands drawn over the page: graphite, not ballpoint */
.jp > .jp-art--plain { filter: none; }   /* clean pen lines, no ballpoint skips */
.jp > .jp-art--pencil { filter: blur(0.3px); opacity: 0.8; }   /* soft graphite, not ballpoint */

/* ---------- prints page: printed pictures pasted in as a collage ---------- */
/* Matte prints with a thin paper border, glued flat (a tight contact shadow, a soft one
   beyond), each at its own small tilt, overlapping a little. */
.jp-print {
  position: absolute; margin: 0; padding: 0.7cqw; background: #fbfaf5;
  transform: rotate(var(--r, 0deg));
  box-shadow: 0 0.1cqw 0.2cqw rgba(30, 20, 10, 0.28), 0 0.6cqw 1.4cqw -0.3cqw rgba(30, 20, 10, 0.22);
}
.jp-print img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.jp-print__tape { left: 0; top: 0; transform: translate(-42%, -48%) rotate(-38deg); }

/* ---------- spread: one print pasted across two facing pages ---------- */
/* Each page draws the whole sheet (journal.js) and cuts it at its own edge. Where it bridges
   the fold the paper dips a little into the spine: a soft crease, lighter than the page's own
   gutter shading since the sheet doesn't sink all the way in. */
.jp-sheet__fold {
  position: absolute; inset: 0; pointer-events: none; mix-blend-mode: multiply;
  background: linear-gradient(90deg, rgba(60, 48, 34, 0) 40%, rgba(60, 48, 34, 0.07) 46.5%, rgba(60, 48, 34, 0.2) 50%,
    rgba(60, 48, 34, 0.07) 53.5%, rgba(60, 48, 34, 0) 60%);
}
.jp-sheet .jp-print__tape { z-index: 2; }
/* a sheet that runs edge to edge across both pages, like a collage glued over the spread */
.jp-sheet--bleed { padding: 0; background: none; box-shadow: none; }
/* lift: a sheet glued flat, its top and bottom edges casting a faint contact shadow */
.jp-sheet--bleed.jp-sheet--lift { box-shadow: 0 0.12cqw 0.25cqw rgba(30, 20, 10, 0.25), 0 0.5cqw 1.2cqw -0.3cqw rgba(30, 20, 10, 0.18); }
.jp-sheet__tape--tl { left: 0; top: 0; transform: translate(-42%, -48%) rotate(-38deg); }
.jp-sheet__tape--br { left: auto; top: auto; right: 0; bottom: 0; transform: translate(42%, 48%) rotate(-38deg); }

/* ---------- snapshot page: an old print scanned flat onto the page ---------- */
/* Like a scanned scrapbook page: the print lies flat (no shadow), its scan look baked into
   the file (tools/scan_photo.swift: warm black-and-white, soft, lifted blacks, film grain);
   a whisper of uneven scanner light and a crisp edge sit over it. One strip of grey masking
   tape over the top-right corner; a short line centred underneath in the journal's hand. */
.jp-snap { position: absolute; margin: 0; left: 22%; width: 56%; top: 6.5%; }
.jp-snap img { display: block; width: 100%; height: auto; pointer-events: none; -webkit-user-drag: none; }
.jp-snap__scan {
  position: absolute; inset: 0; pointer-events: none;
  /* uneven scanner light (a touch brighter mid-print, falling off to the edges) and the
     print's crisp edge; plain layers, so opening the journal stays smooth */
  background: radial-gradient(ellipse 90% 80% at 45% 40%, rgba(255, 250, 240, 0.05), rgba(50, 40, 30, 0.08) 100%);
  box-shadow: inset 0 0 0 0.1cqw rgba(30, 25, 20, 0.25);
}
/* grey masking tape: matte, slightly see-through, fibrous, torn at both ends */
.jp-washi--grey { --washi-base: rgba(152, 146, 135, 0.74); --washi-print: none; filter: none; width: 18cqw; height: 4.8cqw; }
.jp-washi--grey .jp-washi__paper { filter: grayscale(1) sepia(0.12); }   /* the same fibres, in grey */
.jp-snap__tape { left: 100%; top: 0; transform: translate(-56%, -40%) rotate(33deg); }   /* over the corner, reaching a little onto the print */
.jp-snap-caption {
  position: absolute; left: 8%; right: 8%; top: 77%; margin: 0;
  text-align: center; font-size: calc(4.2cqw * var(--k, 1) * var(--hand, 1)); line-height: 1.4;
}

/* ---------- clipping page: a newsprint picture printed on the page ---------- */
/* As if printed straight onto the journal's paper: its white is multiplied away, so the
   paper's grain runs through the picture and its ragged, ink-bled edges fade into the page.
   Two burgundy star stickers (the site's oxblood) sit on its top edge, and the line is
   handwritten, centred underneath. */
.jp-clip { position: absolute; margin: 0; left: 18%; width: 64%; top: 9.5%; }
.jp-clip img { display: block; width: 100%; height: auto; mix-blend-mode: multiply; pointer-events: none; -webkit-user-drag: none; }
.jp-clip__star { position: absolute; width: 14%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(var(--r, 0deg)); }
.jp-clip__star svg { display: block; width: 100%; height: 100%; fill: #5d0113; filter: drop-shadow(0 0 0.06cqw rgba(40, 0, 10, 0.45)); }
.jp-clip__star--1 { left: 66%; top: 3%; --r: -9deg; }
.jp-clip__star--2 { left: 84%; top: 2.6%; --r: 7deg; width: 15%; }
.jp-clip-caption { top: 79%; }

/* the writing on the photo page: the same hand and ballpoint, drawn as SVG */
.jp-scrawl { position: absolute; inset: 0; pointer-events: none; }
.jp-scrawl svg { display: block; width: 100%; height: 100%; overflow: visible; }
.jp-scrawl text { font-family: "Zeyada", cursive; font-size: 11px; word-spacing: 0.08em; fill: var(--ink); stroke: var(--ink); stroke-width: 0.13px; stroke-linejoin: round; }
.jp-scrawl__arrow { fill: none; stroke: var(--ink); stroke-width: 0.42px; stroke-linecap: round; stroke-linejoin: round; }
/* every bit of handwriting, in black ballpoint */
.jp-date, .jp-title, .jp-text, .jp-list, .jp-fig figcaption, .jp-note, .jp-num, .jp-scrawl, .jp-snap-caption, .jp-art { filter: url(#jp-ballpoint); }
/* each word sits slightly off the line (set per word in journal.js) */
.jp-w { display: inline-block; transform: translateY(var(--wy, 0)) rotate(var(--wr, 0deg)); }
.jr__defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* a list, ticked and crossed in pencil */
.jp-list { margin: 1cqw 0 0; padding: 0; list-style: none; font-size: calc(4.5cqw * var(--k, 1) * var(--hand, 1)); }
.jp-list li { position: relative; margin: 0 0 2.8cqw; padding-left: 8cqw; }
.jp-list li::before {
  content: ""; position: absolute; left: 0; top: 0.25em; width: 4.6cqw; height: 4.6cqw;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 3.5 L17 2.8 L17.4 17 L2.6 17.3 Z' stroke='%231b1b21' stroke-width='1.4' fill='none' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.jp-list li.is-done::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 3.5 L17 2.8 L17.4 17 L2.6 17.3 Z' stroke='%231b1b21' stroke-width='1.4' fill='none' stroke-linejoin='round'/%3E%3Cpath d='M5 10 L9 14.5 L19 -1' stroke='%231b1b21' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}
.jp-list li.is-crossed { color: rgba(27, 27, 33, 0.6); width: fit-content; padding-right: 2cqw; }   /* the line spans just the words */
.jp-list li.is-crossed::after {
  content: ""; position: absolute; left: 7cqw; right: 0; top: 0.35em; height: 0.6em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 20' preserveAspectRatio='none'%3E%3Cpath d='M0 11 C18 7 32 14 50 9 S82 13 100 8' stroke='%231b1b21' stroke-width='1.7' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.jp--list .jp-fig { width: 66%; margin: auto 0 0 auto; transform: rotate(-4deg); }

/* ---------- Controls ---------- */

.jr__close, .jr__btn {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  padding: 0; border: 0; border-radius: 50%;
  background: rgba(252, 247, 238, 0.94);
  color: #3a2a22;
  font: 400 20px/1 Inter, -apple-system, sans-serif;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}
.jr__close { position: fixed; z-index: 3; top: max(14px, env(safe-area-inset-top)); right: max(14px, env(safe-area-inset-right)); font-size: 26px; }
.jr__close:hover, .jr__btn:hover:not(:disabled) { background: #fff; }
.jr__btn:active:not(:disabled) { transform: scale(0.94); }
.jr__btn:disabled { opacity: 0.32; cursor: default; box-shadow: none; }
.jr__close:focus-visible, .jr__btn:focus-visible { outline: 3px solid #f2c98a; outline-offset: 3px; }

.jr__controls {
  position: fixed; z-index: 3; left: 50%; bottom: max(18px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 14px;
  transform: translateX(-50%);
}
.jr__status {
  min-width: 132px; margin: 0;
  color: rgba(255, 248, 236, 0.9);
  font-size: 12.5px; font-weight: 500; text-align: center;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

@media (max-width: 599px) {
  .jr__stage { padding: 62px 16px 78px; }
  .jr__controls { gap: 10px; }
  .jr__status { min-width: 112px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .jr, .jr__frame { transition: none; }
}
