/* ============================================================
   Mobile Filter Drawer — shared across all hub & directory pages
   Usage: Add class "has-mobile-filter-drawer" to the page <body>
          or to the main-layout wrapper.
   ============================================================ */

/* Filter toggle button — only visible on mobile */
.filter-toggle-mobile {
  display: none;
  align-items: center;
  gap: 8px;
  background: #172a74;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(23, 42, 116, 0.25);
  transition: background 0.2s;
}
.filter-toggle-mobile:hover { background: #12225f; }
.filter-toggle-mobile i { font-size: 1rem; }
.filter-toggle-mobile .filter-count-badge {
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

/* Mobile backdrop overlay */
.filter-drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1040;
  opacity: 0;
  transition: opacity 0.3s;
}
.filter-drawer-backdrop.active {
  display: block;
  opacity: 1;
}

/* On mobile: sidebar becomes a slide-in drawer */
@media (max-width: 991.98px) {
  /* Show the toggle button */
  .filter-toggle-mobile { display: inline-flex; }

  /* Override the parent grid layout so sidebar is positioned for drawer */
  .main-layout,
  .dir-main-layout {
    position: relative;
  }

  /* Filter panel becomes fixed drawer */
  .filter-panel,
  .filters-panel,
  .filter-sidebar,
  .dir-filter-panel {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    height: 100dvh;
    z-index: 1050;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 0 !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2) !important;
    padding-bottom: env(safe-area-inset-bottom, 16px) !important;
    padding-top: 16px !important;
  }

  /* When drawer is open */
  .filter-panel.drawer-open,
  .filters-panel.drawer-open,
  .filter-sidebar.drawer-open,
  .dir-filter-panel.drawer-open {
    transform: translateX(0);
  }

  /* Close button inside the drawer */
  .filter-drawer-close {
    display: flex;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #f3f4f6;
    color: #374151;
    font-size: 1.1rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  }
  .filter-drawer-close:hover { background: #e5e7eb; }

  /* Ensure the filter panel doesn't keep sticky on mobile */
  .filter-panel,
  .filters-panel,
  .filter-sidebar,
  .dir-filter-panel {
    top: 0 !important;
  }
}

/* Small phones: even tighter drawer */
@media (max-width: 400px) {
  .filter-panel,
  .filters-panel,
  .filter-sidebar,
  .dir-filter-panel {
    width: 100vw !important;
    max-width: 100vw !important;
  }
}

/* Desktop: hide toggle and close button, reset drawer styles */
@media (min-width: 992px) {
  .filter-toggle-mobile { display: none !important; }
  .filter-drawer-close { display: none !important; }
  .filter-drawer-backdrop { display: none !important; }
}
