/* Bay Point Labs LIMS — shared, lightweight loading and access states. */
html { scrollbar-gutter: stable; }

.bpl-route-transition {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  background: var(--ground);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .01em;
  text-align: center;
  pointer-events: all;
}
.bpl-route-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: bpl-route-spin .75s linear infinite;
}
@keyframes bpl-route-spin { to { transform: rotate(360deg); } }

.bpl-entry-transition {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: none;
  place-items: center;
  overflow: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 42%, rgba(6, 167, 125, 0.14), transparent 34%),
    var(--ground, #ffffff);
  color: var(--ink, #16202a);
  opacity: 1;
  transition: opacity .18s cubic-bezier(.2, .7, .2, 1);
}

:root[data-bpl-entering="1"] .bpl-entry-transition { display: grid; }
.bpl-entry-transition.is-leaving { opacity: 0; pointer-events: none; }

.bpl-entry-center {
  position: relative;
  width: min(360px, 100%);
  text-align: center;
}

.bpl-entry-mark {
  position: relative;
  width: 82px;
  height: 82px;
  margin: 0 auto 22px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(155deg, #0b8264 0%, #06a77d 58%, #0fbd8f 100%);
  box-shadow: 0 18px 45px rgba(6, 167, 125, 0.28);
  animation: bplEntryFloat 2.2s ease-in-out infinite;
}

.bpl-entry-mark::before {
  content: "";
  position: absolute;
  inset: -9px;
  border: 1px solid rgba(6, 167, 125, 0.28);
  border-radius: 30px;
  animation: bplEntryHalo 2.2s ease-out infinite;
}

.bpl-entry-mark img {
  width: 43px;
  height: auto;
  display: block;
  border: 0 !important;
  background: transparent !important;
  filter: none !important;
}

.bpl-entry-transition.is-ready .bpl-entry-mark {
  animation: bplEntryReady .36s cubic-bezier(.2, .8, .2, 1) both;
}

.bpl-entry-kicker {
  margin: 0 0 6px;
  color: var(--accent, #0b8264);
  font: 700 .68rem/1.2 "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.bpl-entry-title {
  margin: 0;
  color: var(--ink, #16202a);
  font-size: clamp(1.35rem, 4vw, 1.7rem);
  font-weight: 800;
  letter-spacing: -.02em;
}

.bpl-entry-status {
  min-height: 1.5em;
  margin: 7px 0 0;
  color: var(--muted, #5b6770);
  font-size: .9rem;
  font-weight: 550;
}

.bpl-entry-track {
  position: relative;
  width: 184px;
  height: 4px;
  margin: 20px auto 0;
  overflow: hidden;
  border-radius: 999px;
  background: var(--line, #e5eaee);
}

.bpl-entry-track::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 46%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0b8264, #37d4a6);
  animation: bplEntrySweep 1.15s cubic-bezier(.45, 0, .3, 1) infinite;
}

.bpl-entry-transition.is-ready .bpl-entry-track::after {
  width: 100%;
  animation: none;
}

.bpl-entry-retry {
  display: none;
  margin: 18px auto 0;
  border: 1px solid var(--line-strong, #cbd4da);
  border-radius: 10px;
  padding: 8px 14px;
  background: var(--card, #ffffff);
  color: var(--ink, #16202a);
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
}

.bpl-entry-transition.is-slow .bpl-entry-retry { display: block; }
.bpl-entry-retry:hover { border-color: var(--accent, #0b8264); color: var(--accent, #0b8264); }
.bpl-entry-retry:focus-visible { outline: 2px solid var(--accent, #0b8264); outline-offset: 2px; }

.bpl-access-pending {
  max-width: 430px;
  margin: 8vh auto;
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 18px 20px;
  border: 1px solid var(--line, #e5eaee);
  border-radius: 15px;
  background: var(--card, #ffffff);
  color: var(--ink, #16202a);
  box-shadow: 0 12px 32px rgba(16, 24, 32, 0.06);
}

.bpl-access-pending[hidden] { display: none !important; }
.bpl-access-copy b { display: block; margin-bottom: 2px; font-size: .94rem; }
.bpl-access-copy span { color: var(--muted, #5b6770); font-size: .82rem; }

.bpl-access-pulse {
  position: relative;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 11px;
  background: var(--accent-soft, #e2f6f0);
}

.bpl-access-pulse::before,
.bpl-access-pulse::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--accent, #0b8264);
  animation: bplAccessPulse 1.2s ease-out infinite;
}

.bpl-access-pulse::after { animation-delay: .35s; }

@keyframes bplEntryFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes bplEntryHalo {
  0% { transform: scale(.94); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: scale(1.12); opacity: 0; }
}

@keyframes bplEntryReady {
  0% { transform: scale(.96); }
  65% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes bplEntrySweep {
  from { transform: translateX(-115%); }
  to { transform: translateX(315%); }
}

@keyframes bplAccessPulse {
  0% { transform: scale(.45); opacity: .9; }
  100% { transform: scale(1.35); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bpl-route-spinner { animation-duration: 1.5s; }
  .bpl-entry-transition { transition: none; }
  .bpl-entry-mark,
  .bpl-entry-mark::before,
  .bpl-entry-track::after,
  .bpl-access-pulse::before,
  .bpl-access-pulse::after { animation: none !important; }
  .bpl-entry-track::after { width: 72%; }
  .bpl-entry-transition.is-ready .bpl-entry-track::after { width: 100%; }
}

/* Shared colours for the newer analytical modules. */
.mc-rsa { --mfg: #8b5a20; }
.mc-dw { --mfg: #136d90; }
.mc-fm { --mfg: #7652a8; }
:root[data-theme="dark"] .mc-rsa { --mfg: #e1b56e; }
:root[data-theme="dark"] .mc-dw { --mfg: #79c9e9; }
:root[data-theme="dark"] .mc-fm { --mfg: #c0a4e8; }

/* Small initials need the normal-text 4.5:1 threshold against accent-soft. */
:root[data-theme="light"] .avatar { color: #08785b; }

/* Permission links arrive after the session check in a returning tab. The
   shared controller groups them here without changing desktop navigation. */
.bpl-side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
  overscroll-behavior-y: contain;
  padding-right: 3px;
}

/* On phones, keep account controls in the first row and give the module tree
   its own bounded row. A horizontal strip clipped nested folder children, so
   the tree now scrolls vertically and remains usable when a folder is open. */
@media (max-width: 700px) {
  /* Permission-driven navigation changes every protected mobile shell's height
     during session hydration. Keep visible content out of the unstable first
     layout until the shared renderer has built the complete navigation model. */
  html:not(.bpl-navigation-ready) #moduleNav,
  html:not(.bpl-navigation-ready) .sidebar .side-foot,
  html:not(.bpl-navigation-ready) .content-body {
    visibility: hidden;
  }
  .sidebar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 8px;
    min-height: 0;
    flex-wrap: nowrap !important;
    overflow: visible !important;
    align-self: stretch !important;
  }
  .sidebar .brand { grid-column: 1; grid-row: 1; min-width: 0; flex: 0 0 auto; }
  .sidebar .bpl-side-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    height: auto;
    max-height: min(52vh, 360px);
    flex-direction: column;
    align-items: stretch;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-width: thin;
    overscroll-behavior-y: contain;
  }
  .sidebar .side-item,.sidebar .side-folder { width: 100%; flex: 0 0 auto; }
  .sidebar .side-management-label { display: block; }
  .sidebar .side-foot { grid-column: 2; grid-row: 1; flex: 0 0 auto; margin: 0 !important; }
}

@media (max-width: 340px) {
  .sidebar .brand > span:not(.brand-mark) { display: none; }
}

.bpl-idle-warning {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 140;
  width: min(430px, calc(100vw - 40px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--warn, #b76b00) 55%, var(--line));
  border-radius: 16px;
  background: color-mix(in srgb, var(--card) 94%, var(--warn, #b76b00) 6%);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(8, 20, 18, .28);
}
.bpl-idle-warning[hidden] { display: none; }
.bpl-idle-warning > div { display: grid; gap: 4px; min-width: 0; }
.bpl-idle-warning strong { font-size: .92rem; }
.bpl-idle-warning span { color: var(--muted); font-size: .78rem; line-height: 1.45; }
.bpl-idle-warning .button { min-height: 42px; }

@media (max-width: 700px) {
  .bpl-idle-warning {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .bpl-idle-warning .button { width: 100%; min-height: 46px; }
}
