/*
 * Morrowfield, «Time you can hear.» — a page played from footage (tickets/SC-44.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 block of its own — its still, its words — one after another; then the running
 * line, the six parts and the footer.
 *
 * Then (html.live, set before the first paint when the film will play) every act becomes
 * a tall block with a stage that sticks to the screen while the act goes by:
 *   .stage      z1  the canvas of the act — the frame of the moment, the windows and the
 *                   floods drawn over it — and the lines from a word to its thing
 *   .cue        z3  the words: they stand in the flow of the act (`--at`, in screens from
 *                   its top), so the scroll carries them up over the stage
 *   .bar        z5  the name of the house and the acts of the story, fixed
 * Between the acts, in the flow: .band (the line running sideways), .parts (the six
 * parts). After them .foot — the back of the watch.
 *
 * The words take their ink from what lies under them (data-tone, set by the script):
 * light steel on the footage and on the ruby, the page's dark on the gold and on the glow.
 *
 * The colours of the house (tickets/SC-44.md): the dark of the studio #0c0f14, steel
 * #c0c6cf, the gold of the hands #d4af37; and from the footage — the ruby of the jewels
 * and the pale green of the glow in the dark.
 */

:root {
  --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);

  --night: #0c0f14;
  --steel: #c0c6cf;
  --paper: #e9ecf1;
  --gold: #d4af37;
  --ruby: #8f1436;
  --lume: #bdf5d2;

  /* The house's own pair. Instrument Serif for every large word; IBM Plex Mono for
     everything small. The studio's faces (Unbounded, Onest) are in the studio's lime
     corner and nowhere else. */
  --face-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --face-text: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --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: #0c0f14;
  color: #e9ecf1;
  -webkit-text-size-adjust: 100%;
}

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

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

img {
  display: block;
  max-width: 100%;
}

/* Nothing of the page reaches past its sides (the soft plates under the words do). */
main,
.foot {
  overflow-x: clip;
}

/* The ink of anything that takes its colour from what lies under it. */
[data-tone] {
  --ink: #e9ecf1;
  --ink-dim: rgb(233 236 241 / 0.82);
  --mark: #d4af37;
}

[data-tone="gold"],
[data-tone="lume"] {
  --ink: #0c0f14;
  --ink-dim: rgb(12 15 20 / 0.84);
  --mark: #0c0f14;
}

[data-tone="ruby"] {
  --ink: #e9ecf1;
  --ink-dim: rgb(233 236 241 / 0.9);
  --mark: #e9ecf1;
}

/*
 * ——— The header ———
 */

.bar {
  --ink: #e9ecf1;
  --ink-dim: rgb(233 236 241 / 0.82);
  --mark: #d4af37;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: var(--gutter) var(--gutter) 0;
  color: var(--ink);
  line-height: 1;
  pointer-events: none;
}

.live .bar {
  position: fixed;
}

/* Over the footage and the page's dark the header has a soft plate of that dark: what scrolls under it does not tangle with it. */
.bar::before {
  content: "";
  position: absolute;
  inset: 0 0 -46px;
  z-index: -1;
  background-image: linear-gradient(to bottom, rgb(12 15 20 / 0.78), rgb(12 15 20 / 0.5) 45%, rgb(12 15 20 / 0));
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms linear;
}

.live .bar[data-tone="film"]::before,
.live .bar[data-tone="night"]::before {
  opacity: 1;
}

.brand {
  color: var(--ink);
  font-family: var(--face-display);
  font-size: 30px;
  letter-spacing: 0.01em;
  line-height: 1;
  text-decoration: none;
  pointer-events: auto;
  transition: color 240ms linear;
}

.brand:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

.acts {
  display: none;
}

/*
 * ——— The page without the film: the stills and their words ———
 */

.stage {
  display: none;
}

.act {
  position: relative;
}

.shot {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 14px;
  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 {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Under the words a still is darker, so the light steel reads on any of the eight. */
.shot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(to top, rgb(12 15 20 / 0.92), rgb(12 15 20 / 0.5) 32%, rgb(12 15 20 / 0) 64%);
  pointer-events: none;
}

.cue {
  position: relative;
  color: #e9ecf1;
}

/* Every large word: the serif of the house. */
.cue-title,
.cue-label,
.cue-word,
.cue-phrase,
.final-title {
  font-family: var(--face-display);
  font-weight: 400;
}

.cue-title span,
.cue-phrase span,
.final-title span {
  display: block;
  white-space: nowrap;
}

/* The line of the first screen. */
.cue-title {
  font-size: clamp(56px, 7.6vw, 132px);
  letter-spacing: -0.01em;
  line-height: 0.94;
}

/* A word tied to a thing of the picture. */
.cue-label {
  font-size: clamp(40px, 4.8vw, 80px);
  letter-spacing: -0.005em;
  line-height: 1;
  white-space: nowrap;
}

/* The word of the second act. */
.cue-word {
  font-size: clamp(84px, 16.5vw, 300px);
  letter-spacing: -0.02em;
  line-height: 0.9;
  white-space: nowrap;
}

.cue-phrase {
  font-size: clamp(64px, 12.4vw, 226px);
  letter-spacing: -0.02em;
  line-height: 0.9;
}

.cue-final {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.final-title {
  font-size: clamp(40px, 4.4vw, 76px);
  letter-spacing: -0.01em;
  line-height: 1;
}

/* The button: a capsule of the gold of the hands, its arrow in a round of the page's dark. */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  height: 58px;
  margin-top: clamp(18px, 3vh, 30px);
  padding: 6px 6px 6px 26px;
  border-radius: 999px;
  background-color: #d4af37;
  color: #0c0f14;
  font-family: var(--face-text);
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  pointer-events: auto;
  transition: background-color 180ms linear;
}

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

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

.pill-round {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: #0c0f14;
  color: #d4af37;
}

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

.pill:hover .pill-round svg,
.pill:focus-visible .pill-round svg {
  transform: translate3d(4px, 0, 0);
}

/*
 * ——— The film: an act is a tall block with a stage that sticks to the screen ———
 */

.live .act {
  /* As long as the script's table says: the screens its stage is held for, and the screen the stage itself takes. */
  height: calc((var(--len, 1) + 1) * 100vh);
  height: calc((var(--len, 1) + 1) * 100svh);
}

/* The acts lie edge to edge: a hairline of the page must not show between two fields of one colour. */
.live .act + .act {
  margin-top: -1px;
}

.live .stage {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 1;
  display: block;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background-color: #0c0f14;
}

/* The last act is pinned while the parts are still leaving: they go up off the dial like a curtain, and the light goes out under them. */
.live #act-dark {
  margin-top: -36vh;
  margin-top: -36svh;
}

/* Until its canvas is drawn, the second act is the gold it comes up in. */
.live .stage[data-field="gold"] {
  background-color: #d4af37;
}

.live .stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* The first stage comes out of the dark when its first frame is there. */
.live #act-dial .stage canvas {
  opacity: 0;
  transition: opacity 600ms var(--ease-camera);
}

.live.ready #act-dial .stage canvas {
  opacity: 1;
}

/* A shot is no longer a box: its words stand in the flow of the act. */
.live .shot {
  display: contents;
}

.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;
}

/* A line: the gold of the hands over a wider dark one, a ring where it lands.
   (A line that is not drawn is hidden outright: the engine of Safari leaves a dot of it otherwise.) */
.leader {
  visibility: hidden;
  opacity: 0;
  transition:
    opacity 200ms linear,
    visibility 0s linear 200ms;
}

.leader.is-on {
  visibility: visible;
  opacity: 1;
  transition: opacity 260ms linear 60ms;
}

.leader path {
  fill: none;
  stroke-linecap: butt;
  stroke-linejoin: round;
}

.leader .casing {
  stroke: rgb(12 15 20 / 0.55);
  stroke-width: 6;
}

.leader .stroke {
  stroke: #d4af37;
  stroke-width: 2;
}

.leader .ring {
  fill: rgb(12 15 20 / 0.35);
  stroke: #d4af37;
  stroke-width: 2;
}

.leader .dot {
  fill: #e9ecf1;
}

/* A word in the flow of its act: `--at` screens down from the act's top. The scroll carries it. */
.live .cue {
  position: absolute;
  top: calc(var(--at, 0) * 100vh);
  top: calc(var(--at, 0) * 100svh);
  z-index: 3;
  color: var(--ink, #e9ecf1);
  /* The script takes a word out as it comes under the header. */
  opacity: var(--near, 1);
  pointer-events: none;
  transition:
    color 240ms linear,
    opacity 260ms linear;
}

/* A label is there while its thing is on screen. */
.live .cue-label:not(.is-live) {
  opacity: 0;
}

/* Under a word that stands on the footage the picture is one soft plate of the page's dark: no glow round every letter. */
.live .cue-title::before,
.live .cue-label::before,
.live .cue-final::before {
  content: "";
  position: absolute;
  inset: -42% -24%;
  z-index: -1;
  background-image: radial-gradient(closest-side, rgb(12 15 20 / 0.62), rgb(12 15 20 / 0));
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms linear;
}

.live .cue-title[data-tone="film"]::before,
.live .cue-label[data-tone="film"]::before,
.live .cue-final[data-tone="film"]::before,
.live .cue-final[data-tone="night"]::before {
  opacity: 1;
}

.live .cue-title {
  left: var(--gutter);
}

/* Each label comes up on the side its thing is not. */
.live #cue-crystal {
  left: 6%;
}

.live #cue-dial {
  left: 68%;
}

.live #cue-mainspring {
  left: 5%;
}

.live #cue-balance {
  left: 5%;
}

.live #cue-rotor {
  left: 70%;
}

/* The word of the second act lies over the seam of the two acts, in the gold. */
.live .cue-word {
  left: 0;
  right: 0;
  text-align: center;
}

.live .cue-phrase {
  left: var(--gutter);
}

/* The last words: left of the box, over the dark of the studio. */
.live .cue-final {
  left: calc(var(--gutter) + 1vw);
}

/* The acts of the story: a name and, under it, a hairline that fills as the act goes by and stays full after it. */
.live .acts {
  display: block;
  color: var(--ink);
  pointer-events: auto;
}

.acts ol {
  display: flex;
  align-items: flex-start;
  gap: clamp(16px, 2vw, 30px);
  list-style: none;
}

.acts button {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
  min-width: 56px;
  margin: 0;
  padding: 8px 0 10px;
  border: 0;
  background: none;
  color: var(--ink-dim);
  font: inherit;
  font-size: 15px;
  font-weight: 400;
  line-height: 1;
  text-align: left;
  cursor: pointer;
  transition: color 240ms linear;
}

.acts button:hover,
.acts .is-now button {
  color: var(--ink);
}

.acts button:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
  border-radius: 2px;
}

.acts .is-now button {
  font-weight: 500;
}

.acts i {
  position: relative;
  display: block;
  height: 2px;
  overflow: hidden;
  background-color: color-mix(in srgb, currentColor 30%, transparent);
}

.acts i::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--mark);
  transform: scaleX(var(--p, 0));
  transform-origin: 0 50%;
  transition: background-color 240ms linear;
}

.hint {
  display: none;
}

.live .hint {
  position: absolute;
  right: var(--gutter);
  bottom: calc(var(--gutter) + 6px);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #e9ecf1;
  font-size: 15px;
  line-height: 1;
  transition: opacity 360ms var(--ease-camera);
}

.hint i {
  display: block;
  width: 44px;
  height: 2px;
  background-color: #d4af37;
}

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

/*
 * ——— Between the acts: the line of the house, running sideways ———
 */

.band {
  position: relative;
  z-index: 2;
  overflow: hidden;
  padding: clamp(40px, 9vh, 96px) 0 clamp(28px, 6vh, 64px);
  background-color: #0c0f14;
}

.run {
  display: flex;
  align-items: center;
  gap: 0.34em;
  width: -webkit-max-content;
  width: max-content;
  margin-left: -6vw;
  color: #d4af37;
  font-family: var(--face-display);
  font-size: clamp(68px, 10.5vw, 184px);
  font-style: italic;
  letter-spacing: -0.01em;
  line-height: 1.05;
  white-space: nowrap;
  transform: translate3d(var(--run, 0px), 0, 0);
  will-change: transform;
}

.run i {
  display: block;
  flex: none;
  width: 0.5em;
  height: max(2px, 0.022em);
  background-color: #c0c6cf;
}

/*
 * ——— Between the acts: the six parts, as stills of the footage ———
 */

.parts {
  position: relative;
  z-index: 2;
  padding: clamp(28px, 5vh, 56px) var(--gutter) clamp(64px, 12vh, 124px);
  background-color: #0c0f14;
}

.parts-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 1.8vw, 28px);
  max-width: 1220px;
  margin: 0 auto;
}

.parts-col {
  display: grid;
  gap: clamp(20px, 2.2vw, 34px);
  align-content: start;
  will-change: transform;
}

/* The columns stand at three heights, like the wheels on their axles. */
.parts-col:nth-child(2) {
  margin-top: clamp(36px, 5.5vw, 84px);
}

.parts-col:nth-child(3) {
  margin-top: clamp(14px, 2.4vw, 40px);
}

.part img {
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 2px;
}

.part figcaption {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  color: #e9ecf1;
  font-size: clamp(15px, 1.15vw, 18px);
  line-height: 1.3;
}

.part figcaption::before {
  content: "";
  flex: none;
  width: 22px;
  height: 2px;
  background-color: #d4af37;
}

/*
 * ——— The footer: the back of the watch ———
 *
 * The rotor hangs down, at rest (a photograph). Round the steel ring, between its screws,
 * runs what a watchmaker engraves there — set in type along the ring. Under the watch,
 * the one line a wearer needs. The studio's lime corner is the one thing that is the same
 * on every page.
 */

.foot {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 3vh, 40px) var(--gutter) clamp(96px, 12vh, 120px);
  background-color: #0c0f14;
  color: #e9ecf1;
  overflow: hidden;
}

.back {
  position: relative;
  width: min(92vw, 76vh, 780px);
  aspect-ratio: 1;
  /* The studio round the watch goes out into the dark of the page. */
  -webkit-mask-image: radial-gradient(closest-side, #000 78%, rgb(0 0 0 / 0) 100%);
  mask-image: radial-gradient(closest-side, #000 78%, rgb(0 0 0 / 0) 100%);
}

.back img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.engraving {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Cut letters: dark in the steel, a hair of light on their lower edge. */
.engraving text {
  fill: rgb(18 22 28 / 0.78);
  font-family: var(--face-text);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgb(255 255 255 / 0.22);
  stroke-width: 0.8px;
}

.foot-words {
  margin-top: clamp(4px, 1.4vh, 18px);
  text-align: center;
}

/* Small, as on the card in the box. */
.foot-care {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
}

.foot-kind {
  margin-top: 4px;
  color: rgb(233 236 241 / 0.82);
  font-size: 15px;
  line-height: 1.5;
}

/* 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-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 #e9ecf1;
  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, laid across the screen's width ———
 * (The script switches to the tall series at the same ratio.)
 */

@media (max-aspect-ratio: 3 / 4) {
  .brand {
    font-size: 26px;
  }

  /* Without the film: the still, whole, and its words under it. */
  .shot {
    min-height: 0;
    padding: 0 var(--gutter) 34px;
  }

  .shot[data-shot="C1"] {
    padding-top: 68px;
  }

  .still {
    position: relative;
    inset: auto;
    z-index: 0;
    width: calc(100% + 2 * var(--gutter));
    margin: 0 calc(-1 * var(--gutter)) 18px;
    aspect-ratio: 3 / 4;
  }

  .shot::after {
    content: none;
  }

  .cue-title {
    font-size: clamp(52px, 15.5vw, 76px);
  }

  .cue-label {
    font-size: clamp(38px, 11vw, 52px);
  }

  .cue-word {
    font-size: clamp(72px, 21.5vw, 150px);
  }

  .cue-phrase {
    font-size: clamp(60px, 19vw, 132px);
  }

  .final-title {
    font-size: clamp(36px, 10.4vw, 52px);
  }

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

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

  /* With the film: the labels come up along the left edge, under and over the picture. */
  .live #cue-crystal,
  .live #cue-dial,
  .live #cue-mainspring,
  .live #cue-balance,
  .live #cue-rotor {
    left: var(--gutter);
  }

  .live .cue-final {
    left: var(--gutter);
    right: var(--gutter);
  }

  /* The last words stand in the dark under the picture. */
  .live .cue-final {
    --at: 1.78 !important;
  }

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

  /* Only the act on screen keeps its name; the others are their hairlines. */
  .acts ol {
    align-items: flex-end;
    gap: 8px;
  }

  .acts button {
    min-width: 20px;
  }

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

  .live .hint span {
    display: none;
  }

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

  .run {
    font-size: clamp(64px, 19vw, 120px);
  }

  /* Two columns of three: the columns of the wide page are taken apart. */
  .parts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 26px 12px;
  }

  .parts-col {
    display: contents;
  }

  .part figcaption {
    gap: 8px;
    margin-top: 10px;
    font-size: 15px;
  }

  .part figcaption::before {
    width: 12px;
  }

  /* The watch wider than the screen: the ring and its letters stay readable. */
  .foot {
    padding: 16px 0 112px;
  }

  .back {
    width: 128vw;
    margin: 0 -14vw;
  }

  .foot-words {
    padding: 0 var(--gutter);
  }
}

/* ——— Checks ——— */

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