:root {
  --paper: #fbf5ec;
  --ink: #2b2238;
  --ink-soft: #5e5468;
  --dot: rgb(43 34 56 / 0.09);
  --pink: #ff74b1;
  --tomato: #ff5a4e;
  --focus: #6c4fd0;
  --rounded: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Quicksand", system-ui, sans-serif;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background-color: var(--paper);
  /* A pegboard of tiny dots: the surface beads are arranged on. */
  background-image: radial-gradient(circle, var(--dot) 1.4px, transparent 1.6px);
  background-size: 22px 22px;
  background-position: center top;
  color: var(--ink);
  font-family: var(--rounded);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a {
  color: inherit;
}

a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
  border-radius: 999px;
}

.bar,
.foot {
  padding: 1.5rem var(--gutter);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.125rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.wordmark-bead {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 32%, #ffb3a6 0, var(--tomato) 45%, #c7322a 100%);
  transition: transform 400ms var(--spring);
}

.wordmark:hover .wordmark-bead {
  transform: scale(1.25);
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  padding: 0 var(--gutter);
}

.intro {
  order: 2;
  align-self: end;
  padding: 2.5rem 0 1rem;
}

h1 {
  margin: 0;
  font-size: clamp(3.5rem, 15vw, 9.5rem);
  font-weight: 800;
  line-height: 0.92;
  letter-spacing: -0.05em;
}

.lede {
  margin: 0.4em 0 0;
  font-size: clamp(1.75rem, 5.2vw, 3.25rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--ink-soft);
}

.note {
  margin: 1.25rem 0 0;
  max-width: 32ch;
  font-family: system-ui, sans-serif;
  text-wrap: balance;
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.necklace {
  order: 1;
  display: block;
  width: min(calc(100% + 2rem), 34rem);
  height: auto;
  margin: 0 0 1rem;
  justify-self: center;
  overflow: visible;
}

.pin {
  fill: var(--ink);
}

.thread {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.55;
}

.string {
  transform-box: view-box;
  transform-origin: 300px 40px;
  /* Skewing from the pins keeps both ends attached while the bottom swings. */
  animation: sway 9s ease-in-out 1.8s infinite;
}

.bead {
  transform-box: fill-box;
  transform-origin: center;
  animation: thread-on 560ms var(--spring) both;
  animation-delay: calc(var(--order) * 55ms + 150ms);
}

.bead-pop {
  animation:
    thread-on 700ms var(--spring) both,
    pop 3.6s var(--spring) 2.4s infinite;
  animation-delay: calc(var(--order) * 55ms + 150ms), 2.4s;
}

.burst {
  fill: none;
  stroke: var(--pink);
  stroke-width: 5;
  stroke-linecap: round;
  transform-box: view-box;
  transform-origin: 300px 330px;
  opacity: 0;
  animation: burst 3.6s ease-out 2.4s infinite;
}

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9375rem;
  font-family: system-ui, sans-serif;
}

.maker,
.motion {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font: inherit;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px rgb(43 34 56 / 0.18);
  transition:
    color 200ms ease,
    box-shadow 200ms ease,
    background-color 200ms ease;
}

.maker {
  margin-left: auto;
}

.motion {
  cursor: pointer;
}

.motion[hidden] {
  display: none;
}

.maker:hover,
.motion:hover {
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.motion[aria-pressed="true"] {
  background-color: var(--ink);
  color: var(--paper);
  box-shadow: inset 0 0 0 1.5px var(--ink);
}

.motion:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
}

[data-motion="paused"] .necklace,
[data-motion="paused"] .necklace * {
  animation-play-state: paused;
}

@media (min-width: 900px) {
  .stage {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    grid-template-rows: minmax(0, 1fr);
    column-gap: 2rem;
  }

  .intro {
    order: 1;
    padding: 0 0 clamp(1rem, 4vh, 3rem);
  }

  .necklace {
    order: 2;
    width: 100%;
    max-width: 44rem;
    margin: -1.5rem 0 0 auto;
    justify-self: end;
    align-self: start;
  }
}

@keyframes thread-on {
  from {
    transform: scale(0);
  }
  to {
    transform: scale(1);
  }
}

@keyframes pop {
  0%,
  16%,
  100% {
    scale: 1;
  }
  6% {
    scale: 1.12;
  }
}

@keyframes burst {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  5% {
    opacity: 1;
  }
  22% {
    opacity: 0;
    transform: scale(1.18);
  }
  100% {
    opacity: 0;
    transform: scale(1.18);
  }
}

@keyframes sway {
  0%,
  50%,
  100% {
    transform: skewX(0deg);
  }
  25% {
    transform: skewX(2.2deg);
  }
  75% {
    transform: skewX(-2.2deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .string,
  .bead,
  .bead-pop,
  .burst {
    animation: none;
  }

  .wordmark-bead {
    transition: none;
  }

  /* Nothing moves, so there is nothing to pause. */
  .motion {
    display: none;
  }
}
