/* The call surface, its card, dialogs, strip and toast, and the Calls tab, as the web design's call boards draw
   them (canvas "MeshLink Web Screens": project/web.css's calls part, the kit's ml-call pieces). Every piece is a child
   of the frame's .w-app (views/call.tsx). Every colour, size and type style is a token from design/tokens.json
   (tokens.css, written by `tools/keel gen-tokens`); the few web sizes with no token are named once below. Logical
   properties only. Loaded in index.html's order: frame, start, chats, conversation, media, contact, calls, settings. */

.call-surface, .call-float {
  /* The video call's self view on the web board (call-video); the phones' --call-pip-* are a phone's corner. */
  --w-call-pip-inline: 240px;
  --w-call-pip-block: 150px;
  /* The outcome's stacked buttons (call-no-answer) and its text's measure. */
  --w-call-actions: 320px;
  --w-call-text: 360px;
  /* The ringing card with three buttons (call-incoming-stranger's video call). */
  --w-call-float-wide: 400px;
}

/* ---- The Calls tab (calls-empty): the pane's head, the illustration over "No calls yet" ---- */
.calls-pane { display: flex; flex-direction: column; background: var(--surface); }
.calls-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-6);
  text-align: center;
}
.calls-empty-title {
  margin: 0;
  font: var(--title-condensed-weight) var(--title-condensed-size) / var(--title-condensed-line) var(--title-condensed-family);
}
/* ---- The Calls tab's rows (calls): rounded and inset, 2 apart, as the chat list's; the row is tinted on hover ---- */
.calls-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-half);
  flex: 1 1 auto;
  min-block-size: 0;
  margin: 0;
  padding-block: 0 var(--space-2);
  padding-inline: var(--space-2);
  list-style: none;
  overflow-y: auto;
}
.calls-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-block-size: var(--avatar-lg);
  padding-block: var(--space-2-half);
  padding-inline: var(--space-3);
  border-radius: var(--radius-menu);
}
.calls-row:hover, .calls-row:focus-within { background: var(--surface-sunken); }
/* The face, then the name over the kind over the time: the row's own button, its text the board's ml-row__body. */
.calls-row__open {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1 1 auto;
  min-inline-size: 0;
  padding: 0;
  border: none;
  background: none;
  color: var(--ink);
  text-align: start;
}
.calls-row__open .disc { width: var(--avatar-row); height: var(--avatar-row); font-size: var(--title-size); }
.calls-row__body { display: flex; flex-direction: column; gap: var(--space-half); min-inline-size: 0; }
.calls-row__name, .calls-row__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calls-row__name { font: var(--callout-strong-weight) var(--body-size) / var(--body-line) var(--body-family); }
.calls-row__sub { font: var(--footnote-weight) var(--footnote-size) / var(--footnote-line) var(--footnote-family); color: var(--ink-muted); }
.calls-row__sub--missed { font-weight: var(--footnote-strong-weight); color: var(--danger); }
/* The call-back at the row's end: the kit's icon button in mesh. */
.call-back { flex: none; color: var(--mesh); }

/* ---- The placed call (call-outgoing … call-ended): the main pane for voice, the whole window for video ---- */
.call-surface {
  position: absolute;
  inset-block: 0;
  inset-inline: calc(var(--w-rail) + var(--w-pane)) 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--call-bg) 82%, var(--mesh)) 0%, var(--call-bg) 70%);
  color: var(--on-call);
}
.call-surface.full { inset-inline: 0; background: var(--call-bg); }
/* What the surface covers is out of reach while it is up: no focus, nothing read in the panes under it. */
.w-app:has(> .call-surface.pane) > .w-main,
.w-app:has(> .call-surface.pane) > .w-side,
.w-app:has(> .call-surface.full) > .w-rail,
.w-app:has(> .call-surface.full) > .w-list,
.w-app:has(> .call-surface.full) > .w-main,
.w-app:has(> .call-surface.full) > .w-side { visibility: hidden; }

.call-media { position: absolute; inset: 0; z-index: -1; }
.call-media .call-remote { inline-size: 100%; block-size: 100%; object-fit: cover; }
.call-media .call-local, .call-self-off {
  position: absolute;
  inset-inline-end: calc(2 * var(--space-4));
  inset-block-end: calc(2 * var(--space-4));
  inline-size: var(--w-call-pip-inline);
  block-size: var(--w-call-pip-block);
  border-radius: var(--radius-card);
  object-fit: cover;
}
/* My corner while my camera is off: my face where my video was (call-video-camera-off, #1748) */
.call-self-off { display: grid; place-items: center; background: var(--call-self-off); }
.call-media:has(+ .call-self-off) .call-local { visibility: hidden; }

/* The head: Back to chat, the lock, "Voice call" (k-callhead) */
.call-top {
  position: relative;
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: var(--space-1-half);
  padding: var(--space-3) var(--space-4);
  color: var(--on-call-muted);
  font: var(--callout-weight) var(--callout-size) / var(--callout-line) var(--callout-family);
}
.call-top .icon-button { color: var(--on-call); }
.call-top .icon-button:hover { background: var(--call-control); }
.call-top .icon-button:focus-visible { outline: var(--ring) solid var(--on-call); outline-offset: var(--ring); }

/* The middle (w-call__mid): the face, the name, the status */
.call-head, .call-mid {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2-half);
  text-align: center;
}
/* call-video: the name and the clock small, at the top start */
.call-head.small {
  position: relative;
  flex: 1 1 auto;
  align-self: stretch;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0;
  padding: var(--space-1) calc(2 * var(--space-4));
  text-align: start;
}
/* A click on the video between the head and the controls reaches the video (tapVideo hides the controls). */
.call-surface.full .call-head.small { pointer-events: none; }
.call-mid.outcome { position: relative; z-index: 1; pointer-events: none; }
.call-mid.outcome .call-foot { pointer-events: auto; }
.call-face {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: var(--call-avatar);
  block-size: var(--call-avatar);
  border-radius: var(--radius-pill);
  font: var(--title-condensed-weight) calc(var(--call-avatar) * 0.39) / 1 var(--font-sans);
  user-select: none;
}
.call-face.sm { inline-size: var(--call-avatar-sm); block-size: var(--call-avatar-sm); font-size: calc(var(--call-avatar-sm) * 0.39); }
.call-face.faded { opacity: 0.5; }
.call-name {
  margin: var(--space-2) 0 0;
  font: var(--large-title-weight) var(--large-title-size) / var(--large-title-line) var(--large-title-family);
  letter-spacing: var(--large-title-tracking);
}
.call-small-name, .call-title {
  margin: 0;
  color: var(--on-call);
  font: var(--title-condensed-weight) var(--title-condensed-size) / var(--title-condensed-line) var(--title-condensed-family);
}
.call-title { margin-block-start: var(--space-2); }
.call-state {
  margin: 0;
  color: var(--on-call-muted);
  font: var(--body-weight) var(--body-size) / var(--body-line) var(--body-family);
  font-variant-numeric: tabular-nums;
}
.call-head.small .call-state { font: var(--callout-weight) var(--callout-size) / var(--callout-line) var(--callout-family); }
.call-state.warn { color: var(--call-warning); }
.call-muted {
  margin: 0;
  max-inline-size: var(--w-call-text);
  color: var(--on-call-muted);
  font: var(--callout-weight) var(--callout-size) / var(--callout-line) var(--callout-family);
}

/* The controls (ml-call__controls): round buttons with their names under them */
.call-controls {
  position: relative;
  display: flex;
  justify-content: center;
  gap: var(--space-4-half);
  padding: 0 var(--space-4) calc(var(--space-6) - var(--space-1));
  flex: none;
}
.call-controls.hidden { visibility: hidden; }
.call-ctl {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1-half);
  padding: 0;
  border: none;
  background: none;
  color: var(--on-call-muted);
  font: var(--footnote-weight) var(--footnote-size) / var(--footnote-line) var(--footnote-family);
}
.call-btn {
  display: grid;
  place-items: center;
  inline-size: var(--call-button);
  block-size: var(--call-button);
  border-radius: var(--radius-pill);
  background: var(--call-control);
  color: var(--on-call);
}
.call-btn.on { background: var(--call-control-active); color: var(--on-call-control-active); }
.call-btn.end { background: var(--call-end); color: var(--on-call-end); }
.call-ctl:hover .call-btn { opacity: var(--opacity-pressed); }
.call-ctl:focus-visible { outline: none; }
.call-ctl:focus-visible .call-btn, .call-wide:focus-visible { outline: var(--ring) solid var(--on-call); outline-offset: var(--ring); }

/* An outcome: a click anywhere is Done (call-ended); the buttons stacked under the text (call-no-answer, call-busy) */
.call-dismiss { position: absolute; inset: 0; z-index: 0; border: none; background: none; cursor: default; }
.call-foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  inline-size: var(--w-call-actions);
  max-inline-size: 100%;
  margin-block-start: var(--space-5);
}
.w-btn.call-wide { background: var(--call-control); color: var(--on-call); }
.w-btn.call-wide.lead { background: var(--call-control-active); color: var(--on-call-control-active); }
.w-btn.call-wide:disabled { background: var(--call-control); color: var(--on-call); opacity: var(--opacity-disabled); }

/* ---- The ringing card (call-incoming, call-incoming-stranger): .w-float below the chat head ---- */
.call-float.three { inline-size: var(--w-call-float-wide); }
.call-float__row { display: flex; align-items: center; gap: var(--space-3); }
.call-float__who { flex: 1 1 auto; min-inline-size: 0; display: flex; flex-direction: column; }
.call-float__tag { display: inline-flex; align-items: center; gap: var(--space-1); }
.call-float__tag .icon { color: var(--mesh); }
.call-float__pills { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.w-btn.call-pill { color: var(--mesh); }
.w-btn.call-pill.danger { color: var(--danger); }
.call-float__foot { display: flex; gap: var(--space-2); }
.call-float__foot .w-btn { flex: 1 1 0; min-block-size: var(--icon-button); padding-inline: var(--space-3); white-space: nowrap; }
.w-btn.call-decline { background: var(--call-end); color: var(--on-call-end); }
.w-btn.call-accept { background: var(--call-accept); color: var(--on-call-accept); }
.w-btn.call-voice-only { color: var(--ink); }
.call-float .w-btn:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: var(--ring); }

/* ---- The call's dialogs (call-primer…, call-reply, call-video-unavailable): .w-scrim and .w-dialog ---- */
.w-dialog .w-btn:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: var(--ring); }
.call-illo { align-self: center; }
.call-bullets { display: flex; flex-direction: column; gap: var(--space-2-half); margin: 0; padding: 0; list-style: none; }
.call-bullets li {
  display: flex;
  gap: var(--space-2-half);
  align-items: flex-start;
  font: var(--callout-weight) var(--callout-size) / var(--callout-line) var(--callout-family);
}
.call-bullets li::before {
  content: "";
  flex: none;
  inline-size: var(--space-1-half);
  block-size: var(--space-1-half);
  margin-block-start: calc(var(--space-1-half) + 1px);
  border-radius: var(--radius-pill);
  background: var(--mesh);
}
.call-group { display: flex; flex-direction: column; border-radius: var(--radius-card); background: var(--surface-sunken); overflow: hidden; }
.call-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-block-size: var(--icon-button);
  padding: 0 var(--space-4);
  border: none;
  border-block-end: var(--stroke-hairline) solid var(--line);
  background: none;
  color: var(--ink);
  text-align: start;
  font: var(--body-weight) var(--body-size) / var(--body-line) var(--body-family);
}
.call-opt:last-child { border-block-end: none; }
.call-opt:hover { background: var(--surface-raised); }
.call-opt:focus-visible { outline: var(--ring) solid var(--focus); outline-offset: calc(-1 * var(--ring)); }
.call-opt .icon, .call-opt.muted { color: var(--ink-muted); }

/* ---- The strip of a call behind the app (call-minimised): over the main pane's top, the pane pushed down ---- */
.w-callbar {
  position: absolute;
  inset-block-start: 0;
  inset-inline: calc(var(--w-rail) + var(--w-pane)) 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-block-size: var(--call-strip);
  padding: 0 var(--space-4);
  border: none;
  background: var(--call-accept);
  color: var(--on-call-accept);
  font: var(--callout-strong-weight) var(--callout-size) / var(--callout-line) var(--callout-family);
  text-align: start;
}
.w-callbar:focus-visible { outline: var(--ring) solid var(--on-call-accept); outline-offset: calc(-2 * var(--ring)); }
.w-callbar__who { flex: 1 1 auto; font-variant-numeric: tabular-nums; }
.w-app:has(> .w-callbar) > .w-main, .w-app:has(> .w-callbar) > .w-side { padding-block-start: var(--call-strip); }

/* ---- A dropped call (call-dropped): the frame's toast ---- */
.call-toast { z-index: 7; }

/* The rings of the mic and calls illustrations (the shared .illo rules draw the rest); still under reduced motion */
@media (prefers-reduced-motion: no-preference) {
  .illo .a-ring { animation: call-illo-ring 1.1s ease-in-out infinite alternate; }
}
@keyframes call-illo-ring { from { opacity: 0.35; } to { opacity: 1; } }
