/* The cash register button: an oxblood enamel pill with gilt lines on a black page. In its left end the bank of keys,
   in CSS 3D; over it the gilt sign whose window shows the amount flags; under it the cash drawer. The keys' shapes are
   built by script.js, their look and every colour are here. */
:root {
  --page: #000000;          /* the page */
  --enamel: #7b2125;        /* the enamel of the register, at its top */
  --enamel-deep: #3d0c10;   /* the enamel, at its foot */
  --gold-light: #f8e2a4;    /* the gilt lines and frames, where the light falls */
  --gold: #d1a65a;          /* the gilt */
  --gold-dark: #7d5a20;     /* the gilt, in its shadow */
  --ink: #f8ecd4;           /* the words */
  --muted: #d9b9a3;         /* the words while it rings up */
  --nickel-light: #f4f3ee;  /* the nickel rims and stems of the keys, where the light falls */
  --nickel: #a9a8a1;        /* the nickel */
  --nickel-dark: #45443f;   /* the nickel, in its shadow */
  --celluloid: #f6eedb;     /* the faces of the keys */
  --key-print: #2b1c17;     /* the figures on the keys */
  --flag: #f7f0de;          /* the amount flags */
  --flag-print: #161210;    /* the figures on the flags */
  --glass: #150b09;         /* behind the window of the sign */
  --wood: #4a2a17;          /* the inside of the drawer */
  --note-green: #7d9a74;    /* the notes in the drawer */
  --note-blue: #6b86a6;
  --note-rose: #c48a7c;
  --focus: #f8e2a4;         /* 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;
  padding: 72px 16px;
}

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

/* the unit holds the sign over the pill and the room the drawer opens into under it */
.till__unit {
  position: relative;
  padding: 36px 0 48px;
}

.till__body {
  position: relative;
  z-index: 1;
}

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

.till__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: oxblood
   enamel with a gilt line run round it, a little inside its edge */
.till__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(80% 130% at 26% 0%, rgba(255, 236, 214, 0.16), transparent 60%),
    linear-gradient(180deg, var(--enamel), var(--enamel-deep));
  box-shadow:
    inset 0 0 0 3px var(--enamel-deep),
    inset 0 0 0 4px var(--gold),
    inset 0 1px 0 4px rgba(255, 240, 210, 0.2),
    inset 0 -2px 0 rgba(0, 0, 0, 0.4),
    0 1px 0 rgba(255, 230, 200, 0.08),
    0 16px 30px -12px rgba(0, 0, 0, 0.9);
  transition:
    inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    box-shadow 0.4s ease;
}

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

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

/* ---------------------------------------------------------------- the keys */
/* the bed the keys stand in: a dark recess in the enamel, with its own gilt line */
.till__bed {
  position: absolute;
  left: 7px;
  top: 7px;
  width: 84px;
  height: 46px;
  border-radius: 23px;
  background:
    radial-gradient(120% 90% at 50% 10%, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.25) 70%),
    var(--enamel-deep);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.7),
    inset 0 -1px 0 rgba(255, 230, 200, 0.12),
    0 0 0 1px rgba(209, 166, 90, 0.55);
  perspective: 190px;
  perspective-origin: 50% 20%;
  pointer-events: none;
}

/* the plane the keys stand on, laid back so the keys are seen a little from above */
.till__bank {
  position: absolute;
  left: 4px;
  top: -6.5px;
  width: 76px;
  height: 66px;
  transform: rotateX(52deg);
  transform-style: preserve-3d;
}

/* the keys are built four times larger and scaled down in 3D: Chrome paints a layer in 3D at the size it has before
   its transform, so keys built at their real size came out soft, their figures smudged */
.till__big {
  position: absolute;
  left: 0;
  top: 0;
  width: 304px;
  height: 264px;
  transform: scale3d(0.25, 0.25, 0.25);
  transform-origin: 0 0;
  transform-style: preserve-3d;
}

.key {
  position: absolute;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  transform-style: preserve-3d;
  --h: 9;
}

/* each key is a pile of discs at their heights: the stem, the nickel rim and the celluloid face; pressing a key
   lowers its height, and the pile squeezes down */
.key__disc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transform: translateZ(calc(var(--h) * var(--f) * 4px));
  backface-visibility: hidden;
}

.key__disc--stem {
  inset: 21px;
  background: radial-gradient(circle at 35% 30%, var(--nickel), var(--nickel-dark));
}

.key__disc--shade {
  inset: 4px;
  background: rgba(0, 0, 0, 0.55);
  filter: blur(5px);
}

.key__disc--rim {
  background:
    radial-gradient(circle at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.35) 70%, transparent 72%),
    conic-gradient(from 200deg, var(--nickel-light), var(--nickel) 25%, var(--nickel-dark) 50%, var(--nickel) 75%, var(--nickel-light));
}

.key__disc--face {
  inset: 6.4px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 40% 32%, #fff 0%, var(--celluloid) 45%, color-mix(in srgb, var(--celluloid) 82%, #8a6d3c) 100%);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  color: var(--key-print);
  font-family: 'Big Shoulders Display Variable', 'Big Shoulders Display', 'Arial Narrow', sans-serif;
  font-size: 29px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1;
}

/* the key the register is pressing now: its face warms a little (the only change left with reduced motion) */
.key__disc--face::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--gold);
  mix-blend-mode: multiply;
  opacity: var(--lit, 0);
}

/* ---------------------------------------------------------------- the sign and its flags */
.till__sign {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: calc(100% - 4px);
  width: 98px;
  margin-left: -49px;
  display: grid;
  justify-items: center;
  padding: 2px 3px 4px;
  border-radius: 16px 16px 5px 5px;
  background:
    linear-gradient(180deg, rgba(255, 240, 210, 0.16), transparent 40%),
    linear-gradient(180deg, var(--enamel), var(--enamel-deep));
  box-shadow:
    inset 0 0 0 1.5px var(--gold),
    inset 0 0 0 2.5px var(--enamel-deep),
    0 -1px 0 rgba(255, 230, 200, 0.08),
    0 8px 14px -6px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.till__crest {
  padding: 3px 0 2px;
  font-size: 6.4px;
  font-weight: 700;
  font-stretch: 112%;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--gold-light);
}

.till__window {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1.5px;
  width: 84px;
  height: 21px;
  padding: 0 5px 2px;
  border-radius: 3px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.14), transparent 38%),
    var(--glass);
  box-shadow:
    inset 0 0 0 1px var(--gold-dark),
    inset 0 3px 5px rgba(0, 0, 0, 0.8);
  font-family: 'Big Shoulders Display Variable', 'Big Shoulders Display', 'Arial Narrow', sans-serif;
}

.till__mark {
  align-self: center;
  padding: 0 1px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  color: var(--gold);
}

.till__mark--dot {
  align-self: flex-end;
  padding: 0 0.5px 1px;
}

/* a slot is the opening a flag rises through; the flag hides under its lip until its key is pressed */
.till__slot {
  position: relative;
  width: 12px;
  height: 17px;
  overflow: hidden;
  border-radius: 2px 2px 0 0;
  perspective: 60px;
  perspective-origin: 50% 100%;
}

.till__slot--wide {
  width: 19px;
}

.till__flag {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding-top: 1px;
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, #fff, var(--flag) 40%, color-mix(in srgb, var(--flag) 80%, #7a6038));
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  color: var(--flag-print);
  font-size: 15px;
  font-weight: 850;
  line-height: 1;
  transform-origin: 50% 100%;
  transform: translateY(105%);
  backface-visibility: hidden;
}

/* ---------------------------------------------------------------- the drawer */
.till__drawer {
  position: absolute;
  left: 50%;
  top: calc(36px + 60px - 10px);
  width: 176px;
  height: 64px;
  margin-left: -88px;
  overflow: hidden;
  pointer-events: none;
}

.till__slide {
  position: absolute;
  left: 3px;
  right: 3px;
  top: -40px;
  will-change: transform;
}

.till__tray {
  display: block;
  width: 100%;
  height: 40px;
}

.till__front {
  position: relative;
  height: 18px;
  border-radius: 0 0 9px 9px;
  background:
    linear-gradient(180deg, rgba(255, 236, 214, 0.18), transparent 30%),
    linear-gradient(180deg, var(--enamel), var(--enamel-deep));
  box-shadow:
    inset 0 0 0 2px var(--enamel-deep),
    inset 0 0 0 2.8px var(--gold-dark),
    inset 0 1px 0 rgba(255, 240, 210, 0.25),
    0 10px 16px -8px rgba(0, 0, 0, 0.9);
}

.till__pull {
  position: absolute;
  left: 50%;
  top: 9px;
  width: 30px;
  height: 4.5px;
  margin-left: -15px;
  border-radius: 3px;
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 45%, var(--gold-dark));
  box-shadow: 0 1.5px 1.5px rgba(0, 0, 0, 0.6);
}

/* ---------------------------------------------------------------- the words */
.till__faces {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 104px;
  right: 0;
  pointer-events: none;
}

.till__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: 6px;
  text-align: left;
  white-space: nowrap;
  font-size: 16.5px;
  font-weight: 620;
  letter-spacing: -0.006em;
  line-height: 1;
}

[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 the pill never changes size */
.till__word {
  display: inline-grid;
  padding-bottom: 1px;
  font-stretch: 100%;
  font-variant-numeric: tabular-nums;
  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);
}

.till__word::before {
  content: attr(data-wide);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-stretch: 114%;
  font-weight: 680;
}

.till__quiet {
  font-weight: 560;
  color: var(--muted);
}

.till__paid {
  color: var(--gold-light);
  font-weight: 700;
}

.till__sep {
  color: var(--muted);
}

.till__order {
  font-variant-numeric: tabular-nums;
}

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

  .till__btn:not([aria-disabled='true']):hover .till__word {
    font-stretch: 114%;
    font-weight: 680;
  }
}

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

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

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

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

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