/* The falling leaf button: a dark moss pill on a white page, with a twig and a gold ginkgo leaf in its round right
   end. The twig and the leaf are drawn by script.js in an SVG (their colours come from here); the pill, the words and
   the states are CSS. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #26302a;          /* the pill, at its top */
  --pill-deep: #151b17;     /* the pill, at its foot */
  --ink: #f3ecd9;           /* the words */
  --muted: #a7ae9f;         /* the small words */
  --gold: #f2c443;          /* the leaf */
  --gold-deep: #c98a17;     /* the leaf at its rim, and its veins */
  --gold-light: #fff0a8;    /* the light on the leaf */
  --twig: #8c7260;          /* the twig */
  --focus: #26302a;         /* 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: 'Newsreader Variable', 'Newsreader', Georgia, 'Times New Roman', 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: 48px 16px;
}

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

/* the unit holds the pill and, under its right end, the room the leaf falls through */
.leaf__unit {
  position: relative;
  padding-bottom: 116px;
}

/* ---------------------------------------------------------------- the pill */
.leaf__btn {
  position: relative;
  display: block;
  /* the script sets the width from the widest words; this is the width before it does */
  width: 250px;
  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;
}

.leaf__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 */
.leaf__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(60% 120% at 88% 40%, rgba(242, 196, 67, 0.1), transparent 70%),
    linear-gradient(180deg, var(--pill), var(--pill-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45),
    0 1px 2px rgba(21, 27, 23, 0.22),
    0 14px 28px -14px rgba(21, 27, 23, 0.6);
  transition:
    inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    box-shadow 0.4s ease;
}

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

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

/* the twig sits in the right end of the pill and the leaf falls below it; the pointer goes through them */
.leaf__art {
  position: absolute;
  right: -30px;
  top: -20px;
  width: 120px;
  height: 220px;
  overflow: visible;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
/* three faces on top of each other, left of the twig: at rest, while it lets go, and gone */
.leaf__faces {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 30px;
  right: 62px;
  pointer-events: none;
}

.leaf__face {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  /* as wide as the words, not as the pill is now: the script measures them to size the pill */
  width: max-content;
  display: flex;
  align-items: center;
  text-align: left;
  white-space: nowrap;
}

.leaf__face--two {
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
}

[data-face='busy'],
[data-face='done'] {
  opacity: 0;
  visibility: hidden;
}

/* the words at rest: under the pointer they grow heavier and open up, as if the breeze reached them too */
.leaf__word {
  font-size: 19px;
  font-weight: 500;
  font-variation-settings: 'opsz' 24;
  letter-spacing: -0.005em;
  line-height: 1;
  padding-bottom: 2px;
  transition:
    font-weight 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    letter-spacing 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.leaf__small {
  font-size: 12px;
  font-weight: 450;
  font-style: italic;
  font-variation-settings: 'opsz' 12;
  letter-spacing: 0.01em;
  line-height: 1;
  color: var(--muted);
}

.leaf__big {
  font-size: 17.5px;
  font-weight: 520;
  font-variation-settings: 'opsz' 24;
  letter-spacing: -0.005em;
  line-height: 1.05;
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .leaf__btn:not([aria-disabled='true']):hover .leaf__fill {
    inset: -2px -7px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      inset 0 -1px 0 rgba(0, 0, 0, 0.45),
      0 1px 2px rgba(21, 27, 23, 0.22),
      0 18px 32px -14px rgba(21, 27, 23, 0.66);
  }

  .leaf__btn:not([aria-disabled='true']):hover .leaf__word {
    font-weight: 620;
    letter-spacing: 0.02em;
  }
}

/* the keys bring the focus: the words change as under the pointer */
html[data-using='keys'] .leaf__btn:focus-visible:not([aria-disabled='true']) .leaf__word {
  font-weight: 620;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------- reduced motion: no swelling, no change of shape */
@media (prefers-reduced-motion: reduce) {
  .leaf__fill,
  .leaf__word {
    transition: box-shadow 0.3s ease, filter 0.3s ease;
  }

  html[data-using='keys'] .leaf__btn:focus-visible:not([aria-disabled='true']) .leaf__word {
    font-weight: 500;
    letter-spacing: -0.005em;
  }
}

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

  .leaf__btn:not([aria-disabled='true']):hover .leaf__word {
    font-weight: 500;
    letter-spacing: -0.005em;
  }
}
