/* ==========================================================================
   Buttercup Café — components
   The stitch primitive and everything built on top of it. Loaded on every
   page, because the case-study pages reuse the same vocabulary.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. The stitch
   The signature visual: a dashed thread running inside the edge of a sheet
   of paper. One element, one pseudo, themeable with two custom properties.

   Three details that all bite if you get them wrong:
   · `isolation: isolate` — the pseudo uses z-index:-1 so it paints above the
     element's own background but below its content. Without a stacking
     context of its own, -1 would drop it behind the background and vanish.
   · the radius is `parent − inset`, NOT `inherit`. An inset ring given the
     parent's radius has a visibly too-round corner arc.
   · padding is derived from the same token, or text collides with the thread.
   -------------------------------------------------------------------------- */

.stitch {
	position: relative;
	isolation: isolate;
	border-radius: var(--r-card);
}

.stitch::before {
	content: "";
	position: absolute;
	inset: var(--stitch-inset);
	z-index: -1;
	border: var(--stitch-w) dashed var(--stitch-color);
	border-radius: max(0px, calc(var(--r-card) - var(--stitch-inset)));
	pointer-events: none;
}

/* --------------------------------------------------------------------------
   2. Paper
   A plain sheet. The cards and the case-study body are both this, with
   different fills and thread colours.
   -------------------------------------------------------------------------- */

.paper {
	background: var(--card-bg, var(--paper));
	box-shadow: var(--shadow-paper);
	padding: calc(var(--stitch-inset) + var(--stitch-w) + var(--sp-4));
}

/* --------------------------------------------------------------------------
   2b. Washi tape
   One strip, torn at both ends, holding a corner of a sheet down. The
   diagonal hatching is the tape's own weave — without it a flat rectangle
   reads as a sticker. Here rather than with the shelf on the home page
   because Operation Serval's scrapbook screen tapes its photograph down too.
   -------------------------------------------------------------------------- */

.tape {
	position: absolute;
	z-index: 2;
	width: 5.25rem;
	height: 1.4rem;
	/* Colour and weave kept on their own properties. A colour is only legal in
	   the *last* layer of the `background` shorthand, and putting it first
	   throws the whole declaration away — which is a strip of tape you cannot
	   see rather than an error anybody reports. Butter unless a page re-inks
	   it through --tape. */
	background-color: var(--tape, var(--butter));
	background-image: repeating-linear-gradient(
		118deg,
		rgb(255 255 255 / 0.6) 0 5px,
		rgb(255 255 255 / 0) 5px 11px
	);
	box-shadow: 0 1px 3px rgb(88 70 52 / 0.22);
	opacity: 0.92;
	clip-path: polygon(
		0 6%,
		7% 0,
		96% 5%,
		100% 46%,
		95% 100%,
		5% 96%,
		1% 52%
	);
	pointer-events: none;
}

.tape--tl {
	inset: -0.7rem auto auto -1.15rem;
	rotate: -19deg;
}

.tape--tr {
	inset: -0.75rem -1.2rem auto auto;
	rotate: 15deg;
}

/* --------------------------------------------------------------------------
   3. Project card
   Physical paper on a desk. The transform is split across three independent
   CSS properties so that the things that want to move a card can never
   overwrite one another:

     translate  ← position (authored rest offset, or the stage's --x/--y)
     rotate     ← angle (authored rest angle, or the stage's --rot)
     scale      ← hover / grab lift, and nothing else

   This block is the card *out of the stage*: static, in normal flow, exactly
   what a visitor with no JavaScript sees. The scattered, draggable version
   lives under `.board.is-stage` in home.css.

   Deliberately absent: any 3D. There is no perspective and no pointer tilt —
   the card is flat paper seen from above.
   -------------------------------------------------------------------------- */

@property --lift {
	syntax: "<number>";
	inherits: false;
	initial-value: 1;
}

/* Fluid, not fixed. A flat 20rem is wider than the content box of a 320px
   phone, so the cards would sit clipped against the edge of the screen. */
:root {
	--card-w: min(20rem, 100%);
	--card-h: 15rem;
}

@media (min-width: 64rem) {
	:root {
		--card-w: min(26.5rem, 100%);
		--card-h: 19rem;
	}
}

.card {
	position: relative;
	z-index: calc(var(--z, 1) + var(--z-boost, 0));
	display: flex;
	flex-direction: column;
	gap: var(--sp-3);
	width: var(--card-w);
	min-height: var(--card-h);

	translate: var(--rest-x, 0px) calc(var(--rest-y, 0px) + var(--hover-y, 0px));
	rotate: calc(var(--rest-rot, 0deg) * var(--rot-mult, 1));
	scale: var(--lift, 1);

	transition: translate var(--dur) var(--ease-spring),
		rotate var(--dur) var(--ease-spring), scale var(--dur) var(--ease-spring);

	/* Kills the 300ms tap delay without claiming the scroll gesture. */
	touch-action: manipulation;
	-webkit-user-drag: none;
	user-select: none;
	cursor: pointer;
}

html.is-dragging,
html.is-dragging * {
	user-select: none;
	cursor: grabbing !important;
}

/* Children are inert, so a drag that starts on the title behaves exactly like
   one that starts on the paper: the event target is always the card itself,
   and no child can swallow the gesture or claim a text selection. */
.card > * {
	pointer-events: none;
}

/* The lift shadow lives on a pseudo whose *opacity* animates. Animating
   box-shadow directly re-rasterizes the whole card, text included, every
   frame — the single most expensive thing this design could have done. */
.card::after {
	content: "";
	position: absolute;
	inset: 0;
	border-radius: inherit;
	box-shadow: var(--shadow-lift);
	opacity: 0;
	pointer-events: none;
	transition: opacity var(--dur) var(--ease-out);
}

.card:hover,
.card:focus-visible {
	--hover-y: -10px;
	--rot-mult: 0; /* straightens the sheet, whatever its authored angle */
	--lift: 1.03;
	--z-boost: 1000;
}

.card:hover::after,
.card:focus-visible::after,
.card.is-drag::after {
	opacity: 1;
}

.card__plaque {
	align-self: flex-end;
	margin-block-end: calc(var(--sp-2) * -1);
}

.card__title {
	font-size: var(--fs-500);
	letter-spacing: -0.02em;
	text-wrap: balance;
}

@media (min-width: 64rem) {
	.card__title {
		font-size: var(--fs-600);
	}
}

.card__desc {
	font-size: var(--fs-300);
	line-height: var(--lh-snug);
	color: var(--ink-soft);
}

/* Pinned to the bottom of the sheet. Always visible — it is the only thing
   telling you the card is a link, so hiding it until hover is a real loss. */
.card__more {
	margin-block-start: auto;
	font-family: var(--ff-display);
	font-size: var(--fs-200);
	font-weight: 600;
	letter-spacing: 0.02em;
	color: var(--ink-soft);
	transition: translate var(--dur) var(--ease-out);
}

.card:hover .card__more,
.card:focus-visible .card__more {
	translate: 3px 0;
}

/* --------------------------------------------------------------------------
   4. Chips
   -------------------------------------------------------------------------- */

.chips {
	display: flex;
	flex-wrap: wrap;
	gap: var(--sp-1) var(--sp-2);
}

/* Square corners, deliberately. These are cut slips of paper, not pills — a
   radius on something this small reads as a UI tag rather than as part of the
   café's paper vocabulary. */
.chip {
	padding: 0.15rem var(--sp-2);
	background: var(--chip-bg, var(--tan));
	font-family: var(--ff-display);
	font-size: var(--fs-100);
	font-weight: 500;
	letter-spacing: 0.01em;
	color: color-mix(in oklab, var(--ink) 88%, #000);
}

/* The award / internship plaque: a small engraved label. */
.plaque {
	display: inline-block;
	padding: 0.2rem var(--sp-2);
	border: 1.5px solid #c9c6bc;
	border-radius: 3px;
	background: #f2f0e8;
	font-family: var(--ff-display);
	font-size: 0.625rem;
	font-weight: 700;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	color: #55524a;
}

/* --------------------------------------------------------------------------
   4b. Foil
   The trading-card treatment: a gold edge on the ISMAR card, and the award
   itself as a stamped seal. One palette, so the two are recognisably the same
   material at two sizes.

   Drawn, not simulated. This site is pixel art and cut paper, and a
   photographic gold — smooth ramps, white speculars, a bloom around the edge
   — belongs to a different picture; next to the café it reads as chrome
   dropped onto a storybook. So the metal is cel-shaded: flat tones with hard
   stops between them. No gradients that blur, no glow, and nothing that
   moves.

   No outlines either. An ink keyline is how a comic draws gold, but nothing
   else on this site is outlined — the stitch, the chips and the plaid are all
   held together by tone against tone — and a dark rule around the frame is
   the one thing that makes it look borrowed. The edges here are found the
   same way: the deepest tone *is* the edge.

   `.foil` is an empty <span> rather than a pseudo-element for a dull reason:
   .card already spends ::before on the stitch and ::after on the lift shadow.

   The band is cut by the mask pair: paint the whole box, punch out the
   content box, keep what is between them.
   -------------------------------------------------------------------------- */

:root {
	/* Five tones per metal, every surface mixed from them — which is what
	   stops a card edge and its seal from drifting into two different
	   materials. The golds are the café's own butters pushed one step warmer,
	   not metal borrowed from somewhere else: --gold is --butter, --gold-mid
	   is --butter-deep, and the two ends extend that run far enough to read as
	   a material. The silvers are the same idea over the paper greys, kept
	   slightly warm so they sit next to cream rather than on top of it. */
	--gold-lit: #fff6d2;
	--gold: #fce8a9;
	--gold-mid: #fcde6e;
	--gold-deep: #e0b246;
	--gold-shade: #bf8c2a;

	--silver-lit: #fffefa;
	--silver: #f0f1ea;
	--silver-mid: #dcded4;
	--silver-deep: #b4b8aa;
	--silver-shade: #8b9084;

	/* Which metal the foil and the seal are currently cut from. Everything
	   below reads these and never the palette directly, so one class swaps the
	   material on a card and on the stamp inside it at the same time. */
	--metal-lit: var(--gold-lit);
	--metal: var(--gold);
	--metal-mid: var(--gold-mid);
	--metal-deep: var(--gold-deep);
	--metal-shade: var(--gold-shade);
}

.foil {
	position: absolute;
	inset: 0;
	z-index: 5;
	border-radius: inherit;
	padding: var(--foil-w, 4px);

	/* Hard stops, no blending: each tone holds its band and then changes at a
	   line. Four bands running once from lit at the top-left to deep at the
	   bottom-right — the frame is lit from one side and shaded away from it,
	   which is the whole of how a drawing says "metal".

	   Once, and in order, matters. An earlier version repeated the light tone
	   twice along the run to suggest a second glint, and on a 5px band tracing
	   a 400px rectangle those extra stops land at unrelated points on each
	   edge: the frame stops reading as shaded and starts reading as blotchy.

	   The lit tone is only a corner glint, and the run proper starts a step
	   down. The page is cream and the palest gold is very nearly cream, so a
	   band that opens on it loses its whole top-left edge to the background. */
	background: linear-gradient(
		135deg,
		var(--metal-lit) 0 8%,
		var(--metal-mid) 8% 40%,
		var(--metal-deep) 40% 72%,
		var(--metal-shade) 72% 100%
	);

	-webkit-mask: linear-gradient(#000 0 0) content-box,
		linear-gradient(#000 0 0);
	mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
	-webkit-mask-composite: xor;
	mask-composite: exclude;

	pointer-events: none;
}

/* ---- the card wearing it ------------------------------------------------ */

/* Nothing added to the sheet's own shadow: no outline, no outer glow — the
   band is wide enough to be the frame by itself.

   The thread comes off. The stitch is what an ordinary sheet has instead of a
   frame, and running both means two borders 6px apart arguing about where the
   edge of the card is. The class stays on the element, though: it carries the
   card's radius and the padding that keeps text off the edge, so it is the
   thread that is switched off, not the stitch.

   `em`, so the band comes down with a card the stage has shrunk. */
.card--foil {
	--foil-w: 0.44em;
	--stitch-color: transparent;
}

/* The other metal. Sits on the card, where both the frame and the seal inside
   it inherit it — or on a seal directly, for one standing on its own. */
.foil-silver {
	--metal-lit: var(--silver-lit);
	--metal: var(--silver);
	--metal-mid: var(--silver-mid);
	--metal-deep: var(--silver-deep);
	--metal-shade: var(--silver-shade);
}

/* ---- the award seal ------------------------------------------------------

   The award is a stamp, not a label: a disc of the same gold pressed flat
   onto the paper. No plate edge and no drop shadow — a stamp is *in* the
   sheet, and anything that lifts it off makes it a sticker again.

   Everything except the type is one background stack on one element: the rim
   in the deepest tone, a pale ring inside it, and the metal underneath in the
   same flat bands as the card edge. Rings are drawn as hard-stopped radial
   gradients rather than as borders or extra elements — a ring at radius r is
   just a gradient that is transparent either side of r.

   The scalloped rim is three mask layers: `inner ADD (teeth INTERSECT disc)`.
   The inner disc, inset by the tooth depth, is the body of the seal; the
   repeating conic is the teeth. The third layer is the one that is easy to
   leave out and impossible to miss once you have — a conic gradient covers
   the whole box, so without a full-radius disc to intersect with, the teeth
   carry on past the rim and the seal renders as a sunburst. Mask layers
   composite bottom-up, so the operator list reads in the opposite order to
   the layers it applies to.
   -------------------------------------------------------------------------- */

.seal {
	/* The stamp is one drawing measured in `em`, so its font-size is the only
	   dial: 5em across, teeth and rings and padding all fractions of the same
	   em. Set the font-size and the whole thing scales.

	   It has to be that way round. The obvious version — a `--seal-size`
	   length with `font-size: calc(var(--seal-size) * 0.088)` — quietly eats
	   itself: `width: var(--seal-size)` in em resolves against the element's
	   *own* font-size, which that rule has just made a fraction of the size,
	   so the seal comes out at a third of what it asks for.

	   The payoff is that a seal on a board card can simply inherit. The stage
	   scales a shrunk card by dropping its font-size, and the stamp comes down
	   with the sheet on its own. */
	--seal-size: 5em;
	--seal-teeth: 0.225em;
	--seal-ring: 0.425em;

	font-size: 1.3rem;

	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.28em;

	flex: none;
	width: var(--seal-size);
	height: var(--seal-size);
	padding: 0.5em;
	border-radius: 50%;

	/* No `overflow: hidden` here, deliberately. The mask is already the shape,
	   and a round overflow clips to the *padding* box — a circle a good deal
	   narrower than the seal, which cuts the ends off the longest line. */

	/* Stamped by hand, so it is a few degrees off true. */
	rotate: var(--seal-tilt, -5deg);

	/* Every circle here is `closest-side`, and that is load-bearing. A
	   percentage colour-stop is a position along the gradient *ray*, and the
	   default ray runs to the farthest corner — so on a square box `50%` lands
	   at 0.71 of the radius, and rings authored as "8px in from the edge" come
	   out well short of it. `closest-side` puts 100% exactly on the rim, which
	   is what the arithmetic below assumes. `background-origin` moves with it:
	   backgrounds are laid out against the padding box by default, which is a
	   smaller circle than the one the mask cuts. */
	background-origin: border-box;
	background: /* The rim, teeth included, in the deepest tone. This is the
			 seal's outline, done the way the rest of the site does an edge —
			 by dropping a step in tone rather than by drawing a dark line —
			 and it is what keeps the stamp legible on cream, on sage and on
			 the moss card alike. */ radial-gradient(
			circle closest-side at 50% 50%,
			transparent calc(100% - var(--seal-teeth) - 0.06em),
			var(--metal-shade) calc(100% - var(--seal-teeth) - 0.06em) 100%
		),
		radial-gradient(
			circle closest-side at 50% 50%,
			transparent calc(100% - var(--seal-ring)),
			var(--metal-lit) calc(100% - var(--seal-ring))
				calc(100% - var(--seal-ring) + 0.1em),
			transparent calc(100% - var(--seal-ring) + 0.1em)
		),
		linear-gradient(
			135deg,
			var(--metal) 0 22%,
			var(--metal-lit) 22% 34%,
			var(--metal) 34% 52%,
			var(--metal-mid) 52% 78%,
			var(--metal-deep) 78% 100%
		);

	-webkit-mask: radial-gradient(
			circle closest-side at 50% 50%,
			#000 calc(100% - var(--seal-teeth)),
			transparent calc(100% - var(--seal-teeth))
		),
		repeating-conic-gradient(#000 0 6deg, transparent 6deg 12deg),
		radial-gradient(circle closest-side at 50% 50%, #000 100%, transparent 100%);
	mask: radial-gradient(
			circle closest-side at 50% 50%,
			#000 calc(100% - var(--seal-teeth)),
			transparent calc(100% - var(--seal-teeth))
		),
		repeating-conic-gradient(#000 0 6deg, transparent 6deg 12deg),
		radial-gradient(circle closest-side at 50% 50%, #000 100%, transparent 100%);
	-webkit-mask-composite: source-over, source-in, source-over;
	mask-composite: add, intersect, add;

	font-family: var(--ff-display);
	text-transform: uppercase;
	text-align: center;
	color: var(--ink);
}

.seal__lead {
	font-size: 0.5em;
	font-weight: 700;
	letter-spacing: 0.06em;
	line-height: 1.1;
	white-space: nowrap;
}

.seal__rule {
	width: 48%;
	height: 0.06em;
	background: var(--metal-shade);
}

.seal__meta {
	font-size: 0.425em;
	font-weight: 600;
	letter-spacing: 0.07em;
	line-height: 1.35;
	color: var(--ink-soft);
	white-space: nowrap;
}

/* On the board the seal is stuck to the corner of the sheet, where an award
   sticker goes. Absolutely positioned, and that is the whole point: the eight
   cards are one deck and have to stay one size, so the stamp is not allowed
   to contribute a single pixel of height to the sheet it sits on.

   `font-size: 1em` is the whole trick: the stamp takes the sheet's own type
   scale, so a card the stage has shrunk wears a stamp shrunk to match. */
.card__seal {
	font-size: 1em;
	--seal-tilt: -7deg;
	position: absolute;
	right: var(--sp-3);
	bottom: var(--sp-3);
}

/* The gutter the stamp stands in. Reserved on the two elements that reach the
   bottom of the sheet, so no line of copy ever runs under the medal. In em,
   like the stamp itself, so the reserve holds when the sheet shrinks.

   Cheaper than it looks: the stamp replaced a plaque that used to take a
   whole row of the card's flow, so the reserve is spending height the sheet
   had already given back. */
.card--foil .card__desc,
.card--foil .card__more {
	padding-inline-end: 5.75em;
}

/* A project's own emblem, stuck in the same corner on the same terms as the
   seal: absolutely placed, sized in em so it shrinks with the sheet, and
   given a gutter so no copy runs under it. Cut on three corners because the
   Serval badge is cut that way in its own game. */
.card__badge {
	position: absolute;
	right: 1.15em;
	bottom: 1.15em;
	width: 3.25em;
	height: 3.25em;
	clip-path: polygon(
		0 0,
		calc(100% - 0.45em) 0,
		100% 0.45em,
		100% calc(100% - 0.45em),
		calc(100% - 0.45em) 100%,
		0.45em 100%,
		0 calc(100% - 0.45em)
	);
}

.card--badge .card__desc,
.card--badge .card__more {
	padding-inline-end: 4em;
}

/* --------------------------------------------------------------------------
   5. Back link
   The way out of a case study. Both case-study shapes use it, so the shape of
   the link lives here; each page decides only how wide its row is and what
   colour the link is tinted against (--page-fill).
   -------------------------------------------------------------------------- */

.back {
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2);
	font-family: var(--ff-display);
	font-size: var(--fs-300);
	font-weight: 600;
	color: color-mix(in oklab, var(--ink) 76%, var(--page-fill, var(--bg-page)));
	transition: color var(--dur) var(--ease-out), gap var(--dur) var(--ease-out);
}

.back:hover {
	color: var(--ink);
	gap: var(--sp-3);
}

/* Sized in ems so the arrow tracks the label. Stated rather than left to the
   SVG's own intrinsic size: with a viewBox and no width/height an inline SVG
   defaults to 300 × 150, which is the whole hero. */
.back svg {
	width: 1.1em;
	height: 1.1em;
	flex: none;
}

/* --------------------------------------------------------------------------
   6. Buttons and link chips
   -------------------------------------------------------------------------- */

.btn {
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2);
	padding: var(--sp-2) var(--sp-5);
	background: var(--paper);
	border-radius: var(--r-pill);
	font-family: var(--ff-display);
	font-size: var(--fs-300);
	font-weight: 600;
	color: var(--ink);
	box-shadow: var(--sh-contact);
	transition: translate var(--dur) var(--ease-spring),
		box-shadow var(--dur) var(--ease-out);
}

.btn:hover:not(:disabled) {
	translate: 0 -2px;
	box-shadow: var(--sh-contact), var(--sh-ambient);
}

.btn:active:not(:disabled) {
	translate: 0 1px;
	box-shadow: var(--shadow-sunk);
}

.btn:disabled {
	opacity: 0.45;
	cursor: default;
}

/* Footer contact chips — the stitch primitive at small scale. */
.chip-link {
	--stitch-inset: 0.3rem;
	--stitch-w: 2px;
	--stitch-color: color-mix(in srgb, var(--tan-deep) 55%, transparent);
	--r-card: var(--r-md);
	display: inline-flex;
	align-items: center;
	gap: var(--sp-2);
	padding: var(--sp-3) var(--sp-5);
	background: var(--paper);
	font-family: var(--ff-display);
	font-size: var(--fs-300);
	font-weight: 600;
	box-shadow: var(--sh-contact);
	transition: translate var(--dur) var(--ease-spring),
		box-shadow var(--dur) var(--ease-out), background var(--dur) var(--ease-out);
}

.chip-link:hover {
	translate: 0 -3px;
	background: var(--paper-warm);
	box-shadow: var(--sh-contact), var(--sh-ambient);
}

.chip-link svg {
	width: 1.05em;
	height: 1.05em;
	flex: none;
}

/* --------------------------------------------------------------------------
   7. Speech bubble
   The pixel-art bubble PNGs are replaced with a real CSS bubble: it scales
   with its text instead of stretching a bitmap, and the tail is a rotated
   square that inherits the border.
   -------------------------------------------------------------------------- */

.bubble {
	/* A line change is three beats, and all three are different numbers on
	   purpose. She stops talking quickly, thinks, and then comes back slowly —
	   which is the shape of someone answering, and the reason the fade out and
	   the fade in are not one duration used twice.

	     --say-out   she goes quiet. Mirrored in js/modules/jar.js as SAY,
	                 which is how long that module waits before putting the new
	                 words in: the text may only change while there is nothing
	                 on screen, so those two have to move together.
	     --say-wait  the beat before she answers. On the way back only, and
	                 nothing in JavaScript knows about it — it is only ever the
	                 delay on one transition.
	     --say-in    she reappears. The longest of the three, because this is
	                 the one the reader is waiting for; at the same speed as
	                 the fade out the new line arrives before the eye has come
	                 back to it. */
	--say-out: 180ms;
	--say-wait: 200ms;
	--say-in: 360ms;

	position: relative;
	display: inline-block;
	max-width: min(22rem, 80vw);
	padding: var(--sp-3) var(--sp-5);
	background: var(--paper);
	border: 2.5px solid var(--ink);
	border-radius: 1.25rem;
	font-family: var(--ff-display);
	font-size: var(--fs-400);
	font-weight: 600;
	letter-spacing: 0.02em;
	line-height: var(--lh-snug);
	text-align: center;
	box-shadow: 3px 3px 0 rgb(51 57 59 / 0.14);
	color: var(--ink);
	/* The resting state, spelled out rather than left at `none`. Both ends of
	   the fade are then the same filter function with a different number in
	   it, which is the one form of filter interpolation nothing has to be
	   clever about — `none` is defined as interpolable, but only by being
	   rewritten into whatever it is being compared against. */
	filter: opacity(1);
	/* Only for the no-JS page, where the `.js`-scoped rule in §10b that
	   carries the same fade never applies. */
	transition: filter var(--say-in) var(--ease-out) var(--say-wait);
}

/* Her line is swapped at the bottom of a short fade rather than snapped, so
   the bubble never shows two different lengths of text on consecutive frames
   while it is still floating. js/modules/jar.js holds the class for a beat
   longer than this transition takes, and changes the words underneath it.

   The whole bubble goes, not just the writing. Fading the text alone was the
   first version and it left the one thing that actually jumps: her four lines
   are four different lengths, so the outline snapped to a new width around
   text that was not there yet. Taking the box with it means the resize happens
   while there is nothing on screen to see it happen, and she comes back at
   whatever size the new line needs.

   `filter: opacity()` and not `opacity`, because `opacity` on this element is
   already owned by the entrance in §10b — one property, one owner. Two writers
   on `opacity` here would mean a swap that fights an entrance whenever the
   section is scrolled into view mid-sentence, and a delay that has to be right
   for both. `filter` is free, and the two never have to agree on anything. */
.bubble.is-swap {
	filter: opacity(0);
}

.bubble::after,
.bubble::before {
	content: "";
	position: absolute;
	inset-block-end: -0.55rem;
	inset-inline-start: var(--tail-x, 2rem);
	width: 1rem;
	height: 1rem;
	background: var(--paper);
	border-right: 2.5px solid var(--ink);
	border-bottom: 2.5px solid var(--ink);
	rotate: 45deg;
	border-bottom-right-radius: 3px;
}

/* The lower pseudo only exists to mask the bubble's own bottom border
   where the tail joins it. */
.bubble::before {
	inset-block-end: -0.3rem;
	border: 0;
	rotate: 0deg;
	height: 0.5rem;
	width: 1.4rem;
	inset-inline-start: calc(var(--tail-x, 2rem) - 0.2rem);
	border-radius: 0;
}

.bubble.is-in {
	animation: bubble-float 3.6s var(--dur-slow) ease-in-out infinite;
}

@keyframes bubble-float {
	0%,
	100% {
		translate: 0 0;
	}
	50% {
		translate: 0 -8px;
	}
}

/* --------------------------------------------------------------------------
   8. Caret
   -------------------------------------------------------------------------- */

.caret {
	display: inline-block;
	width: 0.06em;
	visibility: hidden;
}

.caret.is-on {
	visibility: visible;
	animation: caret-blink 1s steps(1, end) infinite;
}

@keyframes caret-blink {
	0%,
	50% {
		opacity: 1;
	}
	50.01%,
	100% {
		opacity: 0;
	}
}

/* --------------------------------------------------------------------------
   9. Chibi portrait
   -------------------------------------------------------------------------- */

.chibi {
	position: relative;
	display: grid;
	place-items: center;
	width: clamp(8.5rem, 18vw, 12rem);
	aspect-ratio: 1;
	padding: 1.4rem;
	border-radius: var(--r-pill);
	background: var(--chibi-bg, var(--paper-warm));
	box-shadow: var(--sh-contact), var(--sh-ambient);
}

.chibi img {
	image-rendering: pixelated;
}

.chibi__sunflower {
	position: absolute;
	inset-block-end: 0;
	width: 3.2rem;
	image-rendering: pixelated;
}

.chibi__sunflower--left {
	inset-inline-start: 0;
	translate: -8% 18%;
}

.chibi__sunflower--right {
	inset-inline-end: 0;
	translate: 8% 18%;
}

/* --------------------------------------------------------------------------
   10. The jar of folded questions

   A glass jar with five folded slips fanned inside it, and the letter that
   comes out of it. Only the look of those two objects lives here — where they
   sit, and the poses the note moves between, are layout and belong to
   home.css §2.

   The jar is pixel art on the snake plant's grid — 54 art pixels across, so
   one of its pixels is one of the plant's at every size the room is drawn,
   and the two read as the same hand. It is drawn in two layers, because glass
   is the one material you see both sides of at once, and the paper has to go
   between them:

     `.jar::before`  jar-back.png — the far side: the tint of the glass, and
                     the back rim of the floor seen through the front
     `.jar__cavity`  the clip that keeps the slips inside the silhouette
     `.jar__slips`   the paper, in the belly of that cavity
     `.jar__art`     jar-front.png — the near wall, its reflections, the
                     cloth and twine, and the shadow on the floor

   The order is the whole trick. Reflections drawn under the slips would put
   the paper in front of the glass; a tint drawn over them would fog the
   questions. Front and back on either side of the paper is what makes it
   *in* the jar.

   The light comes from the upper left, as it does on the plant: the long
   window-light runs down the left wall, the cloth is pale on its left and
   shaded on its right, and the shadow falls away to the lower right in the
   plant's own flat grey, so the two stand on one floor. The glass is
   `--sage`-green rather than the blue every stock jar is drawn in, because
   the jar belongs to the café.
   -------------------------------------------------------------------------- */

/* --- the five papers ------------------------------------------------------ */

/* A tint is several decisions at once — the paper, the rules printed on it,
   the stamp, and the colours its drawing is inked in — so it is set in one
   place and inherited down. js/data/qa.js names the tint; nothing in the
   data knows a colour.

   The crease and the rules are deliberately *not* tinted. A fold drawn in
   each paper's own deeper tone disappears on butter, where --butter and
   --butter-deep are a few percent apart in lightness. A single warm brown at
   low alpha reads as what it actually is — a shadow lying in a fold, ink on
   a page — and it reads that way on all five papers.

   Declared on the slot as well as the note, because the slip in the jar *is*
   the folded note: its edges are the very same two folds, and they have to
   be shaded by the same values or the slip you pick up is not the letter
   that comes out. */
.jar__slot,
.note {
	--sheet: var(--paper);
	/* The same paper in the shadow of a flap — the strip under the cover. */
	--sheet-under: color-mix(in srgb, var(--sheet) 84%, rgb(120 96 66));
	--crease: rgb(120 96 66 / 0.5);
	--crease-wash: rgb(120 96 66 / 0.22);
	--rule: rgb(120 96 66 / 0.16);

	--art-ink: var(--ink);
	--art-ink-soft: var(--ink-soft);
	--art-glint: var(--ink-faint);
	--art-paper: var(--paper);
	--art-shade: color-mix(in srgb, var(--paper) 78%, var(--ink-faint));
	--art-glass: var(--sage);
	--art-glass-shade: var(--moss-deep);
	--art-accent: var(--peach-deep);
	--art-warm: var(--butter-deep);

	/* The stamp is white paper round a picture printed on a paler copy of
	   the letter's own colour — related to the sheet it is stuck on, but
	   never the same, or the picture sinks into the page. */
	--stamp-paper: var(--paper);
	--stamp-ground: color-mix(in srgb, var(--sheet) 45%, var(--paper));
}

[data-tint="moss"] {
	--sheet: var(--moss);
}

[data-tint="peach"] {
	--sheet: var(--peach);
	/* The one paper whose accent would otherwise sit on its own tint —
	   peach bars on a peach stamp. Moss is the palette's other warm neutral
	   and is the only swap the five drawings need. */
	--art-accent: var(--moss-deep);
}

[data-tint="butter"] {
	--sheet: var(--butter);
}

[data-tint="sage"] {
	--sheet: var(--sage);
}

[data-tint="tan"] {
	--sheet: var(--tan);
}

/* --- the glass ------------------------------------------------------------ */

/* `.jar` is the *drawing's* box, not the file's. Everything below is a
   percentage of it, so the one thing that has to be right is that this box
   and the painted jar are the same rectangle — get that wrong and the glass
   wash sits beside the glass. */
.jar {
	position: relative;
	isolation: isolate;
	width: 100%;
	/* The glass and its cloth, 54×80 art pixels — the shadow is not counted,
	   so the box is the jar and the jar is what gets centred in the room.

	   Taller than it is wide, which is what a jar is: wider than tall is a
	   lunchbox however well the glass is drawn, and four slips fanned down the
	   inside need the height to read as a stack. */
	aspect-ratio: 54 / 80;
}

/* Both layers are bitmaps scaled up five-fold and more, so both are
   `pixelated` — the default smooth resample turns hard pixel edges into a
   soft blur, which is exactly the look pixel art is not. */
.jar::before,
.jar__art {
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0;
	image-rendering: pixelated;
	pointer-events: none;
}

/* The far side of the glass, behind the paper. It is 54×80 on the nose, so
   it simply fills the box. */
.jar::before {
	content: "";
	inset: 0;
	z-index: 0;
	background: url("../static/PixelArt/jar-back.png") 0 0 / 100% 100% no-repeat;
}

/* The near side, over the paper. The canvas shares the box's top-left corner
   and is 84 pixels square: the jar is the first 54 of them across, and the
   rest is floor for the shadow to fall on, out to the right and a few rows
   below the base. So the width is 84/54 of the box and the height follows
   from the file. Overflow is not clipped and does not need to be: what hangs
   outside the jar is shadow or nothing.

   Above the cavity, so the cloth overlaps the topmost slip and the base
   crops the bottom one. That overlap is the whole illusion: paper that is
   merely *behind* a jar is paper on the table. */
.jar__art {
	z-index: 2;
	/* `max-width: none` is load-bearing, not tidying. base.css resets every
	   image to `max-width: 100%`, and this one is deliberately wider than its
	   own box — so the reset clamps it back to the jar, and the shadow is
	   squeezed in under the glass. */
	width: 155.556%;
	max-width: none;
	height: auto;
}

/* The inside of the glass. Everything that is meant to be *in* the jar goes
   in here and is clipped to the walls, so a slip can never be seen standing
   outside the glass it is supposed to be behind. Its box is the inside of the
   wall in the drawing — x 2…52 of 54, y 17…75 of 80 — and the radii are the
   shoulder and the floor. */
.jar__cavity {
	position: absolute;
	inset: 21.25% 3.704% 6.25%;
	z-index: 1;
	overflow: hidden;
	border-radius: 18% 18% 10% 10% / 15% 15% 7% 7%;
}

/* --- the slips ------------------------------------------------------------ */

/* The slips get the belly, not the whole cavity. A slip fanned up under the
   shoulder is half behind the cloth's shadow with its question in the hidden
   half — which fails the one thing the jar has to do, which is be readable at
   rest. Paper settles at the bottom of a jar anyway, and the bottom of this
   box is the middle of the jar's floor, so the last slip rests on it.

   In jar terms the belly is 76.73% of the jar wide, centred, and runs from
   39.25% to 90% of its height; the insets are that, said against the cavity.
   It is the belly the fan below was solved for — change it, and re-solve. */
.jar__slips {
	position: absolute;
	inset: 24.83% 8.566% 5.172%;
	list-style: none;
}

/* The pile is hand-placed per slip rather than solved. With five of them a
   solver would be more machinery than the problem deserves, and hand values
   let each slip lie at an angle that looks *dropped in* rather than dealt.

   They lie in two loose columns, left and right in turn, so each one
   overlaps its neighbours only at a corner. That is the point of the
   arrangement: a slip only reads as folded paper if you can see the whole
   of it — the fold along the top, the flap, the strip of paper showing under
   the flap's edge. A neat stack shows five top edges and no paper.

   The slot owns the pose and the button inside it owns the hover lift. That
   split is the whole reason hovering a slip does not have to restate its own
   place in the pile — one owner per property, per element. The tilt is a
   custom property rather than a bare `rotate` only so the button can read
   it and straighten up a little as it is lifted.

   Height comes from `top` and only the sideways nudge from `translate`,
   which is not a stylistic choice: a percentage in `translate` resolves
   against the element's *own* box, not its parent's. `top` is the one that
   means "a fifth of the way down the jar". */
.jar__slot {
	position: absolute;
	left: 50%;
	/* A slip is the folded letter, so it has the letter's proportion: 70% of
	   the belly wide is 26% of it tall at `--note-ratio` 2.75. Rows 18.5%
	   apart in alternate columns meet only at a corner, and the last row ends
	   on the floor of the jar. The columns sit a fifth of a slip either side
	   of the middle, which keeps the outer ends inside the glass even at
	   their tilt. 70% and not less because the question is written in
	   proportion to the slip, and narrower than this it is too small to read
	   on a phone. Change the width or the ratio in css/home.css
	   §2 and the pile has to be laid out again. */
	width: 70%;
	translate: var(--nudge);
	rotate: var(--tilt);
}

.jar__slot:nth-child(1) {
	--nudge: -70%;
	--tilt: 5deg;
	top: 0%;
}
.jar__slot:nth-child(2) {
	--nudge: -30%;
	--tilt: -6deg;
	top: 18.5%;
}
.jar__slot:nth-child(3) {
	--nudge: -68%;
	--tilt: 4deg;
	top: 37%;
}
.jar__slot:nth-child(4) {
	--nudge: -32%;
	--tilt: -5deg;
	top: 55.5%;
}
.jar__slot:nth-child(5) {
	--nudge: -50%;
	--tilt: 2deg;
	top: 74%;
}

/* Its letter is out of the jar, so the slip is not in it. Snapped rather
   than faded: the letter appears in exactly this spot on the same frame, so
   the two are one object changing hands, not one fading out as another
   fades in. Left in the DOM so the gap it leaves is exactly its own, and so
   there is somewhere to land on the way back. */
.jar__slot.is-out {
	opacity: 0;
}

/* A slip is a letter folded in three, seen from outside, and it is drawn as
   one: what makes paper read as *folded* rather than as a coloured card is
   that you can see the layers.

   The top flap is a little shorter than the panels under it — letters are
   rarely folded into exact thirds — so its cut edge stops short of the
   bottom and a strip of the fold underneath shows below it, in the flap's
   shadow. The flap's top edge is the fold itself, and a fold is a bend, not
   a cut: it catches the light as a bright line, and the paper curves away
   from it and darkens slightly towards the loose edge.

   That is exactly what the letter on the stage looks like folded shut — the
   cover and the strip are its top flap and its bottom flap, really there —
   so the letter that leaves the jar is visibly *this* slip, at this size,
   and not a second object that replaced it.

   The shadow falls right as well as down — the jar is lit from the left, and
   paper that casts its shadow straight down is lit from somewhere else. */
.slip {
	position: relative;
	width: 100%;
	aspect-ratio: var(--note-ratio);
	border-radius: 0 0 2px 2px;
	background: var(--sheet-under);
	cursor: pointer;
	box-shadow: 2px 3px 4px -1px rgb(88 70 52 / 0.32);
	transition: translate var(--dur) var(--ease-out),
		rotate var(--dur) var(--ease-out),
		scale var(--dur) var(--ease-spring),
		box-shadow var(--dur) var(--ease-out);
}

/* Picked up rather than highlighted: it rises, comes a little nearer, and
   straightens by half its tilt, the way a slip does between two fingers. */
.slip:hover,
.slip:focus-visible {
	translate: 0 -0.35rem;
	rotate: calc(var(--tilt) * -0.5);
	scale: 1.05;
	box-shadow: 4px 8px 12px -4px rgb(88 70 52 / 0.36);
}

.slip__flap {
	position: absolute;
	inset: 0 0 auto;
	height: calc(var(--flap) * 100%);
}

/* The outside of the top flap — the slip's face in the jar, and the cover of
   the letter on the stage. One rule for both, and in proportional units only
   (percentages, `cqi`), because the letter leaves the jar at exactly the
   slip's size and grows from there: for the hand-off to be invisible, the
   same picture has to be laid out in proportion to its own width, not in
   rem. The question is the only thing written on it. */
.slip__flap,
.note__back.note__cover {
	container-type: inline-size;
	display: grid;
	place-items: center;
	padding-inline: 6%;
	border-radius: 0 0 4% 4% / 0 0 12% 12%;
	background: linear-gradient(
		180deg,
		color-mix(in srgb, var(--sheet) 40%, var(--paper)) 0 3%,
		var(--sheet) 16% 60%,
		color-mix(in srgb, var(--sheet) 92%, rgb(120 96 66)) 100%
	);
}

/* The flap's own shadow, cast on the strip of fold below its edge. */
.slip__flap {
	box-shadow: 0 1px 2px rgb(88 70 52 / 0.38);
}

.note__back.note__cover {
	box-shadow: 0 2px 4px rgb(88 70 52 / 0.38);
}

.slip__q {
	font-family: var(--ff-display);
	/* Floored, for the smallest jar on the smallest phone. The floor only ever
	   applies at slip size, never on the cover, so it cannot show up in the
	   hand-off as anything more than a fraction of a pixel. */
	font-size: max(0.6875rem, 10.5cqi);
	font-weight: 600;
	line-height: 1.1;
	color: var(--ink);
	white-space: nowrap;
}

/* --------------------------------------------------------------------------
   9b. The letter, and the fold

   A sheet folded in three, like a letter: the bottom third folded up first,
   the top third — a little short of a third — folded down over it. Three
   panels, and they are the three beats of the answer — the question on the top flap, the answer
   in the middle, the drawing and a P.S. on the bottom flap.

   ---- why three and not four

   The sheet used to be folded in quarters, and the quarters crossed: the
   right half spanned both rows and the bottom half both columns, so one
   quadrant had to be nested inside another and the cover had to slide
   sideways to stay centred as the sheet grew out of one corner. A letter
   folds about two parallel creases on either side of a middle panel that
   never moves, so it opens *symmetrically* — up and down from the panel in
   the middle of the room — and none of that machinery is needed. The note's
   box is the middle panel, and it does not move at all.

   ---- the order, and why it cannot be the other one

   Paper only comes apart in the reverse of the order it went together. The
   top flap is the outermost, so it opens first and closes last, and the
   bottom flap follows it out and leads it back in. The gap between the two is
   `--ripple`, a fraction of a fold rather than a whole one: the second flap
   starts while the first is still moving, which is the order your hands do it
   in. Much more than half and the two beats separate and the letter reads as
   being opened by committee.

   ---- the swing

   What animates is the *angle*, not the rotation. `--fold-a` is registered
   below as an `<angle>` and is the single thing a flap transitions; `rotate`
   reads it, and so does the light on each face. There is only one moving
   number per flap, and everything visible is a function of it.

   One continuous rotation on `--ease-out`, which starts quick and settles.
   That is the shape of a flap let go: it comes over fast and the last few
   degrees are the paper laying itself down. Deliberately not the spring — a
   flap that overshoots flat and comes back has something still acting on it
   after it has come to rest, and there is nothing on a letter that could.

   ---- the memory

   An opened letter does not lie flat. Paper keeps a little of every fold it
   has been given, so both flaps come to rest a few degrees short of flat,
   tilted back towards each other across the middle panel. That is the whole
   of the effect, and it is most of why this reads as paper rather than as
   three cards: the perspective shortens the two outer panels very slightly,
   and the creases between them stay where you can see them.

   ---- why nothing has to be kept in sync

   Each flap carries both of its faces. `.note__face` is the printed side and
   `.note__back` is the outside, pre-turned with `rotate: x 180deg`; both hide
   their own backface. Which of the two you are looking at is therefore
   decided by the geometry on every frame rather than by a timer — a flap
   shows its outside through the first half of its swing and its printed side
   through the second, correctly, in both directions.

   rotateX and not rotateY on the backs, because these flaps turn about a
   horizontal crease: a back turned about the vertical axis would come round
   upside down, and the top flap's back is the cover, which has writing on it.

   ---- the stacking

   The note carries a `filter` (its shadow), and a filter flattens: its
   children are painted in z-index order rather than sorted by depth. That is
   exactly what a folded letter wants. The top flap is outermost, so it is
   painted last and lies over everything when shut; the bottom flap is under
   it and over the middle panel. Neither ever has to pass *through* the other,
   because the ripple keeps them apart — so order is all the depth there is,
   and the DOM can stay in reading order. Each flap keeps `preserve-3d` for
   its own two faces, which is the only place depth is still needed.
   -------------------------------------------------------------------------- */

/* How far this flap is from lying open, and the only number in the fold.

   Registering it is what makes it animatable — an unregistered custom property
   has no type, so the browser can only swap it at the halfway point instead of
   interpolating it. Given `<angle>`, it tweens, and everything downstream of
   it tweens with it: the rotation, and the light on both faces. It inherits so
   that the faces, which do the shading, read their own flap's angle. */
@property --fold-a {
	syntax: "<angle>";
	inherits: true;
	initial-value: 0deg;
}

.note {
	/* Mirrored in js/modules/jar.js as UNFOLD, which is the fold plus the
	   ripple: the time from the first flap starting to the second flap
	   landing. Change one, change its twin.

	   The fold's duration lives here rather than with the flight in home.css
	   §2, because it belongs to the paper: the letter folds the same way
	   wherever on the stage it happens to be. `--note-w` and `--panel-h` are
	   the other way round — they are how big the room can afford the letter to
	   be, so they are declared on the stage. */
	--dur-fold: var(--dur-slow);
	--fold-ease: var(--ease-out);
	--ripple: calc(var(--dur-fold) * 0.4);

	/* The rest angles: a few degrees of the fold the paper remembers. */
	--memory: 7deg;

	position: relative;
	width: var(--note-w);
	height: var(--panel-h);
	perspective: 1400px;
	/* One shadow for the whole sheet, so it grows and shrinks with the
	   silhouette as the flaps swing rather than being three shadows that
	   overlap at the creases. Down and to the right, like everything else
	   lit from the left on this page. */
	filter: drop-shadow(3px 6px 7px rgb(88 70 52 / 0.24));
}

/* The whole letter is what you press to fold it back — there is no close
   button on it, by design — so the pointer says so over every bit of paper.

   Focus is handed to the letter when it opens, so a screen reader starts
   reading at its title, and Enter or Escape folds it back from there. No
   ring: the note's box is only its middle panel, and an outline round one
   third of an open letter reads as a mistake, not as focus. */
.note {
	cursor: pointer;
}

.note:focus {
	outline: none;
}

.note__flap,
.note__panel {
	position: absolute;
	inset-inline: 0;
	height: var(--panel-h);
	/* No `overflow`, no `opacity`, no `filter` on a flap, ever. Each of the
	   three silently forces `transform-style: flat`, which collapses the flap
	   onto its own plane and its back face starts showing through the front.
	   Anything that needs clipping or fading is done to a face instead. */
	transform-style: preserve-3d;
}

.note__panel {
	inset-block-start: 0;
	z-index: 1;
}

/* The top flap hangs off the middle panel's top edge. Shut, it has turned
   -180° about that crease — forwards, towards you, and down over the middle —
   so its back is what faces the room: the cover.

   It is `--flap` of a panel tall rather than a whole one, so shut it stops
   short of the bottom fold and a strip of the bottom flap shows under its
   edge — the strip the slips in the jar are drawn with. */
.note__flap--top {
	--fold-a: -180deg;

	height: calc(var(--panel-h) * var(--flap));
	inset-block-end: 100%;
	z-index: 3;
	transform-origin: 50% 100%;
	rotate: x var(--fold-a);
	transition: --fold-a var(--dur-fold) var(--fold-ease) var(--ripple);
}

/* The bottom flap hangs off the bottom edge and turns the other way, +180°,
   which is also forwards. */
.note__flap--bottom {
	--fold-a: 180deg;

	inset-block-start: 100%;
	z-index: 2;
	transform-origin: 50% 0;
	rotate: x var(--fold-a);
	transition: --fold-a var(--dur-fold) var(--fold-ease) 0s;
}

/* Open. The delays swap ends: the top flap leads out and the bottom one
   leads back in, and both are declared on the state being *entered*, which
   is the one whose transition the browser uses. */
.note.is-open .note__flap--top {
	--fold-a: calc(var(--memory) * -1);
	transition-delay: 0s;
}

.note.is-open .note__flap--bottom {
	--fold-a: var(--memory);
	transition-delay: var(--ripple);
}

/* --- the two faces of a flap ---------------------------------------------- */

.note__face,
.note__back {
	position: absolute;
	inset: 0;
	backface-visibility: hidden;
	background: var(--sheet);
}

.note__back {
	rotate: x 180deg;
}

/* Cut edges are rounded and folded ones are not, which is the quiet reason a
   folded letter looks folded before it moves: the rounded corners are always
   the four furthest from any crease. On a back the rounding is mirrored,
   because the back is turned over about the crease. */
.note__flap--top > .note__face {
	border-radius: var(--r-md) var(--r-md) 0 0;
	box-shadow: inset 0 -8px 10px -9px var(--crease);
}

.note__panel > .note__face {
	box-shadow: inset 0 8px 10px -9px var(--crease),
		inset 0 -8px 10px -9px var(--crease);
}

.note__flap--bottom > .note__face {
	border-radius: 0 0 var(--r-md) var(--r-md);
	box-shadow: inset 0 8px 10px -9px var(--crease);
}

/* The bottom flap's outside is in the top flap's shadow whenever it can be
   seen shut, so it is the darker paper the slips show under their flaps. The
   top flap's outside is the cover, drawn with the slips in §10. */
.note__flap--bottom > .note__back {
	border-radius: var(--r-md) var(--r-md) 0 0;
	background: var(--sheet-under);
}

/* The light on a face, and the real thing rather than a fade timed to look
   like it. A flat surface catches light in proportion to the cosine of its
   angle to it, so the printed side's shade is `1 − cos(--fold-a)`: nothing
   when it lies open, total when it is edge-on. The outside is the same curve
   turned half a circle — lit when the flap is shut, dark edge-on.

   Nothing here is transitioned. The angle is the only thing that animates
   and this is derived from it, so the light cannot disagree with the pose.
   `clamp` because the cosine keeps going past ±90°, where the face is turned
   away and the value still has to be a legal opacity. */
.note__face::after,
.note__back::after {
	content: "";
	position: absolute;
	inset: 0;
	pointer-events: none;
	border-radius: inherit;
	background: rgb(88 70 52 / 0.45);
}

.note__face::after {
	opacity: clamp(0, 1 - cos(var(--fold-a)), 1);
}

.note__back::after {
	opacity: clamp(0, 1 + cos(var(--fold-a)), 1);
}

/* --- what is written on it ------------------------------------------------ */

/* The top flap is a letterhead: who it is from in small capitals up top, and
   the question set at the bottom of the panel, right against the crease, so
   it reads straight on into the answer below it. */
.note__flap--top > .note__face {
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	padding: var(--sp-3) var(--sp-5);
}

.note__from {
	position: absolute;
	inset-block-start: var(--sp-3);
	inset-inline-start: var(--sp-5);
	font-family: var(--ff-display);
	font-size: var(--fs-100);
	font-weight: 600;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	color: var(--ink-soft);
}

/* Sized from the panel rather than from the type scale, because it is the
   panel's one job: a quarter of its height, so the letterhead is mostly
   title and not mostly paper, held between two sizes that are still a
   heading on a phone and still a note on a laptop. */
.note__q {
	font-family: var(--ff-display);
	font-size: clamp(1.5rem, calc(var(--panel-h) / 4), 2.25rem);
	line-height: var(--lh-tight);
	color: var(--ink);
}

/* The middle panel is ruled, like letter paper, and the rules are the lines
   the answer is written on: one every `1.5em` of the answer's own size,
   starting at the top of the content box where the first line starts. Drawn
   as the face's background rather than under the paragraph, so the page is
   ruled all the way down whether the answer runs to three lines or five.

   The answer has to fit this one panel — text does not run across a crease
   — and the panel is sized from the room, so the type is sized from the
   panel: `--panel-h / 10`, held between the two body sizes the section
   already uses. The longest answer in js/data/qa.js is what that was
   checked against, at the shortest room and the narrowest phone. */
.note__panel > .note__face {
	padding: var(--sp-3) var(--sp-5);
	font-size: clamp(var(--fs-200), calc(var(--panel-h) / 10), var(--fs-300));
	background: linear-gradient(transparent calc(100% - 1px), var(--rule) 0)
			0 0 / 100% 1.5em content-box,
		var(--sheet);
}

.note__text {
	line-height: 1.5;
	color: var(--ink);
}

.note__text a {
	text-decoration: underline;
	text-decoration-color: var(--art-accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 2px;
	transition: text-decoration-color var(--dur) var(--ease-out);
}

.note__text a:hover,
.note__text a:focus-visible {
	text-decoration-color: var(--ink);
}

/* The bottom flap: the drawing as a stamp stuck in the corner, and a P.S.
   beside it. The stamp is as tall as the panel allows and square, and goes
   on a few degrees crooked, because nobody has ever stuck a stamp on
   straight. */
.note__flap--bottom > .note__face {
	display: grid;
	grid-template-columns: auto 1fr;
	align-items: center;
	gap: var(--sp-4);
	padding: var(--sp-3) var(--sp-5);
}

.note__stamp {
	height: calc(var(--panel-h) - var(--sp-8));
	aspect-ratio: 1;
	rotate: -4deg;
	/* A hard offset drop rather than a blur: a pixel stamp with a soft shadow
	   under it stops being a pixel stamp. */
	filter: drop-shadow(2px 2px 0 rgb(120 96 66 / 0.25));
}

.note__stamp > svg {
	display: block;
	width: 100%;
	height: 100%;
}

.note__ps {
	font-family: var(--ff-display);
	font-size: var(--fs-200);
	line-height: var(--lh-snug);
	color: var(--ink-soft);
}

.note__ps-mark {
	font-weight: 700;
	color: var(--ink);
}

/* --------------------------------------------------------------------------
   9c. The plain list

   What ships in the HTML, and the only version a crawler, a reader with no
   JavaScript, or a reader who has asked for reduced motion ever sees. A
   <details> is already a fold, so this needs no script to do the one thing
   the jar exists to do.
   -------------------------------------------------------------------------- */

.qa__list {
	display: grid;
	gap: var(--sp-4);
	max-width: 44rem;
	margin-inline: auto;
}

.qa-note {
	padding: var(--sp-4) var(--sp-5);
	background: var(--paper);
	border-radius: var(--r-md);
	box-shadow: var(--shadow-paper);
}

.qa-note > summary {
	font-family: var(--ff-display);
	font-size: var(--fs-500);
	color: var(--ink);
	cursor: pointer;
}

.qa-note > p {
	margin-block-start: var(--sp-3);
	max-width: var(--measure);
}

/* The same underline the letter gives its links, minus the per-tint accent
   — the list is plain paper. */
.qa-note a {
	text-decoration: underline;
	text-decoration-color: var(--accent);
	text-decoration-thickness: 2px;
	text-underline-offset: 2px;
}

.qa-note__ps {
	color: var(--ink-soft);
}

/* --------------------------------------------------------------------------
   11. The say panel

   Dimah's voice, wherever it appears — the café intro in the hero and the
   answers on the Q&A board are the same act, so they are the same component.
   A visual-novel text panel: no outline, just a soft cream sheet lifted off
   the page by a diffuse shadow, with a striped café awning running down the
   left edge as the only piece of colour. She speaks; the reader clicks on.
   -------------------------------------------------------------------------- */

.saypanel {
	/* Warm orange, dark enough to clear 4.5:1 on the panel — the label is
	   small text, not decoration. */
	--speaker: #a9550f;
	--rail-w: 12px;
	--awning-a: #fcde6e;
	--awning-b: #fff7d6;

	position: relative;
	width: 100%;
	max-width: 42rem;
	min-height: 9.5rem;
	padding: var(--sp-5) var(--sp-8) var(--sp-8)
		calc(var(--rail-w) + var(--sp-6));
	background: #faf6e6;
	border-radius: 16px;
	box-shadow: 0 1px 2px rgb(88 70 52 / 0.1), 0 12px 28px -14px rgb(88 70 52 / 0.3);
}

/* The awning: horizontal bands down the rail. Hard colour stops, so these are
   stripes and not a gradient wash. The rail rounds its own left corners, which
   is why the panel does not need `overflow: hidden`. */
.saypanel::before {
	content: "";
	position: absolute;
	inset: 0 auto 0 0;
	width: var(--rail-w);
	border-radius: 16px 0 0 16px;
	background: repeating-linear-gradient(
		to bottom,
		var(--awning-a) 0 8px,
		var(--awning-b) 8px 16px
	);
}

.saypanel__who {
	margin-block-end: var(--sp-2);
	font-size: var(--fs-200);
	font-weight: 700;
	letter-spacing: 0.06em;
	color: var(--speaker);
}

.saypanel__line {
	font-size: var(--fs-400);
	line-height: 1.65;
	color: var(--ink);
}

/* The intro cycles through lines of different lengths, so the panel would
   grow and shrink under them as each one wraps to a different number of
   rows. Every chunk she will say is stacked into this one grid cell — the
   spoken one visible, the rest invisible placeholders — which makes the cell
   as tall as the longest of them from the start and keeps it there. Sized
   from the copy itself, so it stays right at any width and needs no
   updating when the copy changes. */
.saypanel__line--reserved {
	display: grid;
}

.saypanel__line--reserved > * {
	grid-area: 1 / 1;
	align-self: start;
}

/* `visibility` rather than `opacity`: still occupies its space, but is out of
   the accessibility tree and unselectable. */
.saypanel__ghost {
	visibility: hidden;
	pointer-events: none;
}

/* Hidden until she has finished the line — `hidden` rather than opacity, so
   it is out of the tab order and unclickable while it is not offered. */
.saypanel__next {
	position: absolute;
	inset-block-end: 0.85rem;
	inset-inline-end: 1.1rem;
	padding: 0.15rem 0.35rem;
	font-size: 0.95rem;
	line-height: 1;
	color: var(--speaker);
	background: none;
	border: 0;
	border-radius: 6px;
	cursor: pointer;
	animation: next-in var(--dur) var(--ease-out) both,
		next-bob 1.4s var(--dur) ease-in-out infinite;
}

/* In the hero she is standing to the right of the panel, so it gets a tail
   pointing across at her. No border to interrupt any more, so it is one
   rotated square of the panel colour and nothing else. Only in the
   two-column layout — stacked, there is nothing to its right to point at. */
@media (min-width: 60.01rem) {
	.saypanel--hero::after {
		content: "";
		position: absolute;
		inset-block-start: calc(50% - 0.6rem);
		inset-inline-end: -0.5rem;
		width: 1.2rem;
		height: 1.2rem;
		background: #faf6e6;
		border-radius: 0 3px 0 0;
		rotate: 45deg;
	}
}

@keyframes next-in {
	from {
		opacity: 0;
		scale: 0.6;
	}
	to {
		opacity: 1;
		scale: 1;
	}
}

@keyframes next-bob {
	0%,
	100% {
		translate: 0 0;
	}
	50% {
		translate: 0 4px;
	}
}

/* Anywhere in the panel advances, so the arrow is a hint rather than a
   target you have to hit. The cursor only offers it when there is something
   to advance to. */
.saypanel.is-typing,
.saypanel.is-ready {
	cursor: pointer;
}

/* --------------------------------------------------------------------------
   10b. Entrance states

   Scoped to `.js`, which an inline snippet in <head> stamps on <html>. With
   scripting off, the greeting, the portrait and the answer box are simply
   present — rather than permanently invisible, waiting for a class that will
   never arrive. Each element staggers itself with --in-delay, so the
   choreography is CSS rather than a chain of setTimeouts.
   -------------------------------------------------------------------------- */

.js :is(.bubble, .chibi, .saypanel) {
	opacity: 0;
	transition: opacity var(--dur) var(--ease-out),
		scale var(--dur-slow) var(--ease-spring);
	transition-delay: var(--in-delay, 0ms);
}

/* The bubble is the one of the three that changes what it says after it has
   arrived, so it carries a second fade the entrance's stagger must not delay —
   see `.bubble.is-swap`. Restating the shorthand here is what lets the two
   channels keep separate delays: written as the plain `transition-delay` above,
   one number would have had to serve both.

   The durations and delays are then restated as their own three-value lists
   rather than left inside the shorthand, because only that lets the rule below
   change the third of each and leave the first two — the entrance's — alone.
   This rule is the *coming back*: the slow fade, after the beat. */
.js .bubble {
	scale: 0.4;
	transition: opacity var(--dur) var(--ease-out),
		scale var(--dur-slow) var(--ease-spring),
		filter var(--say-in) var(--ease-out);
	transition-delay: var(--in-delay, 0ms), var(--in-delay, 0ms),
		var(--say-wait);
}

/* And this rule is the going away, which is the whole reason those two lists
   are separate: a transition uses the timings of the state it is moving *to*,
   so the class arriving reads its timings from here and the class leaving
   reads them from the rule above. Quick, and starting on the frame it is
   asked to. One duration and one delay on both sides would have been a slower
   blink; two of each is her stopping, thinking, and answering. */
.js .bubble.is-swap {
	transition-duration: var(--dur), var(--dur-slow), var(--say-out);
	transition-delay: var(--in-delay, 0ms), var(--in-delay, 0ms), 0s;
}
.js .chibi {
	scale: 0;
}
.js .saypanel {
	scale: 0.96;
}

.js :is(.bubble, .chibi, .saypanel).is-in {
	opacity: 1;
	scale: 1;
}

/* --------------------------------------------------------------------------
   12. Reduced motion — the calm board
   Straight, evenly spaced, no rotation, no tilt, no drag, nothing that
   moves on its own. The content is identical.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
	.card {
		--rest-x: 0px !important;
		--rest-y: 0px !important;
		--rest-rot: 0deg !important;
		translate: none;
		rotate: none;
		transform: none;
	}

	/* Matches the specificity of the `.js`-scoped entrance states above, so
	   these win and nothing is left hidden waiting for an animation that
	   will never run. */
	.js :is(.bubble, .chibi, .saypanel),
	:is(.bubble, .chibi, .saypanel) {
		opacity: 1;
		scale: 1;
		animation: none;
	}

	/* The arrow still appears — it is the only signal that the line is over
	   and there is something to click — it just stops moving. */
	.saypanel__next {
		animation: none;
	}

	.card__more {
		opacity: 0.75;
		translate: 0 0;
	}
}
