/* Shared focus policy, loaded after page styles: no rectangular rings or glows.
   Important is limited to indicators to override legacy component/Bootstrap rules.
   Existing control borders, validation errors and layouts remain unchanged. */
body { --focus-line-color: var(--color-gold-dark); }
:is(.site-navbar, .shop-footer, .brand-surface-dark) { --focus-line-color: var(--color-gold); }
:is(.home-campaign, .home-piece, .home-category-panel) { --focus-line-color: #fff; }
.btn-gold { --focus-line-color: var(--color-ink); }

body :where(a, button, input, select, textarea, summary, [tabindex]):focus {
  outline: none !important;
  box-shadow: none !important;
}

/* A bottom line, rather than a box, identifies keyboard focus on every control. */
body :is(a, button, select, summary, [tabindex]):focus-visible {
  box-shadow: 0 2px 0 var(--focus-line-color) !important;
}
body input:where([type="checkbox"], [type="radio"], [type="file"], [type="range"], [type="color"], [type="button"], [type="submit"], [type="reset"], [type="image"]):focus-visible {
  box-shadow: 0 2px 0 var(--focus-line-color) !important;
}

/* Text entry uses a finer line, fading in/out without changing box dimensions.
   Keep buttons, toggles, uploads and sliders out of this shared transition. */
body :is(input:not(:where([type="checkbox"], [type="radio"], [type="file"], [type="hidden"], [type="range"], [type="color"], [type="button"], [type="submit"], [type="reset"], [type="image"])), textarea, select):not(:disabled) {
  transition: border-color 220ms ease, box-shadow 220ms ease, background-color 220ms ease, color 220ms ease;
}
body :is(input:not(:where([type="checkbox"], [type="radio"], [type="file"], [type="hidden"], [type="range"], [type="color"], [type="button"], [type="submit"], [type="reset"], [type="image"])), textarea, select):not(:disabled):focus {
  box-shadow: 0 1px 0 var(--focus-line-color) !important;
}

/* Validation stays red and immediate rather than fading into the decorative gold. */
body :is(input, textarea, select):is(.input-validation-error, .is-invalid, [aria-invalid="true"], :user-invalid) {
  --focus-line-color: var(--bs-danger, #b42318);
  border-color: var(--bs-danger, #b42318) !important;
  transition: none;
}

body :is(a, button, summary, [role="option"]):focus-visible {
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* The navbar search already has its own line; do not draw a second one. */
body .shop-header-search {
  transition: border-bottom-color 220ms ease;
}
body .shop-header-search:focus-within {
  outline: none !important;
  box-shadow: none !important;
  border-bottom-color: var(--focus-line-color);
}
body .shop-header-search input:focus {
  box-shadow: none !important;
}
body .shop-header-search:has(input:is(.input-validation-error, .is-invalid, [aria-invalid="true"], :user-invalid)) {
  border-bottom-color: var(--bs-danger, #b42318) !important;
  transition: none;
}

/* The upload input is visually hidden: indicate focus on its visible label. */
body .product-image-manager input:focus-visible + .image-dropzone {
  outline: none !important;
  box-shadow: 0 2px 0 var(--focus-line-color) !important;
  text-decoration: underline;
  text-underline-offset: 4px;
}
body .jewel-card-link:focus-visible .jewel-card-media {
  outline: none;
}

/* Box shadows can disappear in high-contrast mode; keep a system-color line. */
@media (forced-colors: active) {
  body :is(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    border-bottom: 2px solid Highlight !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body :is(input, textarea, select), body .shop-header-search { transition: none !important; }
}
