/* The bunting button: a raspberry pill on a white page, with a string of cloth pennants hanging from under it. The
   string and the pennants are drawn by script.js in an SVG behind the pill (their colours come from here); the pill,
   the words and the states are CSS. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #a3214d;          /* the pill, at its top */
  --pill-deep: #6f1232;     /* the pill, at its foot */
  --ink: #fff3ea;           /* the words */
  --muted: #f2b9c8;         /* the small words, and the date at rest */
  --string: #6f1232;        /* the string */
  --flag-a: #ff7a59;        /* the pennants, in turn: coral */
  --flag-b: #ffcf5c;        /* sun */
  --flag-c: #7fcfc3;        /* mint */
  --flag-d: #ffb3c7;        /* pink */
  --flag-e: #f6efe2;        /* cream */
  --focus: #a3214d;         /* 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: 'Anybody Variable', 'Anybody', 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: 48px 16px;
}

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

/* the unit holds the pill and, under it, the room the pennants hang in */
.bunting__unit {
  position: relative;
  padding-bottom: 64px;
  isolation: isolate;
}

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

.bunting__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 */
.bunting__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(90% 140% at 20% 0%, rgba(255, 255, 255, 0.14), transparent 62%),
    linear-gradient(180deg, var(--pill), var(--pill-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(111, 18, 50, 0.22),
    0 14px 28px -14px rgba(111, 18, 50, 0.6);
  transition:
    inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    box-shadow 0.4s ease;
}

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

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

/* the string and the pennants, behind the pill and under it; the pointer goes through them */
.bunting__art {
  position: absolute;
  z-index: 0;
  left: 0;
  top: 0;
  width: 100%;
  height: 140px;
  overflow: visible;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
/* three faces on top of each other: at rest, while the answer goes, and on the list */
.bunting__faces {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 30px;
  right: 30px;
  pointer-events: none;
}

.bunting__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;
  gap: 12px;
  text-align: left;
  white-space: nowrap;
}

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

[data-face='busy'],
[data-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, so nothing moves beside them */
.bunting__word {
  display: inline-grid;
  padding-bottom: 1px;
  font-size: 18px;
  font-weight: 640;
  font-stretch: 92%;
  letter-spacing: -0.004em;
  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);
}

.bunting__word::before {
  content: attr(data-wide);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 106%;
  font-weight: 740;
}

.bunting__date {
  font-size: 14px;
  font-weight: 560;
  font-stretch: 90%;
  line-height: 1;
  color: var(--muted);
}

.bunting__small {
  font-size: 11.5px;
  font-weight: 540;
  font-stretch: 96%;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--muted);
}

.bunting__big {
  font-size: 16.5px;
  font-weight: 680;
  font-stretch: 86%;
  letter-spacing: -0.004em;
  line-height: 1.05;
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .bunting__btn:not([aria-disabled='true']):hover .bunting__fill {
    inset: -2px -7px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.2),
      inset 0 -1px 0 rgba(0, 0, 0, 0.3),
      0 1px 2px rgba(111, 18, 50, 0.22),
      0 18px 32px -14px rgba(111, 18, 50, 0.66);
  }

  .bunting__btn:not([aria-disabled='true']):hover .bunting__word {
    font-stretch: 106%;
    font-weight: 740;
  }
}

/* the keys bring the focus: the words widen as under the pointer */
html[data-using='keys'] .bunting__btn:focus-visible:not([aria-disabled='true']) .bunting__word {
  font-stretch: 106%;
  font-weight: 740;
}

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

  html[data-using='keys'] .bunting__btn:focus-visible:not([aria-disabled='true']) .bunting__word {
    font-stretch: 92%;
    font-weight: 640;
  }
}

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

  .bunting__btn:not([aria-disabled='true']):hover .bunting__word {
    font-stretch: 92%;
    font-weight: 640;
  }
}
