@font-face {
  font-family: "Dirtyline 36Daysoftype 2022";
  src:
    url("assets/fonts/dirtyline-36daysoftype-2022.woff2") format("woff2"),
    url("assets/fonts/dirtyline-36daysoftype-2022.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

:root {
  --color-bg: #000;
  --color-text: #fff;
}

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

/* Each page fills the screen; scrolling snaps from one page to the next */
html {
  background: var(--color-bg);
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-y: none;
  /* full-screen pages: a scrollbar would only shift the layout */
  scrollbar-width: none;
}

body {
  margin: 0;
  background: var(--color-bg);
}

/* --u is one design pixel: the 1920×1080 screen on desktop, 402×874 on mobile */
main {
  --frame-w: 1920;
  --frame-h: 1080;
  --page-gap: 31;
  --u: min(100vw / var(--frame-w), 100dvh / var(--frame-h));

  overflow-x: clip;
}

.page {
  display: grid;
  place-items: center;
  height: 100dvh;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* The design is one tall frame: the two screens are separated by a short gap that
   the first screen's items hang into. Scrolling never rests on the gap. */
.page-gap {
  height: calc(var(--page-gap) * var(--u));
}

.page--gif {
  overflow: hidden;
}

/* One screen of the design, scaled to fit the viewport */
.stage {
  position: relative;
  width: calc(var(--frame-w) * var(--u));
  height: calc(var(--frame-h) * var(--u));
}

.title {
  --title-x: 959.5;
  --title-y: 265;
  --title-size: 324;

  position: absolute;
  left: calc(var(--title-x) * var(--u));
  top: calc(var(--title-y) * var(--u));
  translate: -50% 0;
  margin: 0;
  font-family: "Dirtyline 36Daysoftype 2022", sans-serif;
  font-size: calc(var(--title-size) * var(--u));
  font-weight: 400;
  font-feature-settings: "salt" 1, "ss01" 1;
  line-height: 1;
  text-align: center;
  color: var(--color-text);
}

.title__lines {
  display: block;
}

.title__lines--mobile {
  display: none;
}

.title__line {
  display: block;
  white-space: pre;
}

/* Trimming per line removes the half-leading between lines; restore the 1em line pitch */
.title__line + .title__line {
  margin-top: calc(1em - 1cap);
}

/* Typing animation: the static text keeps the final centred layout,
   the typed text is laid over it from the left edge. */
.title__line {
  position: relative;
  width: fit-content;
  margin-inline: auto;
}

.title__static,
.title__typed {
  display: block;
  text-box: trim-both cap alphabetic;
}

.title__typed {
  position: absolute;
  inset: 0 auto auto 0;
  text-align: left;
}

.is-typing .title__static {
  visibility: hidden;
}

.caret {
  display: inline-block;
  width: 0.03em;
  height: 1cap;
  margin-left: 0.04em;
  /* don't let the caret push the text around */
  margin-right: -0.07em;
  background: currentColor;
}

.caret--blink {
  animation: caret-blink 1.06s step-end infinite;
}

@keyframes caret-blink {
  50% {
    opacity: 0;
  }
}

/* Items are placed in design pixels: --x / --y / --w / --h, rotation --r,
   entrance delay --d (from the Figma timeline). */
.item {
  /* --shift is the anchor offset: 0% = top-left, -50% = centre */
  --shift: 0%;
  --rise: calc(10 * var(--u));
  --ease-pop: cubic-bezier(0.05, 0.4, 0.5, 1);

  position: absolute;
  left: calc(var(--x) * var(--u));
  top: calc(var(--y) * var(--u));
  width: calc(var(--w) * var(--u));
  height: calc(var(--h) * var(--u));
  max-width: none;
  pointer-events: none;
  user-select: none;
  translate: var(--shift) var(--shift);
  rotate: var(--r, 0deg);

  /* Entrance from the Figma timeline: fade in, rise 10px, grow from 90%,
     untwist from -20°, each on its own duration, starting at --d. */
  animation:
    item-fade calc(400ms - var(--cut, 0ms)) cubic-bezier(0.5, 0, 0.5, 1) var(--d, 0ms) both,
    item-scale calc(800ms - var(--cut, 0ms)) var(--ease-pop) var(--d, 0ms) both,
    item-rotate calc(900ms - var(--cut, 0ms)) var(--ease-pop) var(--d, 0ms) both,
    item-rise calc(1000ms - var(--cut, 0ms)) var(--ease-pop) var(--d, 0ms) both;
}

/* --x / --y are the centre point; rotated around it */
.item--cat-smug,
.item--cat-black,
.item--blue,
.item--red {
  --shift: -50%;
}

.item--picard {
  --x: 1530.43;
  --y: 913.03;
  --w: 322.18;
  --h: 184.36;
  --d: 308.54ms;
}

.item--cat-smug {
  --x: 207.46;
  --y: 926.59;
  --w: 317.09;
  --h: 238.07;
  --r: -13.9deg;
  --d: 66.6ms;
}

.item--cat-black {
  --x: 1717.25;
  --y: 209.41;
  --w: 147.99;
  --h: 220;
  --r: 31.12deg;
  --d: 476.94ms;
}

.item--blue {
  --x: 222;
  --y: 224;
  --w: 200;
  --h: 200;
  --r: -90deg;
  --d: 200.72ms;
  /* this one's keyframes end 200.72ms early in Figma */
  --cut: 200.72ms;
}

.item--green {
  --x: 1546;
  --y: 428;
  --w: 162;
  --h: 162;
  --d: 547.06ms;
}

.item--yellow {
  --x: 909;
  --y: 927;
  --w: 200;
  --h: 200;
  --d: 708.54ms;
}

.item--red {
  --x: 1304.625;
  --y: 154.625;
  --w: 277;
  --h: 277;
  --r: -15deg;
  --d: 0ms;
}

@keyframes item-fade {
  from {
    opacity: 0;
  }
}

@keyframes item-scale {
  from {
    scale: 0.9;
  }
}

@keyframes item-rotate {
  from {
    rotate: calc(var(--r, 0deg) - 20deg);
  }
}

@keyframes item-rise {
  from {
    translate: var(--shift) calc(var(--shift) + var(--rise));
  }
}

/* A page's items wait for the page to scroll into view (script.js sets .is-active) */
.js .page:not(.is-active) .item {
  animation: none;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .item,
  .js .page:not(.is-active) .item {
    animation: none;
    opacity: 1;
  }
}

/* ---------- Page 2: the GIF ---------- */

.logo {
  position: absolute;
  left: calc(218.5 * var(--u));
  top: calc(56 * var(--u));
  translate: -50% 0;
  font-family: "Dirtyline 36Daysoftype 2022", sans-serif;
  font-size: calc(48 * var(--u));
  font-feature-settings: "salt" 1, "ss01" 1;
  line-height: 1;
  white-space: nowrap;
  text-box: trim-both cap alphabetic;
  text-decoration: none;
  color: var(--color-text);
}

.logo__break {
  display: none;
}

.gif {
  position: absolute;
  left: calc(627 * var(--u));
  top: calc(228 * var(--u));
  width: calc(665 * var(--u));
  height: calc(502 * var(--u));
  margin: 0;
}

.gif__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain; /* show the whole GIF, whatever its proportions */
  transition: opacity 200ms ease;
}

.gif.is-loading .gif__image {
  opacity: 0.35;
}

.actions {
  position: absolute;
  left: calc(959.5 * var(--u));
  top: calc(762 * var(--u));
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: calc(8 * var(--u));
}

.action {
  display: flex;
  align-items: center;
  gap: calc(8 * var(--u));
  padding: calc(12 * var(--u)) calc(20 * var(--u)) calc(12 * var(--u)) calc(16 * var(--u));
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-family: "Geist", system-ui, sans-serif;
  font-size: calc(32 * var(--u));
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  color: var(--color-text);
  cursor: pointer;
  transition:
    background-color 150ms ease,
    color 150ms ease;
}

/* Hover states from Figma: each button takes the colour of one of the shapes */
.action--send {
  --hover-bg: #00b5ff;
}

.action--say {
  --hover-bg: #00d370;
  --hover-radius: 0;
}

/* "Another GIF" gets a wavy yellow cloud instead of a pill: drawn behind the
   button, 4px taller than it top and bottom, as in Figma */
.action--another {
  --hover-bg: transparent;
  --hover-color: #000;
  position: relative;
  isolation: isolate;
}

.action--another::before {
  content: "";
  position: absolute;
  inset: calc(-4 * var(--u)) 0 calc(-4 * var(--u)) calc(1 * var(--u));
  z-index: -1;
  background: url("data:image/svg+xml,%3Csvg preserveAspectRatio='none' width='249.032' height='64' viewBox='0 0 249.032 64' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23F8FD00'%3E%3Cpath d='M64.0316 32C64.0316 49.6731 49.6977 64 32.0158 64C14.334 64 0 49.6731 0 32C0 14.3269 14.334 0 32.0158 0C49.6977 0 64.0316 14.3269 64.0316 32Z'/%3E%3Cpath d='M94.865 32C94.865 49.6731 80.531 64 62.8491 64C45.1673 64 30.8333 49.6731 30.8333 32C30.8333 14.3269 45.1673 0 62.8491 0C80.531 0 94.865 14.3269 94.865 32Z'/%3E%3Cpath d='M125.698 32C125.698 49.6731 111.364 64 93.6825 64C76.0006 64 61.6667 49.6731 61.6667 32C61.6667 14.3269 76.0006 0 93.6825 0C111.364 0 125.698 14.3269 125.698 32Z'/%3E%3Cpath d='M156.532 32C156.532 49.6731 142.198 64 124.516 64C106.834 64 92.5 49.6731 92.5 32C92.5 14.3269 106.834 0 124.516 0C142.198 0 156.532 14.3269 156.532 32Z'/%3E%3Cpath d='M187.365 32C187.365 49.6731 173.031 64 155.349 64C137.667 64 123.333 49.6731 123.333 32C123.333 14.3269 137.667 0 155.349 0C173.031 0 187.365 14.3269 187.365 32Z'/%3E%3Cpath d='M218.198 32C218.198 49.6731 203.864 64 186.182 64C168.501 64 154.167 49.6731 154.167 32C154.167 14.3269 168.501 0 186.182 0C203.864 0 218.198 14.3269 218.198 32Z'/%3E%3Cpath d='M249.032 32C249.032 49.6731 234.698 64 217.016 64C199.334 64 185 49.6731 185 32C185 14.3269 199.334 0 217.016 0C234.698 0 249.032 14.3269 249.032 32Z'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
  opacity: 0;
  transition: opacity 150ms ease;
}

@media (hover: hover) {
  .action--another:hover:not(:disabled)::before {
    opacity: 1;
  }
}

.action__icon--hover {
  display: none;
}

@media (hover: hover) {
  .action:hover:not(:disabled) {
    background: var(--hover-bg);
    border-radius: var(--hover-radius, 999px);
    color: var(--hover-color, var(--color-text));
  }

  .action--another:hover:not(:disabled) .action__icon {
    display: none;
  }

  .action--another:hover:not(:disabled) .action__icon--hover {
    display: block;
  }
}

/* Pressed: the same fill at 30% (70% transparent). Comes after the hover
   rules so it wins while the mouse is down. */
.action:active:not(:disabled) {
  background: color-mix(in srgb, var(--hover-bg) 30%, transparent);
  border-radius: var(--hover-radius, 999px);
}

.action--another:active:not(:disabled)::before {
  opacity: 0.3;
}

/* Black text would vanish on the faded yellow, so keep it white */
.action--another:active:not(:disabled) {
  color: var(--color-text);
}

.action--another:active:not(:disabled) .action__icon {
  display: block;
}

.action--another:active:not(:disabled) .action__icon--hover {
  display: none;
}

.action:focus-visible,
.contact:focus-visible,
.logo:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 2px;
}

.action:disabled {
  opacity: 0.5;
  cursor: default;
}

.action picture {
  display: contents;
}

.action source {
  display: none;
}

.action__icon {
  flex: none;
  width: calc(32 * var(--u));
  height: calc(32 * var(--u));
}

.action__label {
  display: block;
  /* line box = cap height, as in the design */
  padding-block: calc((32 * var(--u) - 1cap) / 2);
  text-box: trim-both cap alphabetic;
}

.item--green-badge {
  --x: 1791;
  --y: 990;
  --w: 162;
  --h: 162;
  --d: 547.06ms;
}

/* "Contact me": the blue flower in the bottom-left corner, a link.
   The link box is the flower's 200×200 square, centred at (88, 1054). */
.contact {
  --size: 200;
  position: absolute;
  left: calc((88 - var(--size) / 2) * var(--u));
  top: calc((1054 - var(--size) / 2) * var(--u));
  width: calc(var(--size) * var(--u));
  height: calc(var(--size) * var(--u));
  border-radius: 50%;
  color: var(--color-text);
  text-decoration: none;
}

.item--contact {
  --shift: -50%;
  --x: calc(var(--size) / 2);
  --y: calc(var(--size) / 2);
  --w: var(--size);
  --h: var(--size);
  --r: -90deg;
  --d: 200.72ms;

  /* Spins while the link is hovered and stops where it is when the pointer
     leaves. Uses `transform` so it adds to the entrance's `rotate`. */
  animation:
    item-fade calc(400ms - var(--cut, 0ms)) cubic-bezier(0.5, 0, 0.5, 1) var(--d, 0ms) both,
    item-scale calc(800ms - var(--cut, 0ms)) var(--ease-pop) var(--d, 0ms) both,
    item-rotate calc(900ms - var(--cut, 0ms)) var(--ease-pop) var(--d, 0ms) both,
    item-rise calc(1000ms - var(--cut, 0ms)) var(--ease-pop) var(--d, 0ms) both,
    contact-spin 3s linear infinite paused;
}

@media (hover: hover) {
  .contact:hover .item--contact {
    animation-play-state: running;
  }
}

@media (prefers-reduced-motion: reduce) {
  .item--contact {
    animation: none;
  }
}

@keyframes contact-spin {
  to {
    transform: rotate(360deg);
  }
}

.contact__text {
  position: absolute;
  left: 50%;
  top: calc(50% - 14 * var(--u));
  translate: -50% -50%;
  font-family: "Geist", system-ui, sans-serif;
  font-size: calc(24 * var(--u));
  font-weight: 500;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  text-box: trim-both cap alphabetic;
}

.badge__text {
  position: absolute;
  left: calc(1866.5 * var(--u));
  top: calc(1044 * var(--u));
  translate: -50% 0;
  margin: 0;
  font-family: "Dirtyline 36Daysoftype 2022", sans-serif;
  font-size: calc(16 * var(--u));
  font-feature-settings: "salt" 1, "ss01" 1;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  text-box: trim-both cap alphabetic;
  color: var(--color-text);
}

/* Mobile: the 402×874 frame. Same animations, different composition. */
@media (max-aspect-ratio: 4 / 5) {
  main {
    --frame-w: 402;
    --frame-h: 874;
    --page-gap: 72;
  }

  .title {
    --title-x: 201.5;
    --title-y: 148;
    --title-size: 156;
  }

  .title__lines--desktop {
    display: none;
  }

  .title__lines--mobile {
    display: block;
  }

  .item--cat-smug,
  .item--yellow,
  .item--red {
    display: none;
  }

  .item--picard {
    --x: 24;
    --w: 280;
    --h: 160.03;
    /* sits on the bottom edge of the screen, however tall the phone is */
    top: auto;
    bottom: calc((var(--frame-h) * var(--u) - 100dvh) / 2);
  }

  .item--cat-black {
    --x: 324.29;
    --y: 212.17;
    --w: 119.8;
    --h: 178.09;
  }

  .item--blue {
    --x: 63.23;
    --y: 85.23;
    --w: 100.35;
    --h: 100.35;
    --r: -108.02deg;
  }

  .item--green {
    --x: 280;
    --y: 631;
    --w: 94;
    --h: 94;
  }

  /* Page 2 */
  .logo {
    left: calc(89.5 * var(--u));
    top: calc(24 * var(--u));
    font-size: calc(32 * var(--u));
    text-align: center;
    white-space: pre;
  }

  .logo__break {
    display: inline;
  }

  .gif {
    left: calc(32 * var(--u));
    top: calc(222 * var(--u));
    width: calc(338 * var(--u));
    height: calc(338 * 502 / 665 * var(--u));
  }

  .actions {
    left: 50%;
    top: calc(526 * var(--u));
    flex-direction: column;
    gap: calc(16 * var(--u));
  }

  .action {
    font-size: calc(24 * var(--u));
  }

  .action__icon {
    width: calc(24 * var(--u));
    height: calc(24 * var(--u));
  }

  .action__label {
    padding-block: calc((24 * var(--u) - 1cap) / 2);
  }

  .item--green-badge {
    --x: 281;
    --y: 775;
  }

  .badge__text {
    left: calc(356.5 * var(--u));
    top: calc(829 * var(--u));
  }

  /* Same 200×200 flower as desktop, centred at (56, 851) */
  .contact {
    left: calc((56 - var(--size) / 2) * var(--u));
    top: calc((851 - var(--size) / 2) * var(--u));
  }
}
