/*
 * Archive additional filters
 *
 * Map visibility and filter visibility are deliberately independent states.
 * The filter form lives in one responsive dialog on desktop and mobile, so a
 * hidden map never forces the filter panel to remain open.
 */

body.wp-child-theme-marnamic:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
  > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog {
  position: fixed !important;
  inset: 0 !important;
  z-index: 10050 !important;
  display: none !important;
  width: 100% !important;
  height: 100% !important;
  align-items: center !important;
  justify-items: center !important;
  padding: clamp(16px, 4vw, 40px) !important;
  overflow: hidden !important;
  background: rgba(7, 17, 19, 0.78) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
}

body.wp-child-theme-marnamic.marnamic-archive-filters-visible:is(.marnamic-archive-search-results, .marnamic-vendor-discovery) {
  overflow: hidden !important;
}

body.wp-child-theme-marnamic.marnamic-archive-filters-visible:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
  > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog {
  display: grid !important;
}

body.wp-child-theme-marnamic:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
  > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog
  > :is(.hp-widget--vendor-filter, .hp-widget--listing-filter) {
  position: relative !important;
  display: block !important;
  width: min(720px, 100%) !important;
  max-width: 720px !important;
  max-height: min(820px, calc(100dvh - clamp(32px, 8vw, 80px))) !important;
  margin: 0 !important;
  padding: 28px 24px 24px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  color: var(--marnamic-cream, #f1e9dd) !important;
  background: linear-gradient(180deg, #18272b 0%, #132124 100%) !important;
  border: 1px solid rgba(161, 192, 195, 0.34) !important;
  border-radius: 14px !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42) !important;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
}

body.wp-child-theme-marnamic:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
  > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog
  :is(.hp-modal, .hp-modal--mobile) {
  position: static !important;
  inset: auto !important;
  z-index: auto !important;
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
  opacity: 1 !important;
  visibility: visible !important;
  transform: none !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  clip: auto !important;
  clip-path: none !important;
  pointer-events: auto !important;
}

body.wp-child-theme-marnamic:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
  > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog
  :is(.hp-form--vendor-filter, .hp-form--listing-filter) {
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

body.wp-child-theme-marnamic:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
  > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog
  .marnamic-archive-filter-close {
  position: sticky !important;
  top: 0 !important;
  z-index: 3 !important;
  float: right !important;
  margin: 0 0 12px 16px !important;
}

body.wp-child-theme-marnamic:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
  > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog
  .marnamic-archive-filter-close + :is(.hp-modal, .hp-modal--mobile) {
  clear: both !important;
}

/* The toolbar always exposes both independent controls. */
body.wp-child-theme-marnamic.marnamic-archive-search-results
  .marnamic-archive-workspace-actions
  .marnamic-archive-filter-button {
  display: inline-flex !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

body.wp-child-theme-marnamic.marnamic-archive-search-results
  .marnamic-archive-workspace-actions
  .marnamic-archive-filter-button.is-panel-visible {
  color: var(--marnamic-cream, #f1e9dd) !important;
  background: rgba(5, 113, 124, 0.72) !important;
  border-color: var(--marnamic-teal, #61a5ac) !important;
}

body.wp-child-theme-marnamic.marnamic-archive-search-results
  .marnamic-archive-workspace-actions
  .marnamic-archive-filter-button.is-panel-visible:is(:hover, :focus-visible) {
  color: var(--marnamic-cream, #f1e9dd) !important;
  background: var(--marnamic-teal-dark, #05717c) !important;
  border-color: var(--marnamic-teal, #61a5ac) !important;
}

/* The unfiltered discovery view exposes the same secondary action directly
 * below the Was/Wo search instead of withholding all specialist filters. */
body.wp-child-theme-marnamic.marnamic-vendor-discovery
  .hp-page__header
  .marnamic-archive-discovery-filter-button {
  position: relative !important;
  display: inline-flex !important;
  visibility: visible !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  align-items: center !important;
  justify-content: center !important;
  justify-self: end !important;
  gap: 8px !important;
  margin: -6px 0 0 !important;
  padding: 0 16px !important;
  color: var(--marnamic-cream, #f1e9dd) !important;
  background: #0f191b !important;
  border: 1px solid rgba(161, 192, 195, 0.34) !important;
  border-radius: 10px !important;
  box-shadow: none !important;
  pointer-events: auto !important;
}

/* ListingHive gives every .button a positioned ::before hover layer. Keep
 * that layer inside this button and prevent it from intercepting the Was/Wo
 * search controls around it. */
body.wp-child-theme-marnamic.marnamic-vendor-discovery
  .hp-page__header
  .marnamic-archive-discovery-filter-button::before,
body.wp-child-theme-marnamic.marnamic-vendor-discovery
  .hp-page__header
  .marnamic-archive-discovery-filter-button::after {
  pointer-events: none !important;
}

body.wp-child-theme-marnamic.marnamic-vendor-discovery
  .hp-page__header
  .marnamic-archive-discovery-filter-button:is(:hover, :focus-visible, .is-panel-visible) {
  color: #132124 !important;
  background: var(--marnamic-teal, #61a5ac) !important;
  border-color: var(--marnamic-teal, #61a5ac) !important;
}

/* Without a map the result grid uses the full width. The filter dialog remains
 * available because it is mounted directly below body, not inside the hidden
 * sidebar. */
@media (min-width: 1100px) {
  body.wp-child-theme-marnamic.marnamic-archive-search-results.marnamic-archive-map-hidden
    .hp-page.marnamic-archive-workspace
    > .hp-row {
    position: relative !important;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.wp-child-theme-marnamic.marnamic-archive-search-results.marnamic-archive-map-hidden
    .hp-page.marnamic-archive-workspace
    > .hp-row
    > .hp-page__sidebar {
    position: absolute !important;
    inset: 0 auto auto 0 !important;
    display: block !important;
    width: 0 !important;
    height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }

  body.wp-child-theme-marnamic.marnamic-archive-search-results.marnamic-archive-map-hidden
    .hp-page.marnamic-archive-workspace
    > .hp-row
    > .hp-page__content {
    grid-column: 1 !important;
    width: 100% !important;
  }
}

body.wp-child-theme-marnamic.marnamic-archive-filters-visible > .select2-container--open,
body.wp-child-theme-marnamic.marnamic-archive-filters-visible .select2-dropdown {
  z-index: 10070 !important;
}

@media (max-width: 1099px) {
  body.wp-child-theme-marnamic:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
    > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog {
    align-items: stretch !important;
    padding: 12px !important;
  }

  body.wp-child-theme-marnamic:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
    > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog
    > :is(.hp-widget--vendor-filter, .hp-widget--listing-filter) {
    width: 100% !important;
    max-width: none !important;
    max-height: calc(100dvh - 24px) !important;
    padding: 18px !important;
    border-radius: 12px !important;
  }

  body.wp-child-theme-marnamic.marnamic-archive-search-results
    .marnamic-archive-workspace-actions
    .marnamic-archive-filter-button {
    width: 100% !important;
  }

  body.wp-child-theme-marnamic.marnamic-vendor-discovery
    .hp-page__header
    .marnamic-archive-discovery-filter-button {
    width: 100% !important;
    justify-self: stretch !important;
    margin-top: -4px !important;
  }
}

@media (prefers-reduced-motion: no-preference) {
  body.wp-child-theme-marnamic:is(.marnamic-archive-search-results, .marnamic-vendor-discovery)
    > .marnamic-archive-filter-shell.marnamic-archive-filter-dialog
    > :is(.hp-widget--vendor-filter, .hp-widget--listing-filter) {
    animation: marnamic-archive-filter-enter 160ms ease-out both;
  }
}

@keyframes marnamic-archive-filter-enter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
