/* Apple‑style modal overrides */
#site-modal.modal-overlay {
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 2rem;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

#site-modal.is-open {
  opacity: 1;
  visibility: visible;
}

/* Prevent background scroll when modal is open */
html.modal-open,
body.modal-open {
  overflow-x: hidden !important;
  overflow-y: hidden !important;
  overflow: hidden !important;
}

#site-modal .modal-content-container {
  position: relative;
  background: var(--color-white);
  border-radius: 1rem;
  width: 87.5%;
  max-width: 900px;
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
  padding: 1rem 1rem 4rem;
  box-sizing: border-box;
}

#site-modal .modal-body {
  height: auto;
}

/* Loading state */
#site-modal .modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: #666;
}

#site-modal .modal-loading[aria-hidden="true"] {
  display: none;
}

#site-modal .loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #007aff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Sticky close button, top‑left like Apple */
#site-modal .modal-close-button {
  position: sticky;
  top: 0rem;
  right: 1rem;
  margin-left: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(125, 125, 125, 0.8);
  border: none;
  padding: 0;
  display: flex;
  padding: 10px;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  z-index: 10;
}

#site-modal .modal-close-button:hover {
  background: rgba(0, 0, 0, 0.8);
  color: var(--color-white);
}

#site-modal .modal-close-button:active {
  background: #dfdfe4;
}

#site-modal .modal-close-button:focus {
  outline: 2px solid #007aff;
  outline-offset: 2px;
}

#site-modal .modal-close-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Content styling*/
#site-modal .modal-header-image {
  display: block;
  width: 100%;
  height: 400px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  object-fit: cover;
  object-position: center;
  border-radius: 1rem;
  margin: -2.5rem 0 2rem;
}

/* Focus trap support */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 600px) {
  #site-modal .modal-content-container {
    width: 100%;
    height: auto;
    padding: 1rem 0 3rem;
    margin-top: 1rem;
    margin-bottom: 0;
  }

  #site-modal.modal-overlay {
    padding: 1rem;
  }

  #site-modal .modal-header-image {
    display: block;
    width: 90%;
    height: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    object-fit: cover;
    object-position: center;
    border-radius: 1rem;
    margin: -2.5rem auto 2rem;
  }
}