/* BAU brand color and the Bootstrap overrides that apply it.
 *
 * Three unrelated blues were in play before this: Bootstrap's own default
 * primary (#0d6efd, left untouched - every .btn-primary, link, and form
 * focus ring), a hand-picked navbar background (#0a1a31), and a
 * hand-picked .btn-secondary/.bg-secondary tint (rgb(109, 143, 193), also
 * below the 4.5:1 contrast its white button text needs). None of the three
 * was BAU's own navy (#023473).
 *
 * This file is the one place loaded on every page (directly on the
 * password-reset and admin bases, via index.css's @import everywhere
 * else), so the brand tokens and overrides live here rather than in
 * index.css, which the password-reset pages never load.
 *
 * Bootstrap 5.3's compiled CSS does not make every color actually track
 * its own --bs-primary custom property - .btn-primary, .nav-pills, and the
 * focus/checked states below all hardcode their hex at build time - so
 * each of those needs its own override alongside the --bs-primary* tokens
 * that utility classes (.text-primary, .bg-primary, .border-primary) and
 * this file's own `var(--bs-primary, #0d6efd)` fallbacks do follow.
 */
:root {
  --brand-navy: #023473;
  --brand-navy-rgb: 2, 52, 115;
  --brand-navy-hover: #022c62;
  --brand-navy-hover-rgb: 2, 44, 98;
  --brand-navy-active: #022756;
  --brand-navy-bg-subtle: #f0f3f7;
  --brand-navy-border-subtle: #8da4c0;
  /* A tint of the brand navy rather than an unrelated gray or blue, so
     secondary/neutral controls (remove buttons, pills, outline buttons)
     read as the same family as the primary ones - but light enough to
     stay secondary, and still >=4.5:1 against the white text Bootstrap's
     .btn-secondary uses (the color it replaces measured 3.31:1). */
  --brand-secondary: #4e719d;
  --brand-secondary-hover: #45638a;
  --brand-secondary-active: #3d587a;

  --bs-primary: var(--brand-navy);
  --bs-primary-rgb: var(--brand-navy-rgb);
  --bs-primary-bg-subtle: var(--brand-navy-bg-subtle);
  --bs-primary-border-subtle: var(--brand-navy-border-subtle);
  --bs-primary-text-emphasis: var(--brand-navy-active);
  --bs-link-color: var(--brand-navy);
  --bs-link-color-rgb: var(--brand-navy-rgb);
  --bs-link-hover-color: var(--brand-navy-hover);
  --bs-link-hover-color-rgb: var(--brand-navy-hover-rgb);
}

.btn-primary {
  --bs-btn-bg: var(--brand-navy);
  --bs-btn-border-color: var(--brand-navy);
  --bs-btn-hover-bg: var(--brand-navy-hover);
  --bs-btn-hover-border-color: var(--brand-navy-hover);
  --bs-btn-active-bg: var(--brand-navy-active);
  --bs-btn-active-border-color: var(--brand-navy-active);
  --bs-btn-disabled-bg: var(--brand-navy);
  --bs-btn-disabled-border-color: var(--brand-navy);
  --bs-btn-focus-shadow-rgb: var(--brand-navy-rgb);
}

.btn-secondary,
.bg-secondary {
  --bs-btn-bg: var(--brand-secondary);
  --bs-btn-border-color: var(--brand-secondary);
  --bs-btn-hover-bg: var(--brand-secondary-hover);
  --bs-btn-hover-border-color: var(--brand-secondary-hover);
  --bs-btn-active-bg: var(--brand-secondary-active);
  --bs-btn-active-border-color: var(--brand-secondary-active);
  --bs-btn-disabled-bg: var(--brand-secondary);
  --bs-btn-disabled-border-color: var(--brand-secondary);
  --bs-btn-focus-shadow-rgb: var(--brand-navy-rgb);
  background-color: var(--brand-secondary) !important;
}

.btn-outline-secondary {
  --bs-btn-color: var(--brand-secondary-active);
  --bs-btn-border-color: var(--brand-secondary);
  --bs-btn-hover-bg: var(--brand-secondary);
  --bs-btn-hover-border-color: var(--brand-secondary);
  --bs-btn-active-bg: var(--brand-secondary-active);
  --bs-btn-active-border-color: var(--brand-secondary-active);
  --bs-btn-focus-shadow-rgb: var(--brand-navy-rgb);
}

/* Bootstrap's own .btn already transitions color/background/border on
   hover; this adds a small lift so the fill above isn't an instant flat
   swap, and takes it away again on the press itself so the button still
   reads as going down, not just changing color. Skipped under reduced
   motion, where the color transition alone is left to do the work. */
.btn-primary,
.btn-secondary,
.btn-outline-secondary {
  transition: color 0.15s ease-out, background-color 0.15s ease-out,
    border-color 0.15s ease-out, box-shadow 0.15s ease-out,
    transform 0.15s ease-out;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-outline-secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(var(--brand-navy-rgb), 0.25);
}

.btn-primary:active,
.btn-secondary:active,
.btn-outline-secondary:active {
  transform: translateY(0);
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .btn-primary:hover,
  .btn-secondary:hover,
  .btn-outline-secondary:hover {
    transform: none;
    box-shadow: none;
  }
}

.nav-pills {
  --bs-nav-pills-link-active-bg: var(--brand-navy);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--brand-navy-border-subtle);
  box-shadow: 0 0 0 0.25rem rgba(var(--brand-navy-rgb), 0.25);
}

.form-check-input:checked {
  background-color: var(--brand-navy);
  border-color: var(--brand-navy);
}

.h-fit-content {
  height: fit-content;
}

.scroll {
  height: 300px;
  overflow-y: scroll;
}

m-inline-0 {
  margin-inline: 0px;
}

.flex-center-column {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 1.5rem;
}

.flex-center-row {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: row;
  gap: 1.5rem;
}

.flex-start-row {
  display: flex;
  flex-direction: row;
  gap: 1.5rem;
}

.flex-start-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.card-rect {
  background: white;
  width: 100%;
}

.w-60 {
  width: 60%;
}

.w-70 {
  width: 70%;
}

.w-fit-content {
  width: fit-content;
}
.pre-scrollable {
  max-height: 300px;
  overflow-y: scroll;
}
.cursor-pointer {
  cursor: pointer;
}
.gap-small {
  gap: 0.175rem;
}

.card-hover {
  box-shadow: 0 5px 15px -5px rgba(0, 0, 0, 0.1);
}

.center_to_page {
  width: 100vw;
  height: 100vh;
}

.move-right {
  margin-left: auto;
  margin-right: 0;
}

.pl-0 {
  padding-left: 0px;
}

.align-header-with-image {
  display: inline-block;
  vertical-align: middle;
  margin: 0;
}

@keyframes fade-down {
  0% {
    opacity: 0;
    transform: translateY(-30px) scale(0.9);
  }

  100% {
    opacity: 1;
    transform: translateY(0px) scale(1);
  }
}

@keyframes fade-up {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.9);
  }

  100% {
    opacity: 1;
    transform: translateY(0px) scale(1);
  }
}

.anim-fadeup {
  animation: fade-up 0.5s;
}

.grid-span-col {
  /* see http://stackoverflow.com/questions/47319464/ddg#47320149 */
  grid-column: 1/-1;
}

/* ---------------------------------------------------------------------------
 * Autocomplete (multi-select combobox) - see common.js
 *
 * The panel used to be positioned with magic offsets (top: 42px passed in per
 * instance, a close icon at left: 195px; bottom: 31px) over a box pinned to
 * max-width: 215px. It overlapped its own input on narrow screens and the
 * field never filled its column.
 * ------------------------------------------------------------------------ */

.autocomplete__input {
  min-height: 44px; /* touch target */
}

/* The panel is anchored to the input, not to the whole field: the field also
   holds the selected pills, so anchoring there pushed the suggestions below
   them and left a gap under the box. */
.autocomplete__field {
  position: relative;
}

.autocomplete__panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1056; /* above a Bootstrap modal's own stacking context */
  margin-top: 2px;
  background-color: var(--bs-body-bg, #fff);
  border: 1px solid var(--bs-border-color, #dee2e6);
  border-radius: 0.375rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.autocomplete__list {
  max-height: 16rem;
  overflow-y: auto;
  margin-bottom: 0;
}

.autocomplete__option {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  border-left: 0;
  border-right: 0;
}

.autocomplete__option:hover,
.autocomplete__option.is-active {
  background-color: var(--bs-primary-bg-subtle, #cfe2ff);
}

/* Not colour alone: the active row also carries a leading bar, so the
   keyboard position is visible to someone who cannot distinguish the tint. */
.autocomplete__option.is-active {
  box-shadow: inset 3px 0 0 var(--bs-primary, #0d6efd);
}

.autocomplete__empty {
  color: var(--bs-secondary-color, #6c757d);
  font-size: 0.875rem;
}

.autocomplete__busy {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--bs-secondary-color, #6c757d);
}

.autocomplete__busy.htmx-request {
  display: flex;
}

.autocomplete__pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  list-style: none;
  padding-left: 0;
  margin: 0.5rem 0 0;
}

.autocomplete__pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding-right: 0.25rem;
  font-size: 0.8125rem;
  white-space: normal;
  text-align: left;
}

.autocomplete__pill-badge {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.0625rem 0.3rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
}

.autocomplete__pill-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.autocomplete__pill-remove:hover,
.autocomplete__pill-remove:focus-visible {
  background-color: rgba(255, 255, 255, 0.25);
}

.autocomplete__pill-remove:focus-visible,
.autocomplete__option:focus-visible {
  outline: 2px solid var(--bs-primary, #0d6efd);
  outline-offset: 2px;
}

@media (pointer: coarse) {
  /* Fingers need the bigger target; a mouse does not. */
  .autocomplete__pill-remove {
    width: 2.25rem;
    height: 2.25rem;
  }
}

/* The "Add <what you typed>" row on tag fields, for a research area the
   department's list does not cover yet. */
.autocomplete__option--new {
  gap: 0.375rem;
}

.autocomplete__new-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--bs-primary, #0d6efd);
}

/* "Add <field>" under a multi-row field's rows (components/
   dynamic_base_input.html). Outline rather than the solid secondary it used
   to be, so it still reads as a button - keeping a visible click target
   rather than text easy to miss - without being as loud as the form's
   actual submit button. */
.dynamic-form-add {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-top: 0.25rem;
}

/* An external-profile link on the profile page (components/profile/
   profile_tags_skills_fragment.html). Used to be a btn-outline-primary
   inside a flex-column, which stretches its children full width by
   default - every link rendered as a giant, mostly-empty bordered box
   instead of a compact item. A light tinted chip instead, matching the
   Tags row directly above it in the same card. */
.external-profile-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--brand-navy-bg-subtle);
  color: var(--brand-navy);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease-out, color 0.15s ease-out;
}

.external-profile-link:hover,
.external-profile-link:focus-visible {
  background: var(--brand-navy);
  color: #fff;
}

/* ============================================================================
   Batch-import paper navigator (research_form.js, batch mode of the Add
   Research panel). A column of colored index tabs, one per paper in the
   batch - like the stick-on tabs along a planner's page edge - so which
   papers are done, in progress, or untouched reads at a glance, and a tab
   jumps straight to that paper instead of walking Next/Back to find it.
   ============================================================================ */
#batch_nav_rail {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.75rem 0.25rem 0.75rem 0;
  flex-shrink: 0;
}

.batch-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bs-secondary-bg, #e9ecef);
  color: #6c757d;
  padding: 0;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  cursor: pointer;
  transition: background-color 0.15s ease-out, color 0.15s ease-out;
}

.batch-tab:focus-visible {
  outline: 2px solid var(--brand-navy);
  outline-offset: 2px;
}

.batch-tab--active {
  box-shadow: 0 0 0 2px var(--brand-navy);
}

.batch-tab--in-progress {
  background: var(--brand-navy-bg-subtle);
  color: var(--brand-navy);
}

/* Done fills solid with the theme's own blue, rather than a different
   (green) color for "done" than the rest of this rail already uses for
   "in progress"/"active" - one color standing for the whole idea of
   "this step and BAU" instead of introducing a second one. */
.batch-tab--complete {
  background: var(--brand-navy);
  color: #fff;
}

.batch-tab__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.batch-tab__num {
  min-width: 1ch;
}

/* The preview is a popover anchored to the square (position:relative
   above), not the square itself growing - position:absolute takes it
   out of normal flow entirely, so expanding it on hover can never push
   the Details form (or any other tab) sideways. Same pattern as any
   icon-rail tooltip (VS Code's activity bar, a dock): the trigger never
   resizes, only a floating panel appears over whatever's next to it. */
.batch-tab__flyout {
  position: absolute;
  top: 0;
  left: calc(100% + 0.5rem);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 12rem;
  padding: 0.6rem 0.75rem;
  background: #fff;
  color: #212529;
  border-radius: 0.5rem;
  box-shadow: 0.125rem 0.25rem 0.75rem rgba(0, 0, 0, 0.2);
  text-align: left;
  font-weight: 400;
  line-height: 1.3;
  opacity: 0;
  transform: scale(0.92);
  transform-origin: top left;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out;
  pointer-events: none;
}

.batch-tab:hover .batch-tab__flyout,
.batch-tab:focus-visible .batch-tab__flyout {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.batch-tab__flyout-title {
  font-size: 0.8125rem;
  color: #212529;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.batch-tab__flyout-meta {
  font-size: 0.6875rem;
  color: #6c757d;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#rf_batch_layout {
  min-height: 0;
}

@media (max-width: 767.98px) {
  #rf_batch_layout {
    flex-direction: column;
  }
  #batch_nav_rail {
    flex-direction: row;
    overflow-x: auto;
    padding: 0 0 0.5rem 0;
    gap: 0.5rem;
  }
  .batch-tab__flyout {
    display: none;
  }
}

.batch-select-checkbox {
  margin-top: 0.2rem;
}

/* ============================================================================
   Floating toast notifications (base.html + common.js's toast auto-hide
   timer) replacing the inline alert banner Django's messages framework
   used to render - a popup island with a shrinking progress bar instead
   of a strip pushing page content down.
   ============================================================================ */
.app-toast {
  min-width: 320px;
  max-width: 420px;
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.16);
  background: #fff;
  padding: 0;
  overflow: hidden;
}

.app-toast + .app-toast {
  margin-top: 0.5rem;
}

.app-toast .toast-body {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  font-size: 0.875rem;
  color: #212529;
}

.app-toast__icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1.3;
}

.app-toast--success .app-toast__icon { color: #146c43; }
.app-toast--error .app-toast__icon { color: #b02a37; }
.app-toast--warning .app-toast__icon { color: #997404; }
.app-toast--info .app-toast__icon,
.app-toast--debug .app-toast__icon { color: var(--brand-navy); }

.app-toast__progress {
  height: 3px;
  width: 100%;
  background: rgba(0, 0, 0, 0.08);
}

.app-toast__progress-bar {
  height: 100%;
  width: 100%;
  background: currentColor;
  transition: width linear;
}

.app-toast--success .app-toast__progress-bar { background: #146c43; }
.app-toast--error .app-toast__progress-bar { background: #b02a37; }
.app-toast--warning .app-toast__progress-bar { background: #997404; }
.app-toast--info .app-toast__progress-bar,
.app-toast--debug .app-toast__progress-bar { background: var(--brand-navy); }

/* ============================================================================
   Co-author hover peek (import results list, research_form.js) - a BAU
   account's name, colored navy, reveals a small profile preview on hover;
   a "not on BAU yet" name stays plain grey text with nothing to peek at,
   which is itself the point - the color alone tells them apart before
   anyone even hovers.
   ============================================================================ */
.coauthor-peek-wrapper {
  position: relative;
  display: inline-block;
  cursor: default;
}

.coauthor-peek-card {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translateX(-50%) translateY(0.25rem);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: max-content;
  max-width: 220px;
  padding: 0.5rem 0.625rem;
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 0.375rem 1rem rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease-out, transform 0.12s ease-out;
  z-index: 5;
  text-align: left;
  white-space: normal;
}

.coauthor-peek-wrapper:hover .coauthor-peek-card,
.coauthor-peek-wrapper:focus-visible .coauthor-peek-card {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.coauthor-peek-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.coauthor-peek-avatar--initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-navy-bg-subtle);
  color: var(--brand-navy);
  font-size: 0.75rem;
  font-weight: 600;
}

.coauthor-peek-info {
  font-size: 0.75rem;
  line-height: 1.3;
  min-width: 0;
}
