/* Header "add" flow (shop/service/classified/vehicle/real estate) rendered
   as an overlay above the current page instead of a full-page navigation.
   Backed by the native <dialog> element: showModal() paints the ::backdrop
   below it; every close path (X, backdrop click, Cancel link, Escape,
   successful submit, browser Back) is unified in static/js/form-modal.js. */

#form-modal {
  border: none;
  padding: 0;
  margin: auto;
  width: min(640px, calc(100vw - 2rem));
  max-height: min(88vh, 900px);
  border-radius: 20px;
  background: #FBF9F4;
  box-shadow: 0 24px 64px -12px rgba(15, 23, 21, .35);
  overflow: hidden;
}

#form-modal::backdrop {
  background: rgba(15, 23, 21, .45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#form-modal[open] {
  display: flex;
  flex-direction: column;
}

.form-modal-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: .5rem .5rem 0;
  flex: none;
}

.form-modal-close {
  appearance: none;
  border: none;
  background: rgba(15, 23, 21, .06);
  color: #153E35;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 999px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.form-modal-close:hover,
.form-modal-close:focus-visible {
  background: rgba(15, 23, 21, .12);
}

#form-modal-body {
  overflow-y: auto;
  padding: .5rem 1.5rem 1.5rem;
  -webkit-overflow-scrolling: touch;
}

#form-modal-body .form-card {
  max-width: none;
  margin: 0;
  border: none;
  padding: 0;
  box-shadow: none;
}

#form-modal[aria-busy="true"] #form-modal-body {
  opacity: .55;
  pointer-events: none;
}

html.form-modal-open,
body.form-modal-open {
  overflow: hidden;
}

/* Mobile: full-screen sheet instead of a centered card. */
@media (max-width: 639px) {
  #form-modal {
    width: 100vw;
    height: 100dvh;
    max-height: none;
    max-width: none;
    border-radius: 0;
  }

  .form-modal-bar {
    position: sticky;
    top: 0;
    padding-top: max(.75rem, env(safe-area-inset-top));
    background: #FBF9F4;
    z-index: 1;
    padding-left: .75rem;
    padding-right: .75rem;
  }

  .form-modal-close {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.25rem;
  }

  #form-modal-body {
    padding: .5rem 1.25rem calc(1.5rem + env(safe-area-inset-bottom));
  }

  #form-modal-body input,
  #form-modal-body select,
  #form-modal-body textarea {
    font-size: 16px; /* prevents iOS Safari from zooming the viewport on focus */
  }
}

@media (prefers-reduced-motion: no-preference) {
  #form-modal[open] { animation: form-modal-in .18s ease-out; }
}

@media (prefers-reduced-motion: no-preference) and (max-width: 639px) {
  #form-modal[open] { animation: form-modal-in-mobile .22s cubic-bezier(.22,.61,.36,1); }
}

@keyframes form-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: none; }
}

@keyframes form-modal-in-mobile {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
