/* ──────────────────────────────────────────────────────────────────────────
   CodeNow interactive demo modal — codenow.pro/#demo
   Loaded lazily when the user clicks the topbar DEMO button. Pure CSS
   (no framework). Inherits CSS variables from the host page (--bg, --text,
   --accent, etc.) so it picks up the homepage's dark/indigo theme.
   ────────────────────────────────────────────────────────────────────────── */

.cn-demo-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(4, 4, 8, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: stretch;
  justify-content: center;
  overflow-y: auto;
  -webkit-font-smoothing: antialiased;
}
.cn-demo-overlay.open { display: flex; }
.cn-demo-overlay * { box-sizing: border-box; }

.cn-demo-modal {
  position: relative;
  width: 100%;
  max-width: 1360px;
  margin: 32px auto;
  padding: 28px 40px 32px;
  background: linear-gradient(180deg, #0d0d12 0%, #08080b 100%);
  border: 1px solid #2e2e3a;
  border-radius: 18px;
  box-shadow:
    0 0 0 2px rgba(99, 102, 241, 0.45),
    0 0 60px rgba(99, 102, 241, 0.25),
    0 30px 80px rgba(0, 0, 0, 0.6);
  color: var(--text, #f3f3f7);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Close button — top-right */
.cn-demo-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #2e2e3a;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-2, #c4c4cf);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cn-demo-close:hover { color: var(--text, #fff); background: rgba(255,255,255,0.08); border-color: #4a4a5e; }

/* Tab toggle — segmented control */
.cn-demo-tabs {
  display: inline-flex;
  margin: 8px auto 24px;
  background: #131319;
  border: 1px solid #23232c;
  border-radius: 10px;
  padding: 4px;
  align-self: center;
}
.cn-demo-tab-row { display: flex; justify-content: center; }
.cn-demo-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-2, #c4c4cf);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 9px 18px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cn-demo-tab:hover { color: var(--text, #fff); }
.cn-demo-tab.active {
  background: linear-gradient(135deg, #6366f1, #ec4899);
  color: #fff;
}

/* Screenshot stage */
.cn-demo-stage {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  background: #0a0a0e;
  border: 1px solid #23232c;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.cn-demo-stage-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 250ms ease;
}
.cn-demo-stage-img.active { opacity: 1; z-index: 2; }
.cn-demo-stage-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim, #8a8a96);
  font-size: 14px;
  text-align: center;
  padding: 24px;
  z-index: 1;
}
.cn-demo-audio-blocked {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  display: none;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.5);
  border-radius: 8px;
  color: #f59e0b;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.cn-demo-audio-blocked.show { display: inline-flex; align-items: center; gap: 6px; }

/* Caption box */
.cn-demo-caption {
  max-width: 1280px;
  margin: 18px auto 0;
  padding: 14px 20px;
  background: rgba(99, 102, 241, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.18);
  border-radius: 10px;
  color: var(--text-2, #c4c4cf);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  min-height: 60px;
}

/* Step indicator dots */
.cn-demo-dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 18px auto 14px;
}
.cn-demo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid #4a4a5e;
  cursor: pointer;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.cn-demo-dot:hover { border-color: var(--accent, #6366f1); transform: scale(1.15); }
.cn-demo-dot.past { background: #4a4a5e; border-color: #4a4a5e; }
.cn-demo-dot.active {
  background: var(--accent, #6366f1);
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

/* Control bar */
.cn-demo-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 6px auto 14px;
}
.cn-demo-btn {
  appearance: none;
  border: 1px solid #2e2e3a;
  background: #131319;
  color: var(--text-2, #c4c4cf);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cn-demo-btn:hover { color: var(--text, #fff); background: #1a1a22; border-color: #4a4a5e; }
.cn-demo-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cn-demo-btn-primary {
  background: linear-gradient(135deg, #6366f1, #ec4899);
  color: #fff;
  border-color: transparent;
}
.cn-demo-btn-primary:hover { color: #fff; background: linear-gradient(135deg, #7376f3, #f159a8); border-color: transparent; }

/* Progress bar */
.cn-demo-progress {
  position: relative;
  height: 4px;
  max-width: 1280px;
  margin: 4px auto 0;
  background: #1a1a22;
  border-radius: 2px;
  overflow: hidden;
}
.cn-demo-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #ec4899);
  transition: width 80ms linear;
}

/* End-of-demo CTA panel */
.cn-demo-cta {
  display: none;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  margin: 18px auto 4px;
  padding: 22px;
  background: rgba(99, 102, 241, 0.07);
  border: 1px solid rgba(99, 102, 241, 0.30);
  border-radius: 12px;
  max-width: 720px;
  text-align: center;
}
.cn-demo-cta.show { display: flex; }
.cn-demo-cta-h { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: var(--text, #fff); }
.cn-demo-cta-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* Returning-visitor toast */
.cn-demo-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  padding: 14px 16px 14px 18px;
  background: #131319;
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  max-width: 320px;
  display: none;
  font-size: 13px;
  color: var(--text-2, #c4c4cf);
  animation: cn-demo-toast-in 0.3s ease;
}
.cn-demo-toast.show { display: block; }
.cn-demo-toast-h { display: block; font-weight: 700; color: var(--text, #fff); margin-bottom: 4px; }
.cn-demo-toast-row { display: flex; gap: 8px; margin-top: 10px; }
.cn-demo-toast-btn {
  appearance: none;
  border: 1px solid #2e2e3a;
  background: transparent;
  color: var(--text-2, #c4c4cf);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.cn-demo-toast-btn:hover { background: #1a1a22; color: #fff; }
.cn-demo-toast-btn-primary { background: var(--accent, #6366f1); color: #fff; border-color: transparent; }
.cn-demo-toast-btn-primary:hover { background: #7376f3; }

@keyframes cn-demo-toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* DEMO topbar button — matches existing nav-cta pattern but indigo-glow */
.nav-demo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.5);
  color: var(--text, #fff) !important;
  border-radius: 8px;
  font-weight: 700;
  font-size: 12px !important;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.nav-demo-btn::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #6366f1);
  box-shadow: 0 0 6px var(--accent, #6366f1);
  animation: cn-demo-pulse 1.6s ease-in-out infinite;
}
.nav-demo-btn:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.8);
  text-decoration: none !important;
}
@keyframes cn-demo-pulse {
  0%, 100% { opacity: 1;   transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.85); }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
  .cn-demo-modal {
    margin: 0;
    padding: 16px 14px 22px;
    border-radius: 0;
    border: 0;
    min-height: 100vh;
  }
  .cn-demo-close { top: 10px; right: 10px; }
  .cn-demo-tabs { margin-top: 36px; }
  .cn-demo-tab { padding: 8px 14px; font-size: 12px; }
  .cn-demo-stage { border-radius: 10px; }
  .cn-demo-caption { font-size: 14px; padding: 12px 14px; }
  .cn-demo-controls { flex-wrap: nowrap; gap: 6px; }
  .cn-demo-btn { padding: 8px 10px; font-size: 12px; }
  .cn-demo-dots { gap: 8px; }
  .cn-demo-dot { width: 8px; height: 8px; }
}
