/* 10, use cases (site/sections/10-use-cases.html). Linked by
   scripts/build-home.mjs. One .vs-card frame holds a horizontally
   scrollable tablist (each tab carries its own thin progress fill,
   css/js/acts/10-use-cases.js drives the auto-advance through it) and a
   stage: the active case's copy beside its demo. Demo internals
   (.vs-ucd*) are shared by every case; js/usecase-demos.js builds them. */

.vs-uc { border-top: 1px solid var(--vs-line); }

.vs-uc__head { max-width: 52ch; margin-bottom: clamp(1.25rem, 2.5vw, 2rem); }
.vs-uc__title {
  margin: 0;
  font-family: var(--sc-font-display); font-weight: var(--vs-display-weight);
  font-size: var(--vs-h2); line-height: var(--sc-leading-tight);
  letter-spacing: var(--vs-display-track); text-wrap: balance;
}
.vs-uc__lede {
  margin: var(--sc-3) 0 0; max-width: 46ch;
  font-size: var(--sc-t-base); line-height: 1.5; color: var(--sc-ink-soft);
  text-wrap: pretty;
}

/* ---------------------------------------------------------------- frame -- */
.vs-uc__frame { --vs-uc-advance: 7s; }

.vs-uc__tablist {
  display: flex; gap: var(--sc-1);
  padding: var(--sc-2) var(--sc-2) 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--vs-line);
}
.vs-uc__tablist::-webkit-scrollbar { display: none; }

.vs-uc__tab {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem;
  min-width: 8rem;
  padding: var(--sc-3) var(--sc-3);
  background: none; border: 0; border-radius: var(--sc-r-sm) var(--sc-r-sm) 0 0;
  color: var(--sc-ink-soft);
  cursor: pointer;
  transition: color 160ms var(--vs-ease-card, ease);
}
.vs-uc__tab-label {
  font-family: var(--sc-font-display); font-weight: var(--vs-display-weight);
  font-size: var(--sc-t-sm); letter-spacing: -0.005em; white-space: nowrap;
}
.vs-uc__tab[aria-selected="true"] { color: var(--sc-ink); }
.vs-uc__tab:focus-visible { outline: 2px solid var(--sc-accent); outline-offset: -2px; }

.vs-uc__tab-track {
  width: 100%; height: 2px;
  background: var(--vs-line-strong);
  border-radius: 999px;
  overflow: hidden;
}
.vs-uc__tab-fill {
  display: block; width: 100%; height: 100%;
  background: var(--sc-accent);
  transform-origin: left; transform: scaleX(0);
}
.vs-uc__tab.is-active .vs-uc__tab-fill { animation: vs-uc-fill var(--vs-uc-advance) linear forwards; }
.vs-uc__frame.is-held .vs-uc__tab-fill { animation-play-state: paused; }
@keyframes vs-uc-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (hover: hover) and (pointer: fine) {
  .vs-uc__tab:hover { color: var(--sc-ink); }
}

/* ---------------------------------------------------------------- stage -- */
.vs-uc__case {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  align-items: center;
  gap: clamp(1.5rem, 3vw, 3rem);
  padding: clamp(1.25rem, 2.4vw, 2rem);
}
/* A class selector of equal specificity to [hidden] beats the UA stylesheet
   on source order alone, so the inactive panels' own display: grid would
   otherwise win over the browser's default [hidden] { display: none }. */
.vs-uc__case[hidden] { display: none; }

.vs-uc__copy { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sc-4); }
/* The case's one line is the column's statement, set in the display face. */
.vs-uc__text {
  margin: 0; max-width: 22ch;
  font-family: var(--sc-font-display); font-weight: var(--vs-display-weight);
  font-size: clamp(1.35rem, 1rem + 1.1vw, 1.9rem); line-height: 1.18;
  letter-spacing: -0.02em; color: var(--sc-ink);
  text-wrap: balance;
}
.vs-uc__see {
  color: var(--vs-accent-text, var(--sc-ink)); font-weight: 600;
  font-size: var(--sc-t-sm);
  text-decoration-thickness: 1px; text-underline-offset: 0.3em;
}
.vs-uc__see:hover { color: var(--sc-ink); }
.vs-uc__see:focus-visible { outline: 2px solid var(--sc-accent); outline-offset: 3px; border-radius: 2px; }

.vs-uc__demo {
  position: relative;
  min-height: clamp(240px, 22vw, 290px);
  background: var(--sc-canvas);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -18px 30px -30px rgba(22, 23, 21, 0.35);
  border: 1px solid var(--vs-line);
  border-radius: var(--vs-card-r, 10px);
  overflow: hidden;
}

/* ============================================================ demo base = */
.vs-ucd {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: var(--sc-3);
  padding: clamp(1rem, 2.2vw, 1.375rem);
  font-family: var(--sc-font-text); font-size: var(--sc-t-sm); color: var(--sc-ink);
}
.vs-ucd__top { display: flex; align-items: center; gap: var(--sc-2); flex: none; }
.vs-ucd__status {
  font-family: var(--sc-font-display); font-weight: var(--vs-display-weight);
  font-size: var(--sc-t-sm); letter-spacing: -0.01em;
}
.vs-ucd__tag {
  margin-inline-start: auto;
  padding: 0.2em 0.6em;
  font-family: var(--vs-mono); font-size: var(--sc-t-xs); letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--sc-ink-soft);
  border: 1px dashed var(--vs-line-strong); border-radius: 999px;
}

/* Shared enter transition for items a demo appends over time. */
.vs-ucd-in { opacity: 0; translate: 0 6px; transition: opacity 260ms var(--sc-ease-out), translate 260ms var(--sc-ease-out); }
.vs-ucd-in.is-in { opacity: 1; translate: 0 0; }

/* Continuous loops (wave, ping, typing dots) freeze while the demo is held. */
.vs-uc__demo.is-frozen .vs-ucd__wave span,
.vs-uc__demo.is-frozen .vs-ucd__dot.is-ringing::after,
.vs-uc__demo.is-frozen .vs-ucd__bubble--typing span { animation-play-state: paused; }

/* ------------------------------------------------------------- 1 voice -- */
.vs-ucd__dot { position: relative; flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--sc-ink-soft); }
.vs-ucd__dot.is-ringing { background: var(--sc-accent); }
.vs-ucd__dot.is-ringing::after {
  content: ""; position: absolute; inset: -5px; border-radius: 50%;
  border: 1px solid var(--sc-accent);
  animation: vs-ucd-ping 1.3s var(--sc-ease-out) infinite;
}
.vs-ucd__dot.is-live { background: var(--vs-ok); }
@keyframes vs-ucd-ping { from { transform: scale(0.6); opacity: 0.9; } to { transform: scale(1.9); opacity: 0; } }

.vs-ucd__wave { display: flex; align-items: flex-end; gap: 3px; height: 1.6rem; flex: none; }
.vs-ucd__wave span { width: 3px; height: 100%; border-radius: 2px; background: var(--vs-line-strong); transform: scaleY(0.22); transform-origin: bottom; }
.vs-ucd__wave.is-live span {
  background: var(--sc-accent);
  animation: vs-ucd-wave 1.1s ease-in-out infinite;
  animation-delay: calc(var(--i) * 90ms);
}
@keyframes vs-ucd-wave { 0%, 100% { transform: scaleY(0.22); } 50% { transform: scaleY(1); } }

.vs-ucd__lines { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 0.4rem; overflow: hidden; }
.vs-ucd__line { display: flex; gap: 0.4em; line-height: 1.4; }
.vs-ucd__line-who { flex: none; font-weight: 600; color: var(--sc-ink-soft); }
.vs-ucd__line-who:empty { display: none; }
.vs-ucd__line--result {
  margin-top: 0.15rem; padding: 0.4em 0.65em;
  border-radius: var(--sc-r-sm);
  background: color-mix(in srgb, var(--vs-ok) 14%, transparent);
  color: var(--vs-ok); font-weight: 600;
}

/* ----------------------------------------------------------- 2 support -- */
.vs-ucd__chat { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 0.45rem; overflow: hidden; }
.vs-ucd__bubble { max-width: 84%; padding: 0.45em 0.7em; border-radius: 10px; line-height: 1.4; }
.vs-ucd__bubble--user { align-self: flex-end; background: var(--sc-accent); color: var(--sc-accent-ink); border-bottom-right-radius: 3px; }
.vs-ucd__bubble--bot { align-self: flex-start; background: var(--sc-surface); border: 1px solid var(--vs-line); border-bottom-left-radius: 3px; }
.vs-ucd__bubble--typing { display: flex; gap: 0.3em; padding: 0.6em 0.75em; }
.vs-ucd__bubble--typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--sc-ink-soft); animation: vs-ucd-typing 1s ease-in-out infinite; }
.vs-ucd__bubble--typing span:nth-child(2) { animation-delay: 0.15s; }
.vs-ucd__bubble--typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes vs-ucd-typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-3px); opacity: 1; } }
.vs-ucd__handoff { margin: 0; padding-top: 0.55rem; border-top: 1px dashed var(--vs-line-strong); color: var(--sc-ink-soft); flex: none; }

/* ---------------------------------------------------------- 3 workflow -- */
.vs-ucd__chain { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.vs-ucd__node {
  position: relative; display: flex; align-items: center;
  padding: 0.5rem 0; padding-inline-start: 1.9rem;
  opacity: 0.45;
  transition: opacity 240ms var(--sc-ease-out);
}
.vs-ucd__node.is-active, .vs-ucd__node.is-done { opacity: 1; }
.vs-ucd__node:not(:last-child)::before {
  content: ""; position: absolute; left: 0.42rem; top: 1.65rem; bottom: -0.15rem; width: 1px;
  background: var(--vs-line-strong);
}
.vs-ucd__nodeicon {
  position: absolute; left: 0; flex: none;
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  border: 1.5px solid var(--vs-line-strong); background: var(--sc-surface);
  transition: background-color 200ms var(--sc-ease-out), border-color 200ms var(--sc-ease-out), transform 200ms var(--sc-ease-out);
}
.vs-ucd__node.is-active .vs-ucd__nodeicon { border-color: var(--sc-accent); transform: scale(1.15); }
.vs-ucd__node.is-done .vs-ucd__nodeicon { background: var(--vs-ok); border-color: var(--vs-ok); transform: scale(1); }
.vs-ucd__nodetext { line-height: 1.35; }

/* --------------------------------------------------------- 4 lead gen -- */
.vs-ucd__leads { list-style: none; margin: 0; padding: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 0.75rem; }
.vs-ucd__lead { display: grid; grid-template-columns: minmax(0, 1fr) 4rem auto; align-items: center; gap: 0.6rem; }
.vs-ucd__leadname { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vs-ucd__leadtrack { height: 4px; border-radius: 999px; background: var(--vs-line-strong); overflow: hidden; }
.vs-ucd__leadbar { display: block; height: 100%; width: 100%; background: var(--sc-accent); transform-origin: left; transform: scaleX(0); transition: transform 700ms var(--sc-ease-out), background-color 240ms var(--sc-ease-out); }
.vs-ucd__leadstate { font-family: var(--vs-mono); color: var(--sc-ink-soft); text-align: right; white-space: nowrap; transition: color 200ms var(--sc-ease-out); }
.vs-ucd__lead.is-booked .vs-ucd__leadstate { color: var(--vs-ok); font-weight: 600; }
.vs-ucd__lead.is-booked .vs-ucd__leadbar { background: var(--vs-ok); }

/* -------------------------------------------------------------- 5 crm -- */
.vs-ucd__fields { margin: 0; flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 0.6rem; }
.vs-ucd__field {
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem;
  padding-bottom: 0.5rem; border-bottom: 1px dashed var(--vs-line);
  opacity: 0.5; transition: opacity 240ms var(--sc-ease-out);
}
.vs-ucd__field.is-filled { opacity: 1; }
.vs-ucd__fieldkey { margin: 0; font-family: var(--vs-mono); font-size: var(--sc-t-xs); letter-spacing: 0.04em; text-transform: uppercase; color: var(--sc-ink-soft); }
.vs-ucd__fieldval { margin: 0; font-weight: 600; min-height: 1.1em; }

/* -------------------------------------------------------------- phones -- */
@media (max-width: 860px) {
  .vs-uc__case { grid-template-columns: minmax(0, 1fr); }
  .vs-uc__demo { min-height: 240px; }
}
@media (max-width: 480px) {
  .vs-uc__tab { min-width: 7rem; padding: var(--sc-2) var(--sc-2); }
}

/* ------------------------------------------------------- reduced motion -- */
@media (prefers-reduced-motion: reduce) {
  .vs-uc__tab-track { display: none; }
  .vs-uc__tab-fill { animation: none !important; }
  .vs-uc__tab { transition: none; }
  .vs-ucd-in { opacity: 1; translate: none; transition: none; }
  .vs-ucd__wave span,
  .vs-ucd__dot.is-ringing::after,
  .vs-ucd__bubble--typing span { animation: none !important; }
  .vs-ucd__leadbar,
  .vs-ucd__nodeicon,
  .vs-ucd__node,
  .vs-ucd__field { transition: none; }
}
