/*
 * Tarnwick Coffee Roasters — a one-page project in live 3D (tickets/SC-13.md).
 *
 * Layers of the pinned stage, back to front:
 *   .field     z0  a field of espresso and the name: what is here without WebGL
 *   #gl        z1  the roastery and the things in it; the name and the phrase are
 *                  painted on its wall, the floods are its light
 *   .scrim     z2  the lens, darker to its edges, under the words
 *   .dive      z3  the colour of the crema, while the camera is inside it
 *   .bar …     z4  the interface, which stands still: the captions of act 1, the callouts
 *                  of act 2, the line and the button of act 4
 * After the stage, in the flow of the page: .foot.
 * The interface is cream everywhere: the room is dark where its words stand.
 *
 * Brand colours: site/src/variants/pavilion/concepts/Site.module.css (coffee) and
 * tickets/SC-13.md — terracotta, the cream of a paper bag, espresso.
 */

:root {
  /* The brand: terracotta #c4532d, the cream of a paper bag #f3e3cf, espresso #2a1a12 — written out
     where they are used, so a checker of contrast reads them. */

  --ease-camera: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-text: cubic-bezier(0.16, 1, 0.3, 1);
  --gutter: clamp(16px, 2.6vw, 40px);

  /* The roaster's own pair. Bitter — a slab, the type of a stamp on a paper bag, the one on the
     sign and the labels — for everything large: the names of the roasts, the words of the chain,
     the line of the last act, the name in the bar and in the footer. Source Sans 3 for everything
     small. The studio's faces (Unbounded, Onest) are in the studio's lime corner and nowhere else. */
  --face-display: "Bitter", Georgia, "Times New Roman", serif;
  --face-brand: "Bitter", Georgia, "Times New Roman", serif;
  --face-text: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --face-studio-display: "Unbounded", "Arial Black", Arial, sans-serif;
  --face-studio-text: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: #2a1a12;
  color: #f3e3cf;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  color: #f3e3cf;
  font-family: var(--face-text);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior-y: none;
}

p,
h1,
h2,
h3,
ol,
ul {
  margin: 0;
  padding: 0;
}

/* ——— The pinned scene ——— */

/* 6.3 screens of scroll for the four acts, and the screen the stage itself takes. */
.scene {
  position: relative;
  height: 730vh;
}

.stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  /* What the cream words stand on, whatever is or is not drawn over it. */
  background-color: #2a1a12;
  color: #f3e3cf;
}

/* ——— z0: without WebGL ——— */

.field {
  position: absolute;
  inset: 0;
  background-color: #2a1a12;
  background-image: radial-gradient(120% 88% at 50% 44%, #3b261b 0%, #2a1a12 48%, #1b100a 100%);
}

.word {
  position: absolute;
  left: 0;
  right: 0;
  top: 46%;
  transform: translate3d(0, -50%, 0);
  color: #c4532d;
  font-family: var(--face-brand);
  font-size: var(--word-size, 15vw);
  font-weight: 900;
  line-height: 0.8;
  letter-spacing: -0.035em;
  text-align: center;
  white-space: nowrap;
  user-select: none;
  -webkit-user-select: none;
}

/* Act 3 is painted on the wall of the scene; its words are here for a reader that does not see it. */
.phrase-plain {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  font-family: var(--face-display);
  font-size: clamp(30px, 3.3vw, 54px);
  font-weight: 900;
  line-height: 1.05;
}

/* ——— z1: the roastery ——— */

#gl {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 900ms var(--ease-camera);
}

#gl.is-ready {
  opacity: 1;
}

/* ——— z2: the lens ——— */

/* Darker where the words stand: along the top and the foot, and at the two sides. */
.scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to bottom, rgb(20 11 7 / 0.62), rgb(20 11 7 / 0) 17%),
    linear-gradient(to top, rgb(20 11 7 / 0.74), rgb(20 11 7 / 0) 36%),
    linear-gradient(to right, rgb(20 11 7 / 0.5), rgb(20 11 7 / 0) 32%),
    linear-gradient(to left, rgb(20 11 7 / 0.44), rgb(20 11 7 / 0) 30%);
}

/* ——— z3: inside the crema ——— */

.dive {
  position: absolute;
  inset: 0;
  background-color: #c4532d;
  opacity: var(--dive, 0);
  pointer-events: none;
}

/* ——— The interface is cream: the room is dark where it stands ——— */

[data-ui] {
  --ui: #f3e3cf;
  --ui-dim: rgb(243 227 207 / 0.86);
  --ui-line: rgb(243 227 207 / 0.5);
  color: #f3e3cf;
  /* A hard edge under the letters, no glow: a blurred shadow is drawn anew by Safari every time
     the words change or a line moves near them, and that cost whole frames. The dark the words
     need is in the lens (.scrim) and under the callouts (.callout::before). */
  text-shadow: 0 1px 0 rgb(20 11 7 / 0.42);
}

/* ——— z4: the interface ——— */

.bar {
  position: absolute;
  top: var(--gutter);
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--face-brand);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  flex: none;
  width: 28px;
  height: 28px;
}

.brand-disc {
  fill: #c4532d;
}

.brand-water {
  fill: none;
  stroke: #2a1a12;
  stroke-width: 1.8;
}

.bar-note {
  color: var(--ui-dim);
}

/* The captions share one cell; one is shown at a time. */
.captions {
  position: absolute;
  left: var(--gutter);
  bottom: calc(var(--gutter) + 4px);
  display: grid;
  width: min(30vw, 420px);
}

.caption {
  grid-area: 1 / 1;
  align-self: end;
}

.title {
  font-family: var(--face-display);
  font-size: clamp(30px, 3.3vw, 54px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.04;
}

.notes {
  margin-top: 12px;
  font-size: clamp(16px, 1.3vw, 19px);
  font-weight: 500;
  line-height: 1.36;
}

/* A line comes up from under a mask and leaves the way it came. */
.line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.16em;
  margin-bottom: -0.16em;
}

.line > span {
  display: block;
  transform: translate3d(0, 122%, 0);
  transition: transform 320ms var(--ease-camera);
}

.caption.is-on .line > span,
.detail.is-on .line > span,
.final.is-on .line > span {
  transform: none;
  transition: transform 700ms var(--ease-text) calc(var(--i, 0) * 70ms + 160ms);
}

/* The pointer of the roasts: three dots, light to dark, as on the roaster's own roast scale. */
.index {
  position: absolute;
  right: calc(var(--gutter) - 14px);
  top: 50%;
  transform: translateY(-50%);
  transition:
    opacity 420ms var(--ease-camera),
    visibility 0s linear 0s,
    color 420ms var(--ease-camera);
}

.stage:not([data-act="0"]) .index,
.stage:not([data-act="0"]) .captions {
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 420ms var(--ease-camera),
    visibility 0s linear 420ms;
}

.dots {
  display: flex;
  flex-direction: column;
  list-style: none;
}

.dots button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}

.dots i {
  display: block;
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  transition:
    transform 500ms var(--ease-text),
    background-color 300ms linear;
}

.dots button:hover i,
.dots button:focus-visible i {
  transform: scale(1.25);
}

.dots button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: -6px;
  border-radius: 50%;
}

.stage[data-state="1"] .dots li:nth-child(1) i,
.stage[data-state="2"] .dots li:nth-child(2) i,
.stage[data-state="3"] .dots li:nth-child(3) i {
  background-color: currentColor;
  transform: scale(1.7);
}

.hint {
  position: absolute;
  right: var(--gutter);
  bottom: calc(var(--gutter) + 4px);
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ui-dim);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  transition:
    opacity 420ms var(--ease-camera),
    color 420ms var(--ease-camera);
}

.hint i {
  display: block;
  width: 1px;
  height: 34px;
  background-color: currentColor;
}

.stage.is-moving .hint {
  opacity: 0;
}

/* ——— Act 2: the chain ——— */

.detail,
.final {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.leader path {
  fill: none;
  stroke: var(--ui);
  stroke-width: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 300ms var(--ease-camera);
}

.leader .dot {
  fill: var(--ui);
  opacity: 0;
  transition: opacity 200ms linear;
}

.leader .ring {
  fill: none;
  stroke: var(--ui);
  stroke-width: 1;
  opacity: 0;
  transition: opacity 200ms linear;
}

.detail.is-on .leader path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 700ms var(--ease-text) 140ms;
}

.detail.is-on .leader .dot {
  opacity: 1;
  transition: opacity 240ms linear 520ms;
}

.detail.is-on .leader .ring {
  opacity: 0.5;
  transition: opacity 240ms linear 620ms;
}

.callout {
  position: absolute;
  left: var(--gutter);
  top: 30%;
  width: min(27vw, 400px);
  isolation: isolate;
}

/* Under the words of a callout the lens is a little darker: one soft plate, not a glow round every letter. */
.callout::before {
  content: "";
  position: absolute;
  inset: -46% -30%;
  z-index: -1;
  background-image: radial-gradient(closest-side, rgb(20 11 7 / 0.46), rgb(20 11 7 / 0));
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms linear;
}

.detail.is-on .callout::before {
  opacity: 1;
  transition: opacity 600ms linear 120ms;
}

.detail[data-n="1"] .callout {
  left: auto;
  right: var(--gutter);
  top: 40%;
  text-align: right;
}

.detail[data-n="1"] .callout-word {
  margin-left: auto;
}

/* Three words in one row: the middle callout is wider and its word a size smaller. */
.detail[data-n="1"] .callout {
  width: min(38vw, 560px);
}

.detail[data-n="1"] .callout-word {
  font-size: clamp(30px, 3.5vw, 58px);
  white-space: nowrap;
}

.detail[data-n="1"] .callout-text {
  max-width: 30ch;
  margin-left: auto;
}

.detail[data-n="2"] .callout {
  top: 56%;
}

/* The saucer comes close on the right: the lines stay short of it. */
.detail[data-n="2"] .callout-text {
  max-width: 31ch;
}

.callout-word {
  width: -webkit-fit-content;
  width: fit-content;
  font-family: var(--face-display);
  font-size: clamp(34px, 4.2vw, 68px);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.02;
}

.callout-text {
  margin-top: 12px;
  color: var(--ui-dim);
  font-size: clamp(16px, 1.35vw, 20px);
  font-weight: 500;
  line-height: 1.4;
}

/* ——— Act 4: the three together ——— */

.final-body {
  position: absolute;
  left: var(--gutter);
  top: 50%;
  width: min(48vw, 720px);
  transform: translate3d(0, -50%, 0);
}

.final-title {
  font-family: var(--face-display);
  font-size: clamp(3rem, 5.4vw, 6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* The button: a capsule with its arrow in a round — espresso on the field, the cream of the bag. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  height: 58px;
  margin-top: clamp(24px, 4vh, 44px);
  padding: 6px 6px 6px 26px;
  border-radius: 999px;
  background-color: #2a1a12;
  color: #f3e3cf;
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  transition:
    opacity 240ms linear,
    transform 320ms var(--ease-camera),
    background-color 180ms linear;
}

.final.is-on .pill {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition:
    opacity 420ms linear 440ms,
    transform 700ms var(--ease-text) 440ms,
    background-color 180ms linear;
}

.pill:hover {
  background-color: #1b100a;
}

.pill:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.pill-round {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: #f3e3cf;
  color: #2a1a12;
  transition: transform 180ms var(--ease-camera);
}

.pill-round svg,
.studio svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 180ms var(--ease-camera);
}

.pill:hover .pill-round,
.pill:focus-visible .pill-round {
  transform: scale(1.06);
}

.pill:hover .pill-round svg,
.pill:focus-visible .pill-round svg {
  transform: rotate(45deg);
}

/* The disc of the roaster — its price tag — a little askew: where shipping becomes free. */
.seal {
  position: absolute;
  left: 37.5%;
  top: 14%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: clamp(112px, 9.6vw, 142px);
  aspect-ratio: 1;
  padding: 14px;
  border-radius: 50%;
  background-color: #f3e3cf;
  color: #2a1a12;
  text-align: center;
  opacity: 0;
  transform: rotate(-24deg) scale(0.6);
  transition:
    opacity 200ms linear,
    transform 320ms var(--ease-camera);
}

.final.is-on .seal {
  opacity: 1;
  transform: rotate(-9deg);
  transition:
    opacity 240ms linear 620ms,
    transform 800ms var(--ease-text) 620ms;
}

.seal b {
  font-family: var(--face-display);
  font-size: clamp(30px, 2.9vw, 42px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.seal span {
  max-width: 9ch;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.12;
}

/*
 * ——— The footer: the roaster's own paper on kraft ———
 *
 * Two things lie on a sheet of kraft: the tag that hangs on a bag (cream card, a hole for
 * the string) and the label on the parcel (white paper). Both are ruled like a form: a
 * firm line round every fact. The studio's lime corner is the one thing that is the same
 * on every page of the studio.
 */

.foot {
  --rule: 1.5px solid #2a1a12;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(22px, 3.2vw, 48px);
  padding: clamp(48px, 9vh, 92px) var(--gutter) clamp(104px, 15vh, 150px);
  /* Kraft: the photographed paper of the bag (textures/paper.webp), dyed the colour of kraft. */
  background-color: #c6a57a;
  background-image: url("textures/paper.webp");
  background-size: 720px;
  background-blend-mode: multiply;
  color: #2a1a12;
}

.tag,
.parcel {
  position: relative;
  display: grid;
  border: var(--rule);
}

/* The tag: a cream card, a corner cut where the string goes through. */
.tag {
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  border-radius: 4px;
  /* The card of the tag: the same paper, in its own cream. */
  background-color: #f6e9d6;
  background-image: url("textures/paper.webp");
  background-size: 560px;
  background-position: 30% 40%;
  background-blend-mode: multiply;
  transform: rotate(-0.7deg);
}

.tag-hole {
  position: absolute;
  left: 18px;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  border: var(--rule);
  border-radius: 50%;
  background-color: #c6a57a;
}

.tag-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.4vw, 20px);
  padding: 20px 20px 20px 58px;
  border-bottom: var(--rule);
}

.foot-mark {
  flex: none;
  width: clamp(44px, 4.6vw, 72px);
  height: clamp(44px, 4.6vw, 72px);
}

.foot-name {
  font-family: var(--face-brand);
  font-size: clamp(1.75rem, 3.4vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1;
}

.foot-name span {
  display: block;
}

.foot-name span:last-child {
  margin-top: 6px;
  font-family: var(--face-text);
  font-size: clamp(15px, 1.25vw, 18px);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.2;
}

.box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px 18px;
  font-size: 16px;
  line-height: 1.35;
}

.box b,
.box strong {
  font-family: var(--face-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

/* The day: said in two lines, the day itself in the brand's terracotta, deepened for the paper. */
.box-day {
  justify-content: center;
  font-size: clamp(16px, 1.3vw, 19px);
  font-weight: 500;
}

.box-day b {
  color: #a8431f;
  font-size: clamp(1.6rem, 2.8vw, 2.8rem);
}

.tag .box-day {
  border-left: var(--rule);
  border-bottom: var(--rule);
}

.roasts {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  list-style: none;
}

.roasts li + li {
  border-left: var(--rule);
}

.roasts .box {
  padding: 20px 20px 22px;
}

.roasts b {
  font-size: clamp(1.3rem, 1.75vw, 1.7rem);
}

.roasts strong {
  margin-top: 10px;
  font-size: clamp(1.6rem, 2.5vw, 2.5rem);
}

/* The roast scale of the label: three dots, as many filled as the roast is dark. */
.scale {
  display: block;
  width: 46px;
  height: 12px;
  margin-top: 8px;
  background-image:
    radial-gradient(circle at 6px 6px, #2a1a12 0 4.4px, rgb(42 26 18 / 0) 5px),
    radial-gradient(circle at 23px 6px, rgb(42 26 18 / 0) 0 3px, #2a1a12 3.4px 4.6px, rgb(42 26 18 / 0) 5px),
    radial-gradient(circle at 40px 6px, rgb(42 26 18 / 0) 0 3px, #2a1a12 3.4px 4.6px, rgb(42 26 18 / 0) 5px);
}

.scale[data-level="2"] {
  background-image:
    radial-gradient(circle at 6px 6px, #2a1a12 0 4.4px, rgb(42 26 18 / 0) 5px),
    radial-gradient(circle at 23px 6px, #2a1a12 0 4.4px, rgb(42 26 18 / 0) 5px),
    radial-gradient(circle at 40px 6px, rgb(42 26 18 / 0) 0 3px, #2a1a12 3.4px 4.6px, rgb(42 26 18 / 0) 5px);
}

.scale[data-level="3"] {
  background-image:
    radial-gradient(circle at 6px 6px, #2a1a12 0 4.4px, rgb(42 26 18 / 0) 5px),
    radial-gradient(circle at 23px 6px, #2a1a12 0 4.4px, rgb(42 26 18 / 0) 5px),
    radial-gradient(circle at 40px 6px, #2a1a12 0 4.4px, rgb(42 26 18 / 0) 5px);
}

/* The label on the parcel: white paper, a little askew, the roaster's postmark over its corner. */
.parcel {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  margin-top: clamp(18px, 5vh, 52px);
  /* The label: the same paper again, bleached. */
  background-color: #fffdf8;
  background-image: url("textures/paper.webp");
  background-size: 600px;
  background-position: 70% 10%;
  background-blend-mode: multiply;
  transform: rotate(1deg);
}

.parcel .box-day {
  grid-column: 1 / -1;
  padding-right: 110px;
  border-bottom: var(--rule);
}

.box-where b {
  font-size: clamp(1.25rem, 1.5vw, 1.45rem);
}

.box-free {
  border-left: var(--rule);
}

.box-free b {
  font-size: clamp(1.6rem, 2.5vw, 2.5rem);
}

.postmark {
  position: absolute;
  right: 12px;
  top: -26px;
  width: clamp(76px, 7vw, 100px);
  height: auto;
  transform: rotate(-14deg);
}

/* The studio signs in its own colours, not the brand's: volt and ink, in the corner. */
.studio {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px var(--gutter) 18px 26px;
  border-top-left-radius: 28px;
  background-color: #d6fa50;
  color: #0a0a0a;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1;
  text-decoration: none;
  transition: background-color 180ms linear;
}

.studio-by {
  font-family: var(--face-studio-text);
  text-transform: uppercase;
}

.studio-name {
  font-family: var(--face-studio-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.studio:hover,
.studio:focus-visible {
  background-color: #b8dc2c;
}

.studio:focus-visible {
  outline: 2px solid #f3e3cf;
  outline-offset: 3px;
}

.studio svg {
  width: 16px;
  height: 16px;
}

.studio:hover svg,
.studio:focus-visible svg {
  transform: rotate(45deg);
}

/* ——— A tall screen: the word in two halves, over the bag and under it ——— */

@media (max-aspect-ratio: 4 / 5) {
  .scene {
    height: 700vh;
    height: 700svh;
  }

  .word {
    top: 12%;
    bottom: 25%;
    left: 5%;
    right: 5%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transform: none;
    font-size: var(--word-size, 30vw);
  }

  .word span:first-child {
    text-align: left;
  }

  .word span:last-child {
    text-align: right;
  }

  .bar-note {
    display: none;
  }

  .brand {
    font-size: 20px;
  }

  .captions {
    width: min(78vw, 320px);
    bottom: calc(var(--gutter) + 6px + env(safe-area-inset-bottom, 0px));
  }

  .title {
    font-size: 30px;
  }

  .notes {
    margin-top: 8px;
    font-size: 16px;
  }

  /* Under the bar: the name of the roaster takes the whole first line. */
  .index {
    top: calc(var(--gutter) + 34px);
    right: 4px;
    transform: none;
  }

  .dots {
    flex-direction: row;
  }

  .hint {
    bottom: calc(var(--gutter) + 6px + env(safe-area-inset-bottom, 0px));
  }

  .hint span {
    display: none;
  }

  /* The callouts stand at the foot of the screen, one at a time. */
  .callout,
  .detail[data-n="1"] .callout,
  .detail[data-n="2"] .callout {
    left: var(--gutter);
    right: var(--gutter);
    top: auto;
    bottom: calc(var(--gutter) + 6px + env(safe-area-inset-bottom, 0px));
    width: auto;
    text-align: left;
  }

  .callout-word,
  .detail[data-n="1"] .callout-word {
    margin-left: 0;
    font-size: 34px;
  }

  .callout::before {
    inset: -40% -12% -30%;
  }

  .callout-text,
  .detail[data-n="1"] .callout-text,
  .detail[data-n="2"] .callout-text {
    margin-top: 8px;
    margin-left: 0;
    max-width: 32ch;
    font-size: 16px;
  }

  .final-body {
    top: auto;
    bottom: calc(var(--gutter) + 10px + env(safe-area-inset-bottom, 0px));
    width: auto;
    transform: none;
  }

  .final-title {
    font-size: clamp(2.4rem, 11.4vw, 3.2rem);
  }

  .pill {
    height: 54px;
    margin-top: 18px;
  }

  .pill-round {
    width: 42px;
    height: 42px;
  }

  .seal {
    left: auto;
    right: var(--gutter);
    top: 9%;
    width: 104px;
    padding: 12px;
  }

  .seal b {
    font-size: 32px;
  }

  .seal span {
    font-size: 14px;
  }

  .foot {
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: 96px;
  }

  .tag,
  .parcel {
    transform: none;
  }

  .tag {
    grid-template-columns: minmax(0, 1fr);
  }

  .tag-head {
    padding-left: 54px;
  }

  .tag .box-day {
    border-left: 0;
  }

  .roasts {
    grid-template-columns: minmax(0, 1fr);
  }

  .roasts li {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 12px;
  }

  .roasts li + li {
    border-left: 0;
    border-top: var(--rule);
  }

  .roasts b,
  .roasts span,
  .scale {
    grid-column: 1;
  }

  .roasts strong {
    grid-column: 2;
    grid-row: 1 / span 3;
    margin-top: 0;
  }

  .parcel {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 26px;
  }

  .box-free {
    border-left: 0;
    border-top: var(--rule);
  }
}

/*
 * ——— Reduced motion (or ?still): the acts become plain sections ———
 *
 * No pinned stage and no long scroll: the script draws one frame of each act
 * and sets it in a section of its own (.still) — the field, the picture of
 * the things, the words — one under another.
 */

.rm .scene {
  height: auto;
}

.rm .stage {
  position: relative;
}

.rm .stage[hidden] {
  display: none;
}

.still {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
}

.still-shot {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* A still carries its own lens. */
.still::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to bottom, rgb(20 11 7 / 0.62), rgb(20 11 7 / 0) 17%),
    linear-gradient(to top, rgb(20 11 7 / 0.74), rgb(20 11 7 / 0) 36%),
    linear-gradient(to right, rgb(20 11 7 / 0.5), rgb(20 11 7 / 0) 32%),
    linear-gradient(to left, rgb(20 11 7 / 0.44), rgb(20 11 7 / 0) 30%);
}

.still > [data-ui] {
  z-index: 1;
}

.rm .hint,
.rm .index,
.rm .dive,
.rm .scrim {
  display: none;
}

.rm #gl,
.rm [data-ui],
.rm .line > span,
.rm .leader path,
.rm .leader circle,
.rm .pill,
.rm .seal {
  transition: none !important;
}

.rm .line > span {
  transform: none;
}

.rm .caption:not(.is-on) {
  display: none;
}

.rm .leader path {
  stroke-dashoffset: 0;
}

.rm .leader .dot {
  opacity: 1;
}

.rm .leader .ring {
  opacity: 0.5;
}

.rm .pill {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.rm .seal {
  opacity: 1;
  transform: rotate(-9deg);
}

/* Before the script has run, or without it. */
@media (prefers-reduced-motion: reduce) {
  .scene {
    height: auto;
  }

  .stage {
    position: relative;
  }

  #gl,
  [data-ui],
  .line > span {
    transition: none;
  }
}

/* ——— No WebGL: the field, the word and the words stay ——— */

.no-gl #gl,
.no-gl .dive,
.no-gl .scrim {
  display: none;
}

.no-gl .phrase-plain {
  position: absolute;
  left: var(--gutter);
  top: 22%;
  width: auto;
  height: auto;
  clip-path: none;
  color: #f3e3cf;
}

/* ——— Checks ——— */

.hud {
  position: fixed;
  left: 8px;
  top: 64px;
  z-index: 20;
  margin: 0;
  padding: 8px 10px;
  border-radius: 4px;
  background: rgb(0 0 0 / 0.82);
  color: #b6ff7a;
  font: 11px/1.45 ui-monospace, Menlo, monospace;
  white-space: pre;
  pointer-events: none;
}

.labels {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  overflow: auto;
  background: #222;
}

.labels canvas {
  display: block;
  width: auto;
  height: 92vh;
}
