/* ============== DEMO MODAL (fullscreen) ============== */
.demo-modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: none;
  font-family: var(--body);
}
.demo-modal.open { display: block; }
.demo-modal[aria-hidden="false"] { display: block; }

.demo-backdrop {
  position: absolute; inset: 0;
  background: rgba(5, 12, 24, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: demoFade 0.25s ease;
}
@keyframes demoFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.demo-container {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, #061525 0%, #0a1929 100%);
  color: var(--offwhite);
  animation: demoPop 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  display: flex; flex-direction: column;
}
@keyframes demoPop {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}

.demo-close {
  position: absolute; top: 18px; right: 18px;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: rgba(11,29,51,0.7);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 50%;
  color: rgba(240,253,250,0.85);
  font-size: 22px; line-height: 1;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}
.demo-close:hover {
  background: rgba(11,29,51,0.95);
  color: #fff;
  border-color: rgba(255,255,255,0.25);
  transform: scale(1.05);
}

/* ===== Permission screen ===== */
.demo-permission {
  flex: 1;
  display: grid; place-items: center;
  padding: 40px 24px;
}
.demo-permission-inner {
  text-align: center;
  max-width: 460px;
}
.demo-brand {
  display: block;
  height: 80px;
  width: auto;
  margin: 0 auto 32px;
  filter: drop-shadow(0 6px 20px rgba(8,145,178,0.4));
}
.demo-camera-icon {
  width: 84px; height: 84px;
  margin: 0 auto 28px;
  border-radius: 24px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--teal) 0%, var(--mint) 100%);
  box-shadow: 0 14px 40px -10px rgba(6,214,160,0.45), 0 0 0 1px rgba(255,255,255,0.08);
  animation: cameraPulse 2.6s ease-in-out infinite;
}
.demo-camera-icon svg { color: #fff; }
@keyframes cameraPulse {
  0%, 100% { box-shadow: 0 14px 40px -10px rgba(6,214,160,0.45), 0 0 0 1px rgba(255,255,255,0.08), 0 0 0 0 rgba(6,214,160,0.4); }
  50%      { box-shadow: 0 14px 40px -10px rgba(6,214,160,0.6),  0 0 0 1px rgba(255,255,255,0.08), 0 0 0 22px rgba(6,214,160,0); }
}
.demo-permission h3 {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #fff;
  margin-bottom: 14px;
}
.demo-permission p {
  font-size: 15.5px;
  color: rgba(240,253,250,0.65);
  line-height: 1.55;
  margin-bottom: 30px;
}
.demo-permission .btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 30px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 15px;
  background: var(--teal); color: #fff;
  transition: all 0.2s;
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 8px 24px -8px rgba(8,145,178,0.5);
}
.demo-permission .btn:hover {
  transform: translateY(-2px);
  background: #0AA0C4;
  box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset, 0 14px 30px -10px rgba(8,145,178,0.65);
}
.demo-note {
  margin-top: 22px !important;
  font-size: 12.5px !important;
  font-family: var(--mono);
  color: rgba(240,253,250,0.45) !important;
  letter-spacing: 0.04em;
}
.demo-permission-error {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: 10px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  font-size: 13px;
  display: none;
}
.demo-permission-error.show { display: block; }

/* ===== Running demo (fullscreen video call) ===== */
.demo-running {
  position: absolute; inset: 0;
  display: none;
}
.demo-running.active { display: block; }

/* Video fills the entire screen */
.demo-video {
  position: absolute; inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(8,145,178,0.22) 0%, transparent 60%),
    linear-gradient(180deg, #0a1929 0%, #061525 100%);
}
.demo-video video {
  width: 100%; height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* mirror like a webcam */
  display: block;
}
.demo-video.no-camera video { display: none; }
.demo-video.no-camera::after {
  content: "Camera unavailable — running in UI demo mode";
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--mono); font-size: 13px;
  color: rgba(240,253,250,0.6);
  letter-spacing: 0.05em;
  padding: 10px 18px;
  background: rgba(11,29,51,0.6);
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
}

/* Top gradient for header readability */
.demo-running::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 110px;
  background: linear-gradient(180deg, rgba(5,12,24,0.7) 0%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}
/* Bottom gradient for metrics readability */
.demo-running::after {
  content: "";
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 180px;
  background: linear-gradient(0deg, rgba(5,12,24,0.75) 0%, transparent 100%);
  z-index: 2;
  pointer-events: none;
}

/* Header overlay */
.demo-head {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px 28px;
  font-family: var(--mono); font-size: 11.5px;
  color: rgba(240,253,250,0.7);
  letter-spacing: 0.05em; text-transform: uppercase;
  z-index: 3;
}
.demo-head > div { display: flex; align-items: center; gap: 10px; }
.demo-head .if-dots { display: flex; gap: 6px; }
.demo-head .if-dots span { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.18); }
.demo-head .if-dots span:nth-child(1) { background: #ef4444; box-shadow: 0 0 8px rgba(239,68,68,0.4); }
.demo-head .if-dots span:nth-child(2) { background: #f59e0b; }
.demo-head .if-dots span:nth-child(3) { background: #10b981; }
.demo-head .if-rec {
  color: var(--mint);
  background: rgba(11,29,51,0.6);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(6,214,160,0.25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.demo-head .if-rec::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #ef4444;
  margin-right: 8px;
  display: inline-block;
  animation: pulse 1.4s ease-in-out infinite;
}

/* Behavioral overlay tag */
.demo-overlay {
  position: absolute; top: 22px; left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px; border-radius: 8px;
  background: rgba(11,29,51,0.65); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-family: var(--mono); font-size: 11px; color: rgba(240,253,250,0.9);
  letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid rgba(255,255,255,0.08);
  z-index: 3;
}

/* Face markers — bigger and positioned over center where face is */
.demo-marker {
  position: absolute;
  border: 1.5px dashed rgba(6,214,160,0.55);
  border-radius: 10px;
  z-index: 3;
  pointer-events: none;
}
.demo-marker .lbl {
  position: absolute; top: 50%;
  transform: translateY(-50%); margin-left: 10px; left: 100%;
  font-family: var(--mono); font-size: 10.5px; color: var(--mint);
  background: rgba(11,29,51,0.85); padding: 4px 8px; border-radius: 5px;
  white-space: nowrap; letter-spacing: 0.05em;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.demo-marker.m-eyes-d { width: 16%; aspect-ratio: 4/1; top: 32%; left: 42%; }
.demo-marker.m-posture-d {
  width: 22%; aspect-ratio: 1/1.3; top: 36%; left: 39%;
  border-color: rgba(8,145,178,0.55);
}
.demo-marker.m-posture-d .lbl {
  color: var(--teal-2);
  left: auto; right: 100%;
  margin-left: 0; margin-right: 10px;
}

/* Wave at bottom-left of screen */
.demo-wave {
  position: absolute;
  left: 28px;
  bottom: 28px;
  width: 220px;
  height: 40px;
  display: flex; gap: 3px; align-items: flex-end;
  padding: 0 6px;
  z-index: 3;
  background: rgba(11,29,51,0.55);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.demo-wave span {
  flex: 1; background: linear-gradient(180deg, var(--mint) 0%, var(--teal) 100%);
  border-radius: 2px; opacity: 0.85;
  animation: wv 1.5s ease-in-out infinite;
}

/* Metrics overlay (top-right, below close button) */
.demo-metrics {
  position: absolute;
  top: 80px;
  right: 28px;
  display: flex; flex-direction: column; gap: 10px;
  width: 220px;
  z-index: 3;
}
.demo-metric {
  background: rgba(11,29,51,0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 14px;
}
.demo-metric .lbl {
  font-family: var(--mono); font-size: 10px;
  color: rgba(240,253,250,0.55);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.demo-metric .val {
  font-family: var(--display); font-size: 22px; color: #fff;
  margin-top: 4px; font-weight: 500;
}
.demo-metric .val em { font-style: normal; color: var(--mint); }
.demo-metric .bar {
  margin-top: 8px; height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px; overflow: hidden;
}
.demo-metric .bar i {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--teal) 0%, var(--mint) 100%);
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ===== Chat widget (bottom-right floating) ===== */
.demo-chat {
  position: absolute;
  right: 28px;
  bottom: 28px;
  width: 360px;
  max-height: 60vh;
  background: rgba(11, 29, 51, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 18px;
  box-shadow: 0 24px 60px -12px rgba(0,0,0,0.7), 0 0 0 1px rgba(6,214,160,0.08);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 4;
  animation: chatSlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}
@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.demo-chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
.demo-chat-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--teal) 0%, var(--mint) 100%);
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 600; font-size: 12.5px;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.08);
  position: relative;
  flex-shrink: 0;
}
.demo-chat-avatar::after {
  content: "";
  position: absolute; right: -2px; bottom: -2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--mint);
  border: 2px solid var(--navy-2);
}
.demo-chat-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.demo-chat-meta strong {
  font-family: var(--display); font-size: 14px; font-weight: 600; color: #fff;
}
.demo-chat-meta span {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--mint); letter-spacing: 0.04em;
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 3px;
}
.demo-chat-meta span::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px rgba(6,214,160,0.2);
}

.demo-chat-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}
.demo-chat-body::-webkit-scrollbar { width: 5px; }
.demo-chat-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 4px; }
.demo-chat-body::-webkit-scrollbar-track { background: transparent; }

.msg {
  display: flex; max-width: 88%;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg .bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  word-wrap: break-word;
}
.msg-ai { align-self: flex-start; }
.msg-ai .bubble {
  background: rgba(255,255,255,0.07);
  color: rgba(240,253,250,0.95);
  border: 1px solid rgba(255,255,255,0.06);
  border-bottom-left-radius: 5px;
}
.msg-user { align-self: flex-end; }
.msg-user .bubble {
  background: linear-gradient(135deg, var(--teal) 0%, #0AA0C4 100%);
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 14px -4px rgba(8,145,178,0.45);
}

.msg-typing .bubble {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 13px 14px;
}
.msg-typing .bubble i {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(240,253,250,0.55);
  animation: typing 1.2s ease-in-out infinite;
}
.msg-typing .bubble i:nth-child(2) { animation-delay: 0.15s; }
.msg-typing .bubble i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50%      { transform: translateY(-4px); opacity: 1; }
}

.demo-chat-input {
  display: flex; gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
.demo-chat-input input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.demo-chat-input input::placeholder { color: rgba(240,253,250,0.4); }
.demo-chat-input input:focus {
  border-color: rgba(6,214,160,0.5);
  background: rgba(255,255,255,0.09);
}
.demo-chat-input button {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--mint) 100%);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.demo-chat-input button:hover { transform: translateY(-1px); }
.demo-chat-input button:active { transform: translateY(0); }
.demo-chat-input button svg { width: 16px; height: 16px; }

/* Mobile */
@media (max-width: 760px) {
  .demo-close { top: 14px; right: 14px; width: 36px; height: 36px; }
  .demo-head { padding: 16px 18px; font-size: 10.5px; }
  .demo-overlay { font-size: 10px; padding: 6px 10px; top: 64px; }
  .demo-metrics {
    flex-direction: row;
    top: auto; bottom: 12px;
    right: 12px; left: 12px;
    width: auto;
    z-index: 3;
  }
  .demo-metric { flex: 1; padding: 8px 10px; }
  .demo-metric .val { font-size: 16px; }
  .demo-metric .lbl { font-size: 9px; }
  .demo-wave { display: none; }
  .demo-chat {
    right: 12px; bottom: 120px; left: 12px;
    width: auto;
    max-height: 45vh;
  }
  .demo-marker .lbl { font-size: 9px; padding: 2px 5px; }
  .demo-marker.m-eyes-d { width: 28%; left: 36%; top: 30%; }
  .demo-marker.m-posture-d { width: 40%; left: 30%; top: 35%; }
}
