/**
 * MSiR Demo Integration - November 2025
 * Modal demo system with trigger cards
 */

/* ========================================
   DEMO TRIGGER CARDS
   ======================================== */
.demo-trigger-card {
  margin: var(--space-3xl) 0;
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
  cursor: pointer;
}

.demo-trigger-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-xl);
}

/* 4-color border cycle */
.demo-trigger-card:nth-of-type(4n+1) { border-top: 4px solid var(--scientific-cyan); }
.demo-trigger-card:nth-of-type(4n+2) { border-top: 4px solid var(--mad-magenta); }
.demo-trigger-card:nth-of-type(4n+3) { border-top: 4px solid var(--experiment-orange); }
.demo-trigger-card:nth-of-type(4n+4) { border-top: 4px solid var(--flash-green); }

.demo-preview-section {
  position: relative;
  height: 300px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.demo-preview-svg {
  width: 100%;
  height: 100%;
}

.demo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(45, 49, 66, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.demo-trigger-card:hover .demo-overlay {
  opacity: 1;
}

.demo-launch-btn {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg) var(--space-2xl);
  background: var(--scientific-cyan);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.125rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-base);
}

.demo-launch-btn:hover {
  background: var(--mad-magenta);
  transform: scale(1.05);
}

.demo-info-section {
  padding: var(--space-xl);
}

.demo-info-section h3 {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--laboratory-dark);
  margin-bottom: var(--space-md);
}

.demo-description {
  font-size: 1.125rem;
  line-height: 1.7;
  color: #6c757d;
}

/* ========================================
   DEMO MODAL
   ======================================== */
.demo-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(45, 49, 66, 0.95);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.3s ease;
}

.demo-modal.active {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.demo-modal-content {
  position: relative;
  width: 95vw;
  height: 90vh;
  max-width: 1400px;
  background: white;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.demo-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg) var(--space-xl);
  background: var(--laboratory-dark);
  color: white;
}

.demo-modal-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}

.demo-modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  padding: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

.demo-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: rotate(90deg);
}

.demo-modal-iframe-container {
  width: 100%;
  height: calc(100% - 70px); /* Subtract header height */
  position: relative;
}

.demo-modal-iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.demo-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
  gap: var(--space-lg);
}

.demo-loading.hidden {
  display: none;
}

.demo-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #e9ecef;
  border-top-color: var(--scientific-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.demo-loading-text {
  font-weight: 600;
  color: var(--laboratory-dark);
}

/* ========================================
   DEMO ERROR STATE
   ======================================== */
.demo-error {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
  padding: var(--space-2xl);
  text-align: center;
  gap: var(--space-lg);
}

.demo-error.active {
  display: flex;
}

.demo-error-icon {
  font-size: 4rem;
}

.demo-error-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--experiment-orange);
}

.demo-error-message {
  color: #6c757d;
  max-width: 500px;
}

.demo-retry-btn {
  padding: var(--space-md) var(--space-xl);
  background: var(--scientific-cyan);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-base);
}

.demo-retry-btn:hover {
  background: var(--mad-magenta);
  transform: translateY(-2px);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 768px) {
  .demo-preview-section {
    height: 200px;
  }

  .demo-modal-content {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }

  .demo-info-section {
    padding: var(--space-lg);
  }

  .demo-info-section h3 {
    font-size: 1.5rem;
  }

  .demo-launch-btn {
    padding: var(--space-md) var(--space-xl);
    font-size: 1rem;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
.demo-modal:focus-within .demo-modal-content {
  outline: 2px solid var(--scientific-cyan);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .demo-modal,
  .demo-modal-content {
    animation: none;
  }
}
