/* The sensitive plant button: a pale sage pill with a living leaf of mimosa pudica inside, lit from the upper left.
   The leaf and its shadow are drawn by script.js on the two canvases (their colours come from here); the pill, the
   words, the evening that falls when the notifications are paused and the states are CSS. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #eef3ea;          /* the pill, where the light falls on it */
  --pill-deep: #dfe7d9;     /* the pill, at its lower edge */
  --leaf: #5b8e3d;          /* the leaflets, their upper side */
  --leaf-under: #a9c69b;    /* the leaflets, their paler underside */
  --leaf-glow: #86ae45;     /* the leaflets seen against the light, lit through */
  --vein: #c6e0ad;          /* the vein down the middle of every leaflet */
  --stem: #8c4a3a;          /* the stalk and the ribs of the leaf, reddish as in the real plant */
  --shade: #1f3a1b;         /* the shadow the leaf casts on the pill */
  --ink: #1e3a22;           /* the words */
  --dusk: #7c8cc0;          /* the evening light that falls on the pill while the notifications are paused */
  --focus: #2b6a36;         /* 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(--ink);
  font-family: 'Rosario Variable', 'Rosario', 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;
}

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

/* ---------------------------------------------------------------- the pill */
.mimosa__btn {
  position: relative;
  display: block;
  width: min(340px, calc(100vw - 32px));
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background:
    radial-gradient(120% 140% at 18% 0%, color-mix(in srgb, #ffffff 55%, transparent), transparent 62%),
    linear-gradient(180deg, var(--pill), var(--pill-deep));
  /* a lit rim along the top, a darker one along the bottom, a hairline edge and a soft shadow on the page */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 color-mix(in srgb, var(--shade) 10%, transparent),
    0 0 0 1px color-mix(in srgb, var(--shade) 12%, transparent),
    0 1px 2px color-mix(in srgb, var(--shade) 14%, transparent),
    0 14px 28px -16px color-mix(in srgb, var(--shade) 55%, transparent);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
  /* a finger drawn along the leaf brushes it; up and down still scrolls the page */
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 160ms cubic-bezier(0.23, 1, 0.32, 1), box-shadow 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

@media (hover: hover) and (pointer: fine) {
  .mimosa__btn:hover {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      inset 0 -1px 0 color-mix(in srgb, var(--shade) 10%, transparent),
      0 0 0 1px color-mix(in srgb, var(--shade) 15%, transparent),
      0 2px 3px color-mix(in srgb, var(--shade) 14%, transparent),
      0 18px 32px -16px color-mix(in srgb, var(--shade) 62%, transparent);
  }
}

.mimosa__btn:active {
  transform: scale(0.97);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 color-mix(in srgb, var(--shade) 10%, transparent),
    0 0 0 1px color-mix(in srgb, var(--shade) 12%, transparent),
    0 1px 1px color-mix(in srgb, var(--shade) 14%, transparent),
    0 8px 18px -12px color-mix(in srgb, var(--shade) 55%, transparent);
}

.mimosa__btn[aria-busy='true'] {
  cursor: progress;
}

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

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

/* the leaf, and under it its shadow: drawn sharp, blurred here, as a shadow on a matt surface is */
.mimosa__shade,
.mimosa__leaf {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.mimosa__shade {
  opacity: 0.24;
  filter: blur(1.1px);
}

/* the leaf as it was, fading away over the new one, when the motion is reduced */
.mimosa__ghost {
  opacity: 0;
}

/* the evening: a cool light that falls from the right while the notifications are paused */
.mimosa__dusk {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--dusk) 18%, transparent) 0%, color-mix(in srgb, var(--dusk) 62%, transparent) 100%);
  mix-blend-mode: multiply;
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
/* the script sets where they stand and how wide they are: in the mouth of the leaf, clear of every leaflet */
.mimosa__label {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 1px;
  font-size: 15px;
  font-weight: 560;
  line-height: 1;
  letter-spacing: 0.004em;
  white-space: nowrap;
  color: var(--ink);
  pointer-events: none;
}

.mimosa__words {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .mimosa__btn,
  .mimosa__btn:active {
    transform: none;
  }

  .mimosa__btn:active {
    filter: brightness(0.97);
  }
}
