.exhibitions-router {
  position: relative;
  isolation: isolate;
  padding-block: 3rem;
}

/* Heading is the Figma "Headline/H3" style = Text Std Bold, not Display.
   Overrides x-intro-stack's hard-coded font-display (card titles use font-sans
   in the markup). */
.exhibitions-router__heading {
  font-family: var(--font-sans);
}

@media (min-width: 60rem) {
  .exhibitions-router {
    padding-block: 4rem;
  }
}

/* ── Intro: heading | body columns (heading column wider, matches Figma) ── */
@media (min-width: 60rem) {
  .exhibitions-router__intro .exhibitions-router__lead {
    grid-template-columns: 848fr 448fr;
  }
}

/* ── Filter trigger + count badge ──────────────────────────────────── */
.exhibitions-router__filters-toggle {
  background: var(--color-charcoal);
  font-size: var(--text-body);
  cursor: pointer;
}

/* Filter opener: plain colour switch on hover, no slide-fill */
.exhibitions-router__filters-toggle:hover,
.exhibitions-router__filters-toggle:focus-visible {
  background: var(--er-accent, var(--color-light-blue));
  color: var(--color-charcoal);
}

/* Slide-fill hover (mirrors the theme btn-* pattern): a ::before wipes in from
   the left. Apply = light to dark accent. */
.exhibitions-router__apply {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  transition: color 0.3s ease;
}

.exhibitions-router__apply::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  transform: translate3d(-101%, 0, 0);
  transition: transform 600ms var(--ease-settle);
}

.exhibitions-router__apply:hover::before,
.exhibitions-router__apply:focus-visible::before {
  transform: translate3d(0, 0, 0);
}

/* Small bordered pill showing the active-filter count */
.exhibitions-router__filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start; /* sits at the top of the "Filters" text, like a sup */
  /* Snug ~13px circle (Figma 2067-78220); min-width + pill radius so a 2-digit
     count grows into a pill instead of clipping. */
  min-width: 0.8125rem;
  height: 0.8125rem;
  padding-inline: 0.15rem;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: inherit; /* follows the trigger (white at rest, charcoal on hover) / modal title */
  font-size: 0.625rem; /* 10px */
  font-weight: 400;
  line-height: 1;
  text-align: center;
}

.exhibitions-router__filter-count.is-hidden {
  display: none;
}

/* ── Filter modal ──────────────────────────────────────────────────── */
.exhibitions-router__modal[hidden] {
  display: none;
}

.exhibitions-router__modal {
  position: fixed;
  inset: 0;
  z-index: 1000; /* above the sticky site header (z-50); JS portals it to <body> */
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.exhibitions-router__modal.is-open {
  opacity: 1;
}

/* Logged-in: offset the modal below WP's fixed admin bar (WP's own px breakpoints). */
@media (min-width: 601px) {
  body.admin-bar .exhibitions-router__modal {
    top: 46px;
  }
}

@media (min-width: 783px) {
  body.admin-bar .exhibitions-router__modal {
    top: 32px;
  }
}

.exhibitions-router__modal-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--color-charcoal) 50%, transparent);
  border: 0;
}

/* Anchored top-left, full viewport height; groups scroll within (header +
   footer stay pinned). */
.exhibitions-router__modal-panel {
  position: relative;
  display: flex;
  width: 100%;
  max-width: 45rem;
  height: 100%;
  /* Right padding (4.25rem) clears the scrollbar rail. */
  padding: 2rem 4.25rem 2rem 2rem;
  background: var(--er-accent-dark, var(--color-dark-blue));
  transform: translateX(-2rem);
  transition: transform 0.3s ease;
}

.exhibitions-router__modal.is-open .exhibitions-router__modal-panel {
  transform: translateX(0);
}

.exhibitions-router__modal-form {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* ── Modal header ──────────────────────────────────────────────────── */
.exhibitions-router__modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  /* Reserves the close-X band (2rem); divider lands at 5rem, aligned with the scrollbar top. */
  min-height: 2rem;
}

.exhibitions-router__modal-title {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--text-body);
}

/* Close X pinned at the top of the right rail; the scroll indicator runs below
   it (mirrors SectionNavigation's sticky-close-over-scroll pattern). */
.exhibitions-router__modal-close {
  position: absolute;
  top: 2rem;
  right: 1.125rem; /* keeps the X centred over the scrollbar (both centre at 34px from the edge) */
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  cursor: pointer;
}

.exhibitions-router__modal-divider,
.exhibitions-router__group-divider {
  flex: none; /* never let the flex column compress the 1px line to nothing */
  height: 1px;
  background: var(--color-white);
}

/* ── Scrollable groups ─────────────────────────────────────────────── */
.exhibitions-router__groups {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  /* Tighter gap so collapsed groups sit close (the divider also has this gap on
     each side, so it doubles between rows). BugHerd #149. */
  gap: 1rem;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none; /* custom progress bar stands in */
}

.exhibitions-router__groups::-webkit-scrollbar {
  display: none;
}

.exhibitions-router__group {
  flex: none; /* keep full height; the groups container scrolls instead */
  display: flex;
  flex-direction: column;
}

/* Gap between the row and its options only when open, so a closed group leaves no
   empty space below its row (#149). */
.exhibitions-router__group[open] {
  gap: 2rem;
}

.exhibitions-router__group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
  list-style: none;
  font-size: var(--text-body);
}

.exhibitions-router__group-row::-webkit-details-marker {
  display: none;
}

.exhibitions-router__chevron {
  flex: none;
  transition: transform 0.2s ease;
}

.exhibitions-router__group[open] .exhibitions-router__chevron {
  transform: rotate(180deg);
}

.exhibitions-router__group-options {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.exhibitions-router__option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: var(--text-body); /* Body/P2 — base 16px */
  font-weight: 400;
  line-height: 1.2;
}

/* White square checkbox; filled white when checked (matches Figma) */
.exhibitions-router__checkbox {
  appearance: none;
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  border: 1px solid var(--color-white);
  background: transparent;
  cursor: pointer;
}

.exhibitions-router__checkbox:checked {
  background: var(--color-white);
}

/* ── Footer actions ────────────────────────────────────────────────── */
.exhibitions-router__modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.exhibitions-router__modal-actions .exhibitions-router__clear {
  font-size: var(--text-body-small);
  text-decoration: none; /* overrides the theme-global link underline */
}

.exhibitions-router__modal-actions .exhibitions-router__clear:hover,
.exhibitions-router__modal-actions .exhibitions-router__clear:focus-visible {
  text-decoration: underline;
}

.exhibitions-router__apply {
  background: var(--er-accent, var(--color-light-blue));
  font-size: var(--text-body);
  cursor: pointer;
}

.exhibitions-router__apply::before {
  background: var(--er-accent-dark, var(--color-dark-blue));
}

.exhibitions-router__apply:hover,
.exhibitions-router__apply:focus-visible {
  color: var(--color-white);
}

@media (prefers-reduced-motion: reduce) {
  .exhibitions-router__apply::before {
    transition: none;
  }
}

/* ── Scroll progress bar ───────────────────────────────────────────── */
.exhibitions-router__scrollbar {
  position: absolute;
  top: 5rem; /* aligns with the divider under the header (padding 2rem + header 2rem + gap 1rem) */
  bottom: 2rem;
  right: 2rem; /* 32px clear to the panel edge; centred under the close X */
  width: 4px;
  background: color-mix(in srgb, var(--color-white) 50%, transparent);
}

.exhibitions-router__scrollbar[hidden] {
  display: none;
}

.exhibitions-router__scrollbar-thumb {
  position: absolute;
  left: 0;
  width: 100%;
  background: var(--color-white);
}

/* ── Active filter pills ───────────────────────────────────────────── */
/* Active-row "Clear All" — no underline (overrides the theme-global link rule). */
.exhibitions-router__active .exhibitions-router__clear {
  text-decoration: none;
}

.exhibitions-router__pill {
  background: var(--er-accent, var(--color-light-blue));
  font-size: var(--text-body-small);
  text-decoration: none;
}

.exhibitions-router__pill:hover,
.exhibitions-router__pill:focus-visible {
  background: var(--er-accent-dark, var(--color-dark-blue));
  color: var(--color-white);
}

/* ── Current + Upcoming / Past date toggle ─────────────────────────── */
.exhibitions-router__when {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  font-size: var(--text-body-small);
}

/* Both labels stay plain charcoal — the knob position signals the active state
   (matches Figma). aria-current carries it for assistive tech. */
.exhibitions-router__when-opt {
  color: var(--color-charcoal);
  text-decoration: none;
  white-space: nowrap;
}

.exhibitions-router__when-opt:hover,
.exhibitions-router__when-opt:focus-visible {
  text-decoration: underline;
}

/* Outlined pill switch (matches Figma) — a link that toggles the bucket. The
   filled knob sits left for "current + upcoming", right for "past". */
.exhibitions-router__when-track {
  position: relative;
  display: inline-block;
  width: 2.75rem;
  height: 1.5rem;
  flex-shrink: 0;
  border: 1.5px solid var(--color-charcoal);
  border-radius: 999px;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.exhibitions-router__when-track:focus-visible {
  outline: 2px solid var(--color-charcoal);
  outline-offset: 2px;
}

.exhibitions-router__when-knob {
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--color-charcoal);
  transition: transform 0.2s ease;
}

.exhibitions-router__when-track[data-when="past"] .exhibitions-router__when-knob {
  transform: translateX(1.1875rem);
}

@media (prefers-reduced-motion: reduce) {
  .exhibitions-router__when-knob {
    transition: none;
  }
}

/* Full-screen on small viewports */
@media (max-width: 47.9375rem) {
  .exhibitions-router__modal-panel {
    max-width: none;
    max-height: 100%;
    height: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .exhibitions-router__chevron,
  .exhibitions-router__modal,
  .exhibitions-router__modal-panel {
    transition: none;
  }

  .exhibitions-router__modal-panel {
    transform: none;
  }
}

/* ── Results grid (explicit balanced columns → masonry-style) ──────── */
.exhibitions-router__grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.exhibitions-router__col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 60rem) {
  .exhibitions-router__grid {
    flex-direction: row;
    align-items: flex-start;
  }

  .exhibitions-router__col {
    flex: 1 1 0;
    min-width: 0;
  }
}

/* ── Card ────────────────────────────────────────────────────────── */
.exhibitions-router__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--color-charcoal);
  /* Lift via `translate` (not `transform`): the GSAP reveal animates this card's
     transform, so a transform transition would fight it. */
  transition: translate 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* Hover/focus fills the card with the dark accent and flips text to white. */
.exhibitions-router__card:hover,
.exhibitions-router__card:focus-within {
  translate: 0 -4px;
  background: var(--er-accent-dark, var(--color-dark-blue));
  border-color: var(--er-accent-dark, var(--color-dark-blue));
  color: var(--color-white);
}

.exhibitions-router__img {
  display: block;
  width: 100%;
  height: auto;
}

.exhibitions-router__img--placeholder {
  aspect-ratio: 4 / 3;
  background: #d9d9d9;
}

/* Media caption (from the image's Caption field). Base muted colour is the
   `text-charcoal/70` utility; the hovered/focused card flips text to white, so
   re-flip the caption to off-white at the same 70% (mirrors ExhibitionsCarousel). */
.exhibitions-router__caption {
  margin: 0.5rem 0 0;
}

.exhibitions-router__card:hover .exhibitions-router__caption,
.exhibitions-router__card:focus-within .exhibitions-router__caption {
  color: color-mix(in srgb, var(--color-off-white) 70%, transparent);
}

.exhibitions-router__content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2rem;
}

.exhibitions-router__text {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.exhibitions-router__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.exhibitions-router__tag {
  line-height: 1;
  background: var(--er-accent, var(--color-light-blue));
  color: var(--color-charcoal);
}

/* Date line (between the tag and the title) */
.exhibitions-router__date {
  font-size: var(--text-body);
}

/* Event details — audience term(s) with an icon */
.exhibitions-router__details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.exhibitions-router__detail {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.exhibitions-router__detail-icon {
  flex: none;
  height: 1.625rem;
  width: auto; /* mixed-ratio glyphs share a height, keep their aspect */
}

.exhibitions-router__detail-label {
  line-height: 1.2;
}

/* Title link — drop the global underline (only the CTA cue is underlined).
   No own colour transition: the global `a` transition-colors (150ms) otherwise
   lags behind the card's 0.3s hover colour change; let the link track the card. */
.exhibitions-router__card-link {
  color: inherit;
  text-decoration: none;
  transition: none;
}

/* Stretched link: a click anywhere on the card follows the title link. */
.exhibitions-router__card-link::after {
  content: "";
  position: absolute;
  inset: 0;
}

.exhibitions-router__card-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── CTA cue (visual only) ───────────────────────────────────────── */
.exhibitions-router__cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: auto;
  text-transform: uppercase;
}

.exhibitions-router__cta > span:first-child {
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-underline-offset: 3px;
  transition: text-decoration-color 0.3s ease;
}

.exhibitions-router__card:hover .exhibitions-router__cta > span:first-child,
.exhibitions-router__card:focus-within .exhibitions-router__cta > span:first-child {
  text-decoration-color: transparent;
}

/* Internal link → arrow points right (→); external link → up-right (↗).
   Nudges along its own axis on hover. */
.exhibitions-router__cta svg {
  flex: none;
  transition: transform 0.3s ease;
}

.exhibitions-router__cta--external svg {
  transform: rotate(-45deg);
}

.exhibitions-router__card:hover .exhibitions-router__cta svg,
.exhibitions-router__card:focus-within .exhibitions-router__cta svg {
  transform: translateX(4px);
}

.exhibitions-router__card:hover .exhibitions-router__cta--external svg,
.exhibitions-router__card:focus-within .exhibitions-router__cta--external svg {
  transform: rotate(-45deg) translateX(4px);
}

/* ── Pagination (Figma 2080-81708): 25px cells, active = filled charcoal ── */
.exhibitions-router__page,
.exhibitions-router__ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5625rem; /* 25px */
  height: 1.5625rem;
  color: var(--color-charcoal);
  font-size: var(--text-body-medium); /* 18px */
  line-height: 1.2;
  text-decoration: none;
}

.exhibitions-router__page--prev svg {
  transform: rotate(180deg);
}

.exhibitions-router__page.is-current {
  background: var(--color-charcoal);
  color: var(--color-white);
}

.exhibitions-router__page:not(.is-current):hover,
.exhibitions-router__page:not(.is-current):focus-visible {
  background: var(--color-charcoal);
  color: var(--color-white);
}

@media (prefers-reduced-motion: reduce) {
  .exhibitions-router__card {
    transition: none;
  }

  .exhibitions-router__card:hover,
  .exhibitions-router__card:focus-within {
    translate: none;
  }

  .exhibitions-router__cta svg,
  .exhibitions-router__card:hover .exhibitions-router__cta svg,
  .exhibitions-router__card:focus-within .exhibitions-router__cta svg {
    transition: none;
    transform: none;
  }

  .exhibitions-router__cta--external svg,
  .exhibitions-router__card:hover .exhibitions-router__cta--external svg,
  .exhibitions-router__card:focus-within .exhibitions-router__cta--external svg {
    transform: rotate(-45deg);
  }
}
