/* =====================================================================
 * Legal Demo Visualization — Velzyx (industries/legal.html)
 * Audio-synced + IntersectionObserver fallback. Palantir-grade restraint.
 * Color/typography aligned to /styles.css tokens.
 * ===================================================================== */

.lv-section { padding-top: 0; padding-bottom: 0; }
.lv-section .container { max-width: var(--max-width); }

.lv-eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--eyebrow-size);
  letter-spacing: var(--eyebrow-ls);
  text-transform: uppercase;
  color: var(--eyebrow);
  margin-bottom: 14px;
}
.lv-lede {
  max-width: 760px;
  color: var(--text-2);
  margin: 0 0 28px;
}

/* ---------- Audio bar ---------- */
.lv-audio-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  margin-bottom: 28px;
}
.lv-audio-wrap audio {
  flex: 1;
  height: 36px;
  min-width: 0;
}
.lv-audio-caption {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text-3);
  white-space: nowrap;
}
/* Keep the audio control visible even when source is missing.
   Browser shows a disabled player so the user still sees a clear "press play" affordance. */
.lv-audio-wrap.is-missing .lv-audio-caption { color: var(--text-2); }

/* ---------- Hint above viz ---------- */
.lv-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border-left: 2px solid var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 18px;
}
.lv-hint strong { color: var(--text); font-weight: 500; }

/* ---------- Two-panel grid ---------- */
.lv-viz {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  align-items: start;
}
@media (min-width: 920px) {
  .lv-viz { grid-template-columns: 1fr 1fr; }
}

.lv-col {
  background: var(--bg);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 560px;
}
.lv-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.lv-col-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}
.lv-col-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.lv-col-meta::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--text-3);
  border-radius: 50%;
  display: inline-block;
}
.lv-col.is-live .lv-col-meta::before {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(43, 89, 69, 0.5);
  animation: lv-pulse 1.6s ease-out infinite;
}
@keyframes lv-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(43, 89, 69, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(43, 89, 69, 0); }
  100% { box-shadow: 0 0 0 0 rgba(43, 89, 69, 0); }
}

/* ---------- Left: Conversation feed ---------- */
.lv-feed {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: 620px;
  scroll-behavior: smooth;
}
.lv-msg {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 320ms ease, transform 320ms ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 92%;
}
.lv-msg.is-shown {
  opacity: 1;
  transform: translateY(0);
}
.lv-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}
.lv-msg-who {
  color: var(--text);
  font-weight: 500;
}
.lv-msg-body {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.5;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
.lv-msg.is-aria .lv-msg-body {
  background: var(--bg-card);
  border-left: 2px solid var(--accent);
}
.lv-msg.is-caller {
  align-self: flex-end;
}
.lv-msg.is-caller .lv-msg-meta { justify-content: flex-end; }
.lv-msg.is-caller .lv-msg-body {
  background: var(--bg);
  border-right: 2px solid var(--text);
}

/* ---------- Right: Intake form ---------- */
.lv-form {
  padding: 0;
  display: flex;
  flex-direction: column;
}
.lv-form-letterhead {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.lv-form-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.lv-form-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-3);
  text-transform: uppercase;
}
.lv-form-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 4px 8px;
  border: 1px solid var(--line);
  white-space: nowrap;
  transition: color 280ms ease, border-color 280ms ease, background 280ms ease;
}
.lv-form-badge.is-shown {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(43, 89, 69, 0.04);
}

.lv-form-section {
  padding: 14px 22px 6px;
  border-bottom: 1px solid var(--line);
}
.lv-form-section:last-of-type { border-bottom: none; }
.lv-form-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 10px;
}
.lv-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  align-items: baseline;
}
.lv-form-section .lv-row:first-of-type { border-top: none; }
.lv-key {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.lv-val {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  position: relative;
  min-height: 18px;
}
.lv-val::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  width: 80px;
  height: 1px;
  background: var(--line);
  transform: translateY(-50%);
  transition: opacity 200ms ease;
}
.lv-val .lv-val-text {
  display: inline-block;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 280ms ease, transform 280ms ease;
  font-feature-settings: "tnum" 1;
}
.lv-val.is-shown::before { opacity: 0; }
.lv-val.is-shown .lv-val-text {
  opacity: 1;
  transform: translateY(0);
}
.lv-val.is-emphasis.is-shown .lv-val-text {
  color: var(--accent);
  font-weight: 500;
}

/* ---------- Booking confirmation block ---------- */
.lv-booking {
  margin: 0 22px 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 400ms ease, transform 400ms ease, border-color 400ms ease, background 400ms ease;
}
.lv-booking.is-shown {
  opacity: 1;
  transform: translateY(0);
  border-color: var(--accent);
  background: rgba(43, 89, 69, 0.03);
}
.lv-booking-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 0 0 8px;
}
.lv-booking-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  padding: 5px 0;
  align-items: baseline;
  opacity: 0;
  transition: opacity 320ms ease;
}
.lv-booking-row.is-shown { opacity: 1; }
.lv-booking-row .lv-key { font-size: 10px; }
.lv-booking-row .lv-val { font-size: 13.5px; }
.lv-booking-row .lv-val::before { display: none; }
.lv-booking-row .lv-val-text { opacity: 1; transform: none; }

/* ---------- Form footer (stamp) ---------- */
.lv-form-foot {
  margin-top: auto;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-3);
}
.lv-form-foot-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  margin-right: 6px;
}
.lv-form.is-complete .lv-form-foot-dot { background: var(--accent); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .lv-msg, .lv-val .lv-val-text, .lv-booking, .lv-booking-row, .lv-form-badge {
    transition: none !important;
  }
  .lv-col.is-live .lv-col-meta::before { animation: none; }
}

/* ─────────────────────────────────────────────────────────────────────
   Mobile optimization for the legal demo (≤720px)
   - Panels stack vertically (already default via single-column grid)
   - Form panel comes FIRST (it has visible structure even before audio plays)
   - Chat panel drops min-height so empty state isn't a wall of white
   - Field labels tighten so the form fits in narrow viewports
   - Audio bar wraps caption to a second line if needed
   ───────────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .lv-viz {
    gap: 18px;
  }
  .lv-col {
    min-height: 0;
  }
  /* Put the intake form on top — it has visible structure (section titles, field labels)
     even before audio plays, so it sells the demo faster on mobile. */
  .lv-col.lv-form {
    order: 1;
  }
  .lv-col[data-lv-col="feed"] {
    order: 2;
  }
  /* Empty conversation panel — keep it short on mobile until messages start flowing in */
  .lv-feed {
    padding: 14px;
    gap: 10px;
    min-height: 80px;
    max-height: 420px;
  }
  /* Subtle hint when feed is empty (no .lv-msg children yet) */
  .lv-feed:empty::before,
  .lv-feed:has(> .lv-msg:not(.is-shown):first-child:last-child)::before {
    content: 'Conversation begins when you press play.';
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--text-3);
    padding: 4px 2px;
  }
  /* Tighten form rows so 132px label + value fits at 375px width */
  .lv-form-letterhead {
    padding: 14px 16px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .lv-form-section {
    padding: 12px 16px 4px;
  }
  .lv-row {
    grid-template-columns: 96px 1fr;
    gap: 8px;
    padding: 6px 0;
  }
  .lv-key { font-size: 10px; }
  .lv-val { font-size: 13.5px; }
  .lv-val::before { width: 60px; }
  /* Booking confirmation block */
  .lv-booking {
    margin: 0 16px 14px;
    padding: 12px 14px;
  }
  .lv-booking-row {
    grid-template-columns: 90px 1fr;
    gap: 8px;
  }
  /* Audio bar wraps caption on a second line so the play button isn't squeezed */
  .lv-audio-wrap {
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 16px;
  }
  .lv-audio-wrap audio {
    flex: 1 1 100%;
    min-width: 0;
  }
  .lv-audio-caption {
    flex: 1 1 100%;
    white-space: normal;
    line-height: 1.4;
  }
  /* Hint above the viz */
  .lv-hint {
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
  }
}

/* ─────────────────────────────────────────────────────────────────────
   Shared "VZ Demo Player" — mirrors industries/dental.html exactly
   Black bar + white PLAY button + scrubber + time. Same across all
   industry pages so the audio control feels consistent.
   ───────────────────────────────────────────────────────────────────── */
.vz-demo-player {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 22px 24px;
  border: 2px solid var(--text);
  background: #0D0E10;
  color: #EFEFEF;
  margin-bottom: 16px;
  margin-top: 32px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 6px rgba(13, 14, 16, 0.04);
}
.vz-demo-player::before {
  content: "▶ LISTEN";
  position: absolute;
  transform: translate(-24px, -42px);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  padding: 4px 10px;
  background: #0D0E10;
  color: #EFEFEF;
  text-transform: uppercase;
}
.vz-demo-play {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border: none;
  background: #EFEFEF;
  color: #0D0E10;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 180ms, background 180ms;
  letter-spacing: 0.08em;
}
.vz-demo-play:hover { transform: scale(1.04); background: #FFFFFF; }
.vz-demo-play[data-state="play"] .vz-pause,
.vz-demo-play[data-state="pause"] .vz-play { display: none; }
.vz-demo-scrubber {
  flex: 1;
  height: 4px;
  background: rgba(239, 239, 239, 0.2);
  position: relative;
  cursor: pointer;
  min-width: 60px;
  border-radius: 1px;
}
.vz-demo-scrubber-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: #EFEFEF;
  border-radius: 1px;
}
.vz-demo-time {
  font-variant-numeric: tabular-nums;
  min-width: 92px;
  text-align: right;
  color: #EFEFEF;
  font-size: 14px;
}
.vz-demo-source {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 28px;
  margin-top: 0;
  letter-spacing: 0.04em;
}
.vz-demo-source a { color: var(--text-2); border-bottom-color: var(--line); }
audio#legalAudio { display: none; }

@media (max-width: 720px) {
  .vz-demo-player {
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px 18px;
    margin-top: 40px;
  }
  .vz-demo-play {
    width: 56px;
    height: 56px;
    font-size: 12px;
  }
  .vz-demo-scrubber { flex: 1 1 100%; min-width: 0; order: 3; }
  .vz-demo-time { flex: 0 0 auto; font-size: 12px; min-width: 0; }
  .vz-demo-player::before { transform: translate(-18px, -38px); }
}
