/* MailChimp Modal Custom Styles */

/* Modal enhancements */

#mailchimpModal .modal-header {
  border-bottom: 1px solid #e9ecef;
  padding: 1.5rem 1.5rem 1rem;
}

#mailchimpModal .modal-title {
  font-weight: 600;
  font-size: 1.25rem;
}

#mailchimpModal .modal-body {
  padding: 1rem 1.5rem 1.5rem;
}

#mailchimpModal .modal-footer {
  border-top: 1px solid #e9ecef;
  padding: 1rem 1.5rem 1.5rem;
}

/* Form styling with smooth transitions */
#mailchimpForm .form-label {
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.5rem;
  transition: color 0.2s ease-in-out;
}

#mailchimpForm .form-control {
  border-radius: 4px;
  border: 1px solid var(--bs-border-color, #c3cdd6);
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform: translateZ(0); /* Hardware acceleration */
}

#mailchimpForm .form-control:focus {
  border-color: #80bdff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
  transform: translateY(-1px);
}

#mailchimpForm .form-control:hover:not(:focus) {
  border-color: #adb5bd;
  transform: translateY(-0.5px);
}

/* Button enhancements with smooth animations */
#mailchimpForm .btn {
  border-radius: 8px;
  padding: 0.75rem 1.5rem;
  font-weight: 500;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform: translateZ(0); /* Hardware acceleration */
  position: relative;
  overflow: hidden;
}

/* Ripple effect for buttons */
#mailchimpForm .btn::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform: translate(-50%, -50%);
  z-index: 0;
}

#mailchimpForm .btn:active::before {
  width: 300px;
  height: 300px;
}

#mailchimpForm .btn > * {
  position: relative;
  z-index: 1;
}

#mailchimpForm .btn-primary {
  background-color: #007bff;
  border-color: #007bff;
  box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

#mailchimpForm .btn-primary:hover:not(:disabled) {
  background-color: #0056b3;
  border-color: #0056b3;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 123, 255, 0.3);
}

#mailchimpForm .btn-primary:active {
  transform: translateY(-1px);
}

#mailchimpForm .btn-secondary {
  background-color: #6c757d;
  border-color: #6c757d;
  box-shadow: 0 2px 4px rgba(108, 117, 125, 0.2);
}

#mailchimpForm .btn-secondary:hover {
  background-color: #545b62;
  border-color: #4e555b;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 117, 125, 0.3);
}

/* Loading spinner with smooth animation */
@keyframes smoothSpin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulseGlow {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

#loadingSpinner {
  width: 1rem;
  height: 1rem;
  animation: smoothSpin 1s linear infinite;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Button loading state */
#submitBtn {
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#submitBtn:disabled {
  opacity: 0.8;
  transform: scale(0.98);
  animation: pulseGlow 2s ease-in-out infinite;
}

#submitBtn:not(:disabled):hover {
  transform: translateY(-1px) scale(1.02);
}

/* Alert messages with smooth slide-in animation */
@keyframes alertSlideIn {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes alertSlideOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-5px) scale(0.98);
  }
}

#responseMessage {
  margin-bottom: 0;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  animation: alertSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#responseMessage.d-none {
  animation: alertSlideOut 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Animation for modal - Enhanced for smoother experience */
@keyframes modalFadeInScale {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes modalFadeOutScale {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0;
  }
}

@keyframes backdropFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 0.5;
  }
}

@keyframes backdropFadeOut {
  0% {
    opacity: 0.5;
  }
  100% {
    opacity: 0;
  }
}

/* Modal dialog positioning and animations */
#mailchimpModal .modal-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-width: 600px;
  width: 90%;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Desktop specific styles */
@media (min-width: 769px) {
  #mailchimpModal .modal-dialog {
    width: auto;
    max-width: 600px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
  }

  #mailchimpModal .modal-content {
    border-radius: 16px;
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* Show animation */
#mailchimpModal.show .modal-dialog {
  animation: modalFadeInScale 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Hide animation */
#mailchimpModal.fade:not(.show) .modal-dialog {
  animation: modalFadeOutScale 0.3s cubic-bezier(0.55, 0.055, 0.675, 0.19)
    forwards;
}

/* Backdrop animations */
#mailchimpModal.fade .modal-backdrop {
  transition: opacity 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#mailchimpModal.show .modal-backdrop {
  animation: backdropFadeIn 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Modal content animations */
#mailchimpModal .modal-content {
  border: none;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  transform: translateZ(0); /* Enable hardware acceleration */
  will-change: transform, opacity;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Responsive adjustments - Full screen modal on mobile */
@media (max-width: 768px) {
  #mailchimpModal .modal-dialog {
    margin: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }

  #mailchimpModal .modal-content {
    height: 100vh;
    width: 100vw;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    position: relative;
    margin: 0;
    overflow: hidden; /* Prevent content overflow */
  }
  #mailchimpModal .modal-header {
    padding: 1.5rem 1rem 1rem;
    flex-shrink: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
  }

  #mailchimpModal .modal-title {
    color: white;
    font-size: 1.375rem;
    font-weight: 600;
  }

  #mailchimpModal .btn-close {
    filter: invert(1);
    opacity: 0.8;
  }

  #mailchimpModal .modal-body {
    padding: 2rem 1rem;
    flex: 1;
    overflow-y: auto;
    background: #f8f9fa;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    overscroll-behavior-y: contain; /* Prevent scroll chaining */
    height: calc(
      100vh - 80px
    ); /* Calculated height: full height minus header (~80px) only */
    min-height: 0; /* Allow shrinking */
  }

  #mailchimpModal .modal-body p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
  }

  /* Button styling for mobile - now in modal body */
  #mailchimpModal .modal-body .btn {
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 500;
    border-radius: 8px;
    min-height: 56px; /* Better touch target */
  }

  #mailchimpModal .modal-body .d-flex.gap-2 {
    margin-top: 2rem;
  }

  /* Larger form inputs on mobile */
  #mailchimpForm .form-control {
    padding: 1.25rem 1rem;
    font-size: 1.1rem;
    border-radius: 8px;
    min-height: 56px; /* Better touch target */
    border: 2px solid #dee2e6;
  }

  #mailchimpForm .form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
  }

  #mailchimpForm .form-label {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    font-weight: 500;
    color: #495057;
  }

  /* Better spacing for mobile */
  #mailchimpModal .modal-body .row .col-md-6 {
    margin-bottom: 1.5rem;
  }

  #mailchimpModal .modal-body .mb-3 {
    margin-bottom: 2rem !important;
  }

  /* Ensure form has proper bottom padding for scrolling */
  #mailchimpForm {
    padding-bottom: 1rem;
  }

  /* Alert styling on mobile */
  #responseMessage {
    font-size: 1rem;
    padding: 1rem;
    border-radius: 8px;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  #mailchimpModal .modal-header {
    padding: 1rem 0.75rem;
  }

  #mailchimpModal .modal-body {
    padding: 1.5rem 0.75rem;
  }

  #mailchimpModal .modal-footer {
    padding: 1rem 0.75rem;
    flex-direction: column;
    gap: 0.75rem;
  }

  #mailchimpModal .modal-footer .btn {
    margin: 0;
    width: 100%;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 991px) {
  #mailchimpModal .modal-dialog {
    max-width: 90%;
    margin: 1rem auto;
  }
}

/* Form validation states with smooth transitions */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

#mailchimpForm .form-control.is-invalid {
  border-color: #dc3545;
  animation: shake 0.4s ease-in-out;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.15);
}

#mailchimpForm .form-control.is-invalid:focus {
  border-color: #dc3545;
  box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

#mailchimpForm .form-control.is-valid {
  border-color: #28a745;
  box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.15);
  animation: none;
}

#mailchimpForm .form-control.is-valid:focus {
  border-color: #28a745;
  box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Enhanced hover effects for join buttons */
.btn-hover-text[data-bs-toggle="modal"] {
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform: translateZ(0); /* Hardware acceleration */
  position: relative;
  overflow: hidden;
}

.btn-hover-text[data-bs-toggle="modal"]::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transition: left 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.btn-hover-text[data-bs-toggle="modal"]:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.btn-hover-text[data-bs-toggle="modal"]:hover::before {
  left: 100%;
}

.btn-hover-text[data-bs-toggle="modal"]:active {
  transform: translateY(-2px) scale(1.01);
}

/* Add smooth focus states */
.btn-hover-text[data-bs-toggle="modal"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}
