/* 黑咪之爪 · base: tokens, the spread (two A5 pages), type, cover, route bar, print.
   Every sheet is an A4-landscape spread = two A5 pages, like the printed zine.
   Inside a spread everything is sized in --u (1% of the spread's width), so a
   page holds the same amount on any screen and in the PDF. Phones show the two
   pages one under the other at reading size. */

:root {
  --ink-black: #262426;
  --ink-yellow: #ffde00;
  --ink-red: #f05850;
  --ink-blue: #0070b4;
  --stock: #f1ebde;
  --desk: #cfc6b5;
  --rule: color-mix(in srgb, var(--ink-black) 22%, transparent);

  /* Body in a book serif; captions in a cute pencil hand; Yumi speaks in a comic face. */
  --serif: 'EB Garamond', 'Noto Serif SC', 'Songti SC', 'STSong', serif;
  --cute: 'Xiaolai SC', 'Yuanti SC', 'Kaiti SC', cursive;
  --comic: 'ZCOOL KuaiLe', 'Yuanti SC', 'PingFang SC', sans-serif;

  --bar-h: 46px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

*, *::before, *::after { box-sizing: border-box; }
/* No smooth scroll-behavior and no snapping: a reload restores your place instantly and nothing re-centres the page. */
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 28px 0 calc(var(--bar-h) + 40px);
  color: var(--ink-black);
  background: var(--desk);
  font-family: var(--serif);
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.defs { position: absolute; }
img { max-width: 100%; }
.art { display: block; width: 100%; height: auto; mix-blend-mode: multiply; }
a { color: inherit; }
figure { margin: 0; position: relative; }
:focus-visible { outline: 2px dashed var(--ink-blue); outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- The spread ---------- */

.sheet {
  --u: 1cqw;
  --fs: calc(var(--u) * 1.2);
  --lh: 1.85;
  --fs-s: calc(var(--u) * 0.98);
  --fs-lead: calc(var(--u) * 1.5);
  --fs-body: calc(var(--u) * 1.5);
  --cell: calc(var(--u) * 4.4);
  --pad-x: calc(var(--u) * 3.8);
  --pad-y: calc(var(--u) * 3.6);
  --gap: calc(var(--u) * 1.7);

  container-type: inline-size;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(calc(100vw - 48px), calc((100svh - var(--bar-h) - 56px) * 297 / 210));
  aspect-ratio: 297 / 210;
  min-height: 0; /* keep the A4 shape: content never stretches a spread (it made the snap jump) */
  margin: 0 auto 7vh;
  background: var(--stock) url('../../shared/paper_tile.jpg') 0 0 / 627px auto repeat;
  box-shadow: 0 1px 0 rgb(0 0 0 / 0.08), 0 18px 40px -18px rgb(40 30 10 / 0.45);
  overflow: hidden;
}
/* Set the reading size on the sheet's children, not the sheet: on the container itself
   cqw falls back to the viewport, so text grew with the window instead of the page. */
.sheet > * { font: 400 var(--fs-body) / var(--lh) var(--serif); }
/* The fold: a soft valley down the middle. */
.sheet::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 calc(50% - var(--u) * 3);
  width: calc(var(--u) * 6);
  background: linear-gradient(90deg, transparent, rgb(60 40 10 / 0.1) 46%, rgb(60 40 10 / 0.16) 50%, rgb(60 40 10 / 0.1) 54%, transparent);
  pointer-events: none;
  z-index: 5;
}

.page {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: var(--pad-y) var(--pad-x) calc(var(--pad-y) + var(--u) * 1.4);
  overflow: hidden;
}
.page.l { padding-right: calc(var(--pad-x) * 1.15); }
.page.r { padding-left: calc(var(--pad-x) * 1.15); }

.folio {
  position: absolute;
  bottom: calc(var(--u) * 1.6);
  font: 600 calc(var(--u) * 0.85) / 1 var(--serif);
  letter-spacing: 0.08em;
  opacity: 0.65;
}
.page.l .folio { left: var(--pad-x); }
.page.r .folio { right: var(--pad-x); }

.reg { position: absolute; width: calc(var(--u) * 1.6); height: calc(var(--u) * 1.6); color: var(--ink-black); opacity: 0.5; }
.reg-tl { top: calc(var(--u) * 1.4); left: calc(var(--u) * 1.4); }
.reg-br { right: calc(var(--u) * 1.4); bottom: calc(var(--u) * 1.4); }

/* ---------- Figures inside a page ---------- */

/* .fig takes whatever height the text leaves and fits the picture into it. */
.fig { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; align-items: center; }
.fig > .art { flex: 1 1 0; min-height: 0; width: 100%; object-fit: contain; }
.fig.nat { flex: none; width: var(--w, 100%); align-self: var(--al, center); }
.fig.nat > .art { flex: none; height: auto; }
.fig.side { align-self: flex-end; }

/* ---------- Text ---------- */

.prose p { margin: 0 0 0.9em; text-align: left; hanging-punctuation: allow-end; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 900; background: linear-gradient(transparent 64%, color-mix(in srgb, var(--ink-yellow) 75%, transparent) 64%); }

.dropcap p:first-child::first-letter {
  float: left;
  font-size: 3.3em;
  line-height: 0.9;
  font-weight: 900;
  margin: 0.06em 0.1em 0 0;
  text-shadow: 0.04em -0.03em 0 var(--ink-yellow);
}

.lead { margin: 0; font: 600 var(--fs-lead) / 1.75 var(--serif); letter-spacing: 0.02em; text-wrap: pretty; text-align: left; }
.lead.small { font-size: calc(var(--fs-lead) * 0.88); }
.kicker { font-weight: 600; }

.coda { margin: 0; text-align: center; font: 900 calc(var(--u) * 3.4) / 1.3 var(--serif); filter: url(#ink); }
.coda .aside { font-size: 0.6em; }

.pull { margin: 0; }
.pull.latin { font: italic 500 calc(var(--u) * 2.2) / 1.2 'EB Garamond', serif; }
.pull.latin p { margin: 0; }
.pull .answer { margin-top: 0.25em; color: var(--ink-red); mix-blend-mode: multiply; }
.pull cite { display: block; margin-top: 0.7em; font: normal 400 calc(var(--u) * 0.85) / 1.4 'EB Garamond', serif; letter-spacing: 0.04em; opacity: 0.75; }
.latin { font-family: 'EB Garamond', serif; font-style: italic; }

.gloss { font-size: 0.8em; opacity: 0.8; }
/* My asides inside the essay: same face, smaller, blue pen. */
.aside { font-size: 0.86em; color: var(--ink-blue); mix-blend-mode: multiply; }
.aside.emoji { font-size: 1em; }
/* Yumi's lines quoted in the essay. */
q.say { quotes: none; font-family: var(--comic); color: var(--ink-black); }

/* Captions: a cute pencil hand, small, blue. */
.note {
  margin: 0.45em 0 0;
  font: 400 var(--fs-s) / 1.55 var(--cute);
  color: var(--ink-blue);
  mix-blend-mode: multiply;
  text-align: left;
  align-self: stretch;
}
.note.under { margin: 0; }

.marginalia {
  margin: 0;
  writing-mode: vertical-rl;
  font: 400 var(--fs-s) / 1.7 var(--cute);
  letter-spacing: 0.06em;
  color: var(--ink-blue);
  mix-blend-mode: multiply;
}

/* ---------- Covers: the first spread is [blank | front], the last is [back | blank] ---------- */

.sheet.half { background: none; box-shadow: none; }
.sheet.half::after { display: none; }
.sheet.half .page:not(.blank) { background: var(--stock) url('../../shared/paper_tile.jpg') 0 0 / 627px auto repeat; box-shadow: 0 1px 0 rgb(0 0 0 / 0.08), 0 18px 40px -18px rgb(40 30 10 / 0.45); }
.sheet.half .page.blank { visibility: hidden; }

.cover .page, .back .page { padding: calc(var(--u) * 4); }
.back-cover { justify-content: flex-start; }
.blurb { margin: calc(var(--u) * 6) 0 0; max-width: 12em; font: 900 calc(var(--u) * 2.3) / 1.6 var(--serif); filter: url(#ink); }
.back-paw { width: calc(var(--u) * 4.2); margin-top: calc(var(--u) * 2.4); fill: var(--ink-black); transform: rotate(-12deg); opacity: 0.9; }
.colophon { margin: auto 0 0; display: grid; gap: calc(var(--u) * 0.55); font-size: calc(var(--u) * 1); }
.colophon div { display: flex; gap: calc(var(--u) * 1); }
.colophon dt { min-width: 6.2em; color: var(--ink-red); font-weight: 600; }
.colophon dd { margin: 0; }
.imprint { margin: calc(var(--u) * 2) 0 calc(var(--u) * 1); font: 600 calc(var(--u) * 0.85) / 1.4 var(--serif); letter-spacing: 0.1em; opacity: 0.7; }

.front-cover { display: block; }
.issue {
  position: absolute;
  left: calc(var(--u) * 3.4);
  top: calc(var(--u) * 2.6);
  margin: 0;
  font: 900 calc(var(--u) * 9) / 0.9 'EB Garamond', serif;
  color: transparent;
  -webkit-text-stroke: calc(var(--u) * 0.14) var(--ink-red);
  mix-blend-mode: multiply;
}
.issue span { display: block; font: italic 500 calc(var(--u) * 1.4) / 1 'EB Garamond', serif; color: var(--ink-red); -webkit-text-stroke: 0; letter-spacing: 0.1em; }
.title {
  position: absolute;
  right: calc(var(--u) * 3.2);
  top: calc(var(--u) * 3);
  margin: 0;
  writing-mode: vertical-rl;
  font: 900 calc(var(--u) * 7.4) / 1 var(--serif);
  letter-spacing: 0.02em;
  filter: url(#ink);
  z-index: 2;
}
.title .ch { position: relative; display: inline-block; }
.title .plate { display: block; }
.title .plate.y { position: absolute; inset: 0; color: var(--ink-yellow); transform: translate(0.028em, -0.02em); }
.title .plate.k { position: relative; color: var(--ink-black); mix-blend-mode: multiply; }
.cover-cat { position: absolute; left: calc(var(--u) * 3); top: calc(var(--u) * 12.5); width: calc(var(--u) * 31); }
.cover-cat .sun { position: absolute; left: 12%; top: 6%; width: 78%; aspect-ratio: 1; border-radius: 50%; background: var(--ink-yellow); mix-blend-mode: multiply; opacity: 0.85; }
.cover-cat .art { position: relative; }
.date { position: absolute; right: calc(var(--u) * 3.4); bottom: calc(var(--u) * 3); margin: 0; text-align: right; font: 600 calc(var(--u) * 0.95) / 1.5 'EB Garamond', serif; letter-spacing: 0.12em; }

/* A black cat walks the staff's top line, singing. */
.walk-cat { display: block; background: url('../img/walk_strip.png') 0 0 / 800% 100% no-repeat; aspect-ratio: 142 / 120; }
.staff-run { position: absolute; left: calc(var(--u) * 3); right: calc(var(--u) * 3); bottom: calc(var(--u) * 6.4); height: calc(var(--u) * 2.6); z-index: 3; pointer-events: none; }
.stave { position: absolute; inset: 0; width: 100%; height: 100%; }
.stave path { stroke: var(--ink-black); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: 0.55; }
.sheet-note { position: absolute; font: 400 calc(var(--u) * 1.7) / 1 serif; color: var(--ink-black); transform: translateY(-60%); opacity: 0.8; }
.n1 { left: 18%; top: 58%; } .n2 { left: 40%; top: 30%; } .n3 { left: 66%; top: 46%; } .n4 { left: 86%; top: 20%; color: var(--ink-red); }
.singer { position: absolute; left: 0; bottom: 100%; width: calc(var(--u) * 5.2); }
.singer .walk-cat { width: 100%; }
.singer b { position: absolute; right: -8%; top: -6%; font: 400 calc(var(--u) * 1.5) / 1 serif; color: var(--ink-blue); opacity: 0; }

/* ---------- Route bar ---------- */

.route {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 30;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--stock) 92%, transparent);
  backdrop-filter: blur(6px);
  border-top: 1px solid var(--rule);
  font: 600 13px/1 var(--serif);
}
.route-title { text-decoration: none; font-weight: 900; letter-spacing: 0.06em; white-space: nowrap; }
.route-track { position: relative; flex: 1; height: 100%; margin-right: 14px; }
.route-map { position: absolute; left: 0; right: 0; top: 4px; width: 100%; height: 22px; overflow: visible; }
.route-map path { fill: none; vector-effect: non-scaling-stroke; }
.route-map .sea { stroke: var(--ink-blue); stroke-width: 1.4; stroke-dasharray: 4 5; opacity: 0.45; }
/* The red trail is the same line, uncovered left to right exactly as far as the cat. */
.route-map .trail { stroke: var(--ink-red); stroke-width: 2.6; stroke-linecap: round; clip-path: inset(-10px calc((1 - var(--p, 0)) * 100%) -10px -10px); }
.legs { position: absolute; inset: auto 0 4px 0; height: 16px; }
.legs a { position: absolute; left: var(--at, 0); bottom: 0; padding-left: 14px; text-decoration: none; font: 400 12px/16px var(--cute); color: var(--ink-blue); white-space: nowrap; }
.legs a::before { content: ''; position: absolute; left: 0; bottom: 4px; width: 9px; height: 7px; border-radius: 50% 60% 45% 55%; background: #e9d79a; border: 1.5px solid var(--ink-black); }
.legs a b { font: 600 11px/1 'EB Garamond', serif; color: var(--ink-red); }
.legs a.here { color: var(--ink-black); font-weight: 600; }
.walker { position: absolute; left: calc(var(--p, 0) * 100% - 13px); top: calc(var(--wy, 14px) - 20px); width: 26px; }
.walker.back { transform: scaleX(-1); }

/* ---------- Phones: pages one under another, at reading size ---------- */

@media (max-width: 767px) {
  :root { --bar-h: 40px; }
  body { padding-top: 12px; }
  .sheet {
    --u: 13px;
    --fs: 16px;
    --fs-body: 16px;
    --fs-s: 13.5px;
    --fs-lead: 19px;
    --cell: 52px;
    --pad-x: 20px;
    --pad-y: 26px;
    --gap: 18px;
    display: block;
    width: auto;
    aspect-ratio: auto;
    margin: 0 10px 14px;
    container-type: normal;
    overflow: visible;
  }
  .sheet::after { display: none; }
  .page, .page.l, .page.r { min-height: calc((100vw - 20px) * 1.414); padding: var(--pad-y) var(--pad-x) 46px; overflow: visible; }
  .page + .page { border-top: 1px dashed var(--rule); }
  .folio { bottom: 16px; font-size: 11px; }
  .fig { flex: none; }
  .fig > .art { flex: none; height: auto; max-height: 62vh; }
  .route { gap: 10px; padding: 0 10px; }
  .page.blank { display: none; }
  .sheet.half .page:not(.blank) { box-shadow: 0 10px 24px -14px rgb(40 30 10 / 0.45); }
  .route-title { display: none; }
  .legs a { font-size: 11px; }
  .legs a b { display: none; }
}

/* ---------- Print / PDF: one spread per A4-landscape sheet ---------- */

@page { size: 297mm 210mm; margin: 0; }
@media print {
  html { scroll-snap-type: none; }
  body { padding: 0; background: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet { width: 297mm; margin: 0; box-shadow: none; break-after: page; break-inside: avoid; }
  .route { display: none !important; }
  .sheet.half .page:not(.blank) { box-shadow: none; }
}
