/* The button that asks twice: a minimal piece. One ink pill on a white page, a line of Archivo whose width axis
   does the counting, and one vermilion accent for the danger: the last word of the question and the line that
   burns down under it. The pill, the labels and the line are placed by the script.
   In a real page the button sits where its project's actions are; here it stands alone in the middle. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #141414;          /* the pill, and the line it folds into */
  --pill-on: #262626;       /* the pill under the pointer */
  --type: #f6f3ec;          /* the letters on the pill */
  --accent: #ff4a1c;        /* the danger: the last word of the question, the burning line, the focus ring */
  --note: #77736b;          /* Project deleted */
  --ink: #141414;           /* Undo */
}

* {
  box-sizing: border-box;
}

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

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

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

/* every piece is placed from the centre of the frame */
.frame {
  position: relative;
  width: 300px;             /* set by the script: the widest state, plus air */
  max-width: 100%;
  height: 76px;
}

/* ---------------------------------------------------------------- the pill */
.pill {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 60px;              /* width, height and margins are set by the script, frame by frame */
  height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 999px;
  background: var(--pill);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: background-color 0.3s ease;
}

.frame.is-on .pill {
  background: var(--pill-on);
}

/* a label: its centre is the centre of the frame, wherever the pill's edges are (top is set by the script) */
.label {
  position: absolute;
  left: 50%;
  top: 30px;
  transform: translate(-50%, -50%);
  font-size: 17px;
  line-height: 22px;
  color: var(--type);
  white-space: pre;
  font-variation-settings: 'wdth' 100, 'wght' 560;
}

.ch {
  display: inline-block;
  white-space: pre;
  opacity: 0;
  will-change: transform;
}

.ch--accent {
  color: var(--accent);
}

/* the time left: a thin line under the question, burning down from both ends */
.fuse {
  position: absolute;
  left: 50%;
  top: 44px;
  width: 0;
  height: 1.5px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
}

/* ---------------------------------------------------------------- the button: clear, over the pill */
.del {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 180px;             /* set by the script */
  height: 60px;
  margin: -30px 0 0 -90px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.del:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.frame.is-done .del {
  visibility: hidden;
}

/* ---------------------------------------------------------------- once it is done */
/* the row sits on the line the pill folds into (14 px under the centre): its words rise out of that line, so
   the clips that hide them end just on top of it */
.done {
  position: absolute;
  left: 50%;
  top: 50%;
  height: 30px;
  margin-top: -17px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  visibility: hidden;
}

.frame.is-folded .done {
  visibility: visible;
}

/* while the pill folds, its focus ring would draw around nothing: it waits for Undo */
.frame.is-folded .del:focus-visible {
  outline-color: transparent;
}

.done__clip,
.undo__clip {
  display: flex;
  align-items: flex-start;
  height: 30px;
  padding-top: 6px;
  overflow: hidden;
}

.done__text,
.undo__word {
  font-size: 17px;
  line-height: 22px;
  white-space: pre;
}

.done__text {
  color: var(--note);
  font-variation-settings: 'wdth' 100, 'wght' 440;
}

.undo {
  position: relative;
  display: flex;
  align-items: flex-start;
  height: 25px;
  padding: 0 2px;
  white-space: normal;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

/* a finger needs more than the word: the hit area reaches past it, the line stays clear */
.undo::after {
  content: '';
  position: absolute;
  inset: -10px -10px -4px;
}

.undo:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.undo__clip {
  gap: 6px;
}

.undo__arrow {
  flex: none;
  width: 15px;
  height: 15px;
  margin-top: 3.5px;
  overflow: visible;
  opacity: 0;
  transform-origin: 50% 50%;
}

.undo__arrow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.undo__word {
  font-variation-settings: 'wdth' 100, 'wght' 560;
}

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