/* The dialog drawn on a thread: a white page, one ink hairline and one vermilion tip. The outlines of the button
   and of the window are not borders: they are one thin path drawn by the script, the thread. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #141414;           /* the thread, the words, the Archive button */
  --muted: #74716b;         /* the small print */
  --rule: #e9e7e2;          /* the hairline above the buttons */
  --soft: #f3f2ee;          /* the fill of the buttons under the finger */
  --accent: #f0461e;        /* the tip that leads the thread, the tick of Archived */
  --veil: #141414;          /* the page behind the window, darkened a little */
}

@property --hw {
  syntax: '<number>';
  inherits: true;
  initial-value: 0;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

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

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

.slot {
  position: relative;
  display: inline-flex;
}

/* ---------------------------------------------------------------- the button the thread comes out of */
.opener {
  position: relative;
  display: grid;
  place-items: center;
  height: 56px;
  padding: 0 30px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: 560 16px/1 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  letter-spacing: -0.005em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.opener[aria-disabled='true'] {
  cursor: default;
}

/* the fill swells in under the pointer, with a small spring */
.opener__fill {
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  background: var(--soft);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.2s, transform 0.5s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.opener__face {
  position: relative;
  display: grid;
  place-items: center;
}

.opener__label {
  --w: 100;
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-variation-settings: 'wdth' calc(var(--w) + var(--hw));
  transition: --hw 0.45s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.opener__label--done {
  opacity: 0;
}

/* an unseen copy of the words, as wide as they get under the pointer: the button keeps one width in every state,
   so the thread's outline never moves while the words narrow, widen or change */
.opener__label--size {
  visibility: hidden;
  font-variation-settings: 'wdth' 110;
  transition: none;
}

.opener__label svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .opener:not([aria-disabled='true']):hover .opener__fill {
    opacity: 1;
    transform: scale(1);
  }

  .opener:not([aria-disabled='true']):hover .opener__label {
    --hw: 10;
  }
}

/* the finger has the same as the hover, while it is down */
.opener.is-touched:not([aria-disabled='true']) .opener__fill {
  opacity: 1;
  transform: scale(1);
}

.opener:active:not([aria-disabled='true']) .opener__fill {
  transform: scale(0.96);
  transition-duration: 0.12s;
}

.slot__under {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding-top: 10px;
}

.undo {
  --w: 100;
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 520 14px/1 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  font-variation-settings: 'wdth' calc(var(--w) + var(--hw));
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s, --hw 0.45s cubic-bezier(0.3, 1.5, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

.undo[hidden] {
  display: none;
}

@media (hover: hover) {
  .undo:hover {
    --hw: 14;
    color: var(--ink);
  }
}

.undo:active {
  background: var(--soft);
  color: var(--ink);
}

/* ---------------------------------------------------------------- the window */
.veil {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: transparent;
  pointer-events: none;
}

.veil.is-on {
  pointer-events: auto;
}

.layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  pointer-events: none;
}

.box {
  position: relative;
  width: min(392px, 100%);
  padding: 28px 28px 20px;
  visibility: hidden;
  outline: none;
}

.box.is-on {
  visibility: visible;
  pointer-events: auto;
}

/* the paper only comes once the thread has closed round it */
.box__paper {
  position: absolute;
  inset: 0;
  border-radius: var(--radius, 20px);
  background: var(--page);
  box-shadow: 0 34px 70px -40px rgba(20, 20, 20, 0.34), 0 2px 8px rgba(20, 20, 20, 0.03);
  opacity: 0;
}

.box__body {
  position: relative;
}

.box__title {
  margin: 0;
  font-size: 23px;
  line-height: 1.15;
  font-weight: 640;
  letter-spacing: -0.018em;
}

/* the title's words never break, its letters move on their own */
.box__title .word {
  display: inline-block;
  white-space: nowrap;
}

.box__title .ch {
  --w: 100;
  --g: 640;
  display: inline-block;
  font-variation-settings: 'wdth' var(--w), 'wght' var(--g);
}

.box__text {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 420;
}

.box__text strong {
  color: var(--ink);
  font-weight: 560;
}

/* a hairline from edge to edge, drawn from the left */
.box__rule {
  height: 1px;
  margin: 22px -28px 16px;
  background: var(--rule);
  transform-origin: 0 50%;
}

.box__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.act {
  --w: 100;
  height: 42px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  font: 560 15px/1 'Mona Sans Variable', 'Mona Sans', system-ui, sans-serif;
  font-variation-settings: 'wdth' calc(var(--w) + var(--hw));
  cursor: pointer;
  transition: background-color 0.2s, --hw 0.45s cubic-bezier(0.3, 1.5, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

.act--ghost {
  background: transparent;
  color: var(--ink);
}

.act--ink {
  background: var(--ink);
  color: var(--page);
}

@media (hover: hover) {
  .act--ghost:hover {
    background: var(--soft);
  }

  .act:hover {
    --hw: 12;
  }
}

.act--ghost:active {
  background: var(--soft);
}

/* ---------------------------------------------------------------- the focus, for the keys */
.opener:focus-visible,
.act:focus-visible,
.undo:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.opener:focus-visible {
  outline-offset: 5px;
}

html[data-using='pointer'] .opener:focus-visible,
html[data-using='pointer'] .act:focus-visible,
html[data-using='pointer'] .undo:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- the thread */
.thread {
  position: fixed;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.thread path {
  fill: none;
  stroke-linejoin: round;
}

.thread__ink {
  stroke: var(--ink);
  stroke-width: 1;
}

.thread__tip {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: butt;
  opacity: 0;
}

.sr {
  position: absolute;
  /* in cima alla pagina: dopo il palco alto quanto lo schermo allungava la pagina oltre la casella */
  top: 0;
  left: 0;
  margin: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 480px) {
  .box {
    padding: 24px 22px 18px;
  }

  .box__title {
    font-size: 21px;
  }

  .box__rule {
    margin: 20px -22px 14px;
  }
}
