/* The pendulum wave button: a pill of deep bottle green with a window sunk into it, where a row of steel balls
   hangs over a bone white floor. The floor, the balls, their threads, their shadows and the bar are drawn by
   script.js on the canvas; the pill, the window's rim and the words come from here. */
:root {
  --page: #ffffff;          /* the page */
  --body: #173a31;          /* the pill, bottle green */
  --body-lit: #1d4539;      /* the pill under the pointer */
  --edge: #0b201a;          /* the pill's lower lip and its shadow */
  --floor: #ece5d3;         /* the floor of the window, under the pendulums */
  --ink: #2c3a33;           /* the marks printed on the floor */
  --steel: #9aa2a7;         /* the steel of the balls and of the wire */
  --bar: #d0702a;           /* the bar that pulls the balls aside and catches them */
  --words: #f2ecdc;         /* the words and the icon */
  --focus: #173a31;         /* 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(--body);
  font-family: 'IBM Plex Sans Variable', 'IBM Plex 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;
}

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

/* ---------------------------------------------------------------- the pill */
.sync__btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 15px;
  width: min(348px, calc(100vw - 32px));
  height: 60px;
  padding: 8px 22px 8px 8px;
  border: 0;
  border-radius: 999px;
  background: var(--body);
  /* a thin lighter rim on top, a darker lip underneath, and the shadow on the page */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 -2px 0 rgba(0, 0, 0, 0.28),
    0 1px 1px rgba(11, 32, 26, 0.25),
    0 14px 26px -14px color-mix(in srgb, var(--edge) 80%, transparent);
  color: var(--words);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  transition:
    transform 160ms cubic-bezier(0.23, 1, 0.32, 1),
    background-color 220ms ease,
    box-shadow 160ms cubic-bezier(0.23, 1, 0.32, 1);
}

@media (hover: hover) and (pointer: fine) {
  .sync__btn:hover {
    background: var(--body-lit);
  }
}

.sync__btn:active {
  transform: scale(0.97);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28),
    0 1px 1px rgba(11, 32, 26, 0.25),
    0 8px 18px -12px color-mix(in srgb, var(--edge) 80%, transparent);
}

.sync__btn[aria-busy='true'] {
  cursor: progress;
}

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

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

/* ---------------------------------------------------------------- the window */
/* sunk into the pill, with the same curve as its ends (30 of the pill less 8 of the border) */
.sync__well {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  border-radius: 22px;
  overflow: hidden;
  background: var(--floor);
}

.sync__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* the rim of the window throws a little shadow on the floor, over everything inside */
.sync__well::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow:
    inset 0 2px 3px rgba(5, 18, 14, 0.42),
    inset 0 0 0 1px rgba(5, 18, 14, 0.38),
    inset 0 -1px 0 rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the words */
.sync__label {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 560;
  line-height: 1;
  letter-spacing: -0.004em;
  white-space: nowrap;
  pointer-events: none;
}

.sync__words {
  display: block;
}

/* the sync arrows, and the tick that takes their place once the balls are in line */
.sync__icons {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
}

.sync__icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.sync__icon--done {
  opacity: 0;
}

@media (max-width: 359px) {
  .sync__btn {
    gap: 12px;
    padding-right: 18px;
  }

  .sync__label {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sync__btn,
  .sync__btn:active {
    transform: none;
  }

  .sync__btn:active {
    filter: brightness(0.94);
  }
}
