/* The crumpling button: a pale red button on a white page. The script draws its paper in an SVG, so that it can
   crumple into a ball, and the bin the ball is thrown into. */
:root {
  --page: #ffffff;          /* the page */
  --paper: #fff0f0;         /* the button's paper */
  --line: #e5484d;          /* its edge and its words */
  --crease: #b9474a;        /* the creases of the ball */
  --bin: #2f3640;           /* the bin */
  --bin-inside: #1c2128;
  --ink: #2a2d33;
  --muted: #7d828c;
}

* {
  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: 'Red Hat Text 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: 160px 16px 80px;
}

.crumple {
  display: grid;
  justify-items: center;
}

/* on a narrow screen the button moves over to the left, so the bin that comes up on its right is inside the screen */
@media (max-width: 520px) {
  .crumple {
    margin-right: 132px;
  }
}

/* the button's place: the paper is drawn here, and the bin comes up beside it */
.crumple__spot {
  position: relative;
  width: 220px;
  height: 56px;
}

.crumple__art {
  position: absolute;
  overflow: visible;
  pointer-events: none;
}

.crumple__btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--line);
  font: inherit;
  font-size: 17px;
  font-weight: 650;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.crumple__btn > * {
  pointer-events: none;
}

.crumple__icon {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crumple.is-gone .crumple__btn {
  visibility: hidden;
}

/* in the button's place once it has gone */
.crumple__gone {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
}

.crumple__gone[hidden] {
  display: none;
}

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

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

html[data-using='pointer'] .crumple__btn:focus-visible,
html[data-using='pointer'] .crumple__undo:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- the drawing */
.crumple__paper {
  fill: var(--paper);
  stroke: var(--line);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.crumple__shadow {
  stop-color: color-mix(in srgb, var(--line) 38%, transparent);
}

.crumple__crease {
  fill: none;
  stroke: var(--crease);
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.crumple__bin {
  fill: var(--bin);
}

.crumple__bin-inside {
  fill: var(--bin-inside);
}

.crumple__bin-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 2;
  stroke-linecap: round;
}
