/* The popcorn cart button: a cinema-red pill on a white page, with a popcorn cart standing in its round left end.
   The cart, the kettle, the popcorn and the little door are drawn by script.js on a canvas (their colours come from
   here); the pill, the words, the ticket and the states are CSS. */
:root {
  --page: #ffffff;          /* the page */
  --red: #c8102e;           /* the cinema red of the pill and the cart */
  --red-light: #f0455a;     /* the red where the light falls */
  --red-deep: #7d0a1d;      /* the red in its shadow */
  --cream: #fff4dc;         /* the words, the stripes of the canopy */
  --butter: #f6c445;        /* the butter on the popcorn, the light of the lamp */
  --gold: #d9a23b;          /* the gold of the frame, the wheels and the ticket line */
  --gold-light: #ffe08a;    /* the gold where the light falls */
  --night: #16213f;         /* the night blue of the shadows, the time and the ticket's words */
  --steel: #dfe4ea;         /* the steel of the kettle */
  --steel-dark: #6f7984;    /* the steel in its shadow */
  --popcorn: #fffaf0;       /* the popcorn */
  --popcorn-shade: #e8c98a; /* the popcorn in its shadow */
  --kernel: #d98e2b;        /* the kernels before they pop */
  --ticket: #fff7e6;        /* the ticket paper */
  --ticket-deep: #f4e2bd;   /* the ticket paper at its foot */
  --focus: #16213f;         /* 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(--night);
  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;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

/* the whole thing: the cart stands at the left, its wheels on the line of the pill's foot */
.pop {
  position: relative;
  /* the script sets the width from the words; this is the width before it does */
  width: 312px;
  max-width: calc(100vw - 32px);
  height: 140px;
}

/* the canvas covers the cart and the whole pill, plus a margin above for the popcorn flying against the glass and
   for the pennant on the canopy: nothing on it takes the pointer */
.pop__art {
  position: absolute;
  left: 0;
  top: -40px;
  width: 100%;
  height: 180px;
  z-index: 3;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the ticket */
/* it waits hidden behind the pill and rises out of it, torn edge first, when the popcorn is ready */
.pop__ticket {
  position: absolute;
  right: 34px;
  bottom: 10px;
  z-index: 1;
  display: block;
  width: 92px;
  height: 46px;
  transform-origin: 30% 100%;
  filter: drop-shadow(0 6px 8px rgba(22, 33, 63, 0.18));
  pointer-events: none;
}

.pop__ticket svg {
  display: block;
  overflow: visible;
}

.pop__ticket-band {
  font: 760 6.4px/1 'Mona Sans Variable', system-ui, sans-serif;
  font-stretch: 125%;
  letter-spacing: 0.16em;
  fill: var(--cream);
}

.pop__ticket-film {
  font: 700 9.6px/1 'Mona Sans Variable', system-ui, sans-serif;
  font-stretch: 112%;
  fill: var(--night);
}

.pop__ticket-seat {
  font: 560 5.4px/1 'Mona Sans Variable', system-ui, sans-serif;
  letter-spacing: 0.02em;
  fill: var(--night);
  fill-opacity: 0.7;
}

/* ---------------------------------------------------------------- the pill */
.pop__btn {
  position: absolute;
  left: 70px;
  bottom: 0;
  z-index: 2;
  display: block;
  width: 242px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--cream);
  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;
}

.pop__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; a thin gold
   line runs inside its edge, like the trim of a cinema seat */
.pop__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(70% 150% at 32% 0%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(180deg, var(--red), var(--red-deep));
  box-shadow:
    inset 0 0 0 1.5px rgba(255, 224, 138, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.25),
    0 1px 2px rgba(125, 10, 29, 0.25),
    0 14px 28px -14px rgba(125, 10, 29, 0.7);
  transition:
    inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    box-shadow 0.4s ease;
}

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

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

/* ---------------------------------------------------------------- the words */
/* three faces on top of each other, right of the cart: at rest, while it pops, and the show */
.pop__faces {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 42px;
  right: 0;
  pointer-events: none;
}

.pop__face {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  /* as wide as the words: the script measures them to size the pill */
  width: max-content;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

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

/* the words at rest widen on the typeface's width axis under the pointer */
.pop__word {
  display: inline-block;
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 640;
  font-stretch: 100%;
  letter-spacing: -0.006em;
  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);
}

.pop__time {
  padding-bottom: 1px;
  font-size: 14px;
  font-weight: 560;
  line-height: 1;
  color: var(--gold-light);
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

/* while it pops: the words in a quieter tone, with a sheen of butter running through them */
.pop__shine {
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  background: linear-gradient(100deg, rgba(255, 244, 220, 0.62) 0%, rgba(255, 244, 220, 0.62) 38%, var(--gold-light) 50%, rgba(255, 244, 220, 0.62) 62%, rgba(255, 244, 220, 0.62) 100%);
  background-size: 260% 100%;
  background-position: var(--sheen, 100%) 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.pop__done {
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 680;
  font-stretch: 108%;
  letter-spacing: -0.006em;
  line-height: 1;
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .pop__btn:not([aria-disabled='true']):hover .pop__fill {
    inset: -2px -7px;
    box-shadow:
      inset 0 0 0 1.5px rgba(255, 224, 138, 0.6),
      inset 0 1px 0 rgba(255, 255, 255, 0.24),
      inset 0 -2px 0 rgba(0, 0, 0, 0.25),
      0 1px 2px rgba(125, 10, 29, 0.25),
      0 18px 32px -14px rgba(125, 10, 29, 0.78);
  }

  .pop__btn:not([aria-disabled='true']):hover .pop__word {
    font-stretch: 118%;
    font-weight: 700;
  }
}

/* the keys bring the focus: the words widen as under the pointer */
html[data-using='keys'] .pop__btn:focus-visible .pop__word {
  font-stretch: 118%;
  font-weight: 700;
}

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

  html[data-using='keys'] .pop__btn:focus-visible .pop__word {
    font-stretch: 100%;
    font-weight: 640;
  }
}

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

  .pop__btn:not([aria-disabled='true']):hover .pop__word {
    font-stretch: 100%;
    font-weight: 640;
  }
}
