/**
 * Shared Book Demo / schedule modal — matches index.html behavior and styling.
 * Uses site CSS variables when present, with fallbacks for articles/resources pages.
 */

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

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

@keyframes demoScheduleSlideUpSheet {
  from {
    transform: translateY(100%);
    opacity: 0.92;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Demo Form Modal */
.demo-form-modal {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: rgba(15, 12, 28, 0.72);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: demoScheduleFadeIn 0.3s ease;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

.demo-form-container {
  background:
    linear-gradient(145deg, rgba(139, 92, 246, 0.08) 0%, transparent 42%),
    linear-gradient(135deg, #2f3050 0%, #252638 55%, #1e1f30 100%);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: 24px;
  padding: 40px 56px;
  max-width: 560px;
  width: min(100%, 560px);
  position: relative;
  animation: demoScheduleSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 0 120px rgba(124, 58, 237, 0.12);
  max-height: min(92vh, 880px);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: auto;
}

.demo-form-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
  color: rgba(255, 255, 255, 0.92);
  z-index: 2;
  flex-shrink: 0;
}

.demo-form-close:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
  transform: rotate(90deg);
}

.demo-form-close:focus-visible {
  outline: 2px solid var(--violet-light, #8b5cf6);
  outline-offset: 3px;
}

.demo-form h2 {
  font-size: clamp(1.5rem, 4vw, 1.875rem);
  margin: 0 52px 10px 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
  background: linear-gradient(
    135deg,
    var(--violet, #7c3aed) 0%,
    var(--violet-light, #8b5cf6) 50%,
    #fbbf24 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.demo-form p {
  color: rgba(232, 228, 245, 0.72);
  margin: 0 48px 28px 0;
  font-size: 0.98rem;
  line-height: 1.55;
}

.demo-form form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 22px;
}

.demo-form-modal .form-group {
  margin-bottom: 0;
}

.demo-form-modal .form-group.full-width {
  grid-column: 1 / -1;
}

.demo-form-modal .form-group label {
  display: block;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}

.demo-form-modal .form-group input,
.demo-form-modal .form-group select,
.demo-form-modal .form-group textarea {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.28);
  border-radius: 12px;
  color: white;
  font-size: 1rem;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
  min-height: 48px;
}

.demo-form-modal .form-group textarea {
  min-height: 100px;
}

.demo-form-modal .form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.55)' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 42px;
  cursor: pointer;
}

.demo-form-modal .form-group select option {
  background: #2a2b40;
  color: #fff;
}

.demo-form-modal .form-group input:focus,
.demo-form-modal .form-group select:focus,
.demo-form-modal .form-group textarea:focus {
  outline: none;
  border-color: var(--violet, #7c3aed);
  background: rgba(139, 92, 246, 0.1);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.2);
}

.demo-form-modal .form-group textarea {
  resize: vertical;
}

.demo-form-modal .form-submit.full-width {
  grid-column: 1 / -1;
}

.demo-form-modal .form-submit {
  width: 100%;
  padding: 15px 28px;
  background: var(--forest, var(--purple-main, #3b1f6e));
  border: none;
  border-radius: 100px;
  color: var(--white, #ffffff) !important;
  font-size: 0.95rem !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: all 0.3s ease !important;
  margin-top: 6px;
  position: relative;
  overflow: hidden;
  min-height: 52px;
}

.demo-form-modal .form-submit:focus-visible {
  outline: 2px solid rgba(251, 191, 36, 0.85);
  outline-offset: 3px;
}

.demo-form-modal .form-submit::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s ease;
}

.demo-form-modal .form-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(59, 31, 110, 0.2);
  background: var(--forest-light, var(--purple-soft, #4e2d8a));
}

.demo-form-modal .form-submit:hover::before {
  left: 100%;
}

@media (max-width: 768px) {
  .demo-form-modal {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }

  .demo-form-container {
    width: 100%;
    max-width: none;
    border-radius: 22px 22px 0 0;
    padding: max(28px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
    max-height: min(94dvh, 900px);
    animation: demoScheduleSlideUpSheet 0.38s cubic-bezier(0.32, 0.72, 0, 1);
  }

  .demo-form-close {
    top: max(18px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    width: 48px;
    height: 48px;
  }

  .demo-form h2 {
    margin-right: 56px;
  }

  .demo-form p {
    margin-right: 8px;
    margin-bottom: 22px;
  }

  .demo-form form {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .demo-form-modal .form-group.full-width {
    grid-column: 1;
  }
}
