/* ==========================================================================
   Buttercup Café — case study page
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Theme
   The renderer sets data-theme on <html>; everything colour-related follows
   from that one attribute.
   -------------------------------------------------------------------------- */

:root {
	/* The paper sheet itself. Narrow enough to read as a sheet on a desk
	   rather than as a full-bleed page — an 84rem sheet filled the window and
	   stopped looking like an object.

	   The photographs are not confined to it. --spill is how far a gutter
	   figure may hang past the paper edge, the way the originals were taped
	   half-off the card. It is a clamp against the viewport rather than a
	   fixed number, so the overhang shrinks to nothing before it can ever
	   reach the edge of the window. The 6rem of slack is not decoration: it
	   covers the body padding, a classic scrollbar, and the corner a tilted
	   print swings out past its own width. */
	--sheet: 68rem;
	--measure-col: 42rem;
	--spill: clamp(0rem, (100vw - var(--sheet) - 6rem) / 2, 6rem);
}

[data-theme="moss"] {
	--page-fill: var(--moss);
	--accent: var(--moss-deep);
	--chip-bg: var(--moss-deep);
}
[data-theme="peach"] {
	--page-fill: var(--peach);
	--accent: var(--peach-deep);
	--chip-bg: var(--peach-deep);
}
[data-theme="butter"] {
	--page-fill: var(--butter);
	--accent: var(--butter-deep);
	--chip-bg: var(--butter-deep);
}

body {
	background: var(--page-fill, var(--tan));
	padding-block: clamp(1.25rem, 4vw, 3.5rem);
	padding-inline: clamp(0.75rem, 3vw, 2.5rem);
}

/* --------------------------------------------------------------------------
   2. Back link
   -------------------------------------------------------------------------- */

/* The link itself is in css/components.css. What belongs to this page is only
   where it sits: on the sheet's own left edge, above the paper. */
.back {
	max-width: var(--sheet);
	margin: 0 auto var(--sp-6);
}

.back-row {
	max-width: var(--sheet);
	margin-inline: auto;
}

/* --------------------------------------------------------------------------
   3. The sheet
   Same stitch primitive as the home cards, inverted: cream fill with the
   thread tinted by the project's accent.
   -------------------------------------------------------------------------- */

.case {
	--card-bg: var(--cream);
	--stitch-color: var(--accent);
	/* The thread sits further in on a wide sheet than it can afford to on a
	   phone, where 0.85rem of it is a fifth of the margin. */
	--stitch-inset: clamp(0.55rem, 2.2vw, 0.85rem);
	--r-card: 14px;
	max-width: var(--sheet);
	margin-inline: auto;

	/* .paper derives its padding from the thread precisely so that text can
	   never touch it. Overriding the shorthand with a bare clamp threw that
	   derivation away, and at 375px the inline padding (1rem) landed *inside*
	   the thread (0.85rem inset + 3px) — every paragraph started its first
	   character on the stitching. Keep the derived value as the floor and let
	   the clamp only ever add to it. */
	--case-inset: calc(var(--stitch-inset) + var(--stitch-w) + var(--sp-4));
	padding: max(var(--case-inset), clamp(1.75rem, 4vw, 3.25rem))
		max(var(--case-inset), clamp(1rem, 3vw, 2.5rem));
}

.case__head {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--sp-3);
	max-width: 46rem;
	margin: 0 auto var(--sp-10);
	text-align: center;
}

.case__title {
	font-size: var(--fs-700);
}

/* The empty aside on a project with no `meta` list must not open a gap
   between the title and the tags. */
.case__aside:empty {
	display: none;
}

/* -- split header ------------------------------------------------------

   A case study that carries a credits card gets a masthead instead of a
   centred title: the name of the thing on the left at full size, the facts
   about it pinned up on the right. Selected with :has() rather than a class
   from the renderer so the markup stays declarative — and the centred flex
   column above is a perfectly good fallback wherever :has() isn't understood,
   since the two children simply stack. */
.case__head:has(.case__meta) {
	display: grid;
	grid-template-columns: minmax(0, 1.25fr) minmax(15rem, 0.75fr);
	align-items: start;
	gap: clamp(1.5rem, 3vw, 3.5rem);
	max-width: none;
	margin-block-end: var(--sp-12);
	text-align: start;
}

.case__intro {
	display: flex;
	flex-direction: column;
	align-items: start;
	gap: var(--sp-4);
}

.case__head:has(.case__meta) .case__title {
	font-size: var(--fs-800);
	line-height: var(--lh-tight);
	text-wrap: balance;
}

.case__head:has(.case__meta) .chips {
	justify-content: start;
}

/* The one-sentence version, for the reader who is deciding whether to read
   the rest. Empty on projects without a deck, and then it must not add a gap
   to the flex column. */
.case__deck {
	max-width: 34rem;
	font-size: var(--fs-500);
	line-height: var(--lh-snug);
	color: var(--ink-soft);
	text-wrap: pretty;
}

.case__deck:empty {
	display: none;
}

@media (max-width: 52rem) {
	.case__head:has(.case__meta) {
		grid-template-columns: minmax(0, 1fr);
	}

	/* At masthead size the title alone fills a phone screen, so the reader
	   scrolls once before learning anything. Back to the ordinary heading
	   size, where the title, the tags and the deck arrive together. */
	.case__head:has(.case__meta) .case__title {
		font-size: var(--fs-700);
	}

	.case__deck {
		font-size: var(--fs-400);
	}
}

/* --------------------------------------------------------------------------
   4. Body grid

   Three columns: a gutter, the measure, a gutter. Floating figures live in
   the gutters as real grid items, so they can never be clipped by the
   viewport — which is what the old `right-[-180px]` negative offsets did at
   any window narrower than the author's.
   -------------------------------------------------------------------------- */

.case__body {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(0, var(--measure-col)) minmax(0, 1fr);
	column-gap: clamp(0.75rem, 2vw, 2rem);
	align-items: start;
}

/* The renderer sets --row per item rather than an inline `grid-row`, so the
   single-column fallback below can simply hand placement back to auto
   without needing !important to beat an inline style. */
.case__body > * {
	grid-column: 2;
	grid-row: var(--row, auto);
}

.case__p {
	margin-block-end: var(--sp-5);
	font-size: var(--fs-400);
	line-height: var(--lh);
	color: var(--ink);
}

/* Sections are set far apart on purpose: the reader should arrive at one
   heading at a time, with nothing else in the same eyeful. The rule under the
   heading is the same drawn mark the chips and stitching use. */
.case__h2 {
	position: relative;
	margin-block: var(--sp-16) var(--sp-6);
	padding-block-end: var(--sp-3);
	font-size: var(--fs-600);
}

.case__h2::after {
	content: "";
	position: absolute;
	inset-inline-start: 0;
	inset-block-end: 0;
	width: 2.75rem;
	height: 3px;
	border-radius: 2px;
	background: var(--accent);
}

.case__h2:first-child {
	margin-block-start: 0;
}

/* -- credits card ------------------------------------------------------

   Role, timeline, tooling: a card of paper pinned up beside the title, tilted
   the same degree or two as the photographs further down. Labels stack over
   their values rather than sitting in a column beside them — a label column
   wide enough for "built with" leaves "Mixed Reality Utility Kit" breaking
   across four lines in what's left. */

.case__meta {
	margin: 0;
	padding: var(--sp-5) var(--sp-6);
	background: var(--paper);
	border: 2px solid color-mix(in oklab, var(--accent) 55%, var(--paper));
	border-radius: 6px;
	box-shadow: var(--sh-contact), var(--sh-ambient);
	rotate: 1deg;
	font-size: var(--fs-300);
	transition: rotate var(--dur) var(--ease-spring);
}

.case__meta:hover {
	rotate: 0deg;
}

.case__meta dt {
	font-family: var(--ff-display);
	font-size: var(--fs-100);
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--ink-faint);
}

/* A hairline between entries, drawn in the project's accent — the ruling on a
   card rather than a border between rows of a table. */
.case__meta dt:not(:first-of-type) {
	margin-block-start: var(--sp-4);
	padding-block-start: var(--sp-4);
	border-block-start: 1px dashed
		color-mix(in oklab, var(--accent) 45%, var(--paper));
}

.case__meta dd {
	margin: 0.15rem 0 0;
	line-height: var(--lh-snug);
	color: var(--ink);
}

/* -- participant quote -------------------------------------------------

   A slip of paper laid on the sheet at a slight angle. The quotes are in the
   participants' own French; the gloss underneath is the translation, so the
   sentence and its sense both survive. */

.case__quote {
	margin-block: var(--sp-6) var(--sp-8);
	padding: var(--sp-5) var(--sp-6);
	background: var(--paper-warm);
	border-radius: var(--r-md);
	box-shadow: var(--sh-contact), var(--sh-ambient);
	rotate: -0.6deg;
}

.case__quote p {
	font-size: var(--fs-500);
	line-height: var(--lh-snug);
	color: var(--ink);
}

.case__quote p.case__quote-gloss {
	margin-block-start: var(--sp-2);
	font-size: var(--fs-300);
	color: var(--ink-soft);
}

.case__quote cite {
	display: block;
	margin-block-start: var(--sp-3);
	font-family: var(--ff-display);
	font-size: var(--fs-200);
	font-style: normal;
	color: var(--ink-soft);
}

/* -- list --------------------------------------------------------------- */

.case__list {
	margin-block: 0 var(--sp-6);
	padding-inline-start: var(--sp-5);
	list-style: none;
	font-size: var(--fs-400);
	line-height: var(--lh);
	color: var(--ink);
}

.case__list li {
	position: relative;
	margin-block-end: var(--sp-3);
}

/* Drawn, not a bullet glyph: the marker picks up the project accent the same
   way the stitching does. */
.case__list li::before {
	content: "";
	position: absolute;
	inset-inline-start: -1rem;
	inset-block-start: 0.62em;
	width: 0.45rem;
	height: 0.45rem;
	border-radius: 50%;
	background: var(--accent);
}

/* An inline figure in the main column.

   No frame, no shadow, no radius. Several of these images are cut-out PNGs on
   transparency (the wardrobe renders in particular), and a box-shadow on a
   transparent image draws a rectangle around nothing — the drawing ends up
   sitting inside a visible grey card it was never meant to have. The image is
   the object; the paper behind it is already the frame.

   Bounded by height rather than width, because the constraint that actually
   bites is vertical. closet-Photoroom.png is 732×1280: at `width: 100%` of the
   42rem measure it rendered 1175px tall and ate a whole screen. A single
   height cap sizes tall and wide images sensibly from one rule, with no
   per-image number to keep in sync with the artwork.

   The cap is expressed as a *width* derived from the aspect ratio, rather
   than as `width: auto; max-height`. Those two say the same thing about a
   decoded image and completely different things about one that has not
   arrived yet: `auto` has no natural width to shrink-wrap, so the figure is
   0×0 until the bytes land and the page jolts as the reader scrolls. --fig-ar
   is known from the data before the first request goes out. */
.case__figure {
	display: grid;
	justify-items: center;
	margin-block: var(--sp-6) var(--sp-8);
}

.case__figure img {
	width: min(100%, calc(var(--fig-h, 26rem) * var(--fig-ar, 1)));
	aspect-ratio: var(--fig-ar, auto);
}

.case__figure figcaption {
	margin-block-start: var(--sp-3);
	font-size: var(--fs-200);
	color: var(--ink-soft);
	text-align: center;
}

/* -- outbound link ----------------------------------------------------- */

.case__link {
	margin-block: var(--sp-4) var(--sp-8);
	font-family: var(--ff-display);
	font-size: var(--fs-400);
	font-weight: 600;
}

.case__link a {
	color: color-mix(in oklab, var(--accent) 72%, #000);
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 3px;
	transition: color var(--dur) var(--ease-out);
}

.case__link a:hover {
	color: var(--ink);
}

/* -- video ------------------------------------------------------------- */

.case__video {
	position: relative;
	width: 100%;
	max-width: 24rem;
	margin: var(--sp-6) auto var(--sp-10);
	padding: var(--sp-3);
	background: var(--page-fill);
	border: 3px solid var(--accent);
	border-radius: var(--r-lg);
	box-shadow: var(--sh-contact), var(--sh-ambient);
}

.case__video-frame {
	position: relative;
	aspect-ratio: var(--ar, 16 / 9);
	overflow: hidden;
	border-radius: var(--r-sm);
	background: var(--slate);
}

.case__video-frame > * {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
}

.case__video-frame img {
	object-fit: cover;
}

.case__play {
	display: grid;
	place-items: center;
	cursor: pointer;
	transition: background var(--dur) var(--ease-out);
}

.case__play::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgb(0 0 0 / 0);
	transition: background var(--dur) var(--ease-out);
}

.case__play:hover::before {
	background: rgb(0 0 0 / 0.25);
}

.case__play svg {
	position: relative;
	width: 4rem;
	height: 4rem;
	transition: scale var(--dur) var(--ease-spring);
}

.case__play:hover svg {
	scale: 1.1;
}

/* --------------------------------------------------------------------------
   5. Gutter polaroids

   Anchoring is by body-block index rather than a pixel `top`, so a caption
   stays beside the paragraph it describes even after the copy is edited.

   These used to be zero-height wrappers with an absolutely positioned figure
   inside, so that a photograph never stretched the row it was anchored to.
   That is exactly what made the GaTewAY page collide: its three paragraphs
   are short and two of its photographs are anchored to consecutive ones, so
   a 300px figure hanging out of a 90px row landed on top of the next figure.
   Out-of-flow content cannot be asked not to overlap.

   So each figure is now a real grid item spanning from its own anchor row to
   the next figure's anchor row *on the same side* — a range the renderer
   computes from the data, never from a measurement. Two figures on one side
   can no longer occupy the same row, at any copy length, so the collision is
   gone by construction rather than by tuning. The cost is that a row stretches
   when the prose beside it is shorter than the photograph, which reads as a
   photo essay breathing rather than as a bug.
   -------------------------------------------------------------------------- */

.gutter {
	display: grid;
	align-content: start;
	grid-row: var(--row-start, auto) / var(--row-end, auto);
}

/* No justify-self here: the gutter must stretch to fill its column. Sizing it
   to its content collapses it to nothing, which left the photographs 67px
   wide inside a 264px gutter. */
.gutter[data-side="left"] {
	grid-column: 1;
	justify-items: end;
	margin-inline-start: calc(var(--spill) * -1);
}

.gutter[data-side="right"] {
	grid-column: 3;
	justify-items: start;
	margin-inline-end: calc(var(--spill) * -1);
}

.gutter > .polaroid {
	width: 100%;
	max-width: 20rem;
	/* Reserved inside the item, so the grid counts the breathing room when it
	   sizes the row range. A margin between two out-of-flow figures would be
	   invisible to the row algorithm and collapse to nothing. */
	margin-block-end: var(--sp-8);
}

/* The print edge: a warm rule in the project's own accent, mixed back towards
   the paper so it stays a drawn line and never becomes a UI border. Two rules
   at two strengths — the outer one edges the mount, the inner one seats the
   photograph into it, which is what a real print in a paper mount looks like
   and what keeps a pale image from bleeding into the mount. */
.polaroid {
	padding: 0.55rem 0.55rem 0;
	background: var(--paper);
	border: 2px solid color-mix(in oklab, var(--accent) 62%, var(--paper));
	border-radius: 5px;
	box-shadow: var(--sh-contact), var(--sh-ambient);
	rotate: var(--rot, 0deg);
	transition: rotate var(--dur) var(--ease-spring),
		scale var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease-out),
		border-color var(--dur) var(--ease-out);
}

.polaroid:hover,
.polaroid:focus-within {
	position: relative;
	z-index: 5;
	rotate: 0deg;
	scale: 1.04;
	border-color: var(--accent);
	box-shadow: var(--shadow-lift);
}

.polaroid img {
	width: 100%;
	border: 1px solid color-mix(in oklab, var(--accent) 34%, var(--paper));
	border-radius: 2px;
}

/* Captions are always visible. In the original they were hover-only
   tooltips, which hid real information ("Heatmap showing users primarily
   interacted with Browse and My Books") from touch and keyboard entirely. */
.polaroid figcaption {
	padding: 0.6rem 0.25rem 0.75rem;
	font-size: var(--fs-100);
	line-height: 1.4;
	text-align: center;
	color: var(--ink-soft);
}

/* Below this width the gutters are too narrow to hold a photograph, so the
   figures come inline instead — which is what the old md:absolute /
   translate-x-10 pair was fumbling towards. */
@media (max-width: 78rem) {
	.case__body {
		grid-template-columns: minmax(0, 1fr);
	}

	/* The two .gutter[data-side] rules above are more specific than a bare
	   `.case__body > *`, so they have to be unset by name — otherwise they keep
	   placing figures in columns 1 and 3, which silently resurrects the
	   three-column grid as implicit tracks and collapses the text column to
	   zero width. */
	.case__body > *,
	.gutter[data-side="left"],
	.gutter[data-side="right"] {
		grid-column: 1;
		grid-row: auto;
	}

	.case__body > .case__p,
	.case__body > .case__h2,
	.case__body > .case__meta,
	.case__body > .case__quote,
	.case__body > .case__list,
	.case__body > .case__link,
	.case__body > .case__figure {
		max-width: var(--measure-col);
		margin-inline: auto;
		width: 100%;
	}

	.gutter,
	.gutter[data-side="left"],
	.gutter[data-side="right"] {
		justify-self: center;
		justify-items: center;
		/* The overhang has to be unset by name too: a negative margin left
		   over from the three-column layout would pull a centred figure off
		   the side of the sheet. */
		margin-inline: 0;
		margin-block: var(--sp-6) var(--sp-8);
	}

	/* Straightened, and not for taste. A rotated rectangle is bulkier than its
	   own box — each corner swings out by roughly half its height times the
	   sine of the angle — so a 500px-tall print tilted 6° needs about 50px
	   more width than it claims. In the gutters there is margin outside the
	   sheet to absorb that. Here the photograph is already as wide as the
	   column, so the overhang has nowhere to go and leaves the page scrolling
	   sideways by a few pixels. The hover state straightens these anyway. */
	.gutter > .polaroid {
		width: min(20rem, 100%);
		margin-block-end: 0;
		rotate: 0deg;
	}
}

/* --------------------------------------------------------------------------
   6. Zoom affordance
   The button itself, and the lightbox it opens, are in css/lightbox.css —
   shared with the full-bleed case studies. Only the hint that belongs to this
   page's own figures is here.

   The polaroid already lifts as a whole on hover (via :focus-within, so the
   keyboard gets the same lift), so only the bare inline figures need a hint
   of their own.
   -------------------------------------------------------------------------- */

.case__figure .zoom:hover img {
	scale: 1.02;
}

/* --------------------------------------------------------------------------
   7. Loading and not-found states
   -------------------------------------------------------------------------- */

body[data-loading] .case__body::before {
	content: "brewing…";
	display: block;
	grid-column: 2;
	font-family: var(--ff-display);
	color: var(--ink-faint);
	text-align: center;
}

.notfound {
	max-width: 34rem;
	margin-inline: auto;
	text-align: center;
}

.notfound__list {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: var(--sp-2);
	margin-block-start: var(--sp-6);
}

/* --------------------------------------------------------------------------
   8. Page footer
   -------------------------------------------------------------------------- */

.case-foot {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--sp-4);
	max-width: var(--sheet);
	margin: var(--sp-10) auto 0;
	font-family: var(--ff-display);
	font-size: var(--fs-200);
	color: color-mix(in oklab, var(--ink) 62%, var(--page-fill));
}

.case-foot a {
	font-weight: 600;
	transition: color var(--dur) var(--ease-out);
}

.case-foot a:hover {
	color: var(--ink);
}
