/* Shared mobile filter sheet. It stays inside the results section so the
   collapsed action bar is sticky only while that section is being browsed. */
.mobile-filter-sheet-root {
  /* Keep the iOS home-indicator inset outside the visible panel. */
  --mobile-filter-actions-height: calc(42px + 1.5rem);
  --mobile-filter-available-height: calc(
    var(--mobile-filter-viewport-height, 100dvh)
    - var(--bs-navbar-height, 72px)
    - env(safe-area-inset-top, 0px)
    - 1.5rem
  );
  position: sticky !important;
  /* Preserve the same outer gap without counting the safe area twice. */
  bottom: max(0px, calc(0.75rem - env(safe-area-inset-bottom, 0px)));
  /* The navbar blur starts at 1028 and the mobile navigation at 1030. */
  z-index: 1025;
  width: 100%;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  flex: 0 0 100%;
  min-width: 0;
  margin: 0 ;
  pointer-events: none;
}

@media (max-width: 767.98px) {
  .mobile-filter-sheet-root[data-mobile-filter-sheet-state="closed"],
  .mobile-filter-sheet-root[data-mobile-filter-sheet-state="open"] {
    display: block !important;
  }
}

.mobile-filter-sheet__panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: var(--mobile-filter-actions-height);
  padding: 0;
  overflow: hidden;
  pointer-events: auto;
  background: rgba(235, 235, 235, 0.85);
  border-radius: 1rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
  backdrop-filter: blur(14px);
  transition: max-height 0.6s cubic-bezier(0.77, 0, 0.2, 1);
}

[data-bs-theme="dark"] .mobile-filter-sheet__panel {
  background: rgba(12, 12, 12, 0.85);
}

.mobile-filter-sheet__content {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 0;
  width: 100%;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  transform: translateY(2rem);
  transition:
    max-height 0.6s cubic-bezier(0.77, 0, 0.2, 1),
    opacity 0.3s ease,
    transform 0.45s ease,
    visibility 0s linear 0.6s;
}

.mobile-filter-sheet-root[data-mobile-filter-sheet-state="open"] .mobile-filter-sheet__panel {
  max-height: min(720px, var(--mobile-filter-available-height));
}

.mobile-filter-sheet-root[data-mobile-filter-sheet-state="open"] .mobile-filter-sheet__content {
  max-height: calc(min(720px, var(--mobile-filter-available-height)) - var(--mobile-filter-actions-height));
  overflow-y: auto;
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  transition:
    max-height 0.6s cubic-bezier(0.77, 0, 0.2, 1),
    opacity 0.4s ease 0.12s,
    transform 0.45s ease 0.08s,
    visibility 0s linear 0s;
}

.mobile-filter-sheet__actions {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem;
  background: none;
}

/* A modal always owns the viewport. This also covers interrupted Bootstrap
   transitions where the JS hide event did not reach the sheet controller. */
body.modal-open .mobile-filter-sheet-root,
.mobile-filter-sheet-root[data-mobile-filter-modal-suppressed="true"] {
  visibility: hidden !important;
  pointer-events: none !important;
}

@media (max-width: 767.98px) {
  /* These fixed global controls otherwise sit directly on top of the closed
     action bar on routes that expose a mobile filter sheet. */
  body.mobile-filter-sheet-present #xds-cookie-banner,
  body.mobile-filter-sheet-present .xds-cookie-fab {
    bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px));
  }

  body.mobile-filter-sheet-present #xds-share-toast,
  body.mobile-filter-sheet-present #xds-share-toast-fallback {
    bottom: calc(5.25rem + env(safe-area-inset-bottom, 0px)) !important;
  }
}

.mobile-filter-sheet__actions .btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 42px;
}

@media (prefers-reduced-motion: reduce) {
  .mobile-filter-sheet__panel,
  .mobile-filter-sheet__content {
    transition: none !important;
  }
}

@media (min-width: 768px) {
  .mobile-filter-sheet-root,
  .mobile-filter-sheet-root[data-mobile-filter-sheet-state="closed"],
  .mobile-filter-sheet-root[data-mobile-filter-sheet-state="open"] {
    display: none !important;
  }
}
