/* Mobile Demo Handler Styles */

/* Demo Preview (replaces scaled iframe on mobile) */
.demo-preview-mobile {
  position: relative;
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg, 16px);
  overflow: hidden;
  background: var(--surface-secondary);
  display: none; /* Hidden by default, shown by JS on mobile */
}

@media (max-width: 1023px) {
  .demo-preview-mobile {
    display: block;
  }
}

.demo-preview-image {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.demo-preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.1) 0%,
    rgba(0, 0, 0, 0.4) 100%
  );
  opacity: 0;
  transition: opacity 250ms ease;
}

.demo-preview-mobile:hover .demo-preview-overlay,
.demo-preview-mobile:focus-within .demo-preview-overlay {
  opacity: 1;
}

.demo-preview-cta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: var(--accent-primary, #E66300);
  color: white;
  border: none;
  border-radius: var(--radius-md, 12px);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 200ms ease, box-shadow 200ms ease;
  min-height: 48px; /* WCAG touch target */
}

.demo-preview-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.demo-preview-cta:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.demo-preview-cta:focus-visible {
  outline: 2px solid var(--accent-primary, #E66300);
  outline-offset: 4px;
}

.demo-preview-cta svg {
  flex-shrink: 0;
}

/* On very small mobile, stack icon and text */
@media (max-width: 400px) {
  .demo-preview-cta {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
  }

  .demo-preview-cta span {
    font-size: 0.9375rem;
  }
}

/* Demo Modal */
.demo-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.demo-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  animation: fadeIn 250ms ease;
  cursor: pointer;
}

.demo-modal-content {
  position: relative;
  width: 100%;
  max-width: 500px;
  background: var(--surface-primary, white);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

[data-theme="dark"] .demo-modal-content {
  --surface-primary: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
}

.demo-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
}

[data-theme="dark"] .demo-modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.demo-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary, #000);
  margin: 0;
}

.demo-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm, 8px);
  color: var(--text-secondary, rgba(0, 0, 0, 0.6));
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}

.demo-modal-close:hover {
  background: var(--surface-secondary, rgba(0, 0, 0, 0.05));
  color: var(--text-primary, #000);
}

[data-theme="dark"] .demo-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.demo-modal-close:focus-visible {
  outline: 2px solid var(--accent-primary, #E66300);
  outline-offset: 2px;
}

.demo-modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.demo-modal-message {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-secondary, rgba(0, 0, 0, 0.7));
  margin: 0 0 1.5rem 0;
}

.demo-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.demo-modal-actions .btn {
  width: 100%;
  justify-content: center;
  min-height: 48px; /* WCAG touch target */
}

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

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

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .demo-modal-overlay,
  .demo-modal-content,
  .demo-preview-overlay,
  .demo-preview-cta {
    animation: none !important;
    transition: none !important;
  }
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
  .demo-modal {
    padding: 0.5rem;
  }

  .demo-modal-content {
    max-height: 95vh;
  }

  .demo-modal-header {
    padding: 1rem;
  }

  .demo-modal-title {
    font-size: 1.125rem;
  }

  .demo-modal-body {
    padding: 1rem;
  }

  .demo-modal-message {
    font-size: 0.9375rem;
  }
}

/* Landscape mobile adjustments */
@media (max-width: 767px) and (orientation: landscape) {
  .demo-modal-content {
    max-height: 85vh;
  }

  .demo-modal-header {
    padding: 0.875rem 1rem;
  }

  .demo-modal-body {
    padding: 0.875rem 1rem;
  }
}

/* Desktop - hide mobile elements */
@media (min-width: 1024px) {
  .demo-preview-mobile {
    display: none !important;
  }

  /* Ensure iframes are visible */
  .demo-frame-content {
    display: block !important;
  }
}
