/* The sticker button: a coral die-cut sticker on a white page, and the code printed on the page underneath it. The
   script draws the sticker in an SVG: the part still stuck, and the part peeled, folded back over itself. */
:root {
  --page: #ffffff;          /* the page */
  --sticker: #ff5b4d;       /* the sticker */
  --sticker-ink: #ffffff;   /* its words */
  --edge: #ffffff;          /* the white rim of the die cut */
  --back: #f1ece3;          /* the back of the sticker */
  --under: #f6f2ea;         /* the page under the sticker */
  --ink: #2a2522;           /* the code and the words under it */
  --muted: #8d867c;         /* the line under the sticker */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

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

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

.peel {
  display: grid;
  justify-items: center;
  gap: 22px;
}

/* ---------------------------------------------------------------- the sticker and what is under it */
.peel__spot {
  position: relative;
  width: min(300px, calc(100vw - 64px));
  height: 104px;
}

/* the code printed on the page: only seen where the sticker has come away */
.peel__under {
  position: absolute;
  inset: 6px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 12px;
  padding: 0 14px 0 18px;
  border: 1.5px dashed #cfc6b8;
  border-radius: 22px;
  background: var(--under);
}

.peel__off {
  grid-column: 1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.peel__code {
  grid-column: 1;
  font-family: 'Google Sans Code Variable', ui-monospace, monospace;
  font-size: 24px;
  font-weight: 650;
  letter-spacing: 0.06em;
}

.peel__copy {
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #ffffff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.peel__art {
  position: absolute;
  left: -160px;
  top: -160px;
  width: calc(100% + 320px);
  height: calc(100% + 320px);
  overflow: visible;
  pointer-events: none;
}

.peel__label {
  fill: var(--sticker-ink);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* the hand peels this: a button the size of the sticker */
.peel__hit {
  position: absolute;
  inset: 0;
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

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

.peel.is-off .peel__hit {
  visibility: hidden;
}

/* ---------------------------------------------------------------- under the sticker */
.peel__row {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 72px;
}

.peel__hint {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.peel__hint span {
  display: inline-block;
}

.peel__back {
  min-height: 40px;
  padding: 0 18px;
  border: 1.5px solid #e2dbcf;
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.peel__back[hidden] {
  display: none;
}

.peel__hit:focus-visible,
.peel__copy:focus-visible,
.peel__back:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

html[data-using='pointer'] .peel__hit:focus-visible,
html[data-using='pointer'] .peel__copy:focus-visible,
html[data-using='pointer'] .peel__back:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- the drawing */
.peel__rim {
  fill: var(--edge);
}

.peel__face {
  fill: var(--sticker);
}

.peel__back-mid {
  stop-color: var(--back);
}

.peel__back-far {
  stop-color: color-mix(in srgb, var(--back) 86%, #8a7a66);
}
