/* 🎬 ILLUMINATED THREAD DEMOS — Base Styles
 * "The silk thread becomes visible when it catches the light"
 * Glowworm cave aesthetic with service-specific color themes
 */

:root {
  /* Cave darkness */
  --cave-black: #0a0a0f;
  --cave-dark: #12121a;
  --cave-mid: #1a1a2e;
  
  /* Glowworm bioluminescence */
  --glow-primary: #00d4ff;
  --glow-pulse: rgba(0, 212, 255, 0.3);
  
  /* Typography */
  --font-display: 'Space Grotesk', -apple-system, system-ui, sans-serif;
  --font-body: 'Inter', -apple-system, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  
  /* Animation timing */
  --timing-typewriter: 50ms;
  --timing-fade: 500ms;
  --timing-glow: 2000ms;
  
  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 1.5rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
}

/* ============================================================================
   DEMO CONTAINER
   ============================================================================ */

.demo-container {
  min-height: 100vh;
  background: linear-gradient(180deg, var(--cave-black) 0%, var(--cave-dark) 100%);
  color: #e5e7eb;
  font-family: var(--font-body);
  padding: var(--space-lg);
}

.demo-header {
  text-align: center;
  margin-bottom: var(--space-xl);
}

.demo-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 var(--space-sm) 0;
  background: linear-gradient(135deg, var(--service-primary), var(--service-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.demo-tagline {
  font-size: 1.125rem;
  color: #9ca3af;
  margin: 0;
}

.demo-back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--service-primary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  margin-bottom: var(--space-md);
}

.demo-back-link:hover {
  transform: translateX(-4px);
  color: var(--service-accent);
}

/* ============================================================================
   THREAD VISUALIZATION (Progress Indicator)
   ============================================================================ */

.demo-thread {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg) 0;
  position: relative;
  margin-bottom: var(--space-xl);
}

.thread-line {
  position: absolute;
  height: 2px;
  background: linear-gradient(90deg, 
    var(--cave-mid) 0%,
    var(--service-primary) 50%,
    var(--cave-mid) 100%
  );
  width: 80%;
  z-index: 0;
}

.thread-beads {
  display: flex;
  gap: var(--space-md);
  z-index: 1;
  flex-wrap: wrap;
  justify-content: center;
}

.thread-bead {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--cave-dark);
  border: 2px solid var(--cave-mid);
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.thread-bead:hover {
  transform: scale(1.1);
}

.thread-bead.active {
  border-color: var(--service-primary);
  background: var(--cave-mid);
}

.thread-bead.completed {
  background: var(--service-primary);
  border-color: var(--service-primary);
}

.bead-glow {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow-pulse) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.thread-bead.active .bead-glow {
  opacity: 1;
  animation: glow-pulse var(--timing-glow) ease-in-out infinite;
}

.bead-number {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: #9ca3af;
  z-index: 1;
}

.thread-bead.active .bead-number {
  color: var(--service-primary);
}

.thread-bead.completed .bead-number {
  color: var(--cave-black);
}

@keyframes glow-pulse {
  0%, 100% { 
    opacity: 0.5; 
    transform: scale(1); 
  }
  50% { 
    opacity: 1; 
    transform: scale(1.1); 
  }
}

/* ============================================================================
   STAGE (Main Content Area)
   ============================================================================ */

.demo-stage {
  max-width: 900px;
  margin: 0 auto var(--space-xl) auto;
  min-height: 500px;
  position: relative;
}

.bead-content {
  padding: var(--space-xl);
  background: rgba(26, 26, 46, 0.5);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
}

.bead-content[hidden] {
  display: none;
}

.bead-content.active {
  animation: fade-slide-in var(--timing-fade) ease forwards;
}

@keyframes fade-slide-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.bead-title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0 0 var(--space-md) 0;
  color: var(--service-primary);
}

.bead-subtitle {
  font-size: 1rem;
  color: #9ca3af;
  margin: 0 0 var(--space-lg) 0;
}

/* ============================================================================
   CHAT SIMULATION
   ============================================================================ */

.chat-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.chat-message {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  max-width: 100%;
  overflow-wrap: break-word;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--service-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.chat-bubble {
  flex: 1;
  padding: var(--space-md);
  border-radius: 12px;
  background: var(--cave-mid);
  border: 1px solid rgba(255, 255, 255, 0.05);
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.chat-message.user .chat-bubble {
  background: rgba(var(--service-primary-rgb), 0.1);
  border-color: var(--service-primary);
}

.chat-speaker {
  font-weight: 600;
  color: var(--service-primary);
  margin-bottom: var(--space-xs);
  font-size: 0.875rem;
}

.chat-text {
  line-height: 1.6;
  margin: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
  white-space: normal;
}
visible;
  border-right: 2px solid var(--service-primary);
  white-space: normal;
  animation: blink-cursor 0.7s step-end infinite;
  display: inlineid var(--service-primary);
  white-space: nowrap;
  animation: blink-cursor 0.7s step-end infinite;
  display: inline-block;
}

@keyframes blink-cursor {
  50% { border-color: transparent; }
}

/* ============================================================================
   VISUALIZATIONS
   ============================================================================ */

.visualization {
  margin: var(--space-lg) 0;
  padding: var(--space-lg);
  background: var(--cave-black);
  border-radius: 8px;
  border: 1px solid var(--service-primary);
}

.viz-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--service-primary);
  margin: 0 0 var(--space-md) 0;
}

/* Progress bars */
.progress-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.progress-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.progress-label {
  font-size: 0.875rem;
  color: #9ca3af;
  display: flex;
  justify-content: space-between;
}

.progress-bar {
  height: 8px;
  background: var(--cave-mid);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--service-primary), var(--service-accent));
  width: 0%;
  transition: width 1s ease-out;
  border-radius: 4px;
}

.progress-fill.animate {
  width: var(--progress-width);
}

/* Scores/metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-md);
}

.metric-card {
  padding: var(--space-md);
  background: var(--cave-mid);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  text-align: center;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--service-primary);
  margin: 0;
}

.metric-label {
  font-size: 0.875rem;
  color: #9ca3af;
  margin: var(--space-xs) 0 0 0;
}

/* Highlights */
.highlight-box {
  padding: var(--space-md);
  background: rgba(var(--service-primary-rgb), 0.1);
  border-left: 4px solid var(--service-primary);
  border-radius: 4px;
  margin: var(--space-md) 0;
}

.highlight-box.warning {
  background: rgba(239, 68, 68, 0.1);
  border-left-color: #ef4444;
}

.highlight-box.success {
  background: rgba(16, 185, 129, 0.1);
  border-left-color: #10b981;
}

/* ============================================================================
   CONTROLS
   ============================================================================ */

.demo-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--cave-mid);
  border-radius: 12px;
  max-width: 600px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.control-btn {
  padding: 0.75rem 1.5rem;
  background: var(--cave-dark);
  border: 1px solid var(--service-primary);
  border-radius: 8px;
  color: var(--service-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.control-btn:hover:not(:disabled) {
  background: var(--service-primary);
  color: var(--cave-black);
  transform: translateY(-2px);
}

.control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.control-progress {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: #9ca3af;
  padding: 0 var(--space-md);
}

/* ============================================================================
   VALUE STATEMENT (End of demo)
   ============================================================================ */

.value-statement {
  margin-top: var(--space-xl);
  padding: var(--space-xl);
  background: linear-gradient(135deg, rgba(var(--service-primary-rgb), 0.1), rgba(var(--service-accent-rgb), 0.1));
  border-radius: 12px;
  border: 2px solid var(--service-primary);
  text-align: center;
}

.value-statement-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.value-statement-text {
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.6;
  color: #e5e7eb;
  margin: 0 0 var(--space-lg) 0;
}

.value-statement-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.875rem 1.75rem;
  background: var(--service-primary);
  color: var(--cave-black);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.value-statement-cta:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px var(--glow-pulse);
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
.thread-bead:focus,
.control-btn:focus {
  outline: 2px solid var(--service-primary);
  outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
  .demo-title {
    font-size: 2rem;
  }
  
  .demo-container {
    padding: var(--space-md);
  }
  
  .thread-beads {
    gap: var(--space-sm);
  }
  
  .thread-bead {
    width: 40px;
    height: 40px;
  }
  
  .bead-content {
    padding: var(--space-md);
  }
  
  .bead-title {
    font-size: 1.5rem;
  }
  
  .demo-controls {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .control-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .demo-title {
    font-size: 1.5rem;
  }
  
  .thread-bead {
    width: 36px;
    height: 36px;
  }
  
  .bead-number {
    font-size: 0.875rem;
  }
}
