/* The like button: a heart and a count in a white pill, on a white page. Liked, the heart is red and full, a ring
   and short rays burst around it, and the count rolls up by one. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #1d1a1b;           /* the empty heart and the count */
  --red: #ff2f55;           /* the full heart */
  --line: #e8e2dc;          /* the edge of the pill */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

/* ---------------------------------------------------------------- the pill */
.like {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 68px;
  padding: 0 30px 0 22px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--line), 0 18px 36px -26px rgba(40, 20, 24, 0.45);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.like[aria-pressed='true'] {
  background: #fff5f7;
  box-shadow: inset 0 0 0 1.5px #ffd2db, 0 18px 36px -26px rgba(255, 47, 85, 0.55);
}

@media (hover: hover) and (pointer: fine) {
  .like:hover {
    box-shadow: inset 0 0 0 1.5px #d9d1c9, 0 22px 40px -26px rgba(40, 20, 24, 0.5);
  }

  .like[aria-pressed='true']:hover {
    box-shadow: inset 0 0 0 1.5px #ffbdca, 0 22px 40px -26px rgba(255, 47, 85, 0.6);
  }
}

.like:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

/* ---------------------------------------------------------------- the heart, and what bursts around it */
.like__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
}

.like__heart {
  width: 32px;
  height: 32px;
  overflow: visible;
}

.like__outline {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.1;
  stroke-linejoin: round;
  transition: stroke 0.25s ease;
}

.like[aria-pressed='true'] .like__outline {
  stroke: var(--red);
}

.like__fill {
  fill: var(--red);
}

.like__burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  overflow: visible;
  pointer-events: none;
}

.like__ring {
  fill: none;
  stroke: #ff7d96;
  stroke-width: 0;          /* the script grows it as an inline style: an attribute would lose to this rule */
}

.like__burst line {
  stroke-width: 3;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the count: each figure rolls in its own slot */
.like__count {
  display: inline-flex;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: color 0.3s ease;
}

.like[aria-pressed='true'] .like__count {
  color: var(--red);
}

.slot {
  position: relative;
  display: inline-block;
  overflow: hidden;
  padding: 4px 0;
  margin: -4px 0;
}

.slot > span {
  display: inline-block;
}

.slot > span + span {
  position: absolute;
  left: 0;
  top: 4px;
}
