/*
 * Kettlewren, «from leaf to cup» — a page played from footage, and a page that travels
 * (tickets/SC-48.md; the footage, the words, the faces and the colours are those of
 * ../prototype-film, tickets/SC-22.md).
 *
 * This sheet is written in two halves.
 *
 * First, the page as it is without the script, or where motion is not wanted: every shot
 * is a screen of its own — its still, its words at the foot of it — and between the acts
 * lie the blocks of the page: how a tea is brewed, the phrase of the house.
 *
 * Then (html.live, set before the first paint when the film will play) the page becomes
 * four acts with real scroll between them:
 *   .act        as tall as its scene is pinned for, plus one screen (--pin, set by the script)
 *   .stage      the scene of the act: a sticky screen. The page brings it in from below,
 *               holds it and carries it away upwards
 *     .frame      the picture: the first frame of the act (.poster) until the film is
 *                 there, then the footage (.screen, a canvas of its own in every act).
 *                 In the second act it is a round window (clip-path, set by the script) —
 *                 the window of the tea house — that opens on the shelf
 *     .leaders    the lines from a tag to its thing
 *   .cue        the tags of an act lie on the page, not on the scene: they come from
 *               below and leave upwards with the scroll while the picture stands pinned
 *   .block      what lies between two acts and scrolls as any page does: three large
 *               figures on the green of the dry leaf, «Six ways.» on the night
 *   .bar        the name and the stations of the leaf, paper labels fixed over all of it
 * After the film, in the flow of the page: .foot — the card from the tin.
 *
 * Brand colours (tickets/SC-22.md): night #12211b, tea gold #c9a227, paper #e8e2d0.
 */

:root {
  --kw-night: #12211b;
  --kw-deep: #0b1511;
  --kw-gold: #c9a227;
  --kw-gold-ink: #7a5f08;
  --kw-paper: #e8e2d0;
  --kw-iron: #2b2b2d;

  --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 house's own pair: Shippori Mincho — the face of its sign and its labels — for
     every large word, Karla for everything small. The studio's Onest is only in the lime corner. */
  --face-display: "Shippori Mincho", "Hiragino Mincho ProN", Georgia, "Times New Roman", serif;
  --face-text: Karla, system-ui, -apple-system, "Segoe UI", sans-serif;
  --face-studio: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

html {
  background: var(--kw-night);
  color: var(--kw-paper);
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  margin: 0;
  color: var(--kw-paper);
  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;
}

::selection {
  background-color: var(--kw-gold);
  color: var(--kw-night);
}

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

ol,
ul {
  list-style: none;
}

/*
 * ——— The page without the film: seven stills, their words, and the blocks between ———
 */

.stage,
.way,
.hint {
  display: none;
}

.bar {
  position: absolute;
  top: var(--gutter);
  left: var(--gutter);
  right: var(--gutter);
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

/* The name: a paper label in the corner, as on a tin. It reads on any hour of the day. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px 10px 12px;
  border-radius: 3px;
  background: var(--kw-paper) url("textures/paper.webp") center / 420px auto;
  box-shadow: 0 1px 0 rgb(11 21 17 / 0.35);
  color: var(--kw-night);
  font-family: var(--face-display);
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}

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

.brand-mark circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.brand-mark path {
  fill: var(--kw-gold);
}

/* A shot: its still fills a screen, its words stand at the foot of it. */
.shot {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100vh;
  min-height: 100svh;
  padding: 96px var(--gutter) clamp(28px, 6vh, 64px);
  overflow: hidden;
  isolation: isolate;
}

.still {
  position: absolute;
  inset: 0;
  z-index: -2;
  display: block;
}

.still img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Under the words set straight on a still (the first line, the phrase, the last line) it is darker. */
.shot[data-shot="C1"]::after,
.shot[data-shot="C6"]::after,
.shot[data-shot="C7"]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(to top, rgb(11 21 17 / 0.82), rgb(11 21 17 / 0.5) 26%, rgb(11 21 17 / 0) 56%);
  pointer-events: none;
}

.words {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 14px;
}

.six {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
}

.line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.16em;
  margin-bottom: -0.16em;
}

.line > span {
  display: block;
}

/* The line of the first screen. */
.cue-opening,
.cue-final {
  flex: 1 0 100%;
}

.title {
  font-family: var(--face-display);
  font-size: clamp(40px, 5.4vw, 86px);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.04;
}

/*
 * A tag: the word of a thing, on paper. Night ink on washi, a soft shade under it — it
 * lies over the picture as a label lies on a tin.
 */
.tag {
  position: relative;
  width: -webkit-fit-content;
  width: fit-content;
  padding: 11px 20px 13px;
  border-radius: 3px;
  background: var(--kw-paper) url("textures/paper.webp") center / 560px auto;
  box-shadow:
    0 1px 0 rgb(11 21 17 / 0.4),
    0 14px 30px rgb(11 21 17 / 0.28);
  color: var(--kw-night);
  font-family: var(--face-display);
  font-size: clamp(30px, 3.5vw, 54px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.08;
  white-space: nowrap;
}

/* The six names over the six tins: small tags, one to a tin. */
.tag-small {
  padding: 7px 13px 8px;
  font-size: clamp(20px, 1.5vw, 23px);
  box-shadow:
    0 1px 0 rgb(11 21 17 / 0.4),
    0 8px 18px rgb(11 21 17 / 0.26);
}

/* A tea at its bowl: its name, and under it how it is brewed. */
.tag-tea {
  padding: 12px 20px 14px;
}

.tag-word {
  display: block;
  font-size: clamp(30px, 3.1vw, 48px);
  font-weight: 700;
}

.tag-note {
  display: block;
  margin-top: 6px;
  color: #33423b;
  font-family: var(--face-text);
  font-size: clamp(16px, 1.25vw, 18px);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.3;
}

.final-title {
  font-family: var(--face-display);
  font-size: clamp(3rem, 6.4vw, 6.5rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.02;
}

/* The button: a capsule of tea gold, its arrow in a round of night. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  height: 56px;
  margin-top: clamp(20px, 3.2vh, 34px);
  padding: 6px 6px 6px 24px;
  border-radius: 999px;
  background-color: var(--kw-gold);
  color: var(--kw-deep);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 180ms linear;
}

.pill:hover {
  background-color: #dcb53a;
}

.pill:focus-visible {
  outline: 2px solid var(--kw-paper);
  outline-offset: 3px;
}

.pill-round {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--kw-night);
  color: var(--kw-paper);
  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 blocks of the page, between the acts.
 */

.block {
  position: relative;
  overflow: hidden;
  background-color: var(--field);
  color: var(--kw-paper);
}

.block[data-field="tin"] {
  --field: #4f562a;
}

.block[data-field="night"] {
  --field: var(--kw-night);
}

/* How a tea of the house is brewed: three large figures, a word under each. */
.block-brew {
  padding: clamp(44px, 9vh, 96px) var(--gutter) clamp(48px, 10vh, 108px);
}

.brew-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 2.4vw, 40px);
  align-items: start;
}

.brew-facts li {
  padding-top: clamp(14px, 2.4vh, 26px);
  border-top: 2px solid var(--kw-gold);
}

.brew-facts b {
  display: block;
  font-family: var(--face-display);
  font-size: clamp(3.2rem, 9.4vw, 9.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}

.brew-facts span {
  display: block;
  margin-top: clamp(8px, 1.4vh, 16px);
  font-size: clamp(18px, 1.6vw, 24px);
  font-weight: 500;
  line-height: 1.3;
}

/* The phrase of the house. */
.block-phrase {
  padding: clamp(48px, 11vh, 110px) var(--gutter);
}

.phrase {
  font-family: var(--face-display);
  font-size: clamp(54px, 8vw, 120px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 0.98;
}

/* Without the film it is set in one line. */
.phrase .line {
  display: inline-block;
  vertical-align: top;
}

/*
 * ——— The film: the acts, and the page between them ———
 */

.live .bar {
  position: fixed;
  transition: opacity 320ms var(--ease-camera);
}

.live .bar.is-away {
  opacity: 0;
  pointer-events: none;
}

/* An act is as tall as its scene is pinned for, and the screen the scene itself takes. */
.live .act {
  position: relative;
  z-index: 0;
  height: calc((1 + var(--pin, 1)) * 100vh);
  height: calc((1 + var(--pin, 1)) * 100svh);
}

.live .stage {
  position: sticky;
  top: 0;
  z-index: 0;
  display: block;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background-color: var(--night);
}

.live .frame {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background-color: var(--night);
}

.live .poster {
  position: absolute;
  inset: 0;
  display: block;
}

/* Until the script has laid it exactly where the film will lie, the first frame covers its scene. */
.live .poster img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

/* A canvas is shown from its first drawing on: before that the first frame of the act stands there. */
.live .screen {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  visibility: hidden;
}

.live .screen.is-painted {
  visibility: visible;
}

/* A shot is no longer a box: its words lie on the page of its act. */
.live .shot {
  position: static;
  display: block;
  min-height: 0;
  padding: 0;
  overflow: visible;
  isolation: auto;
}

.live .shot::after {
  content: none;
}

.live .still {
  display: none;
}

.live .leaders {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

/*
 * The words of an act. They are set on the page — on the act, which is taller than the
 * screen — so the scroll itself brings them up from below and carries them off at the
 * top, over a picture that stands pinned.
 */
.live .cue {
  position: absolute;
  z-index: 3;
  isolation: isolate;
  pointer-events: none;
  transition:
    color 300ms linear,
    visibility 0s linear 0s;
}

.live .cue:not(.is-on) {
  visibility: hidden;
  transition:
    color 300ms linear,
    visibility 0s linear 340ms;
}

/* A line comes up from under a mask and leaves the way it came. */
.live .line > span {
  transform: translate3d(0, 122%, 0);
  transition: transform 300ms var(--ease-camera);
}

.live .cue.is-on .line > span {
  transform: none;
  transition: transform 640ms var(--ease-text) calc(var(--i, 0) * 70ms + 90ms);
}

/* Under a block of words the picture is one soft plate of the block's own tone: no glow round every letter. */
.live .cue::before {
  content: "";
  position: absolute;
  inset: -58% -34%;
  z-index: -1;
  background-image: radial-gradient(closest-side, var(--plate), rgb(0 0 0 / 0));
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms linear;
}

.live .cue.is-on::before {
  opacity: 1;
  transition: opacity 520ms linear 80ms;
}

/* Over a flood a word takes the flood's ink and has no plate: on one even colour a plate is a smudge. */
.live .cue.is-flat::before {
  opacity: 0;
}

/*
 * A card stands on a flood inside an act: in the middle of the pinned scene (the script
 * moves it into the scene), drifting up as the page goes. On a flood there is nothing to
 * lift the words off.
 */
.live .cue-card {
  left: 50%;
  top: 50%;
  width: -webkit-max-content;
  width: max-content;
  max-width: calc(100vw - 2 * var(--gutter));
  transform: translate3d(-50%, calc(-50% + var(--ty, 0px)), 0);
}

.live .cue-card::before {
  content: none;
}

/*
 * The blocks between the acts scroll as any page does.
 */

.live .block {
  z-index: 1;
}

/*
 * A block after a flood lies over the last of the act before it (--over screens, set by
 * the script from the act's hold). Up there it is clear — the flood itself is the colour —
 * and its words rise over the pinned flood; below the act it paints the same colour on,
 * and flood and block ride away as one page.
 */
.live .block.is-over {
  margin-top: calc(var(--over, 0.2) * -100vh);
  margin-top: calc(var(--over, 0.2) * -100svh);
  background-color: rgb(0 0 0 / 0);
  background-image: linear-gradient(to bottom, rgb(0 0 0 / 0) calc(var(--over, 0.2) * 100vh - 2px), var(--field) calc(var(--over, 0.2) * 100vh - 2px));
  background-image: linear-gradient(to bottom, rgb(0 0 0 / 0) calc(var(--over, 0.2) * 100svh - 2px), var(--field) calc(var(--over, 0.2) * 100svh - 2px));
}


/* The margins round the window are the green of the leaf. */
.live .stage[data-field="leaf"] {
  background-color: #b9c4a3;
}

/* The round window rides in over the green flood as soon as that has shut: the flood and the page of the act are one green. */
.live .act[data-act="tin"] {
  margin-top: -8vh;
  margin-top: -8svh;
}

.live .words,
.live .six {
  display: contents;
}

/* The tags are paper: they need no plate under them. */
.live .cue::before {
  content: none;
}

/* The lines: a thread of tea gold from the tag to its thing, a darker thread under it so the pair reads on mist and on shade alike. */
/*
 * A line that is off is not drawn at all. Its dashes are of no length then, yet WebKit
 * still draws their round caps — a dot was left where every hidden line begins.
 */
.leader {
  visibility: hidden;
  transition: visibility 0s linear 280ms;
}

.leader.is-on {
  visibility: visible;
  transition: visibility 0s linear 0s;
}


.leader path {
  fill: none;
  stroke: var(--kw-gold);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 220ms var(--ease-camera);
}

.leader path.casing {
  stroke: rgb(11 21 17 / 0.62);
  stroke-width: 4.5;
}

.leader .dot {
  fill: var(--kw-gold);
  stroke: rgb(11 21 17 / 0.7);
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 160ms linear;
}

.leader .ring {
  fill: none;
  stroke: var(--kw-paper);
  stroke-width: 1.5;
  opacity: 0;
  transition: opacity 160ms linear;
}

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

.leader.is-on .dot {
  opacity: 1;
  transition: opacity 200ms linear 420ms;
}

.leader.is-on .ring {
  opacity: 0.85;
  transition: opacity 200ms linear 480ms;
}

/* A line comes fast: a tag may be on for a fifth of a second of a quick scroll, and its word must be read. */
.live .line > span {
  transform: translate3d(0, 118%, 0);
  transition: transform 260ms var(--ease-camera);
}

.live .cue.is-on .line > span {
  transform: none;
  transition: transform 480ms var(--ease-text) calc(var(--i, 0) * 60ms + 40ms);
}

/* A tag is unrolled from its edge, and rolled back the way it came. */
.live .tag {
  -webkit-clip-path: inset(-30px 104% -40px -30px);
  clip-path: inset(-30px 104% -40px -30px);
  transition:
    clip-path 240ms var(--ease-camera),
    -webkit-clip-path 240ms var(--ease-camera),
    visibility 0s linear 0s;
}

.live .tag:not(.is-on) {
  transition:
    clip-path 240ms var(--ease-camera),
    -webkit-clip-path 240ms var(--ease-camera),
    visibility 0s linear 320ms;
}

.live .tag.is-on {
  -webkit-clip-path: inset(-30px -30px -40px -30px);
  clip-path: inset(-30px -30px -40px -30px);
  transition:
    clip-path 360ms var(--ease-text),
    -webkit-clip-path 360ms var(--ease-text),
    visibility 0s linear 0s;
}

/*
 * A tag rides: the script lays it on the page (--at, screens from the top of its act) so
 * that it comes on at its line of the screen, and the scroll carries it up from there
 * while its line follows the thing in the pinned picture.
 */
.live .tag {
  top: calc(var(--at, 0.6) * 100vh);
  top: calc(var(--at, 0.6) * 100svh);
  opacity: var(--fade, 1);
  transform: translate3d(0, -50%, 0);
}

/* The first line stands on the morning mist, in the night's ink, and goes up with the page from the first turn of the wheel. */
.live .cue-opening {
  left: var(--gutter);
  top: 19vh;
  top: 19svh;
  color: var(--kw-night);
  opacity: var(--fade, 1);
}

/* Mist is not one tone: under the line it is evened out, softly, with no edge. */
.live .cue-opening::before {
  content: "";
  position: absolute;
  inset: -46% -24% -40% -30%;
  z-index: -1;
  background-image: radial-gradient(closest-side, rgb(240 236 226 / 0.74), rgb(240 236 226 / 0));
  opacity: 1;
}

/* Each tag rides where its frame is quiet, on the side its thing is not. */
.live #cue-house {
  left: 44%;
}

.live #cue-shoot {
  left: 62%;
}

.live #cue-tin {
  left: 7%;
}

.live #cue-iron {
  right: var(--gutter);
}

.live #cue-water {
  left: 6%;
}

.live #cue-leaf {
  left: 6%;
}

.live #cue-name {
  left: 69%;
}

.live #cue-time {
  left: 76%;
}

/*
 * The six names of the shelf: each rides up at its own tin. A name is dim until it
 * crosses the line over the tins; then it is in full ink and a thread ties it to its tin;
 * the next one takes over from it.
 */
.live .six .tag-small {
  left: calc(var(--x) * 1%);
  -webkit-clip-path: none;
  clip-path: none;
  visibility: visible;
  --lit: 0;
  opacity: calc(var(--lit) * var(--fade, 1));
  transform: translate3d(-50%, -50%, 0);
  transition: opacity 220ms linear;
}

.live .six .tag-small .line > span {
  transform: none;
}

.live .six.is-on .tag-small {
  --lit: 0.74;
}

.live .six.is-on .tag-small.is-now {
  --lit: 1;
}

.live #cue-tin-1 { --x: 24.7; }
.live #cue-tin-2 { --x: 35.2; }
.live #cue-tin-3 { --x: 45.7; }
.live #cue-tin-4 { --x: 56.7; }
.live #cue-tin-5 { --x: 68.3; }
.live #cue-tin-6 { --x: 79.8; }

/* The shade: the foot of the shelf goes toward the night while the names ride up through it. */
.live .shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: linear-gradient(to top, rgb(11 21 17 / 0.6), rgb(11 21 17 / 0.3) 24%, rgb(11 21 17 / 0) 44%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms linear;
}

.live .shade.is-on {
  opacity: 1;
}

/* A tea at its bowl: the first three ride over their bowls from the left, the last three under theirs. */
.live #cue-bowl-1 { left: 8%; }
.live #cue-bowl-2 { left: 16%; }
.live #cue-bowl-3 { left: 26%; }
.live #cue-bowl-4 { left: 40%; }
.live #cue-bowl-5 { left: 50%; }
.live #cue-bowl-6 { left: 58%; }

/* The last line rides in from below while the hands take the cup: on the wall the lantern lights, to the right of the kettle — in the night's ink. */
.live .cue-final {
  right: var(--gutter);
  top: calc((var(--pin, 1) + 0.15) * 100vh);
  top: calc((var(--pin, 1) + 0.15) * 100svh);
  width: -webkit-max-content;
  width: max-content;
  color: var(--kw-night);
}

.live .final-title {
  font-size: clamp(3rem, 6vw, 5.6rem);
}

/* On the lit wall the gold capsule would be lost: here it is a capsule of night, its arrow in a round of gold. */
.live .cue-final .pill {
  background-color: var(--kw-night);
  color: var(--kw-paper);
}

.live .cue-final .pill:hover {
  background-color: #1d3329;
}

.live .cue-final .pill-round {
  background-color: var(--kw-gold);
  color: var(--kw-deep);
}

.live .pill {
  opacity: 0;
  transform: translate3d(0, 16px, 0);
  transition:
    opacity 220ms linear,
    transform 300ms var(--ease-camera),
    background-color 180ms linear;
}

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


/* The three figures ride through at three paces: the first a little ahead of the page, the last a little behind. */
.live .block-brew {
  padding-top: 5vh;
  padding-top: 5svh;
  padding-bottom: 20vh;
  padding-bottom: 20svh;
}

.live .brew-facts {
  opacity: 0;
  transition: opacity 360ms linear;
}

.live .block.is-on .brew-facts {
  opacity: 1;
}

.live .brew-facts li {
  transform: translate3d(0, calc((0.5 - var(--p, 0.5)) * (var(--k) - 1) * -150px), 0);
}

/* «Six ways.»: two lines on the night, the second a step to the right; they draw apart a little as the block rides through the screen. */
.live .block-phrase {
  padding: 12vh var(--gutter) 14vh;
  padding: 12svh var(--gutter) 14svh;
}

.live .phrase {
  width: -webkit-max-content;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  font-size: clamp(76px, 15vw, 250px);
  line-height: 0.92;
}

.live .phrase .line {
  display: block;
  opacity: var(--fade, 1);
  transform: translate3d(calc((var(--p, 0.5) - 0.5) * var(--drift, 0vw)), 0, 0);
}

.live .phrase .line:first-child {
  --drift: -10vw;
}

.live .phrase .line + .line {
  --drift: 10vw;
  margin-left: 0.7em;
}

.live .block-phrase .line > span {
  transform: none;
}

/*
 * From leaf to cup: the stations of the story on a paper label. The station on screen is
 * in full ink, and a thread under it fills as its part of the scroll goes by.
 */
.live .way {
  display: block;
  pointer-events: auto;
}

.way ol {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 8px;
  border-radius: 3px;
  background: var(--kw-paper) url("textures/paper.webp") 30% 40% / 420px auto;
  box-shadow: 0 1px 0 rgb(11 21 17 / 0.35);
}

.way button {
  position: relative;
  display: block;
  margin: 0;
  padding: 14px 10px 15px;
  border: 0;
  background: none;
  color: #44524b;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: color 200ms linear;
}

.way button:hover,
.way .is-now button {
  color: var(--kw-night);
}

.way .is-now button {
  font-weight: 700;
}

.way button:focus-visible {
  outline: 2px solid var(--kw-night);
  outline-offset: -4px;
  border-radius: 3px;
}

.way i {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 8px;
  height: 2px;
  overflow: hidden;
  border-radius: 1px;
  background-color: rgb(18 33 27 / 0.2);
}

.way i::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--kw-gold-ink);
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
}

.live .hint {
  position: absolute;
  right: var(--gutter);
  bottom: calc(var(--gutter) + 4px);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 3px;
  background: var(--kw-paper) url("textures/paper.webp") 70% 60% / 420px auto;
  box-shadow: 0 1px 0 rgb(11 21 17 / 0.35);
  color: var(--kw-night);
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  transition: opacity 320ms var(--ease-camera);
}

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

.hint.is-off {
  opacity: 0;
}

/*
 * ——— The footer: the card from the tin ———
 *
 * Every tin has a card in it that says how its tea is brewed. Here it lies on the elm of
 * the table in the light of the lantern: washi, folded once down the middle — the name of
 * the house on one leaf, the six teas with their water and their minutes on the other.
 * (Carried over from the page of SC-18; textures/wood.webp and paper.webp are photographs.)
 */

.foot {
  z-index: 1;
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(48px, 9vh, 88px) var(--gutter) clamp(104px, 15vh, 136px);
  overflow: hidden;
  isolation: isolate;
  background-color: #120c08;
  /* The lantern stands to the left, out of the picture; the table goes dark away from it. */
  background-image:
    radial-gradient(70% 120% at 0% 0%, rgb(255 150 60 / 0.3) 0%, rgb(255 150 60 / 0) 62%),
    linear-gradient(to right, rgb(9 12 9 / 0.62), rgb(9 12 9 / 0.9)),
    url("textures/wood.webp");
  background-size: auto, auto, 920px auto;
  color: var(--kw-night);
}

.card {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  width: min(100%, 1040px);
  border-radius: 2px;
  background: var(--kw-paper) url("textures/paper.webp") center / 760px auto;
  /* It lies on the table: a close dark edge under it, and the wide soft shade of the lantern's light. */
  box-shadow:
    0 1px 1px rgb(0 0 0 / 0.5),
    14px 22px 44px rgb(0 0 0 / 0.5);
  transform: rotate(-1.1deg);
  /* A layer of its own: the card is painted straight and turned by the graphics card. Painted
     turned, its first paint — as the footer nears the screen — was a frame of 70 ms and more
     in Safari's engine. */
  will-change: transform;
}

.card-face {
  display: flex;
  flex-direction: column;
  padding: clamp(28px, 3.4vw, 48px);
  /* The fold: the leaf turns down a little from the crease. */
  background-image: linear-gradient(to right, rgb(18 33 27 / 0) 82%, rgb(18 33 27 / 0.09) 100%);
}

.card-name {
  font-family: var(--face-display);
  font-size: clamp(2.5rem, 4.6vw, 4.25rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}

.card-line {
  margin-top: 14px;
  font-family: var(--face-display);
  font-size: clamp(1.25rem, 1.7vw, 1.5rem);
  font-weight: 500;
  line-height: 1.3;
}

/* The line breaks at its comma, if it must break. */
.card-line span {
  white-space: nowrap;
}

/* The weight, as a stamp in gold ink. */
.card-stamp {
  display: grid;
  place-content: center;
  width: 112px;
  height: 112px;
  margin-top: auto;
  padding: 12px;
  border: 2px solid #8a6c0c;
  border-radius: 50%;
  color: #6f5708;
  text-align: center;
  transform: rotate(-7deg);
}

.card-stamp b {
  font-family: var(--face-display);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.card-stamp span {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
}

.brew {
  width: 100%;
  border-collapse: collapse;
  border-left: 1px solid rgb(18 33 27 / 0.2);
  /* The other side of the fold catches the light. */
  background-image: linear-gradient(to right, rgb(255 255 255 / 0.26) 0%, rgb(255 255 255 / 0) 16%);
  font-variant-numeric: tabular-nums;
}

.brew th,
.brew td {
  padding: 13px 12px;
  border-bottom: 1px dotted rgb(18 33 27 / 0.42);
  font-size: 17px;
  font-weight: 500;
  line-height: 1.2;
  text-align: right;
  white-space: nowrap;
}

.brew thead th {
  padding-top: clamp(22px, 2.8vw, 36px);
  border-bottom: 1px solid rgb(18 33 27 / 0.6);
  font-size: 15px;
  font-weight: 700;
}

.brew th:first-child {
  padding-left: clamp(24px, 3vw, 44px);
  text-align: left;
  white-space: normal;
}

.brew td:last-child,
.brew th:last-child {
  padding-right: clamp(24px, 3vw, 44px);
}

.brew tbody th {
  font-family: var(--face-display);
  font-size: clamp(1.25rem, 1.8vw, 1.5rem);
  font-weight: 700;
}

.brew tbody tr:last-child th,
.brew tbody tr:last-child td {
  padding-bottom: clamp(24px, 2.8vw, 36px);
  border-bottom: 0;
}

/* A tea's own colour, as a round of it beside its name. */
.chip {
  display: inline-block;
  width: 0.78em;
  height: 0.78em;
  margin-right: 0.6em;
  border-radius: 50%;
  background-color: var(--c, var(--kw-gold));
  box-shadow: 0 0 0 1.5px rgb(18 33 27 / 0.75);
  vertical-align: 0.02em;
}

/* The studio signs in its own colours, not the house'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-family: var(--face-studio);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
  transition: background-color 180ms linear;
}

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

.studio:focus-visible {
  outline: 2px solid var(--kw-paper);
  outline-offset: 3px;
}

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

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

/*
 * ——— A tall screen: the tall frames, a tag at a time ———
 * (The script switches to the tall series at the same ratio.)
 */

@media (max-aspect-ratio: 3 / 4) {
  .brand {
    padding: 8px 14px 9px 10px;
    font-size: 19px;
  }

  .brand-mark {
    width: 22px;
    height: 22px;
  }

  .title {
    font-size: clamp(38px, 11.6vw, 52px);
  }

  .tag {
    padding: 9px 15px 11px;
    font-size: clamp(30px, 8.8vw, 38px);
  }

  .tag-small {
    padding: 7px 12px 8px;
    font-size: 22px;
  }

  .tag-tea {
    padding: 10px 15px 12px;
  }

  .tag-word {
    font-size: clamp(28px, 8vw, 34px);
  }

  .tag-note {
    font-size: 16px;
  }

  .final-title {
    font-size: clamp(2.9rem, 14vw, 3.75rem);
  }

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

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

  /* Without the film the six teas stand over one still: smaller, so the bowls are seen. */
  html:not(.live) .tag-tea {
    padding: 8px 12px 9px;
  }

  html:not(.live) .tag-word {
    font-size: 24px;
  }

  html:not(.live) .tag-note {
    margin-top: 3px;
  }

  .live .cue-opening {
    top: 21vh;
    top: 21svh;
  }

  /* The tags ride up one at a time, from the left edge of the screen. */
  .live #cue-house,
  .live #cue-shoot,
  .live #cue-tin,
  .live #cue-iron,
  .live #cue-water,
  .live #cue-leaf,
  .live #cue-name,
  .live #cue-time,
  .live .tag-tea {
    left: var(--gutter);
    right: auto;
  }

  /* The six names of the shelf ride up in one column: a phone sees the right end of the shelf. */
  .live .six .tag-small {
    left: var(--gutter);
    transform: translate3d(0, -50%, 0);
  }

  /* On a phone the camera passes from the dark window to the lit wall under the last line: it stands on paper, as a card. */
  .live .cue-final {
    left: var(--gutter);
    right: auto;
    top: calc((var(--pin, 1) + 0.12) * 100vh);
    top: calc((var(--pin, 1) + 0.12) * 100svh);
    width: auto;
    padding: 14px 18px 18px;
    border-radius: 3px;
    background: var(--kw-paper) url("textures/paper.webp") center / 560px auto;
    box-shadow:
      0 1px 0 rgb(11 21 17 / 0.4),
      0 14px 30px rgb(11 21 17 / 0.28);
  }

  .live .final-title {
    display: flex;
    gap: 0.24em;
    font-size: clamp(2.6rem, 12vw, 3.2rem);
  }

  .brew-facts {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
  }

  .brew-facts b {
    font-size: clamp(3.6rem, 21vw, 5.4rem);
  }

  .live .brew-facts li {
    transform: none;
  }

  .live .phrase {
    font-size: clamp(72px, 25vw, 118px);
  }

  .live .phrase .line + .line {
    margin-left: 0.2em;
  }

  /* Only the station on screen keeps its name; the others are short threads. */
  .way ol {
    align-items: center;
    gap: 6px;
    padding: 0 10px;
  }

  .way button {
    padding: 13px 2px 14px;
  }

  .way li:not(.is-now) button {
    padding: 16px 0;
  }

  .way li:not(.is-now) span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .way li:not(.is-now) i {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    display: block;
    width: 12px;
  }

  .way i {
    left: 2px;
    right: 2px;
    bottom: 7px;
  }

  .live .hint span {
    display: none;
  }

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

  /* The card on a phone: the two leaves one under the other, the fold across. */
  .foot {
    padding-top: 40px;
    padding-bottom: 108px;
  }

  .card {
    grid-template-columns: minmax(0, 1fr);
    transform: rotate(-0.6deg);
  }

  .card-face {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px 12px;
    padding: 26px 20px 24px;
    background-image: linear-gradient(to bottom, rgb(18 33 27 / 0) 80%, rgb(18 33 27 / 0.09) 100%);
  }

  .card-name {
    flex: 1 0 100%;
    font-size: 2.75rem;
  }

  .card-line {
    flex: 1 1 0;
    margin-top: 0;
    font-size: 1.25rem;
  }

  .card-stamp {
    width: 88px;
    height: 88px;
    margin-top: 0;
  }

  .card-stamp b {
    font-size: 24px;
  }

  .brew {
    border-left: 0;
    border-top: 1px solid rgb(18 33 27 / 0.2);
    background-image: linear-gradient(to bottom, rgb(255 255 255 / 0.26) 0%, rgb(255 255 255 / 0) 10%);
  }

  .brew th,
  .brew td {
    padding: 12px 6px;
    font-size: 16px;
  }

  .brew th:first-child {
    padding-left: 20px;
  }

  .brew td:last-child,
  .brew th:last-child {
    padding-right: 20px;
  }

  .brew tbody th {
    font-size: 1.25rem;
  }
}

/* ——— Checks ——— */

.hud {
  position: fixed;
  left: 8px;
  top: 72px;
  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;
}
