/* Hallmark · component: call demo, face to face (owner's pick A, 24 Nov 2026) · genre: modern-minimal · theme: Summitway design.md (locked system) · states: 8 · contrast: pass · v2.0.0 */
/* Hallmark · pre-emit critique: P4 H5 E4 S5 R4 · weakest: P, it argues by showing one real call rather than claiming anything; the material is the recording and its own word timings */
/* Hallmark · answered F4: the error and ended fills are states of the one play button, not extra primary recipes */

:root {
  --cd-caller: var(--color-copper);
  --cd-ai: var(--color-accent);
  --cd-face: clamp(104px, 13vw, 176px);
}

.call-demo { margin-top: var(--space-lg); }
.call-demo [hidden] { display: none !important; }

.cd-stage {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.3fr) minmax(0, 1fr);
  align-items: center; gap: var(--space-lg);
  padding: var(--space-xl) var(--space-lg); background: var(--color-paper-2); border-radius: var(--radius-card);
}

.cd-person { margin: 0; display: grid; justify-items: center; gap: var(--space-sm); text-align: center; min-width: 0; }
.cd-face { position: relative; width: var(--cd-face); aspect-ratio: 1; border-radius: 50%; }
.cd-face img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; transition: opacity var(--dur-long) var(--ease-out), transform var(--dur-long) var(--ease-out); }
.cd-face::before {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 3px solid var(--cd-ring, var(--color-rule));
  opacity: 0; transform: scale(calc(1 + var(--cd-level, 0) * 0.16));
  transition: opacity var(--dur-short) var(--ease-out);
}
.cd-caller { --cd-ring: var(--cd-caller); }
.cd-ai { --cd-ring: var(--cd-ai); }
.cd-who { font-weight: 600; line-height: 1.25; }
.cd-role { display: block; font-size: var(--text-sm); font-weight: 400; color: var(--color-muted); }
.cd-ai-tag { display: inline-block; vertical-align: 0.1em; margin-left: var(--space-2xs); padding: 0 var(--space-xs); border-radius: var(--radius-pill); background: var(--cd-ai); color: var(--color-accent-ink); font-size: var(--text-xs); font-weight: 600; line-height: 1.6; }

.call-demo[data-speaking="caller"] .cd-caller .cd-face::before,
.call-demo[data-speaking="ai"] .cd-ai .cd-face::before { opacity: 1; }
.call-demo[data-speaking="caller"] .cd-ai .cd-face img,
.call-demo[data-speaking="ai"] .cd-caller .cd-face img { opacity: 0.55; transform: scale(0.94); }

.cd-middle { display: grid; justify-items: center; gap: var(--space-sm); text-align: center; min-width: 0; }
.cd-speaker { font-size: var(--text-sm); font-weight: 600; min-height: 1.4em; color: var(--color-muted); }
.cd-speaker[data-who="caller"] { color: var(--cd-caller); }
.cd-speaker[data-who="ai"] { color: var(--cd-ai); }
.cd-caption {
  margin: 0; max-width: 28ch; min-height: 3.9em;
  font: 400 clamp(1.25rem, 1.1vw + 0.95rem, 1.85rem)/1.28 var(--font-display);
  color: var(--color-ink); overflow-wrap: break-word;
}
.cd-ready .cd-caption .cd-w:not(.is-said) { opacity: 0.32; }
.cd-w { transition: opacity var(--dur-micro) linear; }
.cd-wave { display: flex; align-items: center; gap: var(--space-2xs); height: 44px; }
.cd-wave i { width: 4px; height: 100%; border-radius: 2px; background: var(--color-rule); transform: scaleY(var(--h, 0.08)); transition: background-color var(--dur-short) var(--ease-out); }
.call-demo[data-speaking="caller"] .cd-wave i { background: var(--cd-caller); }
.call-demo[data-speaking="ai"] .cd-wave i { background: var(--cd-ai); }

/* Without scripting the browser's own player shows; with it, ours replaces it. */
.cd-native { display: block; width: 100%; margin-top: var(--space-lg); }
.cd-ready .cd-native { display: none; }
.cd-player { display: none; align-items: center; gap: var(--space-md); margin-top: var(--space-lg); }
.cd-ready .cd-player { display: flex; }

.cd-play {
  flex: none; min-height: 48px; padding: 0 var(--space-lg) 0 var(--space-md);
  display: inline-flex; align-items: center; gap: var(--space-xs);
  border: 0; border-radius: var(--radius-pill);
  background: var(--color-accent); color: var(--color-accent-ink);
  font: 600 var(--text-md)/1 var(--font-body); cursor: pointer;
  transition: background-color var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.cd-play svg { width: 22px; height: 22px; fill: currentColor; }
.cd-play .cd-i-pause, .cd-play .cd-i-wait { display: none; }
.cd-play[data-state="playing"] .cd-i-play { display: none; }
.cd-play[data-state="playing"] .cd-i-pause { display: block; }
.cd-play[data-state="loading"] .cd-i-play { display: none; }
.cd-play[data-state="loading"] .cd-i-wait { display: block; animation: cd-spin 900ms linear infinite; }
.cd-play:hover, .cd-play.is-hover { background: var(--color-accent-hover); }
.cd-play:focus-visible, .cd-play.is-focus { outline: 3px solid var(--color-focus); outline-offset: 3px; transition: none; }
.cd-play:active, .cd-play.is-active { transform: translateY(1px); }
.cd-play:disabled, .cd-play.is-disabled { background: var(--color-paper-3); color: var(--color-muted); cursor: not-allowed; }
.cd-play[data-state="error"] { background: var(--color-error); }
.cd-play[data-state="ended"] { background: var(--color-ink); }
@keyframes cd-spin { to { transform: rotate(1turn); } }

.cd-seek { flex: 1; min-width: 0; height: 44px; margin: 0; accent-color: var(--color-accent); cursor: pointer; background: transparent; }
.cd-seek:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; }
.cd-time { flex: none; min-width: 6.5em; text-align: right; font-size: var(--text-sm); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.cd-honest { font-size: var(--text-sm); color: var(--color-muted); margin: var(--space-md) 0 0; max-width: 66ch; }

@media (max-width: 760px) {
  :root { --cd-face: 96px; }
  .cd-stage { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding: var(--space-lg) var(--space-md); row-gap: var(--space-lg); }
  .cd-middle { grid-column: 1 / -1; grid-row: 2; }
  .cd-player { gap: var(--space-sm); }
  .cd-time { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .cd-face::before { transform: none; }
  .cd-face img, .cd-w, .cd-wave i { transition: none; }
  .cd-wave { display: none; }
  .cd-play[data-state="loading"] .cd-i-wait { animation: none; }
}
