/* The fingerprint button: a graphite pill on a white page, with a Touch ID sensor in its round left end. The sensor,
   its steel ring, the ridges, the ink and the tick are drawn by script.js on a canvas (their colours come from here);
   the pill, the words and the states are CSS. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #22242a;          /* the pill, at its top */
  --pill-deep: #111216;     /* the pill, at its foot */
  --text: #f3f1ec;          /* the words */
  --muted: #9a9ca5;         /* the small words, and the words while it reads */
  --chip: rgba(243, 241, 236, 0.1);   /* the little Lock pill */
  --steel-light: #eef0f3;   /* the sensor's ring, where the light falls */
  --steel: #9aa0a8;         /* the ring */
  --steel-dark: #3c4047;    /* the ring, in its shadow */
  --glass: #0d0e11;         /* the sapphire over the sensor */
  --ridge: #4a4e57;         /* the ridges, dry */
  --ink: #ff3b5c;           /* the ridges, inked */
  --wet: #ffc2b3;           /* the ink at its front, still wet */
  --ok: #3ddc8a;            /* the tick */
  --focus: #22242a;         /* the ring of the keyboard's focus */
}

* {
  box-sizing: border-box;
}

/* a tap is a press 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(--pill);
  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;
}

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

/* ---------------------------------------------------------------- the pill */
.touch__btn {
  position: relative;
  display: block;
  /* the script sets the width from the words; this is the width before it does */
  width: 262px;
  max-width: calc(100vw - 32px);
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text);
  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;
}

.touch__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 */
.touch__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(90% 140% at 18% 0%, rgba(255, 255, 255, 0.07), transparent 62%),
    linear-gradient(180deg, var(--pill), var(--pill-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    inset 0 -1px 0 rgba(0, 0, 0, 0.45),
    0 1px 2px rgba(17, 18, 22, 0.22),
    0 14px 28px -14px rgba(17, 18, 22, 0.6);
  transition:
    inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1),
    box-shadow 0.4s ease;
}

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

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

/* the sensor sits in the round left end of the pill */
.touch__sensor {
  position: absolute;
  left: 0;
  top: 0;
  width: 60px;
  height: 60px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
/* two faces for a line of words, so one can leave while the other comes, and the face of the person signed in */
.touch__faces {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 62px;
  right: 0;
  pointer-events: none;
}

.touch__face {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  /* as wide as the words, not as the pill is now: the script measures it to size the pill */
  width: max-content;
  display: flex;
  align-items: center;
  text-align: left;
  white-space: nowrap;
}

.touch__face[data-face='b'],
.touch__face--done {
  opacity: 0;
  visibility: hidden;
}

/* the words 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 for it */
.touch__word {
  display: inline-grid;
  padding-bottom: 1px;
  font-size: 17px;
  font-weight: 620;
  font-stretch: 100%;
  letter-spacing: -0.008em;
  line-height: 1;
  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), color 0.3s ease;
}

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

/* while it reads, signs in or locks: the words in a quieter tone */
.touch__word.is-quiet {
  color: var(--muted);
  font-weight: 560;
}

/* let go too soon: the words take the colour of the wet ink */
.touch__word.is-warn {
  color: var(--wet);
}

/* the person signed in: a small line over the name, and the little Lock pill at the right end */
.touch__face--done {
  gap: 14px;
}

.touch__who {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.touch__lead {
  font-size: 11.5px;
  font-weight: 520;
  letter-spacing: 0.012em;
  line-height: 1;
  color: var(--muted);
}

.touch__name {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 17px;
  font-weight: 660;
  letter-spacing: -0.008em;
  line-height: 1.05;
}

.touch__lock {
  flex: none;
  display: grid;
  place-items: center;
  height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  background: var(--chip);
  box-shadow: inset 0 0 0 1px rgba(243, 241, 236, 0.12);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* ---------------------------------------------------------------- under the pointer */
@media (hover: hover) and (pointer: fine) {
  .touch__btn:not([aria-disabled='true']):hover .touch__fill {
    inset: -2px -7px;
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.11),
      inset 0 -1px 0 rgba(0, 0, 0, 0.45),
      0 1px 2px rgba(17, 18, 22, 0.22),
      0 18px 32px -14px rgba(17, 18, 22, 0.66);
  }

  .touch__btn:not([aria-disabled='true']):hover .touch__word:not(.is-quiet):not(.is-warn) {
    font-stretch: 116%;
    font-weight: 680;
  }

  .touch__btn:not([aria-disabled='true']):hover .touch__lock {
    background: rgba(243, 241, 236, 0.18);
    box-shadow: inset 0 0 0 1px rgba(243, 241, 236, 0.22);
  }
}

/* the keys bring the focus: the words widen as under the pointer */
html[data-using='keys'] .touch__btn:focus-visible .touch__word:not(.is-quiet):not(.is-warn) {
  font-stretch: 116%;
  font-weight: 680;
}

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

  html[data-using='keys'] .touch__btn:focus-visible .touch__word:not(.is-quiet):not(.is-warn) {
    font-stretch: 100%;
    font-weight: 620;
  }
}

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

  .touch__btn:not([aria-disabled='true']):hover .touch__word:not(.is-quiet):not(.is-warn) {
    font-stretch: 100%;
    font-weight: 620;
  }
}
