/* ========================================
   Modal — Contact Form Dialog
   ======================================== */

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: var(--z-modal);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal[hidden] {
  display: none;
}

.modal:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.modal:not([hidden]) .modal__backdrop {
  z-index: var(--z-modal-backdrop);
  opacity: 1;
}

.modal__container {
  position: relative;
  z-index: var(--z-modal-content);
  width: min(90%, 580px);
  max-height: 90vh;
  background: var(--color-light);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-premium-dark);
  overflow: hidden;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.3s ease, transform 0.3s var(--ease-spring);
}

.modal:not([hidden]) .modal__container {
  opacity: 1;
  transform: scale(1);
}

.modal__content {
  max-height: 90vh;
  overflow-y: auto;
  padding: 2.5rem;
}

.modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--color-light-alt);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
  z-index: 10;
}

.modal__close:hover {
  background: var(--color-primary);
  color: var(--color-text-light);
  transform: scale(1.1);
}

.modal__header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.modal__title {
  font-size: clamp(1.5rem, 3vw + 0.75rem, 2rem);
  font-weight: var(--font-weight-extrabold);
  color: var(--color-secondary);
  margin-bottom: 0.5rem;
  line-height: var(--line-height-tight);
}

.modal__subtitle {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text-secondary);
}

.contact__form--modal {
  padding: 0;
  background: transparent;
  box-shadow: none;
  border: none;
}

.contact__form--modal .form__group {
  margin-bottom: 1.25rem;
}

.contact__form--modal .form__group:last-child {
  margin-bottom: 0;
}

.form__success {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background-color: #d4edda;
  color: #155724;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.form__error-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background-color: #f8d7da;
  color: #721c24;
  border-radius: var(--border-radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

/* Mobile optimizations */
@media (max-width: 767px) {
  .modal__container {
    width: 95%;
    margin: 1.5rem;
    max-height: 85vh;
    border-radius: var(--border-radius-lg);
    transform: translateY(20px);
  }

  .modal:not([hidden]) .modal__container {
    transform: translateY(0);
  }

  .modal__content {
    padding: 2rem 1.5rem;
    max-height: 85vh;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .modal:not([hidden]) .modal__backdrop {
    opacity: 1;
  }

  .modal:not([hidden]) .modal__container {
    opacity: 1;
    transform: none;
  }
}
