/* The ball that bounces on the syllables: a minimal piece. A warm white page, one phrase in a variable face and one
   small ball in the only colour of the page. The syllables are plain HTML, so their weight and width can change
   while they move; the ball, its shadow and the line under the phrase are moved by the script. */
:root {
  --paper: #f4f1ea;   /* the page */
  --ink: #161513;     /* the sung syllables */
  --idle: #c9c2b4;    /* the syllables still to sing */
  --accent: #e2452f;  /* the ball */
  --rule: #d6cfc1;    /* the line under the phrase */
  --muted: #8b857a;   /* the small print */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.top {
  position: absolute;
  top: clamp(14px, 3.2vh, 32px);
  left: clamp(16px, 3vw, 40px);
  right: clamp(16px, 3vw, 40px);
  display: flex;
  justify-content: space-between;
  font-size: clamp(10px, 1.6vh, 13px);
  letter-spacing: 0.02em;
  color: var(--muted);
}

.top__brand {
  color: var(--ink);
  font-weight: 600;
}

.song {
  position: relative;
  font-size: clamp(26px, min(10vw, 13vh), 128px);
  line-height: 1.08;
  padding: 0.9em 0.4em 0.7em;
  touch-action: pan-y;
}

.lines {
  position: relative;
  z-index: 2;
}

.line {
  display: flex;
  justify-content: center;
  white-space: nowrap;
}

.word {
  display: inline-flex;
  margin: 0 0.13em;
}

/* the outer span is moved by GSAP, the inner one carries the weight and the width of the face */
.syl {
  display: inline-flex;
  justify-content: center;
  transform-origin: 50% 100%;
}

/* inside a word the syllables lean towards each other, so a pale word does not fall apart into pieces */
.syl[data-at='first'] {
  justify-content: flex-end;
}

.syl[data-at='last'] {
  justify-content: flex-start;
}

.syl__in {
  display: inline-block;
  color: var(--idle);
  font-weight: 300;
  font-stretch: 92%;
  letter-spacing: -0.01em;
}

.rule {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.rule path {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
}

.ball,
.shadow,
.hit {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.ball {
  width: 0;
  height: 0;
  z-index: 1;
}

.ball__body {
  position: absolute;
  left: calc(var(--r, 10px) * -1);
  top: calc(var(--r, 10px) * -1);
  width: calc(var(--r, 10px) * 2);
  height: calc(var(--r, 10px) * 2);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.55) 0 14%, rgba(255, 255, 255, 0) 38%),
    var(--accent);
  box-shadow: inset -1px -2px 3px rgba(80, 10, 0, 0.18);
  transform-origin: 50% 50%;
  transition: scale 0.25s ease;
}

.shadow {
  width: 0;
  height: 0;
}

.shadow::before {
  content: '';
  position: absolute;
  left: -0.18em;
  top: -0.025em;
  width: 0.36em;
  height: 0.05em;
  border-radius: 50%;
  background: rgba(40, 30, 20, 0.22);
  filter: blur(1.5px);
  transform: scale(var(--s, 1));
  opacity: var(--o, 1);
}

.hit {
  z-index: 3;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}

.hit.is-held {
  cursor: grabbing;
}

@media (hover: hover) {
  .song.is-near .ball__body {
    scale: 1.12;
  }
}

.hint {
  position: absolute;
  bottom: clamp(14px, 3.2vh, 32px);
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: clamp(10px, 1.6vh, 13px);
  letter-spacing: 0.02em;
  color: var(--muted);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  margin: -1px;
}
