/* Start page: "How it works" film (only loaded on /, so the extensions don't ship it). Pure CSS, one 24 s timeline that loops, no script.
   The pause button is a checkbox (works without JavaScript). The stage is decorative
   (aria-hidden), the numbered steps below it carry the same content as text.
   Timeline: 0-9 s sign-up form and alias, 9-15.5 s mails arrive, 15.5-21 s spam and
   switching off, 21-24 s end card. 1 s = 4.1667 %. */
.howto__player {
  --howto-t: 24s;
  display: grid;
  gap: var(--space-4);
  container-type: inline-size;
}

.howto__head {
  display: grid;
  gap: var(--space-2);
  max-width: 62ch;
}

.howto__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  font-weight: var(--fw-h1);
  font-stretch: var(--fst-h1);
  line-height: var(--lh-h1);
}

.howto__lead {
  margin: 0;
  color: var(--ink-2);
}

.howto__pause {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.howto__stage {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background:
    radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 1.5px) 0 0 / 22px 22px,
    var(--ground);
  font-size: clamp(10px, 1.65cqi, 17px);
  line-height: 1.4;
  color: var(--ink);
}

.howto__stage *,
.howto__steps li,
.howto__steps li::before,
.howto__bar {
  animation-duration: var(--howto-t);
  animation-iteration-count: infinite;
  animation-timing-function: ease-in-out;
  animation-fill-mode: both;
}

.howto__pause:checked ~ .howto__stage *,
.howto__pause:checked ~ .howto__controls *,
.howto__pause:checked ~ .howto__steps li,
.howto__pause:checked ~ /* With ui.js the step cards jump to their part of the film (client/ui.ts). */
.howto__player--seekable .howto__steps li {
  cursor: pointer;
}

.howto__player--seekable .howto__steps li:hover {
  background: var(--ground);
}

.howto__player--seekable .howto__steps li:focus-visible {
  outline: 2px solid var(--rose);
  outline-offset: 2px;
}

/* The start page actions again, under the film */
.howto__cta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-3);
  padding-top: var(--space-4);
}

.howto__steps li::before {
  animation-play-state: paused;
}

.howto__scene {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5em;
  opacity: 0;
}

.howto__scene--form {
  animation-name: howto-scene-form;
}

.howto__scene--flow {
  animation-name: howto-scene-flow;
}

.howto__scene--spam {
  animation-name: howto-scene-spam;
}

.howto__scene--end {
  animation-name: howto-scene-end;
}

@keyframes howto-scene-form {
  0% {
    opacity: 0;
    transform: translateY(0.6em);
  }
  1.67%,
  35.83% {
    opacity: 1;
    transform: none;
  }
  37.5%,
  100% {
    opacity: 0;
    transform: translateY(-0.6em);
  }
}

@keyframes howto-scene-flow {
  0%,
  37.5% {
    opacity: 0;
    transform: translateY(0.6em);
  }
  39.17%,
  62.92% {
    opacity: 1;
    transform: none;
  }
  64.58%,
  100% {
    opacity: 0;
    transform: translateY(-0.6em);
  }
}

@keyframes howto-scene-spam {
  0%,
  64.58% {
    opacity: 0;
    transform: translateY(0.6em);
  }
  66.25%,
  85.83% {
    opacity: 1;
    transform: none;
  }
  87.5%,
  100% {
    opacity: 0;
    transform: translateY(-0.6em);
  }
}

@keyframes howto-scene-end {
  0%,
  87.5% {
    opacity: 0;
    transform: scale(0.96);
  }
  89.17%,
  98.33% {
    opacity: 1;
    transform: none;
  }
  100% {
    opacity: 0;
  }
}

/* Shared pieces */
.howto__card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 0.9em;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.howto__alias {
  font-family: var(--font-mono);
  font-size: 0.86em;
  white-space: nowrap;
}

.howto__alias-dot {
  color: var(--rose);
  font-weight: 500;
}

.howto__alias-domain {
  color: var(--ink-3);
}

.howto__fav {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  border-radius: 0.55em;
  background: var(--petrol);
  color: var(--on-petrol);
  font-weight: 700;
}

.howto__mark {
  display: block;
  width: 1.6em;
  height: 1.6em;
  flex: none;
}

.howto__pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0.1em 0.7em;
  border-radius: 999px;
  font-size: 0.8em;
  font-weight: 600;
  white-space: nowrap;
}

.howto__pill::before {
  content: '';
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: currentColor;
}

.howto__pill--ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.howto__pill--off {
  background: var(--surface-2);
  color: var(--ink-2);
}

.howto__pill--warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.howto__pill--crit {
  background: var(--crit-soft);
  color: var(--crit);
}

.howto__icon {
  width: 1.3em;
  height: 1.3em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The pointer moves in em inside its card, so it hits its target at every size. */
.howto__cursor {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  width: 1.5em;
  height: 1.5em;
  pointer-events: none;
}

.howto__cursor path {
  fill: var(--ink);
  stroke: var(--surface);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

/* Scene 1: sign-up form (25 x 25 em) with the extension's suggestion */
.howto__window {
  width: 25em;
  height: 25em;
  overflow: visible;
}

.howto__url {
  display: flex;
  align-items: center;
  gap: 0.8em;
  height: 2.4em;
  padding: 0 1em;
  border-bottom: 1px solid var(--line);
  border-radius: 0.9em 0.9em 0 0;
  background: var(--surface-2);
  color: var(--ink-2);
}

.howto__url span {
  font-size: 0.8em;
}

.howto__dots {
  display: flex;
  gap: 0.35em;
}

.howto__dots i {
  width: 0.6em;
  height: 0.6em;
  border-radius: 50%;
  background: var(--line-strong);
  opacity: 0.6;
}

.howto__form {
  padding: 1.25em 1.5em 0;
}

.howto__h {
  height: 2em;
  margin: 0 0 0.5em;
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 118%;
  font-size: 1em;
  line-height: 2em;
}

.howto__h span {
  font-size: 1.3em;
}

.howto__field {
  position: relative;
  height: 4.1em;
  margin-bottom: 0.75em;
}

.howto__label {
  display: block;
  height: 1.5em;
  color: var(--ink-2);
  font-weight: 600;
  line-height: 1.5em;
}

.howto__label span {
  font-size: 0.85em;
}

.howto__input {
  position: relative;
  display: flex;
  align-items: center;
  height: 2.6em;
  padding: 0 0.8em;
  border: 1px solid var(--line-strong);
  border-radius: 0.6em;
  background: var(--surface);
  white-space: nowrap;
}

.howto__input--mail {
  animation-name: howto-mail-field;
}

@keyframes howto-mail-field {
  0%,
  8.33% {
    border-color: var(--line-strong);
    box-shadow: none;
  }
  8.75%,
  16.25% {
    border-color: var(--petrol);
    box-shadow: 0 0 0 0.2em var(--petrol-soft);
  }
  17.08%,
  100% {
    border-color: var(--rose);
    box-shadow: 0 0 0 0.2em var(--rose-soft);
  }
}

.howto__placeholder {
  position: absolute;
  left: 0.8em;
  color: var(--ink-3);
  animation-name: howto-placeholder;
}

@keyframes howto-placeholder {
  0%,
  16.67% {
    opacity: 1;
  }
  17.08%,
  100% {
    opacity: 0;
  }
}

.howto__typed {
  animation-name: howto-typed;
  animation-timing-function: steps(18, end);
}

@keyframes howto-typed {
  0%,
  17.08% {
    clip-path: inset(0 100% 0 0);
  }
  20.83%,
  100% {
    clip-path: inset(0 0 0 0);
  }
}

.howto__inline-mark {
  position: absolute;
  right: 0.5em;
  width: 1.4em;
  height: 1.4em;
  animation-name: howto-inline-mark;
}

@keyframes howto-inline-mark {
  0%,
  8.33% {
    opacity: 0;
  }
  8.75%,
  16.25% {
    opacity: 1;
  }
  17.08%,
  100% {
    opacity: 0;
  }
}

.howto__popup {
  position: absolute;
  top: 4.3em;
  left: 5.5em;
  z-index: 2;
  display: grid;
  gap: 0.45em;
  width: 18em;
  padding: 0.9em;
  border: 1px solid var(--line);
  border-radius: 0.8em;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation-name: howto-popup;
}

@keyframes howto-popup {
  0%,
  9.17% {
    opacity: 0;
    transform: translateY(-0.4em) scale(0.97);
    visibility: hidden;
  }
  10.42%,
  15.42% {
    opacity: 1;
    transform: none;
    visibility: visible;
  }
  16.67%,
  100% {
    opacity: 0;
    transform: translateY(-0.4em) scale(0.97);
    visibility: hidden;
  }
}

.howto__popup-head {
  display: flex;
  align-items: center;
  gap: 0.5em;
  height: 1.6em;
  color: var(--ink-2);
  font-weight: 600;
  white-space: nowrap;
}

.howto__popup-head span {
  font-size: 0.85em;
}

.howto__popup .howto__mark {
  width: 1.4em;
  height: 1.4em;
}

.howto__popup-addr {
  padding: 0.35em 0.6em;
  border-radius: 0.5em;
  background: var(--ground);
}

.howto__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  height: 2.4em;
  border-radius: 0.6em;
  font-weight: 600;
  white-space: nowrap;
}

.howto__btn--create {
  background: var(--rose);
  color: var(--on-rose);
  animation-name: howto-press-create;
}

@keyframes howto-press-create {
  0%,
  14.58% {
    transform: none;
  }
  15% {
    transform: scale(0.95);
  }
  15.42%,
  100% {
    transform: none;
  }
}

.howto__submit {
  position: relative;
  display: grid;
  height: 2.8em;
}

.howto__submit > span {
  grid-area: 1 / 1;
}

.howto__btn--submit {
  background: var(--petrol);
  color: var(--on-petrol);
  animation-name: howto-press-submit;
}

@keyframes howto-press-submit {
  0%,
  26.67% {
    transform: none;
    opacity: 1;
  }
  27.08% {
    transform: scale(0.96);
    opacity: 1;
  }
  27.92%,
  100% {
    transform: none;
    opacity: 0;
  }
}

.howto__btn--done {
  background: var(--ok-soft);
  color: var(--ok);
  animation-name: howto-done;
}

@keyframes howto-done {
  0%,
  27.5% {
    opacity: 0;
  }
  28.33%,
  100% {
    opacity: 1;
  }
}

/* Pointer in the form: in at 1 s, field at 2 s, "create" at 3.6 s, submit at 6.5 s. */
.howto__cursor--form {
  animation-name: howto-cursor-form;
}

@keyframes howto-cursor-form {
  0%,
  2.5% {
    opacity: 0;
    transform: translate(27em, 27em);
  }
  4.17% {
    opacity: 1;
    transform: translate(24em, 22em);
  }
  7.92%,
  8.33% {
    opacity: 1;
    transform: translate(12em, 13.4em);
  }
  8.54% {
    transform: translate(12em, 13.4em) scale(0.85);
  }
  8.75% {
    transform: translate(12em, 13.4em);
  }
  11.67%,
  14.58% {
    opacity: 1;
    transform: translate(14.5em, 21.4em);
  }
  15% {
    transform: translate(14.5em, 21.4em) scale(0.85);
  }
  15.42%,
  22.92% {
    opacity: 1;
    transform: translate(14.5em, 21.4em);
  }
  26.25%,
  26.67% {
    opacity: 1;
    transform: translate(9em, 22em);
  }
  27.08% {
    transform: translate(9em, 22em) scale(0.85);
  }
  27.5%,
  33.33% {
    opacity: 1;
    transform: translate(9em, 22em);
  }
  35%,
  100% {
    opacity: 0;
    transform: translate(9em, 22em);
  }
}

/* Scene 2: service, alias, inbox in a row (a column on phones), mails travel along */
/* The row is as wide as its three cards, so the scene centres it (fr columns overflowed
   to the right when the address was wider than its share). */
.howto__flow {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, auto);
  align-items: center;
  gap: 6.5em;
  width: max-content;
  max-width: 100%;
}

.howto__node {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 0.5em;
  padding: 1.1em;
  text-align: center;
}

.howto__node small {
  color: var(--ink-2);
  font-size: 0.8em;
  white-space: nowrap;
}

.howto__node strong {
  white-space: nowrap;
}

.howto__capsule {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 0.9em;
  border-radius: 999px;
  background: var(--petrol-soft);
}

.howto__capsule--hidden {
  border: 2px solid var(--petrol);
  background: transparent;
  color: var(--petrol);
}

.howto__node--alias .howto__alias-dot {
  display: inline-block;
  animation-name: howto-dot-pulse;
}

@keyframes howto-dot-pulse {
  0%,
  43.75% {
    transform: none;
  }
  44.79% {
    transform: scale(1.9);
  }
  45.83%,
  47.92% {
    transform: none;
  }
  48.96% {
    transform: scale(1.9);
  }
  50%,
  52.08% {
    transform: none;
  }
  53.13% {
    transform: scale(1.9);
  }
  54.17%,
  100% {
    transform: none;
  }
}

.howto__masked {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 0.8em;
  letter-spacing: 0.1em;
}

.howto__inbox-list {
  display: grid;
  gap: 0.35em;
  width: 100%;
  margin: 0.3em 0 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.howto__inbox-list li {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.35em 0.6em;
  border-radius: 0.45em;
  background: var(--ground);
  font-size: 0.85em;
  white-space: nowrap;
}

.howto__inbox-list li::before {
  content: '';
  width: 0.5em;
  height: 0.5em;
  flex: none;
  border-radius: 50%;
  background: var(--petrol);
}

.howto__inbox-list li:nth-child(1) {
  animation-name: howto-arrive-1;
}

.howto__inbox-list li:nth-child(2) {
  animation-name: howto-arrive-2;
}

.howto__inbox-list li:nth-child(3) {
  animation-name: howto-arrive-3;
}

@keyframes howto-arrive-1 {
  0%,
  47.5% {
    opacity: 0;
    transform: translateY(-0.4em);
  }
  48.33%,
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes howto-arrive-2 {
  0%,
  51.67% {
    opacity: 0;
    transform: translateY(-0.4em);
  }
  52.5%,
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes howto-arrive-3 {
  0%,
  55.83% {
    opacity: 0;
    transform: translateY(-0.4em);
  }
  56.67%,
  100% {
    opacity: 1;
    transform: none;
  }
}

.howto__track {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.howto__flow::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 9%;
  right: 13%;
  border-top: 2px dashed var(--line-strong);
}

.howto__env {
  position: absolute;
  top: 50%;
  left: 12%;
  width: 2em;
  height: 1.5em;
  margin: -0.75em 0 0 -1em;
  color: var(--petrol);
  opacity: 0;
}

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

.howto__env rect {
  fill: var(--surface);
  stroke: currentColor;
  stroke-width: 1.5;
}

.howto__env path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.howto__env--1 {
  animation-name: howto-env-1;
}

.howto__env--2 {
  animation-name: howto-env-2;
}

.howto__env--3 {
  animation-name: howto-env-3;
}

/* Each mail: 10/11/12 s at the service, a short stop at the alias (its dot pulses),
   1.6 s later in the inbox. */
@keyframes howto-env-1 {
  0%,
  41.67% {
    opacity: 0;
    left: 9%;
  }
  42.5% {
    opacity: 1;
    left: 12%;
  }
  44.79%,
  45.42% {
    opacity: 1;
    left: 45%;
  }
  47.5% {
    opacity: 1;
    left: 86%;
  }
  48.34%,
  100% {
    opacity: 0;
    left: 86%;
  }
}

@keyframes howto-env-2 {
  0%,
  45.83% {
    opacity: 0;
    left: 9%;
  }
  46.66% {
    opacity: 1;
    left: 12%;
  }
  48.95%,
  49.58% {
    opacity: 1;
    left: 45%;
  }
  51.66% {
    opacity: 1;
    left: 86%;
  }
  52.5%,
  100% {
    opacity: 0;
    left: 86%;
  }
}

@keyframes howto-env-3 {
  0%,
  50% {
    opacity: 0;
    left: 9%;
  }
  50.83% {
    opacity: 1;
    left: 12%;
  }
  53.12%,
  53.75% {
    opacity: 1;
    left: 45%;
  }
  55.83% {
    opacity: 1;
    left: 86%;
  }
  56.67%,
  100% {
    opacity: 0;
    left: 86%;
  }
}

/* Scene 3: spam arrives, the alias is switched off, the next mail is rejected */
.howto__spam {
  display: grid;
  grid-template-columns: 17em 23em;
  align-items: start;
  gap: 2em;
}

.howto__aliascard {
  display: grid;
  gap: 0.75em;
  width: 17em;
  padding: 1.25em;
}

.howto__aliascard-head {
  display: flex;
  align-items: center;
  gap: 0.6em;
  height: 2.2em;
  font-weight: 600;
}

.howto__aliascard-controls {
  display: flex;
  align-items: center;
  gap: 0.75em;
  height: 1.6em;
  margin-top: 0.15em;
}

.howto__switch {
  position: relative;
  width: 2.5em;
  height: 1.5em;
  flex: none;
  border: 1px solid var(--petrol);
  border-radius: 999px;
  background: var(--petrol);
  animation-name: howto-switch;
}

.howto__switch::after {
  content: '';
  position: absolute;
  top: 0.2em;
  left: 0.2em;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  background: var(--on-petrol);
  transform: translateX(1em);
  animation: inherit;
  animation-name: howto-knob;
}

@keyframes howto-switch {
  0%,
  77.08% {
    background: var(--petrol);
    border-color: var(--petrol);
  }
  77.5%,
  100% {
    background: var(--surface);
    border-color: var(--line-strong);
  }
}

@keyframes howto-knob {
  0%,
  77.08% {
    transform: translateX(1em);
    background: var(--on-petrol);
  }
  77.5%,
  100% {
    transform: none;
    background: var(--line-strong);
  }
}

.howto__state {
  display: inline-grid;
}

.howto__state > span {
  grid-area: 1 / 1;
}

.howto__state .howto__pill--ok {
  animation-name: howto-state-on;
}

.howto__state .howto__pill--off {
  animation-name: howto-state-off;
}

@keyframes howto-state-on {
  0%,
  77.08% {
    opacity: 1;
  }
  77.5%,
  100% {
    opacity: 0;
  }
}

@keyframes howto-state-off {
  0%,
  77.08% {
    opacity: 0;
  }
  77.5%,
  100% {
    opacity: 1;
  }
}

/* Pointer on the switch (2.5 em / 7.5 em inside the card), click at 18.5 s */
.howto__cursor--spam {
  animation-name: howto-cursor-spam;
}

@keyframes howto-cursor-spam {
  0%,
  72.92% {
    opacity: 0;
    transform: translate(12em, 13em);
  }
  73.75% {
    opacity: 1;
    transform: translate(10em, 11.5em);
  }
  76.25%,
  76.67% {
    opacity: 1;
    transform: translate(2.3em, 7.3em);
  }
  77.08% {
    transform: translate(2.3em, 7.3em) scale(0.85);
  }
  77.5%,
  79.17% {
    opacity: 1;
    transform: translate(2.3em, 7.3em);
  }
  80.42%,
  100% {
    opacity: 0;
    transform: translate(4em, 10em);
  }
}

/* The mail that comes after switching off bounces off the card */
.howto__bounce {
  position: absolute;
  top: -2.2em;
  right: 2em;
  width: 2em;
  height: 1.5em;
  color: var(--crit);
  animation-name: howto-bounce;
}

@keyframes howto-bounce {
  0%,
  79.17% {
    opacity: 0;
    transform: translate(-4em, -3em);
  }
  80% {
    opacity: 1;
    transform: translate(-1em, -0.8em);
  }
  81.25% {
    opacity: 1;
    transform: translate(0, 1.2em);
  }
  82.5% {
    opacity: 1;
    transform: translate(0.8em, -1.2em) rotate(14deg);
  }
  84.17%,
  100% {
    opacity: 0;
    transform: translate(1.6em, -2.4em) rotate(24deg);
  }
}

.howto__rejected {
  position: absolute;
  top: -0.9em;
  right: 0.8em;
  animation-name: howto-rejected;
}

@keyframes howto-rejected {
  0%,
  81.25% {
    opacity: 0;
    transform: scale(0.8);
  }
  82.08%,
  100% {
    opacity: 1;
    transform: none;
  }
}

.howto__mailbox {
  width: 23em;
  padding: 0.9em 1em 1em;
}

.howto__mailbox-head {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin-bottom: 0.6em;
  color: var(--ink-2);
  font-weight: 600;
}

.howto__mails {
  display: grid;
  gap: 0.4em;
  margin: 0;
  padding: 0;
  list-style: none;
}

.howto__mails li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.2em 0.6em;
  padding: 0.5em 0.7em;
  border: 1px solid var(--line);
  border-radius: 0.55em;
}

.howto__mails strong,
.howto__mails small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.howto__mails small {
  grid-column: 1;
  color: var(--ink-3);
  font-size: 0.78em;
}

.howto__mails .howto__pill {
  grid-row: 1 / 3;
  grid-column: 2;
}

.howto__mails li:nth-child(2) {
  animation-name: howto-spam-1;
}

.howto__mails li:nth-child(3) {
  animation-name: howto-spam-2;
}

.howto__mails li:nth-child(4) {
  animation-name: howto-spam-3;
}

@keyframes howto-spam-1 {
  0%,
  67.5% {
    opacity: 0;
    transform: translateY(-0.5em);
  }
  68.75%,
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes howto-spam-2 {
  0%,
  69.58% {
    opacity: 0;
    transform: translateY(-0.5em);
  }
  70.83%,
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes howto-spam-3 {
  0%,
  71.67% {
    opacity: 0;
    transform: translateY(-0.5em);
  }
  72.92%,
  100% {
    opacity: 1;
    transform: none;
  }
}

/* Scene 4: end card */
.howto__end {
  display: grid;
  justify-items: center;
  gap: 0.9em;
  text-align: center;
}

.howto__end .howto__mark {
  width: 4.5em;
  height: 4.5em;
}

.howto__end-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 850;
  font-stretch: 125%;
  font-size: 2.2em;
  line-height: 1.05;
}

.howto__end-text {
  margin: 0;
  color: var(--ink-2);
  font-size: 1.1em;
}

/* Controls: pause/play and the progress line */
.howto__controls {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.howto__toggle .howto__when-paused,
.howto__pause:checked ~ .howto__controls .howto__when-playing {
  display: none;
}

.howto__pause:checked ~ .howto__controls .howto__when-paused {
  display: inline-flex;
}

.howto__toggle span {
  align-items: center;
  gap: var(--space-2);
  display: inline-flex;
}

.howto__pause:focus-visible ~ .howto__controls .howto__toggle {
  outline: 2px solid var(--rose);
  outline-offset: 2px;
}

.howto__progress {
  flex: 1;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.howto__bar {
  display: block;
  height: 100%;
  background: var(--petrol);
  transform-origin: left;
  animation-name: howto-progress;
  animation-timing-function: linear;
}

@keyframes howto-progress {
  0% {
    transform: scaleX(0);
  }
  100% {
    transform: scaleX(1);
  }
}

/* The four steps: the text version of the film, the current one lights up */
.howto__steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: howto;
}

.howto__steps li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-content: start;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  counter-increment: howto;
}

.howto__steps li::before {
  content: counter(howto);
  display: grid;
  grid-row: 1 / 3;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 700;
  font-size: var(--fs-small);
}

.howto__steps strong {
  font-weight: 700;
}

.howto__steps span {
  color: var(--ink-2);
  font-size: var(--fs-small);
}

.howto__steps li:nth-child(1) {
  animation-name: howto-step-1;
}
.howto__steps li:nth-child(1)::before {
  animation-name: howto-num-1;
}
.howto__steps li:nth-child(2) {
  animation-name: howto-step-2;
}
.howto__steps li:nth-child(2)::before {
  animation-name: howto-num-2;
}
.howto__steps li:nth-child(3) {
  animation-name: howto-step-3;
}
.howto__steps li:nth-child(3)::before {
  animation-name: howto-num-3;
}
.howto__steps li:nth-child(4) {
  animation-name: howto-step-4;
}
.howto__steps li:nth-child(4)::before {
  animation-name: howto-num-4;
}

/* Step windows: 1 = 0-3.5 s, 2 = 3.5-9 s, 3 = 9-15.5 s, 4 = 15.5-21 s */
@keyframes howto-step-1 {
  0%,
  14.58% {
    border-color: var(--petrol);
    box-shadow: var(--shadow);
  }
  15%,
  100% {
    border-color: var(--line);
    box-shadow: none;
  }
}

@keyframes howto-num-1 {
  0%,
  14.58% {
    background: var(--petrol);
    color: var(--on-petrol);
  }
  15%,
  100% {
    background: var(--surface-2);
    color: var(--ink-2);
  }
}

@keyframes howto-step-2 {
  0%,
  14.58% {
    border-color: var(--line);
    box-shadow: none;
  }
  15%,
  37.5% {
    border-color: var(--petrol);
    box-shadow: var(--shadow);
  }
  37.92%,
  100% {
    border-color: var(--line);
    box-shadow: none;
  }
}

@keyframes howto-num-2 {
  0%,
  14.58% {
    background: var(--surface-2);
    color: var(--ink-2);
  }
  15%,
  37.5% {
    background: var(--petrol);
    color: var(--on-petrol);
  }
  37.92%,
  100% {
    background: var(--surface-2);
    color: var(--ink-2);
  }
}

@keyframes howto-step-3 {
  0%,
  37.5% {
    border-color: var(--line);
    box-shadow: none;
  }
  37.92%,
  64.58% {
    border-color: var(--petrol);
    box-shadow: var(--shadow);
  }
  65%,
  100% {
    border-color: var(--line);
    box-shadow: none;
  }
}

@keyframes howto-num-3 {
  0%,
  37.5% {
    background: var(--surface-2);
    color: var(--ink-2);
  }
  37.92%,
  64.58% {
    background: var(--petrol);
    color: var(--on-petrol);
  }
  65%,
  100% {
    background: var(--surface-2);
    color: var(--ink-2);
  }
}

@keyframes howto-step-4 {
  0%,
  64.58% {
    border-color: var(--line);
    box-shadow: none;
  }
  65%,
  87.5% {
    border-color: var(--petrol);
    box-shadow: var(--shadow);
  }
  87.92%,
  100% {
    border-color: var(--line);
    box-shadow: none;
  }
}

@keyframes howto-num-4 {
  0%,
  64.58% {
    background: var(--surface-2);
    color: var(--ink-2);
  }
  65%,
  87.5% {
    background: var(--petrol);
    color: var(--on-petrol);
  }
  87.92%,
  100% {
    background: var(--surface-2);
    color: var(--ink-2);
  }
}

/* Phones: portrait stage, the flow and the spam scene stack, steps in two columns */
@container (max-width: 640px) {
  .howto__stage {
    aspect-ratio: auto;
    height: 36em;
    font-size: clamp(10px, 3.6cqi, 13px);
  }

  .howto__flow {
    grid-template-columns: minmax(0, 20em);
    justify-content: center;
    gap: 1.6em;
    width: 100%;
  }

  .howto__node {
    padding: 0.8em;
  }

  .howto__flow::before {
    top: 10%;
    bottom: 10%;
    left: 50%;
    right: auto;
    border-top: 0;
    border-left: 2px dashed var(--line-strong);
  }

  .howto__env {
    top: 10%;
    left: 50%;
  }

  .howto__env--1 {
    animation-name: howto-env-1-y;
  }
  .howto__env--2 {
    animation-name: howto-env-2-y;
  }
  .howto__env--3 {
    animation-name: howto-env-3-y;
  }

  .howto__spam {
    grid-template-columns: 21em;
    gap: 1.4em;
  }

  .howto__aliascard,
  .howto__mailbox {
    width: 21em;
  }

  .howto__mails li:nth-child(4) {
    display: none;
  }

  .howto__end-title {
    font-size: 1.8em;
  }

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

@container (max-width: 380px) {
  .howto__steps {
    grid-template-columns: minmax(0, 1fr);
  }
}

@keyframes howto-env-1-y {
  0%,
  41.67% {
    opacity: 0;
    top: 14%;
  }
  42.5% {
    opacity: 1;
    top: 16%;
  }
  44.79%,
  45.42% {
    opacity: 1;
    top: 42%;
  }
  47.5% {
    opacity: 1;
    top: 74%;
  }
  48.34%,
  100% {
    opacity: 0;
    top: 74%;
  }
}

@keyframes howto-env-2-y {
  0%,
  45.83% {
    opacity: 0;
    top: 14%;
  }
  46.66% {
    opacity: 1;
    top: 16%;
  }
  48.95%,
  49.58% {
    opacity: 1;
    top: 42%;
  }
  51.66% {
    opacity: 1;
    top: 74%;
  }
  52.5%,
  100% {
    opacity: 0;
    top: 74%;
  }
}

@keyframes howto-env-3-y {
  0%,
  50% {
    opacity: 0;
    top: 14%;
  }
  50.83% {
    opacity: 1;
    top: 16%;
  }
  53.12%,
  53.75% {
    opacity: 1;
    top: 42%;
  }
  55.83% {
    opacity: 1;
    top: 74%;
  }
  56.67%,
  100% {
    opacity: 0;
    top: 74%;
  }
}

/* Reduced motion: no film. The four scenes become still pictures in a grid, each shown
   at its key moment, and the pause button goes away. */
@media (prefers-reduced-motion: reduce) {
  .howto__stage,
  .howto__stage *,
  .howto__steps li,
  .howto__steps li::before,
  .howto__bar {
    animation: none !important;
  }

  .howto__controls {
    display: none;
  }

  .howto__stage {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    aspect-ratio: auto;
    height: auto;
    gap: 1px;
    background: var(--line);
    font-size: clamp(7px, 0.85cqi, 11px);
  }

  .howto__scene {
    position: relative;
    inset: auto;
    min-height: 30em;
    opacity: 1;
    background: var(--ground);
  }

  .howto__popup,
  .howto__placeholder,
  .howto__inline-mark,
  .howto__cursor,
  .howto__env,
  .howto__btn--submit,
  .howto__state .howto__pill--ok {
    opacity: 0;
  }

  .howto__switch {
    background: var(--surface);
    border-color: var(--line-strong);
  }

  .howto__switch::after {
    transform: none;
    background: var(--line-strong);
  }

  .howto__input--mail {
    border-color: var(--rose);
    box-shadow: 0 0 0 0.2em var(--rose-soft);
  }

  .howto__flow {
    gap: 3em;
  }

  .howto__steps li:first-child {
    border-color: var(--line);
  }

  @container (max-width: 640px) {
    .howto__stage {
      grid-template-columns: minmax(0, 1fr);
      font-size: clamp(9px, 3.2cqi, 12px);
    }
  }
}
