form {
  max-width: var(--form-width);
}

fieldset {
  margin: 0 0 var(--space-md);
  padding: 0;
  border: 0;
}

legend {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: var(--space-sm);
  color: var(--text-color);
}

/* Labels */
label {
  display: block;
  margin-bottom: 0.15rem;
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--text-color);
}

/* Inputs */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]),
select,
textarea {
  width: 100%;
  appearance: none;
  background-color: transparent;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--grey-60);
  border-radius: var(--br-sm);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-color);
  transition: border-color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease), box-shadow var(--duration) var(--ease);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):hover,
select:hover,
textarea:hover {
  border-color: var(--grey-80);
}

/* Focus reads as the border itself turning pink and thickening: the global
   :focus-visible outline is pulled inward over the 1px border (offset -2px),
   so there's no outer halo and no layout shift. */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--primary-color);
  outline-offset: -2px;
}

/* Field error state — `.is-invalid` (generic) / `.is-ineligible` (booking email,
   toggled by booking-modal.js). Stays red on focus too, so the error doesn't
   vanish while someone is fixing it. Selectors mirror the base rules' :not()
   chain so they out-rank them; a 1px inset shadow makes the border read 2px
   without shifting layout. */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):is(.is-invalid, .is-ineligible),
select.is-invalid,
textarea.is-invalid {
  border-color: var(--error-color);
  background-color: var(--error-10);
  box-shadow: inset 0 0 0 1px var(--error-color);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):is(.is-invalid, .is-ineligible):focus-visible,
select.is-invalid:focus-visible,
textarea.is-invalid:focus-visible {
  border-color: var(--error-color);
  outline-color: var(--error-color);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  /* Theme chevron glyph (inc/svg/chevron.svg) — used for all selects instead of
     the browser's native caret / dropdown indicator. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%23707070' d='M201.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 338.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 0.7rem;
  padding-right: 2.5rem;
}

/* Textarea */
textarea {
  min-height: 10rem;
  resize: vertical;
}

/* Placeholder */
input::placeholder,
textarea::placeholder {
  color: var(--grey-70);
}

/* Help text */
.form-help {
  margin-top: var(--space-sm);
  margin-bottom: 0;
  font-size: var(--font-sm);
  line-height: 1.4;
  color: var(--grey-70);
  max-width: none;
}

/* Field layout — shared by the booking modal (event.css keeps its own
   spacing) and the Large CTA enquiry form. Markup:
   .form-grid > .form-field (+ --full to span the row) / .form-field--checkbox. */

/* Two-up field rows — stack on narrow screens. */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.25rem var(--space-sm);
}

.form-grid .form-field--full {
  grid-column: 1 / -1;
}

@media (max-width: 32rem) {
  .form-grid {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

/* Checkbox + label row. */
.form-field--checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* The flex display above beats the global [hidden] on specificity, so restore it
   — lets JS collapse a checkbox row (e.g. the booking discount-code toggle). */
.form-field--checkbox[hidden] {
  display: none;
}

.form-field--checkbox input[type="checkbox"] {
  flex: 0 0 auto;
  margin: 0;
}

.form-field--checkbox label {
  flex: 1 1 auto;
  margin: 0;
  font-weight: 400;
  line-height: 1.4;
}

.form-field textarea {
  min-height: 6rem;
}

/* A short note under a field (e.g. the contact form's per-topic hint, linked
   to the select with aria-describedby): a white rounded strip holding an
   .icon-row (pink `info` glyph in an .icon-ol ring + the text), so it reads as
   guidance on a coloured panel without looking like a field or an alert.
   Scoped to .form-field so it out-ranks section-level `p { margin: 0 }`
   resets (e.g. .contact__form p). */
.form-field .form-hint {
  margin: var(--space-sm) 0 0; /* = the field row gap, so it's evenly spaced between the select and the next field */
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--br-sm);
  background-color: var(--white);
}

/* .icon-row's display: flex would otherwise override [hidden]. */
.form-field .form-hint[hidden] {
  display: none;
}

.form-hint .icon-row__icon {
  color: var(--primary-color);
}

/* Lighter ring than the .icon-ol default at this small size. */
.form-hint .icon-row__icon svg {
  --icon-ring: 0.09rem;
  --icon-glyph: 0.6;
}

/* Checkbox / radio groups */
.form-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.form-options label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: 0;
  font-weight: 400;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--primary-color);
  cursor: pointer;
}

/* Disabled */

/* Same treatment as a disabled .button / .cta-button (buttons.css): greyed out,
   not-allowed, no hover change. The text-field selector mirrors the base rule's
   :not() chain so it out-ranks its border/colour (and, sitting after the hover
   rule, wins that tie too). Checkboxes/radios/submit keep just opacity + cursor. */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
  border-color: var(--grey-50);
  color: var(--grey-70);
}

input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
}

input[type="checkbox"]:disabled,
input[type="radio"]:disabled {
  opacity: 0.55;
}

/* Responsive tweak */
@media (max-width: 42rem) {
  .form-card {
  padding: var(--space-md);
  border-radius: var(--br-lg);
  }

  .form-options {
  gap: var(--space-sm);
  }
}

/* Search field — pill input + filled brand disc, matching the group page
   member search (.group-search in carousel.css). Unlike the group search the disc
   stays interactive: the magnifying glass submits, and morphs to an × to clear.
   State is PHP-driven via .has-value (see search-form.php). */

.search-field {
  position: relative;
}

/* Pill input. Extra specificity (form + wrapper + attr) beats the aggressive
   base input rule above; the grey border from that rule is kept. */
.search-form .search-field input[type="search"] {
  width: 100%;
  height: 3rem;
  padding: 0 3.25rem 0 0.875rem;
  border-radius: var(--br-rounded);
}

/* On a grey band (e.g. a route list set to Grey) the transparent pill would
   read as grey — fill it white, as inputs on coloured panels are. */
.section--grey .search-form .search-field input[type="search"] {
  background-color: var(--white);
}

.search-field input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

/* Filled brand disc button */
.search-toggle {
  position: absolute;
  top: 50%;
  right: 5px;
  transform: translateY(-50%);
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.search-toggle:active {
  transform: translateY(-50%);
}

/* Magnifying glass (white, centred on the disc) */
.search-toggle .search-icon {
  position: relative;
  width: 0.95rem;
  height: 0.95rem;
  border: 2.5px solid var(--white);
  border-radius: 50%;
  transform: scale(1);
  opacity: 1;
  transition:
  transform var(--duration-fast) var(--ease),
  opacity var(--duration-fast) var(--ease);
}

/* Handle */
.search-toggle .search-icon::after {
  content: "";
  position: absolute;
  right: -0.32rem;
  bottom: -0.04rem;
  width: 0.45rem;
  height: 2.5px;
  border-radius: var(--br-rounded);
  background: var(--white);
  transform: rotate(45deg);
  transform-origin: left center;
  transition:
  transform var(--duration-fast) var(--ease),
  opacity var(--duration-fast) var(--ease);
}

/* X bars (white) */
.search-toggle::before,
.search-toggle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.1rem;
  height: 2.5px;
  border-radius: var(--br-rounded);
  background: var(--white);
  opacity: 0;
  transform: translate(-50%, -50%) rotate(0deg);
  z-index: 1;
  transition:
  transform var(--duration-fast) var(--ease),
  opacity var(--duration-fast) var(--ease);
}

/* ACTIVE STATE → morph to X */
.search-field.has-value .search-icon {
  opacity: 0;
  transform: scale(0.7);
}

.search-field.has-value .search-icon::after {
  opacity: 0;
  transform: rotate(45deg) scale(0.5);
}

.search-field.has-value .search-toggle::before {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(45deg);
}

.search-field.has-value .search-toggle::after {
  opacity: 1;
  transform: translate(-50%, -50%) rotate(-45deg);
}

.search-summary {
  margin: 0 0 var(--space-md);
  font-size: var(--font-sm);
}

/* Groups list: the results line as a form, with the radius select sitting
   inline in the sentence (template-groups.php). */
.search-radius {
  max-width: none;
}

.search-radius select {
  display: inline-block;
  width: auto;
  margin-inline: 0.25em;
  padding: 0.25rem 2rem 0.25rem 0.625rem;
  background-position: right 0.625rem center;
  font-size: inherit;
}

/* List pages: the search (or the groups search row) and the filter row share
   one wrapping row (`.list-tools`, members / groups / meetings templates).
   Side by side while both fit at their basis — the filters' basis is what
   their pills need: --filter-count (set by list-filters.php) × --filter-width
   plus the gaps between them; otherwise the filters wrap under the search,
   `--space-sm` below it. The Apply button (always without JS, else after a
   keyboard change) is deliberately left out: it wraps inside the filter row,
   so it appearing never moves the row itself. The locate warning (groups)
   follows the filters, on a full line. */
.list-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-sm);
}

.list-tools > :is(.search-form, .search-row) {
  flex: 1 1 20rem;
  min-width: 0;
}

.list-tools > .list-filters {
  flex: 1 1 calc(var(--filter-count, 1) * (var(--filter-width) + var(--space-sm)) - var(--space-sm));
  min-width: 0;
}

.list-tools > .locate-status {
  flex-basis: 100%;
  margin: 0;
}

/* List-page filter dropdowns (list-filters.php — Listing marker › Filters):
   a wrapping row of pill selects at the search pill's height. The chosen
   option carries the filter's name ("County: Lancashire"). The caret is pink
   (a data URI can't read a variable — keep its fill in step with
   --primary-color). */
.list-filters {
  --filter-width: 12rem; /* each pill's basis; .list-tools sizes the row from it */
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.list-filters__field {
  position: relative;
  flex: 1 1 var(--filter-width);
  min-width: 0;
}

.list-filters select {
  height: 3rem;
  padding-block: 0;
  border-radius: var(--br-rounded);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%23d2067c' d='M201.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 338.7 54.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z'/%3E%3C/svg%3E");
  text-overflow: ellipsis;
}

/* On a grey band, filled white like the search pill. */
.section--grey .list-filters select {
  background-color: var(--white);
}

/* A chosen filter: the caret gives way to a pink × link that clears it
   (list-filters.php), in the caret's place inside the select's right padding.
   The × is drawn with two bars, like the search pill's clear button. */
.list-filters__field.is-chosen select {
  background-image: none;
}

.list-filters__clear {
  position: absolute;
  top: 50%;
  right: 0.375rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: var(--primary-color);
  transform: translateY(-50%);
  transition: background-color var(--duration-fast) var(--ease);
}

.list-filters__clear:hover {
  background-color: var(--primary-10);
}

.list-filters__clear::before,
.list-filters__clear::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.875rem;
  height: 2px;
  border-radius: var(--br-rounded);
  background: currentColor;
  transform: translate(-50%, -50%) rotate(45deg);
}

.list-filters__clear::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* Apply (list filters) / Update (radius line): always shown without JS;
   search.js hides it and reveals it only after a keyboard change. `.button`
   sets display, so [hidden] needs its own rule. */
.list-filters__apply {
  flex: none;
  align-self: center;
}

[data-auto-submit-apply][hidden] {
  display: none;
}


/* Groups list: the search pill with the "Find the closest group" locate button
   right beside it, as on the map (template-groups.php; search.js reveals it).
   One row at every width; the pill keeps the standard form width. */
.search-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.search-row .search-form {
  flex: 1 1 0;
  min-width: 0;
}

/* Round locate button — shared by the in-person map (template-map.php) and
   the groups list: pink ring, white disc, pink glyph; fills pink on hover and
   while locating (aria-busy, set by search.js — a second click cancels). */
.locate-button {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border: 2px solid var(--primary-color);
  border-radius: 50%;
  background: var(--white);
  color: var(--primary-color);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}

.locate-button:hover,
.locate-button[aria-busy="true"] {
  background: var(--primary-color);
  color: var(--white);
}

/* display above would override the hidden attribute. */
.locate-button[hidden] {
  display: none;
}

.locate-button svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: currentColor;
}
