/* Flick stickers: the "why join" stickers of a made-up book club, stuck around a round stamp. Brush one fast with
   the mouse and it is shoved and spun the way you hit it, then settles back. */
:root {
  --paper: #f6f1e7;        /* the page */
  --ink: #2a1a14;          /* text and the stamp */
  --accent: #d8431f;       /* the one accent: vermilion */
  --tone-1: #d8431f;       /* the accent, full */
  --tone-2: #f19a74;       /* the accent, light */
  --tone-3: #8f2510;       /* the accent, deep */
  --tone-4: #fbd5c2;       /* the accent, pale */
  --tone-5: #f6f1e7;       /* paper with an accent edge */
  --stage-w: min(94vw, 132vh, 760px);
  --stage-h: min(88vh, 70vw, 560px);
  --pill: calc(var(--stage-h) * 0.072);   /* the type size of a sticker */
}

* { box-sizing: border-box; }

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

body {
  display: grid;
  place-items: center;
  /* a faint grain so the paper is not flat */
  background-image: radial-gradient(rgba(42, 26, 20, 0.035) 0.6px, transparent 0.7px);
  background-size: 4px 4px;
}

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

.stage {
  position: relative;
  width: var(--stage-w);
  height: var(--stage-h);
}

.brand {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  font-size: calc(var(--stage-h) * 0.032);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variation-settings: 'wdth' 90;
}
.brand span { font-weight: 450; opacity: 0.55; }

.hint {
  position: absolute;
  right: 0;
  bottom: 0;
  margin: 0;
  font-size: calc(var(--stage-h) * 0.028);
  font-weight: 450;
  opacity: 0.55;
}

/* the stamp */
.stamp {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--stage-h) * 0.66);
  aspect-ratio: 1;
  translate: -50% -50%;
}
.stamp svg { width: 100%; height: 100%; display: block; overflow: visible; }
.stamp__ring { fill: none; stroke: var(--ink); stroke-width: 3.4; }
.stamp__ring--thin { stroke-width: 1.2; stroke-dasharray: 2 4; opacity: 0.6; }
.stamp__text {
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  font-variation-settings: 'wdth' 80;
  fill: var(--ink);
  text-transform: uppercase;
}
.stamp__book path { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linejoin: round; }
.stamp__book .stamp__spine { stroke-width: 2; }

/* the stickers */
.stickers { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; }

.place {
  position: absolute;
  left: var(--l);
  top: var(--t);
  rotate: var(--r);
}

.body {
  display: block;
  position: relative;
  will-change: transform;
  cursor: grab;
  touch-action: none;
}

.face {
  display: block;
  white-space: nowrap;
  padding: 0.16em 0.62em 0.2em;
  border-radius: 999px;
  font-size: var(--pill);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.025em;
  font-variation-settings: 'wdth' 100;
  color: var(--paper);
  /* a thin lighter rim and a sheen that slides with the turn (--sheen is set by the script) */
  box-shadow: inset 0 0 0 0.06em rgba(255, 255, 255, 0.18), inset 0 -0.09em 0 rgba(0, 0, 0, 0.1);
  background-image: linear-gradient(105deg, transparent calc(30% + var(--sheen, 0%)), rgba(255, 255, 255, 0.22) calc(42% + var(--sheen, 0%)), transparent calc(54% + var(--sheen, 0%)));
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  user-select: none;
  -webkit-user-select: none;
}
.tone-1 { background-color: var(--tone-1); }
.tone-2 { background-color: var(--tone-2); color: var(--ink); }
.tone-3 { background-color: var(--tone-3); }
.tone-4 { background-color: var(--tone-4); color: var(--tone-3); }
.tone-5 { background-color: var(--tone-5); color: var(--accent); box-shadow: inset 0 0 0 0.075em var(--accent); }

/* the soft shadow on the paper: it stays down when the sticker flies, so it drifts, grows and fades */
.shadow {
  position: absolute;
  inset: 12% 4% -4%;
  border-radius: 999px;
  background: rgba(42, 26, 20, 0.22);
  filter: blur(calc(var(--stage-h) * 0.012));
  opacity: 0.55;
  will-change: transform, opacity;
}

@media (hover: hover) and (pointer: fine) {
  .place:hover .face { font-variation-settings: 'wdth' 112; }
}

@media (prefers-reduced-motion: reduce) {
  .face { transition: background-color 0.4s, color 0.4s; }
  .place:hover .face { font-variation-settings: 'wdth' 100; }
  .place:hover .tone-5 { background-color: var(--tone-4); }
}
