/* The cone stepper: how many scoops on a gelato cone. A mint card with the cone and its stack of scoops, drawn by
   the script, and under it a label and a chocolate stepper 60 pixels tall with minus, the number and plus. */
:root {
  --page: #ffffff;               /* the page */
  --card: #d9eee5;               /* the card */
  --ink: #1b2a24;                /* the label */
  --muted: #45605a;              /* the note under the label */
  --limit: #9e2338;              /* the note when a limit is reached */
  --pill: #3b2219;               /* the stepper */
  --disc: rgba(255, 238, 220, 0.13);  /* the buttons' discs */
  --icon: #fff2e3;               /* minus and plus */
  --digit: #fff2e3;              /* the number */
  --wafer-light: #f2c787;        /* the cone, on its lit side */
  --wafer: #dda35d;              /* the cone */
  --wafer-dark: #b5753a;         /* the cone, on its shaded side */
  --wafer-line: #9c5c26;         /* the waffle grid pressed into the cone */
  --rim: #e8b46f;                /* the rolled rim of the cone */
  --floor-shade: #1d5843;        /* the shadow on the card under the cone */
  --strawberry: #f59eab;         /* the first scoop */
  --strawberry-bits: #db5a72;    /* the bits of fruit in it */
  --pistachio: #c4d482;          /* the second scoop */
  --pistachio-bits: #899f45;     /* the chopped nuts in it */
  --stracciatella: #fff6e8;      /* the third scoop */
  --stracciatella-bits: #4b2b1d; /* the chocolate flakes in it */
  --chocolate: #7d4b33;          /* the fourth scoop */
  --lemon: #f6e28a;              /* the fifth scoop */
  --blueberry: #a9acdf;          /* the sixth scoop */
  --hazelnut: #c99c6d;           /* the seventh scoop */
}

* {
  box-sizing: border-box;
}

/* quick taps on the buttons never become a double tap that zooms the page */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Bricolage Grotesque Variable', system-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: 32px 16px;
}

/* ---------------------------------------------------------------- the card */
.cone-card {
  position: relative;
  width: min(340px, 100%);
  padding-bottom: 12px;
  border-radius: 42px;
  background: var(--card);
}

.scene {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 340 / 300;
  overflow: hidden;
  border-radius: 42px 42px 0 0;
}

/* the cone */
.cone__mouth {
  fill: color-mix(in srgb, var(--wafer-dark) 62%, #2a1206);
}

.cone__grid line {
  stroke: var(--wafer-line);
  stroke-width: 1.5;
  stroke-opacity: 0.5;
}

.cone__grid line.is-lit {
  stroke: #fff4df;
  stroke-width: 1;
  stroke-opacity: 0.32;
}

.cone__rim {
  fill: var(--rim);
}

.cone__rim-edge {
  fill: none;
  stroke: var(--wafer-dark);
  stroke-width: 1.3;
  stroke-opacity: 0.8;
}

.cone__rim-light {
  fill: none;
  stroke: #fff4df;
  stroke-width: 1.2;
  stroke-opacity: 0.6;
  stroke-linecap: round;
}

.wafer-light {
  stop-color: var(--wafer-light);
}

.wafer-mid {
  stop-color: var(--wafer);
}

.wafer-dark {
  stop-color: var(--wafer-dark);
}

.floor-shade {
  stop-color: var(--floor-shade);
}

/* a scoop: its flavour comes from --flavour, set by the script */
.scoop__body {
  fill: var(--flavour);
}

.scoop__bits {
  fill: var(--bits);
}

.scoop__crease {
  fill: none;
  stroke: #3c140a;
  stroke-opacity: 0.15;
  stroke-width: 1.3;
  stroke-linecap: round;
}

.scoop__sweep {
  fill: none;
  stroke: #3c140a;
  stroke-opacity: 0.11;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.scoop__sweep.is-lit {
  stroke: #ffffff;
  stroke-opacity: 0.12;
  stroke-width: 1.1;
}

.scoop__light {
  fill: none;
  stroke: #ffffff;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the row under the cone */
.order {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px 0 24px;
}

.order__label {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.order__name {
  font-size: 18px;
  font-weight: 650;
  line-height: 24px;
  letter-spacing: -0.01em;
}

/* the note under the label: the script swaps it, sliding, when a limit is reached */
.order__note {
  display: grid;
  height: 20px;
  clip-path: inset(0 -16px);
}

.order__note-in {
  grid-area: 1 / 1;
  display: block;
  color: var(--muted);
  font-size: 14px;
  font-weight: 480;
  line-height: 20px;
  white-space: nowrap;
}

.order__note-in.is-limit {
  color: var(--limit);
  font-weight: 580;
}

/* ---------------------------------------------------------------- the stepper */
.stepper {
  flex: none;
  display: flex;
  align-items: center;
  height: 60px;
  padding: 6px;
  border-radius: 999px;
  background: var(--pill);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 6px 14px -8px color-mix(in srgb, var(--pill) 70%, transparent),
    0 2px 4px -2px color-mix(in srgb, var(--pill) 50%, transparent);
}

.stepper__btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--icon);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.stepper__disc {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--disc);
  transition: background-color 0.2s ease, scale 0.45s cubic-bezier(0.34, 1.7, 0.5, 1);
}

.stepper__disc svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  transition: opacity 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
  .stepper__btn:not([aria-disabled='true']):hover .stepper__disc {
    background: color-mix(in srgb, var(--disc), #fff2e3 10%);
  }

  .stepper__value:hover {
    background: rgba(255, 242, 227, 0.07);
  }
}

.stepper__btn:active .stepper__disc {
  scale: 0.88;
  transition: background-color 0.2s ease, scale 0.1s ease-out;
}

/* at a limit the button stays pressable (pushing it shakes the tower) but looks spent */
.stepper__btn[aria-disabled='true'] .stepper__disc {
  background: color-mix(in srgb, var(--disc) 40%, transparent);
}

.stepper__btn[aria-disabled='true'] svg {
  opacity: 0.36;
}

.stepper__btn[aria-disabled='true']:active .stepper__disc {
  scale: 0.95;
}

.stepper__btn:focus-visible {
  outline: none;
}

.stepper__btn:focus-visible .stepper__disc {
  box-shadow: 0 0 0 2px var(--pill), 0 0 0 4px var(--icon);
}

/* the number: a field that takes a digit typed by hand as well */
.stepper__value {
  width: 44px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--digit);
  caret-color: var(--digit);
  font: inherit;
  font-size: 26px;
  font-weight: 620;
  line-height: 48px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  outline: none;
  cursor: text;
  transition: background-color 0.2s ease;
}

.stepper__value::selection {
  background: rgba(255, 242, 227, 0.22);
}

.stepper__value:focus-visible {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--digit) 80%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .stepper__disc,
  .stepper__btn:active .stepper__disc,
  .stepper__btn[aria-disabled='true']:active .stepper__disc {
    transition: background-color 0.2s ease;
    scale: none;
  }
}
