/* The coin stack transfer: a graphite card on a black page, the words on the left and the stack of gold coins on the
   right. The coins are painted by script.js with the gold colours below; the card, the words and the button are CSS. */
:root {
  --page: #000000;          /* the page */
  --card: #121315;          /* the card */
  --edge: #24262a;          /* the card's thin edge */
  --ink: #f4f1ea;           /* the words */
  --muted: #8e8b84;         /* the quieter words */
  --gold-deep: #4a2c08;     /* the coins: their darkest metal */
  --gold: #c8923a;          /* the coins: their metal in plain light */
  --gold-pale: #fff0c4;     /* the coins: where they catch the light */
  --relief-dark: #2b1803;   /* the shadow side of the relief on the faces */
  --relief-light: #fff8e2;  /* the lit side of the relief */
  --glow: #e0a64a;          /* the warm light the stack throws on the card */
  --done: #7fd8a2;          /* the tick of a finished transfer */
  --error: #ff8466;         /* the words that say what went wrong */
  --button: #f4f1ea;        /* the button */
  --button-ink: #121315;    /* its words */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap, no zoom */
html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Instrument Sans 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 */
.pay {
  position: relative;
  width: min(384px, 100%);
  min-height: 238px;
  overflow: hidden;
  border-radius: 24px;
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--edge), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  isolation: isolate;
}

.pay__words {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 238px;
  padding: 20px 0 20px 22px;
  margin-right: 148px;
}

.pay__title {
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 520;
  font-stretch: 94%;
  line-height: 1.3;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

/* the amount: it climbs coin by coin, on figures of one width so it does not shuffle */
.pay__amount {
  margin: 12px 0 0;
  font-size: 33px;
  font-weight: 600;
  font-stretch: 86%;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pay__figure {
  display: inline-block;
  transform-origin: 0 80%;
}

.pay__status {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 16px 0 0;
  font-size: 14px;
  font-weight: 560;
  line-height: 20px;
  white-space: nowrap;
}

.pay__sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 450;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* the words that change slide by themselves */
.pay__swap {
  display: inline-block;
}

.pay__swap .is-error {
  color: var(--error);
}

.pay__tick {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--done);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  visibility: hidden;
}

/* ---------------------------------------------------------------- the stack */
/* the stage is the whole right side of the card, from edge to edge: the coins come in through its top */
.pay__stack {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 148px;
  background: radial-gradient(64px 40px at 50% calc(100% - 34px), color-mix(in srgb, var(--glow) 8%, transparent), transparent);
}

/* the coins come in through the top of the card: they appear out of the dark rather than across its edge */
.pay__coins {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 30px);
  mask-image: linear-gradient(180deg, transparent 0, #000 30px);
}

/* ---------------------------------------------------------------- the button */
/* the site's elastic pill: the words widen on the width axis under the pointer, the pill squashes when pressed */
.pay__btn {
  position: relative;
  flex: none;
  height: 36px;
  margin-top: auto;
  padding: 0 17px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--button);
  color: var(--button-ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 36px;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.pay__label {
  display: inline-block;
  font-stretch: 86%;
  transition: font-stretch 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* while the coins fall the button only says so: it steps back */
.pay__btn.is-quiet {
  background: transparent;
  color: var(--muted);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink) 14%, transparent);
  cursor: default;
}

@media (hover: hover) and (pointer: fine) {
  .pay__btn:not(.is-quiet):hover .pay__label {
    font-stretch: 100%;
  }

  .pay__btn:not(.is-quiet):hover {
    background: color-mix(in srgb, var(--button) 86%, var(--gold));
  }
}

.pay__btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* on a narrow phone the stage gives a little room to the words */
@media (max-width: 400px) {
  .pay__words {
    margin-right: 132px;
    padding-left: 20px;
  }

  .pay__stack {
    width: 132px;
  }

  .pay__amount {
    font-size: 31px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pay__label {
    transition: none;
  }
}
