/* The candle button: a dark pill on a black page, lit by the candle in its round left end. The candle, its flame,
   the snuffer, the match and the smoke are drawn by script.js on a canvas (their colours come from here); the pill,
   its warm light, the words and the states are CSS. */
:root {
  --page: #000000;          /* the page */
  --pill: #1d1712;          /* the pill, lit by the candle, at its top */
  --pill-deep: #0f0b08;     /* the lit pill at its foot */
  --pill-out: #121316;      /* the pill once the candle is out */
  --pill-out-deep: #08090b; /* the dark pill at its foot */
  --warm: #ffb265;          /* the candle's light on the pill */
  --ink: #f6e3c4;           /* the words in the candle's light */
  --ink-out: #8d9097;       /* the words in the dark */
  --wax: #efe6d6;           /* the candle's wax */
  --brass: #c99a4e;         /* the dish, the snuffer */
  --flame: #ffb347;         /* the flame's body */
  --flame-core: #fff4d6;    /* its bright heart */
  --flame-base: #4f7bff;    /* the blue at its foot */
  --smoke: #c9cdd4;         /* the smoke */
  --wood: #d9b98a;          /* the match */
  --match-head: #b8322a;    /* the match's head */
  --focus: #ffb265;         /* 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: '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;
  /* room above the pill for the smoke, the snuffer and the match */
  padding: 150px 16px 72px;
}

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

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

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

/* the fill: the dark pill, the warm light of the candle over it (its strength is --glow, set every frame by the
   flame), and the cold dark it turns to once the candle is out (--out) */
.candle__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--pill), var(--pill-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 236, 210, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1);
}

.candle__fill::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    radial-gradient(120px 76px at 32px 22px, color-mix(in srgb, var(--warm) 34%, transparent), transparent 100%),
    radial-gradient(260px 120px at 20px 30px, color-mix(in srgb, var(--warm) 13%, transparent), transparent 100%);
  box-shadow:
    inset 0 1px 0 color-mix(in srgb, var(--warm) 30%, transparent),
    0 0 46px -6px color-mix(in srgb, var(--warm) 26%, transparent);
  opacity: var(--glow, 1);
}

.candle__fill::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--pill-out), var(--pill-out-deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  opacity: var(--out, 0);
}

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

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

/* the canvas reaches above the pill, for the smoke, the snuffer and the match; it never reaches the words */
.candle__art {
  position: absolute;
  left: -20px;
  top: -130px;
  width: 190px;
  height: 194px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
.candle__words {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 72px;
  right: 18px;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.candle__word {
  display: block;
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 620;
  font-stretch: 100%;
  letter-spacing: -0.006em;
  line-height: 1;
  white-space: nowrap;
  color: color-mix(in srgb, var(--ink-out), var(--ink) calc(var(--lit, 1) * 100%));
  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);
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .candle__btn:not([aria-disabled='true']):hover .candle__fill {
    inset: -2px -7px;
  }

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

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

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

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

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

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