/**
 * Marketplace discovery — sidebar filters, gallery layout, mobile drawer.
 */
.discovery-layout {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: var(--space-5, 24px);
  align-items: start;
}

/* Results column width cap — this is what fixes the column count.
   The homepage gallery is always 4-across because its grid sits inside
   .container (max-width 1280px, centered), so the grid itself is capped at
   1216px no matter how wide the screen is. The discovery results column had no
   cap, so repeat(auto-fill, minmax(260px, 1fr)) kept adding columns as the
   viewport grew — measured 4 at 1440px, 5 at 1920px and 8 at 2560px, against
   the homepage's constant 4.
   1216px = 4 x 286px cards + 3 x 24px gaps, i.e. the homepage grid's exact
   width, so cards, gutters and column count all match the reference.
   Applied to .discovery-main (toolbar + gallery) rather than .discovery-layout
   so the filters sidebar keeps its current position untouched, and the toolbar
   stays aligned with the gallery beneath it. */
/* Members section hero gradient.
   Its siblings (--digital, --jobs, --ai-services, --physical-marketplace) live in
   banner.css, and that is where this rule belongs by cohesion — but banner.css
   reaches the browser through `@import url('banner.css')` inside enterprise.css,
   with NO cache-buster on the imported URL. The CDN therefore keeps serving the
   pre-edit copy (cf-cache-status: HIT, max-age=14400), so a rule added there does
   not take effect for up to 4 hours. marketplace-discovery.css is linked with the
   ?v= version, is already the discovery pages' own stylesheet, and loads after
   enterprise.css — so the variant is defined here, once, and applies immediately.
   Same three-stop construction as the other variants, closing on the shared
   #24b7e5 accent. */
.section-hero--members {
  background-image: linear-gradient(135deg, #0f3d3e 0%, #146c66 50%, #24b7e5 100%);
}

/* Services section hero — WorkAndHire brand red.
   Built entirely from the existing brand tokens in tokens.css, no new colours:
     --color-primary        #8c0605
     --color-primary-hover  #6e0504
     --color-primary-active #560403
   Same 135deg three-stop construction as the other section-hero variants. It
   deliberately stays within the red ramp rather than closing on the #24b7e5
   accent, so it does not become a near-duplicate of --physical-marketplace,
   which is the other red hero and already ends on that accent.
   Lives here rather than in banner.css for the same reason as --members above:
   banner.css is @imported without a cache-buster and serves stale for up to 4h. */
.section-hero--services {
  background-image: linear-gradient(
    135deg,
    var(--color-primary, #8c0605) 0%,
    var(--color-primary-hover, #6e0504) 55%,
    var(--color-primary-active, #560403) 100%
  );
}

.discovery-main {
  /* width:100% is required, not optional: .discovery-main is a grid item, and
     `margin-inline: auto` alone makes a grid item shrink-to-fit its content
     instead of filling its track — that collapsed the gallery to 708px / 2
     columns. width:100% keeps it filling the track, max-width caps it, and the
     auto margins then centre the capped block. */
  width: 100%;
  max-width: 1216px;
  margin-inline: auto;
  /* min-width:0 is required on this grid item so it never grows past its track.
     A grid item defaults to min-width:auto (= min-content), so a non-wrapping
     child — the horizontal .discovery-category-nav chip row — would otherwise
     expand the column past the viewport at the <=992px breakpoint (where the
     track is `1fr` = minmax(auto,1fr)), causing page-wide horizontal overflow.
     With min-width:0 the track caps to the viewport and the nav's own
     overflow-x:auto scrolls the chips internally instead. Harmless on desktop,
     where the track is already minmax(0,1fr). */
  min-width: 0;
}

.discovery-sidebar {
  position: sticky;
  top: calc(var(--header-height, 72px) + 16px);
  background: var(--color-bg, #fff);
  border: 1px solid var(--color-border, #d0d0d0);
  border-radius: var(--radius-md, 8px);
  padding: var(--space-4, 16px);
}

.discovery-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3, 12px);
}

.discovery-sidebar__title {
  margin: 0;
  font-size: 1.1rem;
}

/* Same specificity defect as the toolbar button below: `button.btn` (0,1,1) was
   beating `.discovery-sidebar__close` (0,1,0), so the drawer's "Close" button
   also showed on desktop — where the sidebar is static and there is nothing to
   close. Qualified with `button.` so the intended rule applies; it is still shown
   at <=992px where the sidebar really is an off-canvas drawer. */
button.discovery-sidebar__close {
  display: none;
}

.discovery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3, 12px);
  margin-bottom: var(--space-4, 16px);
}

/* Horizontal category nav strip (digital discovery / category landing pages).
   Scrolls horizontally on narrow screens rather than wrapping into a tall block. */
.discovery-category-nav {
  display: flex;
  gap: var(--space-2, 8px);
  overflow-x: auto;
  padding-bottom: var(--space-2, 8px);
  margin-bottom: var(--space-3, 12px);
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.discovery-category-nav__chip {
  flex: 0 0 auto;
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 999px;
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--color-text, #1f2937);
  white-space: nowrap;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.discovery-category-nav__chip:hover {
  border-color: var(--color-primary, #2563eb);
  color: var(--color-primary, #2563eb);
}
.discovery-category-nav__chip.is-active {
  background: var(--color-primary, #2563eb);
  border-color: var(--color-primary, #2563eb);
  color: #fff;
}
/* Category-nav strip rendered at the TOP of the main results column (services
   discovery), i.e. inside .discovery-main and to the right of the filters sidebar,
   so it is centred within the content column and aligned with the cards below —
   never over/under the sidebar. Adds breathing room under the banner; horizontal
   scroll on narrow screens is inherited from .discovery-category-nav so it never
   overflows the page. */
.discovery-category-nav--top {
  margin-top: 0;
  margin-bottom: var(--space-4, 16px);
}
/* Smarter empty state (message + optional reset CTA) */
.wah-gallery-empty { text-align: center; padding: var(--space-5, 32px) var(--space-3, 12px); }
.wah-gallery-empty__msg { margin: 0 0 var(--space-3, 12px); color: var(--color-text-muted, #6c6c6c); }

.discovery-toolbar__count {
  margin: 0;
  color: var(--color-text-muted, #6c6c6c);
  font-size: 0.95rem;
}

.discovery-toolbar__sort {
  margin-left: auto;
}

/* Toolbar "Filters" button — hidden on desktop, shown on mobile.
   That was always the intent of these rules, but they never took effect: the
   element is <button class="btn btn-outline discovery-toolbar__filters">, and
   `.btn, button.btn, input[type="submit"].btn { display: inline-flex }` matches it
   at specificity (0,1,1), which outranks a bare `.discovery-toolbar__filters`
   (0,1,0). So the button stayed visible at every width, duplicating the sidebar's
   own "Filters" heading above the gallery. Qualifying the selector with `button.`
   ties that specificity, and this file loads after enterprise.css, so it wins on
   source order — no !important needed. */
button.discovery-toolbar__filters {
  display: none;
}

.discovery-filters__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2, 8px);
  margin-top: var(--space-3, 12px);
}

/* Members filter panel — sticky Apply/Clear action bar (2026-07-31 task).
   .discovery-sidebar becomes its own scroll container (bounded to viewport
   height) so a long filter list scrolls internally instead of requiring the
   whole page to be scrolled to reach the buttons; .discovery-filters__actions
   is then pinned to the bottom of that container via position:sticky.
   This stylesheet is shared by every marketplace discovery page (services,
   digital, jobs, ai-services, physical-marketplace, members), so everything
   here is scoped under .discovery-page--members (set in page.php) — only
   the Members page filter panel is affected. On mobile the sidebar is
   already the off-canvas drawer with its own overflow:auto (see the
   max-width:992px block below), so the same sticky rule applies there too
   without any extra media query. */
.discovery-page--members .discovery-sidebar {
  max-height: calc(100vh - var(--header-height, 72px) - 32px);
  overflow-y: auto;
}

.discovery-page--members .discovery-filters__actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding-top: var(--space-2, 8px);
  background: var(--color-bg, #fff);
  border-top: 1px solid var(--color-border, #d0d0d0);
}

.discovery-gallery {
  margin-bottom: var(--space-5, 24px);
}

.discovery-empty__title {
  margin: 0 0 var(--space-2, 8px);
}

.discovery-empty__message {
  margin: 0;
  color: var(--color-text-muted, #6c6c6c);
}

.featured-discovery {
  padding: var(--space-6, 32px) 0;
}

.featured-discovery + .featured-discovery {
  padding-top: 0;
}

.featured-discovery__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-3, 12px);
  margin-bottom: var(--space-4, 16px);
}

.featured-discovery__header h2 {
  margin: 0 0 4px;
}

.featured-discovery__sub {
  margin: 0;
  color: var(--color-text-muted, #6c6c6c);
}

.header-search {
  display: flex;
  align-items: center;
  gap: 0;
  max-width: 360px;
  width: 100%;
}

.header-search__input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--color-border, #d0d0d0);
  border-right: 0;
  border-radius: var(--radius-sm, 4px) 0 0 var(--radius-sm, 4px);
  padding: 8px 12px;
  font-size: 0.9rem;
}

.header-search__btn {
  border-radius: 0 var(--radius-sm, 4px) var(--radius-sm, 4px) 0;
  white-space: nowrap;
}

@media (max-width: 992px) {
  .discovery-layout {
    grid-template-columns: 1fr;
  }

  .discovery-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1200;
    width: min(320px, 88vw);
    max-height: 100vh;
    overflow: auto;
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    top: 0;
    border-radius: 0;
  }

  .discovery-sidebar.is-open {
    transform: translateX(0);
  }

  button.discovery-sidebar__close {
    display: inline-flex;
  }

  /* Kept on mobile: below 992px .discovery-sidebar is position:fixed and slid
     off-canvas, so this button is the only way to open the filter drawer. */
  button.discovery-toolbar__filters {
    display: inline-flex;
  }

  .header-search {
    display: none;
  }
}

@media (min-width: 993px) {
  .wah-header__center .header-search {
    display: flex;
  }
}

@media (max-width: 768px) {
  /* Redundant with the 992px rule above (which already covers this range) but
     kept so the selector stays consistent if either breakpoint is retuned. */
  button.discovery-toolbar__filters {
    display: inline-flex;
  }

  /* Match the homepage's mobile inset. The discovery pages have no horizontal
     page padding, so at 390px the gallery sat flush against both screen edges
     (measured x=0, rightGap=0) while the homepage gallery is inset 12px. Safe to
     apply here: below 992px .discovery-sidebar is position:fixed and out of
     flow, so this only insets the results column, never the filters panel. */
  .discovery-page {
    padding-inline: 12px;
  }
}

.discovery-filters .checkbox-inline {
  display: block;
  margin-bottom: 6px;
}

/* Filter drawer backdrop (mobile) */
.discovery-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1190;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.discovery-sidebar-backdrop:not([hidden]) {
  opacity: 1;
  visibility: visible;
}

body.discovery-filters-open {
  overflow: hidden;
}
