/* The badge swipe button: a graphite pill on a white page that is also a card reader, with a slot along its top edge,
   and an ID badge hanging over it on a spring reel. The reel, the cord and the badge are drawn by script.js on a canvas
   that sits between the back of the slot and the front of the pill, so the badge goes into the slot behind the words
   (their colours come from here); the pill, the slot and the words are CSS. */
:root {
  --page: #ffffff;          /* the page */
  --pill: #24272c;          /* the front of the pill, at its top */
  --pill-deep: #131518;     /* the front of the pill, at its foot */
  --slot: #050607;          /* the inside of the slot */
  --ink: #f3f1ec;           /* the words */
  --muted: #9097a0;         /* the words while it works */
  --badge: #fbfaf7;         /* the badge */
  --band: #12705f;          /* the band printed across the top of the badge */
  --stripe: #2a2420;        /* the magnetic stripe along its foot */
  --cord: #1d6f61;          /* the cord */
  --chrome-light: #f6f8fa;  /* the reel, where the light catches it */
  --chrome: #a5adb6;        /* the reel */
  --chrome-dark: #4a5059;   /* the reel, in its shadow */
  --read: #5fe0a8;          /* the line of light in the slot while the reader reads */
  --focus: #24272c;         /* 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(--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: 40px 16px;
}

/* the whole thing: the reel and the badge over the pill, in a box as wide as the pill */
.swipe {
  position: relative;
  width: min(300px, calc(100vw - 32px));
  height: 164px;
}

/* the canvas reaches past the box, so the badge can swing out of it */
.swipe__rig {
  position: absolute;
  left: -40px;
  top: -12px;
  z-index: 1;
  width: calc(100% + 80px);
  height: calc(100% + 24px);
  pointer-events: none;
}

/* an invisible handle over the badge: the hand grabs it here */
.swipe__grip {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 4;
  width: 64px;
  height: 48px;
  border-radius: 6px;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.swipe__grip:active {
  cursor: grabbing;
}

/* ---------------------------------------------------------------- the pill */
/* no z-index of its own: the back of the slot goes under the canvas, the front of the pill over it */
.swipe__btn {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

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

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

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

/* the back of the slot: the pill's whole shape, dark, seen only along its top edge */
.swipe__back,
.swipe__front {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  transition: inset 0.6s cubic-bezier(0.34, 1.9, 0.45, 1), box-shadow 0.4s ease;
}

.swipe__back {
  z-index: 0;
  background:
    linear-gradient(180deg, #2c3036 0, #2c3036 2px, var(--slot) 3.5px, var(--slot) 100%);
  box-shadow:
    0 1px 2px rgba(19, 21, 24, 0.25),
    0 16px 30px -14px rgba(19, 21, 24, 0.6);
}

/* the front of the pill, below the slot: the words are on it and the badge goes behind it */
.swipe__front {
  z-index: 2;
  background:
    radial-gradient(80% 140% at 30% 10%, rgba(255, 255, 255, 0.08), transparent 60%),
    linear-gradient(180deg, var(--pill), var(--pill-deep));
  clip-path: inset(10px 0 0 0);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.5);
}

/* the lip of the slot: a fine bevel of light along the front's top edge, and a shadow just under it */
.swipe__front::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 10px;
  height: 5px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28) 0, rgba(255, 255, 255, 0.28) 1px, rgba(255, 255, 255, 0.04) 1.5px, transparent 5px);
}

/* ---------------------------------------------------------------- the words */
.swipe__faces {
  position: absolute;
  z-index: 3;
  top: 11px;
  bottom: 0;
  left: 18px;
  right: 18px;
  pointer-events: none;
}

.swipe__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  white-space: nowrap;
}

.swipe__face--busy,
.swipe__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 */
.swipe__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);
}

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

.swipe__shine,
.swipe__gone,
.swipe__who {
  padding-bottom: 1px;
  font-size: 16px;
  font-weight: 560;
  letter-spacing: -0.004em;
  line-height: 1;
  color: var(--muted);
}

.swipe__shine {
  background: linear-gradient(100deg, var(--muted) 0%, var(--muted) 38%, var(--ink) 50%, var(--muted) 62%, var(--muted) 100%);
  background-size: 260% 100%;
  background-position: var(--sheen, 100%) 0;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.swipe__who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.swipe__who b {
  font-weight: 660;
  color: var(--ink);
}

.swipe__out {
  flex: none;
  display: grid;
  place-items: center;
  height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(243, 241, 236, 0.09);
  box-shadow: inset 0 0 0 1px rgba(243, 241, 236, 0.12);
  color: var(--ink);
  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) {
  .swipe__btn:not([aria-disabled='true']):hover .swipe__back,
  .swipe__btn:not([aria-disabled='true']):hover .swipe__front {
    inset: -2px -7px;
  }

  .swipe__btn:not([aria-disabled='true']):hover .swipe__word {
    font-stretch: 118%;
    font-weight: 680;
  }

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

html[data-using='keys'] .swipe__btn:focus-visible .swipe__word {
  font-stretch: 118%;
  font-weight: 680;
}

/* ---------------------------------------------------------------- reduced motion: no swelling, no widening */
@media (prefers-reduced-motion: reduce) {
  .swipe__back,
  .swipe__front,
  .swipe__word {
    transition: filter 0.3s ease;
  }

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

@media (prefers-reduced-motion: reduce) and (hover: hover) and (pointer: fine) {
  .swipe__btn:not([aria-disabled='true']):hover .swipe__back,
  .swipe__btn:not([aria-disabled='true']):hover .swipe__front {
    inset: 0;
  }

  .swipe__btn:not([aria-disabled='true']):hover .swipe__front {
    filter: brightness(1.3);
  }

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