/* ═══ EXPERIENCE / LIVE VOICE DEMO ════════════════════════════════════════
   Self-contained styles for the #experience section: a light scenario rail
   paired with a dark, glowing "call console". Everything is namespaced .xp-*
   and reuses the site's design tokens (--accent, --ink, etc.). */

#experience {
  position: relative;
  padding: 120px 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% -10%, rgba(99, 102, 241, 0.10), transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 110%, rgba(20, 184, 166, 0.07), transparent 60%),
    linear-gradient(180deg, #fbfcff 0%, #f3f5ff 100%);
  overflow: hidden;
}
/* faint dotted grid for depth */
#experience .xp-bg {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(99, 102, 241, 0.10) 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 0%, transparent 75%);
          mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 0%, transparent 75%);
  opacity: .6;
  pointer-events: none;
}
#experience .container { position: relative; z-index: 1; }
/* The widget shows/hides controls via the [hidden] attribute (el.hidden = …).
   The .xp-* component rules set `display`, which would otherwise out-rank the
   UA `[hidden]{display:none}` and leave Mute/End/Start visible in the wrong
   state — so make `hidden` authoritative within the demo. */
#experience [hidden] { display: none !important; }

.xp-wrap {
  display: grid;
  /* minmax(0,…) lets the panel column shrink instead of being forced wide by
     the scenario rail's intrinsic min-content width (otherwise the panel's
     centred content gets pushed off-screen on mobile). */
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 26px;
  align-items: stretch;
  max-width: 1020px;
  margin: 0 auto;
}

/* ════════════════════════════ Scenario rail ════════════════════════════ */
.xp-rail { display: flex; flex-direction: column; min-width: 0; }
.xp-rail-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 2px 0 14px 2px;
}
.xp-scenarios { display: flex; flex-direction: column; gap: 10px; }

.xp-scenario {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 13px;
  text-align: left;
  background: rgba(255, 255, 255, 0.65);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: var(--r-md, 14px);
  padding: 14px 16px;
  cursor: pointer;
  overflow: hidden;
  transition: transform .3s var(--ease-out-expo), border-color .25s, box-shadow .3s, background .25s;
  font-family: inherit;
}
/* accent bar that grows in on hover/active */
.xp-scenario::before {
  content: '';
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--accent), #818cf8);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .35s var(--ease-out-expo);
}
.xp-scenario:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.08);
}
.xp-scenario.active {
  border-color: rgba(99, 102, 241, 0.55);
  background: #fff;
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.15);
}
.xp-scenario.active::before,
.xp-scenario:hover::before { transform: scaleY(1); }

.xp-scenario-ic {
  flex: 0 0 auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, rgba(99,102,241,0.12), rgba(129,140,248,0.06));
  color: var(--accent);
  transition: background .25s, color .25s, transform .3s var(--ease-spring);
}
.xp-scenario-ic svg { width: 19px; height: 19px; }
.xp-scenario.active .xp-scenario-ic {
  background: linear-gradient(145deg, var(--accent), #818cf8);
  color: #fff;
  transform: scale(1.04);
}
.xp-scenario-body { display: flex; flex-direction: column; min-width: 0; }
.xp-scenario-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.93rem;
  color: var(--ink);
  line-height: 1.3;
}
.xp-scenario-tag {
  font-size: 0.78rem;
  color: var(--mid);
  margin-top: 4px;
  line-height: 1.5;
}

.xp-rail-foot {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  font-size: 0.74rem;
  color: var(--mid);
}
.xp-rail-foot span { display: inline-flex; align-items: center; gap: 6px; }
.xp-rail-foot svg { width: 14px; height: 14px; color: var(--accent-2); }

/* ════════════════════════════ Call console ════════════════════════════ */
.xp-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 470px;
  padding: 22px 24px 20px;
  border-radius: var(--r-xl, 28px);
  color: #e9eaff;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(129, 140, 248, 0.35), transparent 70%),
    linear-gradient(165deg, #211f4d 0%, #1a1838 55%, #14132b 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 30px 70px rgba(26, 23, 70, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
/* soft moving sheen at the top */
.xp-panel::before {
  content: '';
  position: absolute;
  top: -40%; left: -10%;
  width: 120%; height: 80%;
  background: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.18), transparent 65%);
  pointer-events: none;
}

.xp-panel-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.xp-live-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'DM Mono', monospace;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(233, 234, 255, 0.65);
}
.xp-live-dot span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: xp-blip 2.2s ease-out infinite;
}
@keyframes xp-blip {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

.xp-lang-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 100px;
  padding: 3px;
}
.xp-lang-toggle button {
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(233, 234, 255, 0.6);
  padding: 5px 14px;
  border-radius: 100px;
  transition: background .2s, color .2s;
}
.xp-lang-toggle button.active {
  background: linear-gradient(145deg, var(--accent), #818cf8);
  color: #fff;
  box-shadow: 0 3px 12px rgba(99, 102, 241, 0.4);
}

/* ── Stage: orb + waveform + status ── */
.xp-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0 6px;
}

.xp-orb {
  position: relative;
  width: 116px; height: 116px;
  display: grid; place-items: center;
  margin-bottom: 8px;
  --level: 0;
}
.xp-orb-core {
  position: relative;
  z-index: 2;
  width: 92px; height: 92px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, #a5b4fc, #6366f1 55%, #4f46e5);
  box-shadow:
    0 10px 30px rgba(99, 102, 241, 0.5),
    inset 0 2px 8px rgba(255, 255, 255, 0.35);
  /* scale gently with measured audio level */
  transform: scale(calc(1 + var(--level) * 0.16));
  transition: transform .08s linear, box-shadow .25s;
}
.xp-orb-core svg { width: 36px; height: 36px; color: #fff; }
/* glow that intensifies with level */
.xp-orb-core::after {
  content: '';
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(129, 140, 248, 0.6), transparent 70%);
  opacity: calc(0.25 + var(--level) * 0.75);
  filter: blur(6px);
  z-index: -1;
  transition: opacity .12s linear;
}
/* concentric rings — animate only while live */
.xp-orb-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(129, 140, 248, 0.45);
  opacity: 0;
}
.xp-panel.is-live .xp-orb-ring { animation: xp-ring 2.6s var(--ease-out-expo) infinite; }
.xp-panel.is-live .xp-orb-ring:nth-child(2) { animation-delay: 1.3s; }
@keyframes xp-ring {
  0%   { opacity: .55; transform: scale(0.85); }
  100% { opacity: 0;   transform: scale(1.9); }
}
.xp-panel.is-connecting .xp-orb-core { animation: xp-breathe 1.2s ease-in-out infinite; }
@keyframes xp-breathe { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ── Waveform bars ── */
.xp-wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  margin: 6px 0 2px;
  opacity: 0;
  transition: opacity .3s;
}
.xp-panel.is-live .xp-wave { opacity: 1; }
.xp-wave i {
  display: block;
  width: 4px;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(180deg, #a5b4fc, #6366f1);
  transform: scaleY(0.18);
  transform-origin: center;
  transition: transform .09s ease-out;
}

.xp-status {
  font-size: 0.92rem;
  color: rgba(233, 234, 255, 0.92);
  font-weight: 500;
  text-align: center;
  margin-top: 12px;
  min-height: 22px;
  max-width: 320px;
}
.xp-timer {
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  color: #a5b4fc;
  font-weight: 600;
  margin-top: 6px;
  letter-spacing: 0.04em;
}

/* ── Captions ── */
.xp-captions {
  flex: 1;
  min-height: 0;
  margin: 14px 0 4px;
  max-height: 156px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  -ms-overflow-style: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.18) transparent;
}
.xp-captions::-webkit-scrollbar { width: 5px; }
.xp-captions::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }
.xp-bubble {
  max-width: 86%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.5;
  animation: xp-bubble-in .35s var(--ease-out-expo) both;
}
@keyframes xp-bubble-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.xp-bubble.user {
  align-self: flex-end;
  background: linear-gradient(145deg, var(--accent), #818cf8);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.xp-bubble.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e9eaff;
  border-bottom-left-radius: 4px;
}

/* ── Controls ── */
.xp-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}
.xp-start {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--accent), #818cf8);
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  font-family: inherit;
  padding: 13px 28px;
  border-radius: 100px;
  box-shadow: 0 6px 22px rgba(99, 102, 241, 0.45);
  transition: transform .25s var(--ease-out-expo), box-shadow .25s;
}
.xp-start:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(99, 102, 241, 0.55); }
.xp-start svg { width: 18px; height: 18px; }

.xp-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: #e9eaff;
  padding: 11px 20px;
  border-radius: 100px;
  transition: background .2s, border-color .2s, transform .2s;
}
.xp-icon-btn svg { width: 17px; height: 17px; }
.xp-icon-btn:hover { background: rgba(255, 255, 255, 0.13); transform: translateY(-1px); }
.xp-icon-btn.muted { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.5); color: #fcd34d; }
.xp-end { background: rgba(239, 68, 68, 0.16); border-color: rgba(239, 68, 68, 0.45); color: #fca5a5; }
.xp-end:hover { background: rgba(239, 68, 68, 0.28); }

.xp-note {
  font-size: 0.7rem;
  color: rgba(233, 234, 255, 0.45);
  margin-top: 14px;
  text-align: center;
}

/* ── End / busy / error overlay ── */
.xp-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: rgba(20, 19, 43, 0.82);
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
  border-radius: var(--r-xl, 28px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 36px;
  gap: 10px;
}
.xp-overlay.show { display: flex; animation: xp-fade .3s ease both; }
@keyframes xp-fade { from { opacity: 0; } to { opacity: 1; } }
.xp-overlay-ic {
  width: 62px; height: 62px;
  display: grid; place-items: center;
  font-size: 1.9rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 4px;
}
.xp-overlay h4 { font-size: 1.2rem; color: #fff; margin-bottom: 2px; }
.xp-overlay p { font-size: 0.9rem; color: rgba(233, 234, 255, 0.7); max-width: 340px; line-height: 1.65; }
.xp-overlay .btn-primary {
  width: auto;
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(145deg, var(--accent), #818cf8);
  color: #fff;
  padding: 12px 26px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 6px 22px rgba(99, 102, 241, 0.45);
}
.xp-overlay .xp-icon-btn { margin-top: 4px; }

/* ════════════════════════════ Responsive ════════════════════════════ */
@media (max-width: 880px) {
  /* Stack rail above the console. minmax(0,…) keeps the single track from being
     stretched to the scenario row's intrinsic width. */
  .xp-wrap { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .xp-rail-label { display: none; }
  /* Scenario picker becomes a horizontal, snap-scrolling carousel. */
  .xp-scenarios {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    gap: 10px;
    padding: 2px 16px 10px 2px;   /* trailing pad so the last card clears the edge */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .xp-scenarios::-webkit-scrollbar { display: none; }
  .xp-scenario {
    flex: 0 0 auto;
    min-width: 215px;
    max-width: 80vw;
    scroll-snap-align: start;
  }
  .xp-scenario-tag { display: none; }
  .xp-rail-foot { display: none; }
}
@media (max-width: 600px) {
  #experience { padding: 68px 0; }
  .xp-panel {
    min-height: 0;            /* let the console size to its content */
    padding: 18px 16px 16px;
    border-radius: var(--r-lg, 20px);
  }
  .xp-overlay { border-radius: var(--r-lg, 20px); padding: 28px 22px; }
  /* Header + toggle wrap cleanly on narrow screens. */
  .xp-panel-top { flex-wrap: wrap; gap: 12px; }
  /* Bigger tap targets for the language switch. */
  .xp-lang-toggle button { padding: 8px 16px; font-size: 0.82rem; }
  .xp-orb { width: 104px; height: 104px; }
  .xp-orb-core { width: 84px; height: 84px; }
  .xp-orb-core svg { width: 32px; height: 32px; }
  .xp-status { max-width: 100%; }
  .xp-captions { max-height: 200px; }   /* roomier transcript on tall phones */
  .xp-bubble { max-width: 90%; }
  /* Full-width primary action — the easiest thing to thumb. */
  .xp-controls { gap: 10px; }
  .xp-start { width: 100%; justify-content: center; padding: 14px 24px; }
  /* In-call: mute + end split the row as two equal, comfortable targets. */
  .xp-controls .xp-icon-btn { flex: 1 1 0; justify-content: center; min-height: 46px; }
}
@media (max-width: 380px) {
  .xp-scenario { min-width: 200px; }
  .xp-panel-top { gap: 10px; }
  .xp-live-dot { font-size: 0.6rem; }
  .xp-lang-toggle button { padding: 7px 13px; }
  #experience .section-sub { font-size: 0.95rem; }
}
@media (prefers-reduced-motion: reduce) {
  .xp-orb-ring, .xp-live-dot span, .xp-panel.is-connecting .xp-orb-core { animation: none !important; }
  .xp-orb-core, .xp-wave i { transition: none !important; }
}
