/* The shredder delete button: a red Delete button under a sheet of paper drawn in a canvas, on a white page. Pressed,
   the button becomes a graphite shredder and the sheet goes through it; the canvas draws the sheet above the slot and
   the strips that come out underneath. */
:root {
  --page: #ffffff;          /* the page */
  --paper: #fdfdfb;         /* the sheet, front */
  --paper-back: #e9ebee;    /* the sheet, back (seen when a strip turns over) */
  --paper-edge: #d5dae2;    /* the edges of the sheet and of every strip, so that white paper shows on the white page */
  --doc-ink: #1d2533;       /* the lines of text on the sheet */
  --doc-muted: #8890a0;     /* the small print */
  --doc-invoice: #2f6b57;   /* the colour of the invoice */
  --doc-letter: #7a3b5e;    /* the colour of the letter */
  --doc-report: #3a62c9;    /* the colour of the report */
  --danger: #e5484d;        /* the Delete button */
  --machine: #26282d;       /* the shredder */
  --ink: #1d2533;           /* the ring of the focus */
  --muted: #7c8494;         /* the outline left where the sheet was */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Onest 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: 32px 16px;
}

/* the whole thing: the sheet, the button, and room underneath for the strips to fall */
.shred {
  position: relative;
  display: grid;
  justify-items: center;
  padding-bottom: 170px;
}

/* one canvas over the window, under the button: the sheet and the strips */
.shred__canvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the sheet: the canvas draws it here */
.shred__sheet {
  position: relative;
  width: 208px;
  height: 270px;
}

/* where the sheet was, once it is gone */
.shred__ghost {
  position: absolute;
  inset: 0;
  border: 1.5px dashed color-mix(in srgb, var(--muted) 55%, transparent);
  border-radius: 4px;
  opacity: 0;
}

/* ---------------------------------------------------------------- the button */
.shred__box {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 264px;
  height: 66px;
  margin-top: 22px;
}

.shred__btn {
  position: relative;
  width: 172px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 26px;
  overflow: hidden;
  background: transparent;
  color: #fff;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 14px 26px -14px rgba(22, 28, 40, 0.55), 0 2px 5px rgba(22, 28, 40, 0.14);
  -webkit-tap-highlight-color: transparent;
}

.shred__face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.shred__face--delete {
  background: linear-gradient(180deg, color-mix(in srgb, var(--danger) 86%, #fff), var(--danger) 55%, color-mix(in srgb, var(--danger) 88%, #000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 -1px 0 rgba(0, 0, 0, 0.12);
}

/* the shredder: graphite, with the slot along the top and the cutters along the bottom */
.shred__face--machine {
  opacity: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--machine) 78%, #fff) 0%, var(--machine) 34%, color-mix(in srgb, var(--machine) 80%, #000) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), inset 0 -1px 0 rgba(0, 0, 0, 0.5);
}

.shred__slot {
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 7px;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(180deg, #050506, #15161a);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
}

.shred__teeth {
  position: absolute;
  bottom: 0;
  left: 14px;
  right: 14px;
  height: 7px;
  border-radius: 4px 4px 0 0;
  background: repeating-linear-gradient(90deg, #0b0c0e 0 calc(100% - 1.5px), #3b3e45 calc(100% - 1.5px) 100%);
  background-size: 16px 100%;
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.08);
}

.shred__state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding-top: 1px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 13px;
  font-weight: 520;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.shred__face--undo {
  opacity: 0;
  background: #22252b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* the time left to undo: a thin line along the bottom that drains to the left */
.shred__timer {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 7px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.5);
  transform-origin: 0 50%;
}

.shred__label {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
  pointer-events: none;
}

.shred__label--undo {
  opacity: 0;
}

.shred__icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

/* the lid of the bin opens under the pointer, or under the finger */
.shred__lid {
  transform-origin: 4px 6.5px;
  transition: transform 0.35s cubic-bezier(0.3, 1.7, 0.5, 1);
}

@media (hover: hover) and (pointer: fine) {
  .shred[data-state='idle'] .shred__btn:hover .shred__lid {
    transform: translateY(-1px) rotate(-18deg);
  }
}

.shred__btn[data-press] .shred__lid {
  transform: translateY(-1px) rotate(-18deg);
}

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

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

@media (prefers-reduced-motion: reduce) {
  .shred__lid {
    transition: none;
  }
}
