/* ============================================
   Component: Filter
   Partial: parts/_filter.html.erb
   Stimulus: none
   ============================================ */
/* A page's filters, one form: each filter a fieldset, then the button, wrapping on a phone */
.filter {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.filter fieldset {
  border: 0;
}

.filter legend {
  margin-bottom: var(--spacing-xs);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

/* One filter's options in a row that wraps */
.filter .filter-options {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
}

/* The radio input stays in the keyboard's order and is read by a screen reader: hidden from sight
   only by clipping. Its label, which follows it at once, is what is seen and tapped. */
.filter [type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.filter [type="radio"] + label {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap-target);
  padding: var(--spacing-xs) var(--spacing-md);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-size-md);
  font-weight: 400;
  cursor: pointer;
}

/* The chosen option: its border and weight mark it as well as its colour */
.filter [type="radio"]:checked + label {
  border-color: var(--color-text);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-weight: 700;
}

/* The focus ring as the global rule draws it, round the focused input's label and outside it, on
   the page's background: --color-focus is the accent's colour, so a ring touching an accent-filled
   label couldn't be seen. */
.filter [type="radio"]:focus-visible + label {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.filter [type="submit"] {
  min-height: var(--tap-target);
  padding: var(--spacing-sm) var(--spacing-lg);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--font-size-md);
  cursor: pointer;
}
