/**
 * @file
 * Bootstrap's own transitions, retimed with the motion tokens.
 *
 * Where Bootstrap already transitions something, only the duration and the
 * timing function change, so Bootstrap's reduced-motion rule
 * (transition: none) still switches it off. Every movement (collapse, the
 * modal dialog, offcanvas, the chevron, the switch knob, the tooltip slide,
 * the dropdown drop) has its duration or distance multiplied by
 * --biopama-motion, so it also stops under the site's "Animations: reduced"
 * (akp-motion-reduced), which Bootstrap does not know; colour and opacity
 * fades stay. Selectors start with :root so
 * they win over Bootstrap's own rules by specificity. Toasts are retimed with the
 * site messages, not here. Tokens: biopama_libraries/motion (API.md).
 */

/* Fades (modal backdrop, tooltips, popovers, alerts, tab panes). */
:root .fade {
  transition-duration: var(--biopama-duration-base);
  transition-timing-function: var(--biopama-ease);
}

/* Collapse: height, or width for .collapse-horizontal. */
:root .collapsing {
  transition-duration: calc(var(--biopama-duration-slow) * var(--biopama-motion));
  transition-timing-function: var(--biopama-ease);
}

/* The modal dialog arrives with the gentle overshoot. */
:root .modal.fade .modal-dialog {
  transition-duration: calc(var(--biopama-duration-slow) * var(--biopama-motion));
  transition-timing-function: var(--biopama-ease-spring);
}

/* Offcanvas panels: the tool page sidebar, the map drawer, the edit tray,
   the results tray. biopama_libraries' css/area/area.css times the map's
   bottom edge (--biopama-map-toggle-glide: the edge toggles and the map
   regions riding the results tray) the same: keep them in step. */
:root .offcanvas,
:root .offcanvas-sm,
:root .offcanvas-md,
:root .offcanvas-lg,
:root .offcanvas-xl,
:root .offcanvas-xxl {
  transition-duration: calc(var(--biopama-duration-slow) * var(--biopama-motion));
  transition-timing-function: var(--biopama-ease);
}

/* The accordion chevron. */
:root .accordion-button::after {
  transition-duration: calc(var(--biopama-duration-base) * var(--biopama-motion));
  transition-timing-function: var(--biopama-ease);
}

/*
 * Check boxes, radios and switches: the colour fades (Bootstrap has none),
 * and the switch knob springs across, its duration 0 when motion is off.
 */
:root .form-check-input {
  transition-property: background-color, border-color, background-position;
  transition-duration: var(--biopama-duration-quick), var(--biopama-duration-quick), calc(var(--biopama-duration-base) * var(--biopama-motion));
  transition-timing-function: var(--biopama-ease), var(--biopama-ease), var(--biopama-ease-spring);
}

/* Tooltips: the bubble slides 2px towards its trigger as it fades in. */
:root .tooltip .tooltip-inner {
  transition: translate calc(var(--biopama-duration-base) * var(--biopama-motion)) var(--biopama-ease-spring);
}

:root .tooltip[data-popper-placement^="top"]:not(.show) .tooltip-inner {
  translate: 0 calc(2px * var(--biopama-motion));
}

:root .tooltip[data-popper-placement^="bottom"]:not(.show) .tooltip-inner {
  translate: 0 calc(-2px * var(--biopama-motion));
}

:root .tooltip[data-popper-placement^="left"]:not(.show) .tooltip-inner {
  translate: calc(2px * var(--biopama-motion)) 0;
}

:root .tooltip[data-popper-placement^="right"]:not(.show) .tooltip-inner {
  translate: calc(-2px * var(--biopama-motion)) 0;
}

/* Dropdowns: a short fade and drop as the menu opens; closing is instant. */
:root .dropdown-menu.show {
  transition:
    opacity var(--biopama-duration-quick) var(--biopama-ease),
    translate calc(var(--biopama-duration-base) * var(--biopama-motion)) var(--biopama-ease-spring);
}

@starting-style {
  :root .dropdown-menu.show {
    opacity: 0;
    translate: 0 calc(-0.25rem * var(--biopama-motion));
  }
}
