:root {
  --bg: #fbf7f0;
  --ink: #1d1b19;
  --muted: #6b645b;
  --ball: #e4572e;
  --shadow: rgba(29, 27, 25, 0.2);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16151a;
    --ink: #f2efe9;
    --muted: #a39d94;
    --ball: #ff7a4d;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
}

main { max-width: 36rem; text-align: center; }

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 9vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.lede { margin: 0.75rem 0 0; font-size: 1.2rem; }
.note { margin: 0.25rem 0 0; color: var(--muted); }
a { color: inherit; text-underline-offset: 0.2em; }

/* A bouncing ball with squash and stretch: the first exercise of every animator. */
.stage {
  position: relative;
  width: 10rem;
  height: 11rem;
  margin: 0 auto 2.5rem;
}

.ball {
  position: absolute;
  left: 50%;
  top: 0;
  width: 3rem;
  height: 3rem;
  margin-left: -1.5rem;
  border-radius: 50%;
  background: var(--ball);
  transform-origin: 50% 100%;
  animation: bounce 1.1s infinite;
}

.shadow {
  position: absolute;
  left: 50%;
  bottom: -0.35rem;
  width: 3.6rem;
  height: 0.7rem;
  margin-left: -1.8rem;
  border-radius: 50%;
  background: var(--shadow);
  animation: shadow 1.1s infinite;
}

@keyframes bounce {
  0%   { transform: translateY(0) scale(1, 1); animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
  46%  { transform: translateY(7.6rem) scale(0.88, 1.14); animation-timing-function: linear; }
  50%  { transform: translateY(8rem) scale(1.35, 0.68); animation-timing-function: linear; }
  54%  { transform: translateY(7.6rem) scale(0.9, 1.12); animation-timing-function: cubic-bezier(0, 0.55, 0.45, 1); }
  100% { transform: translateY(0) scale(1, 1); }
}

@keyframes shadow {
  0%   { transform: scale(0.4); opacity: 0.4; animation-timing-function: cubic-bezier(0.55, 0, 1, 0.45); }
  50%  { transform: scale(1.1); opacity: 1; animation-timing-function: cubic-bezier(0, 0.55, 0.45, 1); }
  100% { transform: scale(0.4); opacity: 0.4; }
}

.resting .ball,
.resting .shadow { animation: none; }
.resting .ball { transform: translateY(8rem); }
.resting .shadow { transform: scale(1); }

@media (prefers-reduced-motion: reduce) {
  .ball, .shadow { animation: none; }
  .ball { transform: translateY(8rem); }
  .shadow { transform: scale(1); }
}
