/* =====================================================================
   Paper and Ink · paper.css
   The shared paper objects. Every illustration is a physical object
   resting on the page, drawn in ink, pencil and rubber stamps.
   Figure-specific objects (a particular receipt, a ledger pad) live in
   the essay's own <style>, built from these primitives.
   ===================================================================== */

/* ---- every paper object casts the same soft shadow ---------------------- */
.paperobj { color: var(--slip-ink); box-shadow: 0 1px 1px var(--shadow), 0 10px 24px -12px var(--shadow-deep); }

/* ---- handwriting: Newsreader italic, never a script font ----------------- */
.hand { font-family: var(--serif); font-style: italic; font-size: 1.2rem; line-height: 1.35; }
.hand b { font-style: normal; font-weight: 500; }
.svgnote { font-family: var(--serif); font-style: italic; font-size: 15px; }
.svglab { font-family: var(--serif); font-style: italic; font-size: 17px; }

/* ---- margin notes with hand-drawn pen arrows ---------------------------- */
.mnote { display: flex; gap: .9rem; align-items: flex-start; }
.mnote p { margin: 0; max-width: 26ch; }
.pen { flex: none; width: 64px; height: 40px; overflow: visible; }
.pen path {
  fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 120; stroke-dashoffset: 0; animation: draw .6s ease both;
}
@keyframes draw { from { stroke-dashoffset: 120; } }

/* ---- rubber stamps: double ring, uneven ink, thump in ------------------ */
.stamp {
  display: inline-block; position: relative;
  font-family: var(--sans); font-weight: 600; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .16em; line-height: 1; padding: .5em .75em;
  border: 2px solid currentColor; outline: 1px solid currentColor; outline-offset: 2px;
  opacity: .88; mix-blend-mode: multiply;
  animation: thump .45s cubic-bezier(.3, 1.6, .5, 1) both;
}
.stamp::after {
  content: ""; position: absolute; inset: -5px;
  background-image: var(--noise-paper); background-size: 120px;
}
@keyframes thump { from { scale: 1.6; opacity: 0; } }

/* ---- graph paper held down with masking tape ---------------------------- */
.sheet-scroll { overflow-x: auto; padding: 22px 10px 18px; margin-inline: -10px; }
.sheet {
  position: relative; min-width: 560px; padding: 30px 16px 14px; transform: rotate(.5deg);
  background:
    var(--noise),
    linear-gradient(var(--grid-major) 1px, transparent 1px) 0 0 / 60px 60px,
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px) 0 0 / 60px 60px,
    linear-gradient(var(--grid-minor) 1px, transparent 1px) 0 0 / 12px 12px,
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px) 0 0 / 12px 12px,
    var(--sheet);
  box-shadow: 0 1px 1px var(--shadow), 0 10px 24px -12px var(--shadow-deep);
  touch-action: pan-y; cursor: ew-resize;
}
.sheet::before, .sheet::after {
  content: ""; position: absolute; top: -11px; width: 92px; height: 26px;
  background: var(--noise), var(--tape);
}
.sheet::before { left: 22px; transform: rotate(-6deg); }
.sheet::after { right: 22px; transform: rotate(4deg); }
.sheet svg { display: block; width: 100%; height: auto; overflow: visible; }
.sheet:has(input:focus-visible) { outline: 2px solid var(--life); outline-offset: 6px; }

/* ---- hand-inked chart lines, pencil hatching, notes, ticks --------------- */
.ink path {
  fill: none; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1600; stroke-dashoffset: 0; animation: ink 2.2s cubic-bezier(.4, .1, .3, 1) both;
}
@keyframes ink { from { stroke-dashoffset: 1600; } }
.hatch { animation: wipe 1.4s ease both; }
@keyframes wipe { from { clip-path: inset(0 100% 0 0); } }
.fade { animation: fade .7s ease both; }
@keyframes fade { from { opacity: 0; } }
.tick { font-family: var(--mono); font-size: 11px; fill: var(--slip-ink); }
.tagtext { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.narr { font-style: italic; color: var(--muted); font-size: 1.1rem; margin: 1rem 0 0; max-width: 64ch; min-height: 3.3em; }

/* ---- small underlined text buttons, e.g. "Print it again" ----------------- */
.btn {
  font-family: var(--sans); font-size: .82rem; color: var(--muted); background: none; border: 0; padding: 0;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.btn:hover, .btn:focus-visible { color: var(--ink); }
.btn:focus-visible { outline: 2px solid var(--life); outline-offset: 3px; }

/* ---- the thermal receipt that keeps printing ---------------------------
   Markup: figure > .slipfig > .slip-wrap > .slip (lines, two stamps, a
   .printing block) beside .margin-notes > p.slipnote with a pen-arrow svg.
   Gold lines are Concept A (the part that gets approved once); blue lines
   are Concept B (the part that keeps printing). */
.slipfig {
  display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr);
  gap: 28px 56px; align-items: start; justify-content: center;
}
.slip-wrap { position: relative; padding-block: 8px 24px; }
.slip {
  position: relative; background-color: var(--slip); color: var(--slip-ink);
  background-image: var(--noise); background-size: 180px;
  font-family: var(--mono); font-size: .82rem; line-height: 1.75;
  padding: 26px 24px 34px; transform: rotate(-1.4deg);
  box-shadow: 0 1px 1px var(--shadow), 0 10px 24px -12px var(--shadow-deep);
  /* torn zigzag bottom edge */
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 14px 100%;
}
.slip .hd { text-align: center; letter-spacing: .18em; font-weight: 500; }
.slip .sub { text-align: center; font-size: .72rem; letter-spacing: .1em; opacity: .7; margin-bottom: 10px; }
.slip .rule { border-top: 1px dashed currentColor; opacity: .45; margin: 8px 0; }
.slip .ln { display: flex; gap: 6px; }
.slip .ln span { flex: none; }
.slip .ln i { flex: 1; min-width: 12px; border-bottom: 1px dotted currentColor; opacity: .4; transform: translateY(-.45em); }
.slip .ink-once { color: var(--slip-once); }
.slip .ink-life { color: var(--slip-life); }
.slip .cont { text-align: center; letter-spacing: .14em; font-size: .72rem; margin: 18px 0 8px; }
.slip .cursor-blink {
  display: inline-block; width: .6em; height: 1em; background: currentColor;
  vertical-align: -.15em; animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
/* the continued block prints in jerky steps, like a real thermal printer */
.slip .printing { padding-bottom: 34px; animation: print 2.6s steps(13, end) 1.3s both; }
@keyframes print { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
/* first stamp lands with the gold lines, second after printing finishes */
.slip .stamp.s1 { color: var(--slip-once); display: table; margin: 16px auto 4px; transform: rotate(-7deg); animation-delay: .7s; }
.slip .stamp.s2 { color: var(--slip-life); position: absolute; bottom: 24px; right: 18px; transform: rotate(5deg); animation-delay: 4s; }

/* margin notes beside the receipt; each pen arrow lands with its stamp */
.margin-notes { position: relative; display: grid; gap: 120px; padding-top: 120px; }
.slipnote {
  position: relative; margin: 0; max-width: 26ch; color: var(--ink);
  font-family: var(--serif); font-style: italic; font-size: 1.22rem; line-height: 1.35;
}
.slipnote b { font-style: normal; font-weight: 500; }
.slipnote svg { position: absolute; left: -64px; top: 4px; width: 58px; height: 46px; overflow: visible; }
.slipnote path {
  fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 120; stroke-dashoffset: 0; animation: draw .9s ease-out both;
}
.slipnote:nth-child(1) path { animation-delay: 1s; }
.slipnote:nth-child(2) path { animation-delay: 4.2s; }

@media (max-width: 640px) {
  .slipfig { grid-template-columns: minmax(0, 1fr); }
  .margin-notes { gap: 14px; padding-top: 0; }
  .slipnote svg { display: none; }
}
