@charset "UTF-8";
/**
 * █████████████████████████████████
 *
 * 🎨 Facets UI (SCSS)
 *
 * █████████████████████████████████
 *
 * UI for the facets/filtering system.
 *
 * Features:
 * - Uses global CSS custom properties (`--map-*`) for theme consistency
 * - Accessible disclosure pattern via <details>/<summary>
 * - Overlay modal for small screens
 * - Button primitives for consistent actions
 *
 * Dependencies:
 * - Map plugin foundation tokens (`_foundation.scss`)
 */
.facet-container {
  font-family: inherit;
  color: var(--map-text-primary);
}

/*  ==================================================
      🎛️ Trigger Button
    ==================================================  */
.facet-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--map-spacing-sm);
  padding: 0.5rem 0.75rem;
  background: var(--map-primary-color);
  color: var(--map-background-white);
  border: none;
  border-radius: var(--map-border-radius-sm);
  cursor: pointer;
  font-size: var(--map-font-size-sm);
  transition: background-color var(--map-transition-fast);
}
.facet-trigger:hover {
  background: var(--map-primary-hover);
}

.trigger-icon {
  font-size: var(--map-font-size-base);
}

.filter-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.2rem var(--map-spacing-xs);
  border-radius: var(--map-border-radius-lg);
  font-size: var(--map-font-size-xs);
  min-width: 1.2rem;
  text-align: center;
}

.facet-label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--map-spacing-xs);
}

.facet-options {
  display: grid;
  gap: var(--map-spacing-sm);
  text-wrap: balance;
}

.option-item {
  display: flex;
  align-items: baseline;
  gap: calc(var(--map-spacing-xs) * 0.75);
  /* Virtual fields toggle via [hidden]; without this, display:flex keeps them visible */
}
.option-item[hidden] {
  display: none;
}
.option-item input[type=checkbox] {
  grid-column: 1;
  align-self: flex-start;
  margin-top: 0.1rem;
  margin-right: 0.5ch;
}
.option-item .option-label {
  font-size: 0.9rem;
  flex: 1 1 0%;
  align-self: baseline;
  font-size: 0.9rem;
}
.option-item .option-count {
  font-size: 0.65rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  align-self: baseline;
  font-family: var(--f-mono);
}

.option-count {
  color: var(--map-text-muted);
  font-size: var(--map-font-size-sm);
}

/*  ==================================================
      🪟 Overlay (small screens)
    ==================================================  */
.facet-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: var(--map-z-overlay);
  /* Explicit hidden state — overrides display:flex when [hidden] attribute is set */
}
.facet-overlay[hidden] {
  display: none;
}

.overlay-modal {
  width: min(960px, 92vw);
  background: var(--map-background-white);
  border-radius: var(--map-border-radius-md);
  box-shadow: var(--map-shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--map-border-light);
}

.overlay-content {
  padding: 1rem;
  flex: 1 1 auto;
  overflow: auto;
  /* overlay-content already pads; avoid double gutter with .facets-list */
}
.overlay-content .facets-list {
  padding: 0;
  gap: var(--map-spacing-sm);
}
.overlay-content .filter-actions {
  padding: var(--map-spacing-sm) 0 0;
  margin-top: var(--map-spacing-xs);
}

.overlay-header h3 {
  margin: 0;
  font-size: var(--map-font-size-lg);
  font-weight: 600;
  color: var(--map-text-primary);
  line-height: 1.2;
}

.close-button {
  background: var(--map-background-medium);
  border: none;
  font-size: var(--map-font-size-xl);
  cursor: pointer;
  color: var(--map-text-secondary);
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--map-border-radius-sm);
  transition: all var(--map-transition-fast) ease;
}
.close-button:hover {
  color: var(--map-text-primary);
}

.filter-actions {
  display: flex;
  gap: var(--map-spacing-sm);
  padding: 0.75rem 1rem;
}

/*  ==================================================
      🧩 Facets List Layout
    ==================================================  */
.facets-list {
  display: flex;
  flex-direction: column;
  gap: var(--map-spacing-lg);
  padding: var(--map-spacing-md);
}

.facet-item {
  background-color: var(--map-background-white);
  border: 1px solid var(--map-border-color);
  border-radius: var(--map-border-radius-md);
  transition: all var(--map-transition-fast);
}
.facet-item:hover {
  border-color: var(--map-primary-color);
  box-shadow: var(--map-shadow-sm);
}
.facet-item fieldset {
  border: none;
}

/* Spaces-data toggle — header row above facet cards (map template only) */
.facet-spaces-data {
  border-bottom: 1px solid var(--map-border-light);
  margin-bottom: var(--map-spacing-xs);
}
.facet-spaces-data .facet-spaces-data-header {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--map-spacing-sm);
  align-items: flex-start;
  padding: 0.9rem var(--map-spacing-md);
  margin: 0;
  cursor: pointer;
  font-size: var(--map-font-size-lg);
  font-weight: 600;
  color: var(--map-text-primary);
  line-height: 1.3;
}
.facet-spaces-data .facet-spaces-data-checkbox {
  margin: 0.15rem 0 0;
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
  accent-color: var(--map-primary-color);
}
.facet-spaces-data {
  /* Size of the pool this switch governs — the unfiltered total of spaces that
     hold accessibility data. Sits on its own grid row under the label so a long
     label wraps without shunting the number around. */
}
.facet-spaces-data .facet-spaces-data-count {
  grid-column: 2;
  font-size: var(--map-font-size-sm);
  font-weight: 500;
  color: var(--map-text-secondary);
}

/*  ==================================================
      🔘 Button Primitives
    ==================================================  */
.btn {
  padding: var(--map-spacing-xs) var(--map-spacing-sm);
  border: 0;
  border-radius: var(--map-border-radius-sm);
  cursor: pointer;
  font-size: var(--map-font-size-sm);
  transition: background-color var(--map-transition-fast);
}

.btn--primary {
  background: var(--map-primary-color);
  color: var(--map-background-white);
}

.btn--ghost {
  background: var(--map-background-light);
  color: var(--map-text-secondary);
}

.btn--primary:hover {
  background: var(--map-primary-hover);
}

.btn--ghost:hover {
  background: var(--map-background-medium);
}

.clear-filters {
  padding: var(--map-spacing-xs) var(--map-spacing-sm);
  border: 0;
  border-radius: var(--map-border-radius-sm);
  cursor: pointer;
  font-size: var(--map-font-size-sm);
  transition: background-color var(--map-transition-fast);
  background: var(--map-background-light);
  color: var(--map-text-secondary);
}

.clear-filters:hover {
  background: var(--map-background-medium);
}

.apply-filters {
  padding: var(--map-spacing-xs) var(--map-spacing-sm);
  border: 0;
  border-radius: var(--map-border-radius-sm);
  cursor: pointer;
  font-size: var(--map-font-size-sm);
  transition: background-color var(--map-transition-fast);
  background: var(--map-primary-color);
  color: var(--map-background-white);
  flex: 1;
}

.apply-filters:hover {
  background: var(--map-primary-hover);
}

.clear-filters {
  padding: 0.5rem 0.75rem;
  border-radius: var(--map-border-radius-sm);
}

/* Hide legacy per-facet Apply buttons; use global Apply Filters instead */
.apply-button {
  display: none !important;
}

/*  ==================================================
      📦 Section Container (details/summary)
    ==================================================  */
.section-container {
  /* The top-level checkbox sits beside the disclosure, not inside <summary> —
     interactive controls in a <summary> are unreachable for keyboard/AT users.
     The wrapper grid reproduces the columns the summary itself used to provide. */
}
.section-container .facet-wrapper {
  --facet-gutter: var(--map-spacing-md);
  --facet-checkbox-size: 1.1rem;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  /* The card and its dividers belong to the wrapper now; the inner
     <details> is a plain layout box. */
  border-top: 1px solid var(--map-border-light);
}
.section-container .facet-wrapper:last-child {
  border-bottom: 1px solid var(--map-border-light);
}
.section-container .facet-wrapper {
  /* Explicit placement: without it a facet that has no checkbox
     auto-places its <details> into the narrow first column. */
}
.section-container .facet-wrapper > details {
  grid-column: 2;
}
.section-container .facet-wrapper {
  /* Must out-specify the border-top above, or hover leaves the top edge grey. */
}
.section-container .facet-wrapper:hover {
  border-color: var(--map-primary-color);
}
.section-container .facet-summary-control {
  /* margin, not padding: the label's box is the click target, and it should
     stay the size of the checkbox rather than swallowing the card corner. */
  margin: 0.9rem 0 0 var(--facet-gutter);
  padding: 0;
  cursor: pointer;
}
.section-container .facet-summary-control .facet-summary-checkbox {
  display: block;
  margin: 0.15rem 0 0;
  width: var(--facet-checkbox-size);
  height: var(--facet-checkbox-size);
  cursor: pointer;
}
.section-container {
  /* Re-close the gap the checkbox column opens, so text and body keep the
     same left edge they had when both lived inside the summary. */
}
.section-container .facet-wrapper:has(.facet-summary-control) > details > summary {
  padding-left: var(--map-spacing-sm);
}
.section-container .facet-wrapper:has(.facet-summary-control) > details > .section-content {
  margin-left: calc(-1 * (var(--facet-gutter) + var(--facet-checkbox-size)));
}
.section-container {
  /* Reset default marker and make summary a clear, reachable control */
}
.section-container summary {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr auto auto;
  column-gap: var(--map-spacing-sm);
  align-items: flex-start;
  padding: 0.9rem var(--map-spacing-md);
  cursor: pointer;
  list-style: none;
  color: var(--map-text-primary);
  font-size: var(--map-font-size-lg);
}
.section-container summary::-webkit-details-marker {
  display: none;
}
.section-container summary .facet-summary-text {
  grid-column: 1;
}
.section-container summary .facet-summary-emoji {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  justify-self: end;
  font-size: 0.9em;
  line-height: 1.3;
}
.section-container summary {
  /* Focus visibility for keyboard users */
}
.section-container summary:focus-visible {
  outline: 3px solid var(--map-focus-ring);
  outline-offset: 2px;
  border-radius: var(--map-border-radius-sm);
  background: var(--map-focus-bg);
}
.section-container summary {
  /* Plus/Minus indicator */
}
.section-container summary::after {
  content: "+";
  grid-column: 3;
  grid-row: 1;
  color: var(--map-text-secondary);
  font-weight: 600;
  line-height: 1;
  align-self: flex-end; /* Align plus/minus with the bottom line of text */
  transition: transform var(--map-transition-fast);
}
.section-container details[open] > summary::after {
  content: "−"; /* true minus sign for better typographic balance */
}
.section-container {
  /* When a section is open, show a purple divider under the title block */
}
.section-container details[open] > summary {
  border-bottom: 1px solid var(--map-primary-color);
  margin-bottom: var(--map-spacing-xs);
}
.section-container {
  /* The collapsible content area */
}
.section-container .section-content {
  display: none;
  padding: var(--map-spacing-sm) var(--map-spacing-md) var(--map-spacing-md);
}
.section-container details[open] .section-content {
  display: block;
}

/*  ==================================================
      🚀 Progressive Enhancement Defaults
    ==================================================  */
facets-checkbox:not(:defined),
facets-select:not(:defined),
facets-range:not(:defined) {
  display: none;
}

.facet-form[aria-hidden=true],
.facet-form[inert] {
  display: none !important;
}

div.filter-inline {
  background-color: var(--map-background-white);
}

/* Sticky actions in inline filter containers */
div.filter-inline .filter-actions {
  position: sticky;
  bottom: 0;
  background: var(--map-background-white);
}

/* Inline filters container (actual class in markup) */
.filters-inline {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100svh;
}

.filters-inline .facets-list {
  flex: 1 1 auto;
  overflow: auto;
  /* Leave room so last facet isn't hidden behind sticky filter actions */
  padding-bottom: calc(var(--map-spacing-md) + 3.5rem);
}

.filters-inline .filter-actions {
  position: sticky;
  bottom: 0;
}

/*
█████████████████████████████████
 * 4.3 HTMX HANDLER STYLES
 *    Loading and error indicators for facet operations
█████████████████████████████████
*/
#facet-loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: var(--map-background-white);
  padding: var(--map-spacing-sm) var(--map-spacing-lg);
  border-radius: var(--map-border-radius-md);
  z-index: 9999;
  font-size: var(--map-font-size-sm);
}

#facet-error {
  position: fixed;
  top: var(--map-spacing-lg);
  right: var(--map-spacing-lg);
  background: var(--map-error-color);
  color: var(--map-background-white);
  padding: var(--map-spacing-sm) var(--map-spacing-lg);
  border-radius: var(--map-border-radius-md);
  z-index: 9999;
  font-size: var(--map-font-size-sm);
  max-width: 300px;
}

#facet-error button {
  background: none;
  border: none;
  color: var(--map-background-white);
  margin-left: var(--map-spacing-sm);
  cursor: pointer;
}

/*  ==================================================
    🔍 Autosuggest Facet Component
    (Art Spaces / title search)
    ==================================================  */
/* Autosuggest variant of the facet form */
.facet-form--autosuggest fieldset {
  padding-left: 0;
  padding-right: 0;
}
.facet-form--autosuggest {
  font-size: 0.95em;
}

.facet-autosuggest {
  position: relative;
}

.facet-autosuggest__input-wrapper {
  position: relative;
}

/* Shared icon button styling (arrow + clear) */
.facet-autosuggest__arrow,
.facet-autosuggest__clear {
  position: absolute;
  right: 0.3rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  min-height: 1rem;
  padding: 0;
  background: var(--map-background-medium);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: all var(--map-transition-fast);
}

/* Dropdown arrow button */
.facet-autosuggest__arrow::after {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--map-text-secondary);
  margin: auto;
}
.facet-autosuggest__arrow:hover::after {
  border-top-color: var(--map-text-primary);
}

/* Clear button */
.facet-autosuggest__clear {
  font-size: 0.85em;
  line-height: 1;
  color: var(--map-text-secondary);
}
.facet-autosuggest__clear:hover {
  background: var(--map-text-secondary);
  color: var(--map-background-white);
}

/* Accessible Autocomplete overrides (scoped to facet context) */
.facet-autosuggest .autocomplete__wrapper {
  position: relative;
}
.facet-autosuggest .autocomplete__input {
  width: 100%;
  padding: 0.4rem 1.45rem 0.4rem 0.6rem;
  border: 1px solid var(--map-border-color);
  border-radius: var(--map-border-radius-sm);
  font-size: var(--map-font-size-sm);
  color: var(--map-text-primary);
  background: var(--map-background-white);
  appearance: none;
  box-sizing: border-box;
}
.facet-autosuggest .autocomplete__input:hover {
  border-color: var(--map-primary-color);
}
.facet-autosuggest .autocomplete__input--focused {
  outline: 3px solid var(--map-focus-ring);
  outline-offset: 0;
  border-color: var(--map-primary-color);
}
.facet-autosuggest .autocomplete__dropdown-arrow-down {
  display: none !important;
}
.facet-autosuggest .autocomplete__menu {
  background-color: var(--map-background-white);
  border: 1px solid var(--map-border-color);
  border-top: none;
  border-radius: 0 0 var(--map-border-radius-sm) var(--map-border-radius-sm);
  margin: 0;
  padding: 0;
  max-height: 16rem;
  overflow-y: auto;
  list-style: none;
  width: 100%;
  box-sizing: border-box;
}
.facet-autosuggest .autocomplete__menu--visible {
  display: block;
}
.facet-autosuggest .autocomplete__menu--hidden {
  display: none;
}
.facet-autosuggest .autocomplete__menu--overlay {
  position: absolute;
  left: 0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.facet-autosuggest .autocomplete__option {
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  font-size: var(--map-font-size-sm);
  border-bottom: 1px solid var(--map-border-light);
}
.facet-autosuggest .autocomplete__option:last-child {
  border-bottom: none;
}
.facet-autosuggest .autocomplete__option--focused, .facet-autosuggest .autocomplete__option:hover {
  background-color: var(--map-primary-color);
  color: var(--map-background-white);
}
.facet-autosuggest .autocomplete__option--no-results {
  background-color: var(--map-background-light);
  color: var(--map-text-muted);
  cursor: default;
}
.facet-autosuggest .autocomplete__hint {
  display: none;
}
.facet-autosuggest {
  /* Scrollbar styling */
}
.facet-autosuggest .autocomplete__menu::-webkit-scrollbar {
  width: 6px;
}
.facet-autosuggest .autocomplete__menu::-webkit-scrollbar-track {
  background: var(--map-background-light);
}
.facet-autosuggest .autocomplete__menu::-webkit-scrollbar-thumb {
  background: var(--map-border-color);
  border-radius: var(--map-border-radius-sm);
}

/* Mobile overlay — compact modal, readable facet labels */
@media (max-width: 48em) {
  .facet-overlay {
    padding: 0.35rem;
    align-items: stretch;
  }
  .facet-overlay .overlay-modal {
    width: 100%;
    max-height: 92svh;
    border-radius: var(--map-border-radius-sm);
  }
  .facet-overlay .overlay-header {
    padding: 0.5rem 0.65rem;
  }
  .facet-overlay .overlay-content {
    padding: 0.5rem 0.65rem 0.65rem;
  }
  .facet-overlay .section-container summary {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 0.35rem;
    padding: 0.5rem 0.6rem;
    font-size: var(--map-font-size-base);
  }
  .facet-overlay .section-container summary .facet-summary-text {
    flex: 1 1 auto;
    min-width: 0;
    line-height: 1.3;
  }
  .facet-overlay .section-container summary .facet-summary-emoji {
    flex-shrink: 0;
    align-self: baseline;
  }
  .facet-overlay .section-container summary::after {
    flex-shrink: 0;
    align-self: center;
    margin-left: 0.15rem;
  }
  /* Compact gutter; the shared calc above picks this up via --facet-gutter. */
  .facet-overlay .section-container .facet-wrapper {
    --facet-gutter: 0.6rem;
  }
  .facet-overlay .section-container .facet-summary-control {
    margin-top: 0.5rem;
  }
  .facet-overlay .section-container .facet-wrapper:has(.facet-summary-control) > details > summary {
    padding-left: 0.35rem;
  }
  .facet-overlay .section-container .section-content {
    padding: 0.25rem 0.6rem 0.5rem;
  }
  .facet-overlay .facet-spaces-data .facet-spaces-data-header {
    padding: 0.5rem 0.6rem;
    font-size: var(--map-font-size-base);
  }
}
/* High contrast mode support */
@media (forced-colors: active) {
  .facet-autosuggest .autocomplete__menu {
    border-color: FieldText;
  }
  .facet-autosuggest .autocomplete__option {
    background-color: Field;
    color: FieldText;
  }
  .facet-autosuggest .autocomplete__option--focused,
  .facet-autosuggest .autocomplete__option:hover {
    background-color: Highlight;
    color: HighlightText;
  }
}
