/* The call button: a green pill on a white page that opens into a dark call bar. Everything in the bar sits at a
   fixed place; the script moves the handset from the button to the red key and back. */
:root {
  --page: #ffffff;          /* the page */
  --green: #19b35a;         /* the button */
  --bar: #121316;           /* the call bar */
  --red: #ff3b30;           /* the key that ends the call */
  --ended: #ececf0;         /* the button just after a call */
  --ink: #ffffff;
  --muted: #9a9ea8;         /* the timer */
  --level: #2bd97a;         /* the voice level */
}

* {
  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: #1c1c1f;
  font-family: 'Funnel Sans Variable', system-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;
}

.call {
  display: grid;
  justify-items: center;
  gap: 18px;
}

/* ---------------------------------------------------------------- the shell: the pill, then the bar */
.call__shell {
  position: relative;
  width: 196px;
  height: 60px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 14px 30px -14px rgba(10, 40, 20, 0.45);
  color: var(--ink);
  transition: color 0.4s ease;
}

/* the button covers the whole pill; in the bar it steps aside for the keys */
.call__start {
  position: absolute;
  inset: 0;
  padding: 0 24px 0 64px;
  border: 0;
  border-radius: inherit;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.call__label {
  display: block;
  height: 1.3em;
  overflow: hidden;
  font-size: 17px;
  font-weight: 640;
  letter-spacing: -0.01em;
  line-height: 1.3;
  white-space: nowrap;
}

.call__word {
  display: block;
}

.call.is-ended .call__shell {
  color: #3a3a40;
}

/* the handset: in the pill a white disc on the left; in the bar the red key on the right */
.call__phone {
  position: absolute;
  left: 8px;
  top: 8px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffffff;
  color: var(--green);
  pointer-events: none;
}

.call__phone svg {
  position: relative;
  width: 21px;
  height: 21px;
  fill: currentColor;
}

/* the ring that leaves the handset while it rings */
.call__ripple {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #ffffff;
  opacity: 0;
}

.call__avatar {
  position: absolute;
  left: 12px;
  top: 12px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(140deg, #ffad6b, #ff5f86);
  color: #ffffff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  opacity: 0;
  pointer-events: none;
}

.call__who {
  position: absolute;
  left: 72px;
  top: 0;
  bottom: 0;
  display: grid;
  align-content: center;
  gap: 2px;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}

.call__name {
  font-size: 15px;
  font-weight: 650;
}

.call__line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.call__time {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.call__level {
  display: grid;
  align-items: center;
}

.call__level > * {
  grid-area: 1 / 1;
}

.call__bars {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 14px;
}

.call__bars i {
  display: block;
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: var(--level);
}

/* muted, the level gives way to the word */
.call__muted {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
}

.call__mute,
.call__end {
  position: absolute;
  top: 14px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #ffffff;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.call__mute {
  display: grid;
  place-items: center;
  background: #2a2b31;
  opacity: 0;
  visibility: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

.call__mute[aria-pressed='true'] {
  background: #ffffff;
  color: var(--bar);
}

.call__mute svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.call__slash {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* the red key is drawn by the handset that travels there: this is only where to press */
.call__end {
  top: 12px;
  width: 48px;
  height: 48px;
  background: none;
  visibility: hidden;
}

.call.is-live .call__start {
  visibility: hidden;
}

.call.is-live .call__mute,
.call.is-live .call__end {
  visibility: visible;
}

.call__hint {
  margin: 0;
  color: #8b8b93;
  font-size: 14px;
  text-align: center;
}

.call__hint span {
  display: inline-block;
}

.call__start:focus-visible,
.call__mute:focus-visible,
.call__end:focus-visible {
  outline: 2px solid #1c1c1f;
  outline-offset: 3px;
}

.call.is-live .call__mute:focus-visible,
.call.is-live .call__end:focus-visible {
  outline-color: #ffffff;
}

html[data-using='pointer'] .call__start:focus-visible,
html[data-using='pointer'] .call__mute:focus-visible,
html[data-using='pointer'] .call__end:focus-visible {
  outline: none;
}
