/*
 * Glowflare unified form and action borders, optional visual layer.
 * Turn off in Appearance > Customize > Glowflare Control Borders to restore
 * the underlying component styles. No form markup or JavaScript is changed.
 *
 * This controls ONLY the resting border treatment. Focus indicators, invalid
 * states, high-contrast mode and functional control behaviour remain separate.
 */
:root {
  --gf-control-border-width: 1px;
  --gf-control-button-border: #ffffff;
  --gf-control-button-radius: 15px;
  --gf-control-field-border: #fe0000;
  --gf-control-button-on-light: #353535;
}

/* Text-entry fields, including the public portal and newsletter forms.
 * Exclude all search interfaces, checkboxes, radios and hidden honeypots.
 * The :not() block excludes descendants, not just the search input type. */
html:not(.gf-high-contrast) body :is(
  input:not([type]), input[type="text"], input[type="email"], input[type="password"],
  input[type="tel"], input[type="url"], input[type="number"],
  input[type="date"], input[type="datetime-local"], input[type="time"],
  select, textarea
):not(:is(
  .search-form *, .searchform *, form[role="search"] *,
  .wp-block-search *, .woocommerce-product-search *,
  .dgwt-wcas-search-wrapp *, .gf404-search-form *,
  .gf-mobile-search *, .gf-mobile-search-form *,
  .gf-search *, .gf-search-form *, [data-gf-search] *,
  #gf-newsletter-popup .gf-newsletter-popup__trap
)) {
  border: var(--gf-control-border-width) solid var(--gf-control-field-border) !important;
}

/* Primary calls to action and submit buttons. Icon-only navigation, slider,
 * voting widgets, search and accessibility controls keep their component
 * borders; they are not ordinary action buttons. */
html:not(.gf-high-contrast) body :is(
  .button, .button-accent, .button-primary,
  .wp-block-button__link, .gf-auth-button,
  .fm-portal-button, .fm-portal-public-btn,
  .gf-newsletter-popup__submit, .gf-newsletter-popup__later,
  .newsletter-page-submit,
  button[type="submit"], input[type="submit"], input[type="button"],
  input[type="reset"], .cmplz-cookiebanner .cmplz-btn
):not(:is(
  .button-light, .button-secondary,
  .gf-mobile-header *, .gf-desktop-header *,
  .gf-mobile-access-modal *, .gf-vote-ballot *,
  .gf-stepper *, .gf404-search-form *,
  .search-form *, .searchform *, form[role="search"] *,
  .wp-block-search *, .woocommerce-product-search *,
  .dgwt-wcas-search-wrapp *, .gf-mobile-search *,
  .gf-mobile-search-form *, .gf-search *, .gf-search-form *,
  [data-gf-search] *, .gf-newsletter-popup__close,
  .cmplz-close, .gf-auth-tab
)) {
  border: var(--gf-control-border-width) solid var(--gf-control-button-border) !important;
  border-radius: var(--gf-control-button-radius) !important;
}

/* An otherwise white button cannot have an invisible white boundary. Keep a
 * contrasting neutral edge for these deliberately light button variants. */
html:not(.gf-high-contrast) body :is(.button-light, .button-secondary, .button-outline):not(:is(
  .gf-mobile-header *, .gf-desktop-header *,
  .gf404-search-form *, .search-form *, .searchform *,
  form[role="search"] *, .wp-block-search *,
  .woocommerce-product-search *, .gf-vote-ballot *
)) {
  border: var(--gf-control-border-width) solid var(--gf-control-button-on-light) !important;
  border-radius: var(--gf-control-button-radius) !important;
}

/* The outline variant is white only when its parent surface is dark. */
html:not(.gf-high-contrast) body :is(
  .section-surface-dark, .section-surface-charcoal, .section-surface-accent
) .button-outline {
  border: var(--gf-control-border-width) solid var(--gf-control-button-border) !important;
}

/* The newsletter popup previously forced its input outline off, even for
 * keyboard users. Retain the resting 1px red edge and provide a distinct
 * 2px keyboard focus indicator without the heavy triple ring seen on iOS. */
html:not(.gf-high-contrast) body #gf-newsletter-popup .gf-newsletter-popup__form input:not(.gf-newsletter-popup__trap):focus-visible {
  border: var(--gf-control-border-width) solid var(--gf-control-field-border) !important;
  outline: 2px solid #ffffff !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 1px #151515 !important;
}

/* Respect operating-system forced-colour focus and control boundaries. */
@media (forced-colors: active) {
  html body :is(input,select,textarea,button):focus-visible {
    outline-color: Highlight !important;
    box-shadow: none !important;
  }
}
