/* The hanger button: an espresso pill on a white page, with a kraft paper bag in its round right end and, over it, a
   short steel rail with a linen shirt on a wooden hanger. The rail, the hanger, the shirt and the bag are drawn by
   script.js on a canvas (their colours come from here); the pill, the words and the states are CSS. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #33261f;          /* the pill, at its top */
  --pill-deep: #1e1612;     /* the pill, at its foot */
  --ink: #f6efe4;           /* the words */
  --muted: #b9a998;         /* the words while it adds */
  --chip: rgba(246, 239, 228, 0.1);   /* the little Undo pill */
  --linen: #a9bfd6;         /* the linen of the shirt */
  --linen-deep: #4f6a86;    /* the linen in the shade of its folds */
  --stitch: #e9eff5;        /* the stitches, the buttons and the light on the linen */
  --wood: #d2a36c;          /* the hanger's beech */
  --wood-dark: #8a5a2b;     /* the beech, in its shadow */
  --steel: #c9ced3;         /* the rail and the hook */
  --kraft: #c89b66;         /* the paper bag */
  --kraft-deep: #8c6338;    /* the bag, inside and in its creases */
  --tick: #9fd3a6;          /* the small tick once it is in the bag */
  --focus: #33261f;         /* the ring of the keyboard's focus */
}

* {
  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(--pill);
  font-family: 'Mona Sans Variable', 'Mona Sans', system-ui, -apple-system, 'Segoe 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: 72px 16px;
}

/* the rail and the shirt live in the room over the pill: it is part of the component */
.hang {
  position: relative;
  padding-top: 70px;
}

.hang__cloth {
  position: absolute;
  left: -24px;
  top: 0;
  pointer-events: none;
  z-index: 2;
}

/* ---------------------------------------------------------------- the pill */
.hang__btn {
  position: relative;
  display: block;
  width: 296px;
  max-width: calc(100vw - 32px);
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.hang__btn[aria-disabled='true'] {
  cursor: progress;
}

/* the fill is a layer of its own, so it can swell past the pill with a bounce without moving anything */
.hang__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(90% 140% at 20% 0%, rgba(255, 240, 220, 0.08), transparent 62%),
    linear-gradient(180deg, var(--pill), var(--pill-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 244, 228, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45),
    0 1px 2px rgba(30, 22, 18, 0.22),
    0 14px 28px -14px rgba(30, 22, 18, 0.62);
  transition:
    inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    box-shadow 0.4s ease;
}

.hang__btn:focus-visible {
  outline: 2.5px solid var(--focus);
  outline-offset: 5px;
}

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

/* ---------------------------------------------------------------- the words */
/* three faces on top of each other, left of the bag: at rest, while it adds, and in the bag */
.hang__faces {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 26px;
  right: 62px;
  pointer-events: none;
}

.hang__face {
  position: absolute;
  inset: 0 auto 0 0;
  width: max-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  text-align: left;
  white-space: nowrap;
}

.hang__face--busy,
.hang__face--done {
  opacity: 0;
  visibility: hidden;
}

/* the words at rest widen on the typeface's width axis under the pointer; the wide copy, invisible and zero high,
   holds their room */
.hang__word {
  display: inline-grid;
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 620;
  font-stretch: 100%;
  letter-spacing: -0.008em;
  line-height: 1;
  transition: font-stretch 0.6s cubic-bezier(0.34, 1.9, 0.45, 1), font-weight 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.hang__word::before {
  content: attr(data-wide);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 116%;
  font-weight: 680;
}

/* while it adds: the words in a quieter tone, with a sheen running through them */
.hang__shine {
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 560;
  letter-spacing: -0.004em;
  line-height: 1;
  background: linear-gradient(100deg, var(--muted) 0%, var(--muted) 38%, var(--ink) 50%, var(--muted) 62%, var(--muted) 100%);
  background-size: 260% 100%;
  background-position: var(--sheen, 100%) 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* in the bag: a small tick, the words, and the little Undo pill */
.hang__face--done {
  width: 100%;
  justify-content: space-between;
  gap: 10px;
}

.hang__done {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 16px;
  font-weight: 640;
  letter-spacing: -0.006em;
  line-height: 1;
}

.hang__tick {
  flex: none;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--tick);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hang__undo {
  flex: none;
  display: grid;
  place-items: center;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--chip);
  box-shadow: inset 0 0 0 1px rgba(246, 239, 228, 0.13);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .hang__btn:not([aria-disabled='true']):hover .hang__fill {
    inset: -2px -7px;
    box-shadow:
      inset 0 1px 0 rgba(255, 244, 228, 0.12),
      inset 0 -1px 0 rgba(0, 0, 0, 0.45),
      0 1px 2px rgba(30, 22, 18, 0.22),
      0 18px 32px -14px rgba(30, 22, 18, 0.68);
  }

  .hang__btn:not([aria-disabled='true']):hover .hang__word {
    font-stretch: 116%;
    font-weight: 680;
  }

  .hang__btn:not([aria-disabled='true']):hover .hang__undo {
    background: rgba(246, 239, 228, 0.18);
    box-shadow: inset 0 0 0 1px rgba(246, 239, 228, 0.24);
  }
}

/* the keys bring the focus: the words widen as under the pointer */
html[data-using='keys'] .hang__btn:focus-visible .hang__word {
  font-stretch: 116%;
  font-weight: 680;
}

/* ---------------------------------------------------------------- reduced motion: no swelling, no widening */
@media (prefers-reduced-motion: reduce) {
  .hang__fill,
  .hang__word {
    transition: box-shadow 0.3s ease, filter 0.3s ease;
  }

  html[data-using='keys'] .hang__btn:focus-visible .hang__word {
    font-stretch: 100%;
    font-weight: 620;
  }
}

@media (prefers-reduced-motion: reduce) and (hover: hover) and (pointer: fine) {
  .hang__btn:not([aria-disabled='true']):hover .hang__fill {
    inset: 0;
    filter: brightness(1.25);
  }

  .hang__btn:not([aria-disabled='true']):hover .hang__word {
    font-stretch: 100%;
    font-weight: 620;
  }
}
