/**
 * @file
 * Theme-wide details: focus, body-text links, typography, scrolling, form
 * states and empty views.
 *
 * Colours come from the active preset (Bootstrap's tokens, set on <html> by
 * akp_config's Palette); timing from biopama_libraries/motion. Selectors
 * start with :root to win over Bootstrap's own rules by specificity.
 */

/*
 * Focus: one solid outline in the preset's ring colour, 2px wide, 2px away.
 * The gap is filled with the page colour, so on any surface either the ring
 * or that band stands out by at least 3:1 (checked per preset, STATE of the
 * polish programme). It replaces Bootstrap's translucent box-shadow rings.
 * While an element has keyboard focus the band replaces its own box-shadow.
 * Some Bootstrap focus rules have the same specificity (.nav-link,
 * .page-link, .btn-close): these win because this file loads last in
 * akp/global-styling.
 */
:root :focus-visible {
  outline: 2px solid var(--bs-focus-ring-color);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--bs-body-bg);
}

:root :is(.btn, .form-control, .form-select, .form-check-input, .accordion-button):focus {
  box-shadow: none;
}

:root :is(.btn, .form-control, .form-select, .form-check-input, .accordion-button):focus-visible {
  box-shadow: 0 0 0 2px var(--bs-body-bg);
}

@media (forced-colors: active) {
  :root :focus-visible {
    outline-color: Highlight;
    box-shadow: none;
  }
}

/* Links in body text are underlined; the site's chrome keeps plain links. */
:root .text-formatted a:not(.btn) {
  text-decoration: underline;
  text-decoration-color: rgba(var(--bs-link-color-rgb), var(--bs-link-underline-opacity, 0.5));
  text-underline-offset: 0.15em;
  transition:
    color var(--biopama-duration-quick, 120ms) var(--biopama-ease, cubic-bezier(0.2, 0, 0, 1)),
    text-decoration-color var(--biopama-duration-quick, 120ms) var(--biopama-ease, cubic-bezier(0.2, 0, 0, 1));
}

@media (hover: hover) {
  :root .text-formatted a:not(.btn):hover {
    --bs-link-underline-opacity: 1;
  }
}

/* Typography. */
:root :is(h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6) {
  text-wrap: balance;
}

:root .text-formatted :is(p, li) {
  text-wrap: pretty;
}

:root :is(table, .biopama-readout-popup, .biopama-legend, .view-count) {
  font-variant-numeric: tabular-nums;
}

/* The caret keeps the browser's own colour, the field's text colour, so it shows
   on every field: a primary caret vanished on the dark fields (James,
   2026-11-10: the header search). */
:root {
  accent-color: var(--bs-primary);
}

::selection {
  background-color: rgba(var(--bs-primary-rgb), 0.3);
}

/*
 * Scrolling: an in-page link lands below the sticky header and its target is
 * softly marked; no smooth scrolling. A scrolling panel keeps its scroll
 * inside instead of handing it to the page.
 */
:root {
  scroll-padding-top: var(--biopama-header-height, 0px);
}

:root :target:not(#main-content, .tab-pane, .modal, .offcanvas, .collapse) {
  background-color: rgba(var(--bs-primary-rgb), 0.08);
}

:root :is(.offcanvas-body, .modal-body, .biopama-map-panel-body) {
  overscroll-behavior: contain;
}

/* Form states: the change to invalid colours fades. */
:root :is(.form-control, .form-select) {
  transition-duration: var(--biopama-duration-base, 200ms);
  transition-timing-function: var(--biopama-ease, cubic-bezier(0.2, 0, 0, 1));
}

:root :is(.form-control, .form-select):user-invalid {
  border-color: var(--bs-form-invalid-border-color);
}

/* A view with no results: muted text, nothing more. */
:root .view-empty {
  color: var(--bs-secondary-color);
}
