/* ==========================================================================
   ENGEL — BASE STYLES
   ==========================================================================

   Where styles live (in this order):
   1. Bricks Theme Style, palette and global variables: base elements,
      colours, type, spacing.
   2. Global class settings in Bricks, using those variables.
   3. CSS files, only for what has no Bricks control:
      - engel.css (this file): base rules for bare elements. It loads before
        Bricks' class CSS, so any Theme Style or class setting overrides it.
      - engel-components.css: CSS of specific classes and components. It
        prints after the class CSS.

   Always use variables here; never define them. Tokens come from Bricks.
   ========================================================================== */


/* --------------------------------------------------------------------------
   Form fields outside a Bricks Form element (query filters, search inputs)

   Theme Style only styles fields inside the Form element, so bare fields get
   their base here. Scoped to #brx-header / #brx-content / #brx-footer
   because the builder renders its panel in the same document; :where()
   keeps the scope at zero specificity.

   The :not() guard skips fields that style themselves: `form *` (Forms,
   WooCommerce) and `.field-custom *` (opt-out; add it to the component root).
   Specificity stays (0,0,1), so any class overrides these rules.
   -------------------------------------------------------------------------- */

:where(#brx-header, #brx-content, #brx-footer) :is(
  input:where(
    [type="text"], [type="search"], [type="email"], [type="number"],
    [type="tel"], [type="url"], [type="password"], [type="date"]
  ),
  select,
  textarea
):not(:where(form *, .field-custom *)) {
  font-size: calc(var(--text-s) * 1.2);
  line-height: var(--lh-normal);
  border: 1px solid var(--clr-text-muted);
  border-radius: var(--field-radius);
  padding-block: var(--space-2xs);
  background-color: transparent;
  transition: border-color var(--dur-ui), box-shadow var(--dur-ui);
}

/* Field rule (5 Nov 2026): ink border on hover and focus; focus adds a 1px
   inset ink ring, which is the focus indicator (no outline needed). */
:where(#brx-header, #brx-content, #brx-footer) :is(
  input, select, textarea
):not(:where(form *, .field-custom *, [type="checkbox"], [type="radio"])):is(:hover, :focus) {
  border-color: var(--clr-ink);
}
:where(#brx-header, #brx-content, #brx-footer) :is(
  input, select, textarea
):not(:where(form *, .field-custom *, [type="checkbox"], [type="radio"])):focus {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--clr-ink);
}
/* Checkboxes and radios keep the site focus ring (Bricks' base removes it). */
:where(#brx-header, #brx-content, #brx-footer) input:is([type="checkbox"], [type="radio"]):not(:where(form *, .field-custom *)):focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}
:where(#brx-header, #brx-content, #brx-footer) :is(
  input, select, textarea
):not(:where(form *, .field-custom *))[aria-invalid="true"] {
  border-color: var(--clr-danger);
  box-shadow: inset 0 0 0 1px var(--clr-danger);
}

:where(#brx-header, #brx-content, #brx-footer) select:not(:where(form *, .field-custom *)) {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-10 0 1011 1001'%3E%3Cpath fill='%23333333' d='M534 721l375 -375q27 -33 0 -66q-33 -28 -66 0l-343 342l-342 -342q-33 -28 -66 0q-27 33 0 66l375 375q33 28 67 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--field-arrow-inset) center;
  background-size: var(--field-arrow-size);
  padding-inline-end: calc(
    var(--field-arrow-inset) + var(--field-arrow-size) + var(--field-padding-inline)
  );
}
