/* The banknote button: a pill of deep note-green ink with a fine guilloche printed in it, on a white page. In its left
   end a felt counting tray holds the bundle of notes; the notes, their band and their shadows are drawn by script.js
   in a canvas over the tray, and read their colours from here. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #1b4a36;          /* the pill, at its top */
  --pill-deep: #0d2a1d;     /* the pill, at its foot */
  --guilloche: #7fb898;     /* the fine lines printed in the pill */
  --tray: #08190f;          /* the felt of the counting tray */
  --ink: #f4f0e1;           /* the words */
  --muted: #9fc4ad;         /* the word while the notes are counted */
  --paper: #e3ead6;         /* the face of a note */
  --paper-deep: #c5d5b3;    /* the face of a note, towards its edges */
  --print: #2d5c45;         /* the engraving on the face */
  --back: #b7cda8;          /* the back of a note */
  --back-print: #1f4a35;    /* the engraving on the back */
  --band: #f6f2e7;          /* the paper band round the bundle */
  --band-print: #b8452c;    /* the lines printed on the band */
  --tick: #c9f0d5;          /* the tick beside Paid */
  --focus: #1b4a36;         /* 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;
}

.notes {
  display: grid;
  justify-items: center;
  padding: 24px 0;
}

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

.notes__btn[aria-disabled='true'] {
  cursor: progress;
}

/* the fill is a layer of its own, so it can give under the finger with a bounce without moving the notes */
.notes__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  border-radius: inherit;
  background:
    radial-gradient(70% 120% at 30% 0%, rgba(255, 255, 255, 0.1), transparent 62%),
    linear-gradient(180deg, var(--pill), var(--pill-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -2px 6px rgba(0, 0, 0, 0.35),
    0 1px 1px rgba(13, 42, 29, 0.25),
    0 10px 22px -10px rgba(13, 42, 29, 0.55),
    0 22px 40px -24px rgba(13, 42, 29, 0.5);
  will-change: transform;
}

.notes__guilloche {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--guilloche);
  opacity: 0.22;
}

/* a band of light that crosses the pill under the pointer, as on the foil of a note */
.notes__sheen {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 46%;
  background: linear-gradient(100deg, transparent 0%, rgba(214, 255, 228, 0.16) 45%, rgba(255, 255, 255, 0.22) 50%, rgba(214, 255, 228, 0.16) 55%, transparent 100%);
  transform: translateX(-120%) skewX(-12deg);
  pointer-events: none;
}

/* the counting tray: a felt recess that follows the round end of the pill */
.notes__tray {
  position: absolute;
  left: 6px;
  top: 6px;
  width: 126px;
  height: 48px;
  border-radius: 24px 14px 14px 24px;
  background:
    radial-gradient(90% 120% at 50% 110%, rgba(255, 255, 255, 0.05), transparent 60%),
    var(--tray);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.7),
    inset 0 -1px 0 rgba(255, 255, 255, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.07);
  pointer-events: none;
}

/* the canvas reaches past the tray, above and below the pill, so the halves of the snapped band can fly out */
.notes__canvas {
  position: absolute;
  left: -4px;
  top: -24px;
  width: 144px;
  height: 108px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
.notes__faces {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 140px;
  right: 22px;
  display: grid;
}

.notes__face {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 620;
  letter-spacing: 0.005em;
  font-variant-numeric: tabular-nums;
}

.notes__face[aria-hidden='true'] {
  opacity: 0;
  visibility: hidden;
}

.notes__word {
  display: inline-block;
  font-stretch: 100%;
  will-change: font-stretch;
}

.notes__quiet {
  color: var(--muted);
  font-weight: 520;
}

/* the running amount: two lines that take turns, rolling up one after the other */
.notes__count {
  position: relative;
  display: inline-grid;
  overflow: hidden;
  height: 1.35em;
  line-height: 1.35em;
}

.notes__roll {
  grid-area: 1 / 1;
  text-align: left;
}

.notes__tick {
  width: 20px;
  height: 20px;
  flex: none;
  overflow: visible;
}

.notes__tick path {
  fill: none;
  stroke: var(--tick);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notes__paid {
  display: inline-block;
}

/* ---------------------------------------------------------------- the focus */
.notes__btn:focus {
  outline: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .notes__fill {
    will-change: auto;
  }
}
