/* Order of this file: reset, base, backdrop, type, layout, components, motion.
   Values come from tokens.css; a number that is not a token does not belong here. */

/* ---------- reset ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body, h1, h2, h3, p, ul, ol, dl, dd, figure {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input {
  font: inherit;
  color: inherit;
}

svg {
  display: block;
}

/* ---------- base ---------- */

html {
  background: var(--plum-900);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  font-family: var(--font);
  font-size: var(--t-body);
  line-height: 1.6;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 2px solid var(--powder-lilac);
  outline-offset: 3px;
}

::selection {
  background: var(--powder-mauve);
  color: var(--ink-on-powder);
}

/* Region and unit variants are all in the HTML; the switch on <html> picks the visible one. */
[data-r],
[data-u] {
  display: none;
}

html[data-region="us"] [data-r="us"],
html[data-region="uk"] [data-r="uk"],
html[data-region="au"] [data-r="au"],
html[data-units="us"] [data-u="us"],
html[data-units="metric"] [data-u="metric"] {
  display: contents;
}

/* ---------- backdrop: soft colour fields fixed behind every screen, and a grain over all ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-backdrop);
  pointer-events: none;
  background:
    radial-gradient(58% 52% at 84% 6%, rgb(122 44 72 / 0.42), transparent 72%),
    radial-gradient(44% 50% at 2% 60%, rgb(99 57 79 / 0.4), transparent 72%),
    radial-gradient(52% 46% at 60% 104%, rgb(92 31 54 / 0.42), transparent 72%),
    var(--plum-900);
}

/* the first screen has a light of its own: it covers the backdrop, scrolls away with the page
   and dissolves into the backdrop below the fold */
.opening {
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: min(130vh, 100%); /* never taller than the page, so it always fades out and is never cut off */
  overflow: hidden;
  background: var(--grad-opening);
  -webkit-mask-image: linear-gradient(#000 75%, transparent);
  mask-image: linear-gradient(#000 75%, transparent);
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
}

/* top left: powder lavender */
.blob--lavender {
  top: -320px;
  left: -260px;
  width: 900px;
  height: 900px;
  background: radial-gradient(circle, rgb(196 170 226 / 0.2) 0%, rgb(196 170 226 / 0) 62%);
  filter: blur(30px);
}

/* right: cool blue */
.blob--blue {
  top: 120px;
  right: -200px;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgb(170 185 235 / 0.14) 0%, rgb(170 185 235 / 0.126) 10%, rgb(170 185 235 / 0.095) 20%, rgb(170 185 235 / 0.056) 30%, rgb(170 185 235 / 0.025) 40%, rgb(170 185 235 / 0.007) 50%, rgb(170 185 235 / 0) 60%);
  filter: blur(40px);
}

/* Film grain: a noise texture laid over everything in plain, normal blending. A blend mode such as
   overlay or soft-light fades to nothing over dark colours — exactly where a dark page shows its steps —
   so the noise is simply mixed in at a few percent and works the same on dark and light. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  background: url("../img/grain.png") 0 0 / 256px;
  opacity: var(--grain);
}

/* one dot of grain per screen pixel on dense displays too */
@media (min-resolution: 1.5dppx) {
  body::after {
    background-size: 128px;
  }
}

/* ---------- type ---------- */

.heading,
.figure,
.number {
  background: var(--grad-heading);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 400;
}

.display {
  font-size: var(--t-display);
  font-weight: 500;
  line-height: 0.92;
  letter-spacing: -0.052em;
}

/* each line of the title carries its own gradient; inline, so the paint reaches the descenders */
.display__line {
  background: var(--grad-display);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  color: transparent;
}

/* accent: the words a heading leans on — light italic in the cool powder gradient */
.accent {
  padding-inline: 0.06em; /* an italic leans past its own box; without this the gradient is cut at the edges */
  margin-inline: -0.06em;
  background: var(--grad-display-soft);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  color: transparent;
  font-style: italic;
  font-weight: 300;
}

.heading {
  font-size: var(--t-h2);
  line-height: 1.02;
  letter-spacing: -0.04em;
  padding-bottom: 0.1em;
}

.figure {
  font-size: var(--t-figure);
  line-height: 0.8;
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}

.number {
  display: block;
  font-size: var(--t-number);
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

/* the one figure a panel is about, a step larger */
.number--lg {
  font-size: var(--t-number-lg);
}

.lede {
  max-width: 27ch;
  font-size: var(--t-h3);
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--ink-soft);
}

.link {
  background: linear-gradient(currentColor 0 0) 0 100% / 0 1px no-repeat;
  transition: background-size var(--fast) var(--ease);
}

.link:hover {
  background-size: 100% 1px;
}

/* in the page for screen readers and the keyboard, not for the eye */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.icon {
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- layout ---------- */

.page {
  position: relative;
  z-index: var(--z-page);
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* a short page still fills the screen, with the footer at the bottom */
  padding-inline: var(--gutter);
  overflow: clip; /* the opening light and the hero orb reach past the edges and must not stretch the page */
}

.page > main {
  flex: 1;
}

.section {
  padding-block: var(--sp-9);
}

.section__head {
  display: grid;
  gap: var(--sp-5);
  margin-bottom: var(--sp-7);
}

.section__note {
  max-width: 46ch;
  color: var(--ink-soft); /* the foot of the liquid drop passes behind this line; the muted ink was too faint over it */
}

.hero {
  position: relative;
  display: grid;
  gap: var(--sp-6);
  padding-top: var(--sp-6);
  isolation: isolate;
}

/* a giant, barely lit word behind the title, fading out downwards */
.hero__ghost {
  position: absolute;
  top: calc(var(--t-display) * -0.62);
  left: calc(var(--t-display) * -0.04);
  z-index: -1;
  font-size: calc(var(--t-display) * 2.1);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.05em;
  white-space: nowrap;
  color: rgb(255 236 246 / 0.04);
  /* the word dissolves into the page: full at the top of its letters, gone before their feet */
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 72%);
  mask-image: linear-gradient(to bottom, #000 30%, transparent 72%);
  pointer-events: none;
  user-select: none;
}

/* the liquid drop behind the first screen: a WebGL canvas (assets/js/liquid-blob.js) exactly one screen
   tall. It is laid on the page itself, not on the hero: it starts at the very top, behind the header,
   and runs from one edge of the window to the other — so nothing but the screen can cut the drop. */
.liquid {
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: 100vh;
  min-height: 720px;
  pointer-events: none;
}

.liquid liquid-blob {
  display: block;
  width: 100%;
  height: 100%;
}

.hero__intro {
  display: grid;
  gap: var(--sp-5);
  align-content: end;
}

.hero__instrument {
  position: relative;
}

.bento {
  display: grid;
  gap: var(--sp-4);
}

@media (min-width: 700px) {
  .bento {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .bento__party,
  .bento__kegs,
  .bento__standard,
  .bento__abv {
    grid-column: span 6;
  }

  .bento__wine {
    grid-column: span 2;
  }

  .bento__shot {
    grid-column: span 4;
  }
}

@media (min-width: 1100px) {
  .section__head {
    grid-template-columns: 7fr 4fr;
    align-items: end;
    justify-content: space-between;
  }

  .hero {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--sp-5);
    row-gap: var(--sp-7);
  }

  .hero__title {
    grid-area: 1 / 1 / 2 / -1;
  }

  .hero__intro {
    grid-area: 2 / 1 / 3 / span 5;
  }

  /* the card sits beside the second, shorter line of the title */
  .hero__instrument {
    grid-area: 1 / 7 / 3 / -1;
    align-self: end;
    margin-top: calc(var(--t-display) * 1.04);
  }

  .bento {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-areas:
      "party party party party party party party kegs kegs kegs kegs kegs"
      "wine wine wine shot shot shot shot shot standard standard standard standard"
      "abv abv abv abv abv abv abv abv abv abv abv abv";
  }

  .bento__party { grid-area: party; }
  .bento__kegs { grid-area: kegs; }
  .bento__wine { grid-area: wine; }
  .bento__shot { grid-area: shot; }
  .bento__standard { grid-area: standard; }
  .bento__abv { grid-area: abv; }
}

/* ---------- components ---------- */

/* glass: the matte surface every panel is made of */
.glass {
  position: relative;
  border-radius: var(--r-lg);
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.glass::after,
.bars__item::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: var(--glass-edge);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* squircle.js swaps the plain radius for a Figma smooth corner once it knows the size */
.is-squircle {
  clip-path: var(--squircle);
}

.is-squircle.glass::after,
.is-squircle.bars__item::after {
  padding: 0;
  -webkit-mask: none;
  mask: none;
  clip-path: var(--squircle-ring);
}

.is-squircle:focus-visible {
  outline-offset: -4px;
}

/* header */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-block: var(--sp-5);
}

.header__tools {
  display: flex;
  gap: var(--sp-2);
}

/* on a phone the region decides the units; the separate switch comes back with the space */
.header__tools [data-switch="units"] {
  display: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.brand__mark {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.brand__tick {
  stroke: var(--pink);
}

.nav,
.switch {
  display: inline-flex;
  gap: var(--sp-1);
  padding: var(--sp-1);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--glass-fill-quiet);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.nav {
  order: 3;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav__link,
.switch__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding-inline: var(--sp-4);
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  font-size: var(--t-small);
  font-weight: 500;
  white-space: nowrap;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.nav__link:hover,
.switch__option:hover {
  background: rgb(255 236 246 / 0.08);
  color: var(--ink);
}

.nav__link[aria-current="page"] {
  background: rgb(255 236 246 / 0.1);
  color: var(--ink);
}

.switch__option {
  min-width: 44px;
  padding-inline: var(--sp-3);
}

html[data-region="us"] [data-switch="region"] [value="us"],
html[data-region="uk"] [data-switch="region"] [value="uk"],
html[data-region="au"] [data-switch="region"] [value="au"],
html[data-units="us"] [data-switch="units"] [value="us"],
html[data-units="metric"] [data-switch="units"] [value="metric"] {
  background: var(--grad-powder);
  color: var(--ink-on-powder);
}

/* a switch made of radio buttons keeps its own state */
.switch__option:has(:checked) {
  background: var(--grad-powder);
  color: var(--ink-on-powder);
}

.switch__option:has(:focus-visible) {
  outline: 2px solid var(--powder-lilac);
  outline-offset: 3px;
}

/* low: a slimmer switch for use inside a card — shorter buttons with more room at the sides.
   The button's hit area still reaches a finger-sized height through its ::before. */
.switch--low .switch__option {
  position: relative;
  min-height: var(--sp-6);
  padding-inline: calc(var(--sp-4) + var(--sp-1));
}

.switch--low .switch__option::before {
  content: "";
  position: absolute;
  inset: calc(var(--sp-2) * -1) 0;
}


/* a finger needs a bigger target than a cursor */
@media (pointer: coarse) {
  .nav__link,
  .switch__option,
  .chip,
  .button--ghost {
    min-height: 44px;
  }
}

@media (min-width: 900px) {
  .nav {
    order: 0;
    width: auto;
  }

  .header__tools [data-switch="units"] {
    display: inline-flex;
  }
}

/* search */
.search {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: 540px;
  padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-5);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  color: var(--ink-mute);
  transition: border-color var(--fast) var(--ease);
}

.search:focus-within {
  border-color: rgb(255 236 246 / 0.4);
}

.search__input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 0;
  outline: 0; /* the whole capsule lights up instead, see :focus-within */
  background: transparent;
  color: var(--ink);
}

.search__input::placeholder {
  color: var(--ink-mute);
  opacity: 1;
}

.search__input::-webkit-search-cancel-button {
  display: none;
}

.search__key {
  display: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  font: 500 var(--t-micro) var(--font);
}

.search__go {
  display: grid;
  place-items: center;
  flex: none;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--grad-powder);
  color: var(--ink-on-powder);
  cursor: pointer;
}

.search__go .icon,
.button .icon {
  transition: transform var(--fast) var(--ease);
}

.search__go:hover .icon,
.button:hover .icon {
  transform: translateX(3px);
}

@media (hover: hover) and (min-width: 700px) {
  .search__key {
    display: grid;
  }
}

/* chips and tags */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.chip,
.tag {
  display: inline-flex;
  align-items: center;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: var(--t-small);
  color: var(--ink-soft);
}

.chip {
  min-height: 40px;
  padding-inline: var(--sp-4);
  background: var(--glass-fill-quiet);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.chip:hover {
  background: rgb(255 236 246 / 0.1);
  color: var(--ink);
}

.tag {
  min-height: 32px;
  padding-inline: var(--sp-3);
  font-weight: 500;
}

.tag--well {
  border-color: transparent;
  background: var(--glass-well);
  font-weight: 400;
}

/* buttons */
.button {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 48px;
  padding-inline: var(--sp-5);
  border: 0;
  border-radius: var(--r-pill);
  font-size: var(--t-small);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.button--powder {
  background: var(--grad-powder);
  color: var(--ink-on-powder);
}

.button--plum {
  background: var(--grad-plum);
  color: #f6eff2;
}

/* ghost: the link out of a card — an outline and an arrow, no fill, so it reads as a button and not as a caption */
.button--ghost {
  min-height: 40px;
  padding-inline: var(--sp-4);
  border: var(--hair) solid var(--leader);
  background: transparent;
  color: var(--ink-soft);
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}

.button--ghost:hover {
  background: rgb(255 236 246 / 0.08);
  color: var(--ink);
}

/* the orb: a cool powder light the hero card is frosted over */
.orb {
  position: absolute;
  top: 30%;
  right: 16%;
  width: 88%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--grad-orb);
  filter: blur(40px);
  transform: translate(50%, -50%);
}

/* answer: one number, what it counts and the working */
.answer {
  display: grid;
  gap: var(--sp-6);
  padding: var(--sp-5);
}

.answer__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.answer__main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-4) var(--sp-5);
}

.answer__words {
  display: grid;
  gap: var(--sp-1);
  font-size: var(--t-h3);
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.answer__words small {
  font-size: var(--t-small);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

/* scale: one capsule per serving, lit by a single gradient that runs along the filled ones.
   --n is how many capsules stand in the row, --on how many of them are filled. */
.scale {
  container-type: inline-size;
  padding-top: calc(var(--dot) + var(--sp-2)); /* the dot over the last filled capsule */
  padding-bottom: var(--sp-5); /* the counts under the row */
}

/* capsules stand shoulder to shoulder; a short row keeps the same step instead of spreading out */
.scale__bars {
  --pitch: calc(var(--sp-6) + var(--sp-1));
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, var(--pitch)));
}

.scale__bar {
  --slot: min(100cqw / var(--n), var(--pitch));
  --gap: clamp(var(--sp-1), 1.2cqw, var(--sp-2));
  position: relative;
  height: var(--sp-7);
}

/* the capsule, empty, and its fill on top */
.scale__bar::before,
.scale__bar::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: calc(var(--gap) / 2);
  width: calc(var(--slot) - var(--gap));
  border-radius: var(--r-pill);
}

.scale__bar::before {
  top: 0;
  background: var(--line);
}

/* the gradient is as wide as the row and shifted back by the capsule's own offset,
   so the colour runs across the capsules as if they were one strip */
.scale__bar::after {
  height: calc(var(--fill, 1) * 100%);
  background: var(--grad-pour) calc(-1 * (var(--i) * var(--slot) + var(--gap) / 2)) 0 / calc(var(--slot) * var(--on)) 100% no-repeat;
}

/* wide: the row runs the full width of its panel, however many capsules it has */
.scale--wide .scale__bars {
  --pitch: calc(100cqw / var(--n));
}

/* the one bright mark: a small dot over the capsule the count ends on */
.scale__end {
  position: absolute;
  bottom: calc(100% + var(--sp-2));
  left: 50%;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--pink);
  transform: translateX(-50%);
}

/* a count sits under the capsule it counts */
.scale__count {
  position: absolute;
  top: calc(100% + var(--sp-2));
  left: 50%;
  font-size: var(--t-micro);
  font-style: normal;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
  transform: translateX(-50%);
}

@media (min-width: 700px) {
  .answer {
    padding: var(--sp-6);
  }
}

/* card: a bento cell */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding: var(--sp-5);
  border-radius: var(--r-lg);
}

.card--powder {
  /* a light panel: the ink tokens flip, so everything inside reads dark */
  --ink: var(--ink-on-powder);
  --ink-soft: #33202b;
  --ink-mute: var(--ink-on-powder-mute);
  --line: rgb(31 14 23 / 0.2);
  --leader: rgb(31 14 23 / 0.42);
  --grad-heading: linear-gradient(100deg, var(--plum-900), var(--plum-600));
  background: var(--grad-powder-panel);
  color: var(--ink);
}

.card__title {
  font-size: var(--t-h3);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.card__figure {
  font-size: var(--t-h3);
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--ink-soft);
}

.card__note {
  max-width: 46ch;
  font-size: var(--t-small);
  color: var(--ink-mute);
}

/* the head of a card: its title, and to the right of it whatever switches the reading;
   when the two no longer fit side by side, the switch drops under the title */
.card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3) var(--sp-4);
}

/* the foot of a card: what the figures are counted in, and the one way out of the card */
.card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-top: auto;
}

.card__side {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: var(--sp-5);
}

.card__side .card__figure {
  margin-top: auto;
}

.card__side .button {
  margin-top: auto;
}

@media (min-width: 700px) {
  .card {
    padding: var(--sp-6);
  }

  .card--split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-8);
  }
}

/* planner: the dial on one side, the crowd it stands for on the other */
.planner {
  display: grid;
  gap: var(--sp-6);
}

.planner__dial {
  display: grid;
  gap: var(--sp-5);
  justify-items: start;
}

.planner__dial .dial {
  justify-self: stretch;
}

@media (min-width: 700px) {
  .planner {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: var(--sp-8);
  }
}

/* dots: a head count, one dot for every few people; one gradient runs along each row */
.dots {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, calc(var(--sp-4) + var(--sp-1))));
  gap: var(--sp-2);
}

.dots__dot {
  aspect-ratio: 1;
  border: var(--hair) solid var(--line);
  border-radius: 50%;
  transition: border-color var(--fast) var(--ease);
}

.dots__dot.is-guest {
  border-color: var(--leader);
}

.dots__dot.is-drinking {
  border-color: transparent;
  background: var(--grad-pour) calc(var(--c) / 9 * 100%) 0 / calc(1000% + 9 * var(--sp-2)) 100% border-box;
}

.crowd {
  display: grid;
  gap: var(--sp-4);
  justify-items: start;
}

/* note: the small print under a drawing — what it counts, in what, on what terms.
   The same line, with the same pink dot in front, in every card. */
.note {
  position: relative;
  padding-left: calc(var(--dot) + var(--sp-2));
  font-size: var(--t-micro);
  line-height: 1.5;
  color: var(--ink-mute);
}

.note::before {
  content: "";
  position: absolute;
  top: calc((1lh - var(--dot)) / 2); /* level with the first line, however many lines there are */
  left: 0;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--pink);
}

/* bars: each total in a tall tile that fills from the bottom as the guest count grows —
   just above its name at the fewest guests, to the brim at the most. The lit tile is poured
   in the capsule gradient. --level (0 to 1) is set on .bars and animated as a number, so the
   fill and the colour of the figure it passes move together. */
@property --level {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

.bars {
  --rest: calc(var(--sp-4) * 2 + var(--t-small) * 1.3); /* the fill's height at the fewest guests: the name's line with the same padding above and below it */
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  transition: --level var(--slow) var(--ease);
}

.bars__item {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
  height: calc(var(--sp-10) * 2);
  border-radius: var(--r-md);
  background: var(--glass-fill-quiet);
  container-type: size;
}

.bars__item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--line);
  clip-path: inset(calc((1 - var(--level)) * (100% - var(--rest))) 0 0 round var(--r-md));
}

.bars__item.is-lit::before {
  background: linear-gradient(180deg, var(--pour-3), var(--pour-1));
}

.bars dd,
.bars dt {
  position: relative;
  padding: var(--sp-4);
}

.bars dd {
  background: var(--grad-heading);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: var(--t-number-sm);
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.bars dt {
  font-size: var(--t-small);
  line-height: 1.3;
  color: var(--ink-soft);
}

/* on the lit tile the figure turns dark exactly where the light fill has risen over it */
.bars__item.is-lit dd {
  --edge: calc((1 - var(--level)) * (100cqh - var(--rest)));
  background-image: linear-gradient(to bottom, var(--ink) var(--edge), var(--ink-wine) var(--edge));
}

.bars__item.is-lit dt {
  color: var(--ink-on-powder);
}

@media (min-width: 700px) {
  .bars {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* dial: a number and the slider that sets it */
.dial {
  --thumb: var(--sp-5);
  display: grid;
  gap: var(--sp-2);
}

.dial__value {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  font-size: var(--t-small);
  color: var(--ink-mute);
}

.dial__marks {
  position: relative;
  height: var(--sp-4);
  margin-inline: calc(var(--thumb) / 2); /* the thumb's centre stops half a thumb short of each end */
  font-size: var(--t-micro);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
}

.dial__marks li {
  position: absolute;
  top: var(--sp-1);
  left: calc(var(--at) * 100%);
  transform: translateX(-50%);
}

.dial__marks li::before {
  content: "";
  position: absolute;
  bottom: calc(100% + var(--sp-1));
  left: 50%;
  width: var(--hair);
  height: var(--sp-1);
  background: var(--leader);
}

.range {
  --p: 21%;
  width: 100%;
  height: var(--sp-6);
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.range::-webkit-slider-runnable-track {
  height: var(--stroke);
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--powder-mauve), var(--powder-ice) var(--p), var(--line) var(--p));
}

.range::-moz-range-track {
  height: var(--stroke);
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--powder-mauve), var(--powder-ice) var(--p), var(--line) var(--p));
}

.range::-webkit-slider-thumb {
  width: var(--thumb);
  height: var(--thumb);
  margin-top: calc((var(--stroke) - var(--thumb)) / 2);
  border: var(--stroke) solid var(--powder-ice);
  border-radius: 50%;
  background: var(--plum-800);
  -webkit-appearance: none;
  appearance: none;
}

.range::-moz-range-thumb {
  box-sizing: border-box;
  width: var(--thumb);
  height: var(--thumb);
  border: var(--stroke) solid var(--powder-ice);
  border-radius: 50%;
  background: var(--plum-800);
}

/* tally: labelled totals under a hairline */
.tally {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-5) var(--sp-4);
}

.tally__item {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--sp-1);
  padding-top: var(--sp-3);
  border-top: var(--hair) solid var(--line);
}

.tally dt {
  font-size: var(--t-micro);
  letter-spacing: 0.01em;
  color: var(--ink-mute);
}

.tally dd {
  background: var(--grad-heading);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-size: var(--t-number);
  line-height: 1;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
}

.tally--small dd {
  font-size: var(--t-h3);
  letter-spacing: -0.02em;
}

@media (min-width: 700px) {
  .tally {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* meter: a named amount; under the name a bar filled as far as its share of the largest,
   and the figure at the end of that same line — the bar's hairline leads the eye to it,
   the way the dotted leader does in .rows */
.meters {
  display: grid;
  flex: 1; /* in a card taller than its list, the spare height goes between the rows, not inside them */
  align-content: space-between;
  gap: var(--sp-5);
}

.meter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "name value"
    "track value";
  gap: var(--sp-2) var(--sp-3); /* the name sits close on its bar; the figure, taller than the bar, rises beside the name */
}

.meter__name {
  grid-area: name;
  overflow: hidden;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.meter__name small {
  margin-left: var(--sp-1);
  font-size: inherit;
  font-weight: 400;
  color: var(--ink-mute);
}

.meter__value {
  grid-area: value;
  align-self: last baseline; /* the bar stands on the figure's baseline, as the dotted leader does in .rows */
  min-width: 3ch; /* every row keeps the same room for its figure, so the bars share one scale */
  font-size: var(--t-h3);
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.meter__track {
  grid-area: track;
  align-self: last baseline;
  height: var(--sp-2);
  overflow: hidden; /* trims the hairline where the row ends */
  container-type: inline-size;
}

.meter__fill {
  position: relative;
  display: block;
  width: calc(var(--to) * 100%);
  height: 100%;
  border-radius: var(--r-pill);
  background: var(--grad-pour);
}

/* the unfilled rest of the row is a hairline that starts where the bar ends, and follows it as it grows */
.meter__fill::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 100%;
  width: 100cqw;
  height: var(--hair);
  background: var(--line);
}

/* pick: one of a few readings of the same block, chosen with radio buttons — no script.
   The radios carry value="0", "1", "2"; whatever is marked data-v shows only for its own value. */
.pick {
  display: contents;
}

.pick:has([value="0"]:checked) [data-v]:not([data-v="0"]),
.pick:has([value="1"]:checked) [data-v]:not([data-v="1"]),
.pick:has([value="2"]:checked) [data-v]:not([data-v="2"]) {
  display: none;
}

@supports not selector(:has(*)) {
  .pick [data-v]:not([data-v="0"]) {
    display: none;
  }
}

/* swap: readings that take turns in one spot. They are stacked in a single cell, so the spot is
   always as wide as the widest of them — a switch beside it never jumps when the reading changes. */
.swap {
  display: grid;
}

.swap > [data-v] {
  grid-area: 1 / 1;
}

.pick:has([value="0"]:checked) .swap > [data-v]:not([data-v="0"]),
.pick:has([value="1"]:checked) .swap > [data-v]:not([data-v="1"]),
.pick:has([value="2"]:checked) .swap > [data-v]:not([data-v="2"]) {
  display: block;
  visibility: hidden;
}

/* rows: name, dotted leader, value — the way a bar menu is set */
.rows {
  display: grid;
  gap: var(--sp-3);
  align-self: stretch;
}

.rows__item {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
}

.rows__name {
  display: flex;
  flex: 1;
  align-items: baseline;
  gap: var(--sp-3);
  font-size: var(--t-small);
  white-space: nowrap;
  color: color-mix(in srgb, var(--ink) calc(var(--lit, 0) * 100%), var(--ink-mute));
  transition: color var(--slow) var(--ease);
}

.rows__name::after {
  content: "";
  flex: 1;
  border-bottom: var(--hair) dotted var(--leader);
}

/* the dot in front of a keyed row: hollow, pink when its part of the drawing is lit */
.rows__key {
  flex: none;
  align-self: center;
  width: var(--sp-2);
  height: var(--sp-2);
  border: var(--stroke) solid color-mix(in srgb, var(--pink) calc(var(--lit, 0) * 100%), var(--leader));
  border-radius: 50%;
  background: color-mix(in srgb, var(--pink) calc(var(--lit, 0) * 100%), transparent);
  transition: background-color var(--slow) var(--ease), border-color var(--slow) var(--ease);
}

.rows__value {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.rows__value small {
  margin-left: var(--sp-2);
  font-size: var(--t-small);
  color: var(--ink-mute);
}

/* keyed: parts that share a data-key light up together. The visitor's region is lit to begin with;
   pointing at any keyed part lights its key instead. A lit part reads --lit: 1, the others 0. */
.keyed [data-key] {
  --lit: 0;
}

html[data-region="us"] .keyed:not(:has([data-key]:hover)) [data-key="us"],
html[data-region="uk"] .keyed:not(:has([data-key]:hover)) [data-key="uk"],
html[data-region="au"] .keyed:not(:has([data-key]:hover)) [data-key="au"],
.keyed:has([data-key="us"]:hover) [data-key="us"],
.keyed:has([data-key="uk"]:hover) [data-key="uk"],
.keyed:has([data-key="au"]:hover) [data-key="au"] {
  --lit: 1;
}

/* aside: a drawing with its list — stacked in a narrow card, side by side once the card has room */
.keyed {
  container-type: inline-size;
}

.aside {
  display: grid;
  align-items: center;
  gap: var(--sp-5);
  margin-block: auto;
}

@container (min-width: 28rem) {
  .aside {
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--sp-6);
  }
}

/* rings: quantities as nested circles standing on one point, each area to scale */
.rings {
  justify-self: center;
  max-width: 100%;
  height: auto;
  overflow: visible;
}

.rings__ring {
  fill: rgb(255 236 246 / calc(var(--lit) * 0.12)); /* only the lit circle is filled, in the translucent material of an empty capsule */
  pointer-events: all; /* pointing anywhere inside an unfilled circle still lights it */
  transition: fill var(--slow) var(--ease);
  stroke: var(--leader);
  stroke-width: 0.7px; /* thinner than the lit ring's one pixel */
  vector-effect: non-scaling-stroke; /* the width holds whatever size the drawing is shown at */
}

/* the lit ring's border: the same circle drawn again in the lavender-to-powder gradient */
.rings__edge {
  fill: none;
  stroke: url("#rings-edge");
  stroke-width: var(--hair);
  vector-effect: non-scaling-stroke;
  opacity: var(--lit);
  pointer-events: none;
  transition: opacity var(--slow) var(--ease);
}

.rings__stop--edge-1 { stop-color: var(--edge-1); }
.rings__stop--edge-2 { stop-color: var(--edge-2); }
.rings__stop--edge-3 { stop-color: var(--edge-3); }

/* the lit ring's own figure, written inside the smallest circle */
.rings__value {
  fill: var(--ink);
  font-size: var(--t-h3);
  letter-spacing: -0.02em;
  text-anchor: middle;
  font-variant-numeric: tabular-nums;
  opacity: var(--lit);
  pointer-events: none;
  transition: opacity var(--slow) var(--ease);
}

.rings__note {
  font-size: var(--t-micro);
  letter-spacing: 0;
}

/* footer */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-block: var(--sp-6);
  border-top: 1px solid var(--line);
  font-size: var(--t-small);
  color: var(--ink-soft); /* sits straight on the backdrop, over its brightest field */
}

/* not found */
.lost {
  display: grid;
  gap: var(--sp-5);
  justify-items: start;
  padding-block: var(--sp-9);
}

/* ---------- motion ---------- */

/* The drawings come alive twice: when they scroll into view, and when the region is switched.
   - .scale and .meters are held empty until app.js marks them .is-seen, then pour in.
   - Each region has its own copy of a drawing; the copy being switched to is rendered afresh,
     so its animation runs again by itself, and the rest of the block fades in with it.
   Without JavaScript (no .js on <html>) everything is simply drawn full. */
@media (prefers-reduced-motion: no-preference) {
  html.js .scale:not(.is-seen) .scale__bar::after {
    height: 0;
  }

  html.js .scale:not(.is-seen) .scale__end {
    opacity: 0;
  }

  html.js .meters:not(.is-seen) .meter__fill {
    width: 0;
  }

  /* capsules fill from the bottom like glasses under a tap, one after another along the row */
  .scale.is-seen .scale__bar::after {
    animation: pour var(--pour) var(--ease-pour) backwards;
    animation-delay: calc(var(--i) / var(--on) * var(--pour-spread));
  }

  /* the pink dot lands once the last capsule is nearly full */
  .scale.is-seen .scale__end {
    animation: appear var(--slow) var(--ease) backwards;
    animation-delay: calc(var(--pour-spread) + var(--pour) * 0.7);
  }

  .meters.is-seen .meter__fill {
    animation: run var(--pour) var(--ease-pour) backwards;
    animation-delay: calc(var(--row) * 60ms);
  }

  /* after the first switch of region, the block that is switched to fades in */
  html.has-switched [data-r] > * {
    animation: appear var(--slow) var(--ease) backwards;
  }

  /* a reading that has just been picked fades in the same way */
  .pick [data-v] {
    animation: appear var(--slow) var(--ease) backwards;
  }
}

@keyframes pour {
  from { height: 0; }
}

@keyframes run {
  from { width: 0; }
}

@keyframes appear {
  from { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0s;
  }
}
