/* Shared by every page, whatever its look: the crisis bar and the back-to-top button.
   Loaded after the page's theme stylesheet, so it uses that theme's colours. */

/* Smooth scrolling for in-page links (back-to-top, table of contents) on every page, off for reduced motion */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Crisis bar: same markup and look on every page, always first in the body */
.topbar { border-top: 4px solid var(--bad); border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar .in { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 6px 28px; align-items: center; justify-content: space-between; }
.sos { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 2px 18px; align-items: baseline; font-size: 0.93rem; }
.sos .lbl { color: var(--bad); font-weight: 700; }
.sos b { font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (min-width: 900px) { .topbar { min-height: 81px; box-sizing: border-box; display: flex; align-items: center; } .topbar .in { width: 100%; } }

/* Back to top: small and quiet, appears once the reader has scrolled about a screen down.
   Browsers with scroll-driven animations need no script (the guide page has none);
   elsewhere assets/totop.js adds .on as a fallback. */
.to-top {
  position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); z-index: 40;
  width: 40px; height: 40px; border-radius: 999px; display: grid; place-items: center;
  background: var(--surface); color: var(--muted); border: 1px solid var(--line); text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
}
.to-top svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.to-top.on { opacity: 0.75; visibility: visible; transform: none; transition: opacity 0.25s ease, transform 0.25s ease; }
.to-top.on:hover, .to-top.on:focus-visible { opacity: 1; color: var(--ink); }
.to-top:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@supports (animation-timeline: scroll()) {
  .to-top { transition: none; animation: to-top-show linear both; animation-timeline: scroll(root); animation-range: 60vh 100vh; }
  @keyframes to-top-show { from { opacity: 0; visibility: hidden; transform: translateY(6px); } to { opacity: 0.75; visibility: visible; transform: none; } }
  /* No hover/focus override of the animation: it used to pin the button visible after a click (the pointer or focus stays on it), so it never hid at the top. */
  .to-top:hover, .to-top:focus-visible { color: var(--ink); }
}
@media (prefers-reduced-motion: reduce) { .to-top, .to-top.on { transition: none; transform: none; } @keyframes to-top-show { from { opacity: 0; visibility: hidden; } to { opacity: 0.75; visibility: visible; } } }
@media print { .to-top { display: none; } }

/* Crisis numbers pop-up (assets/crisis.js): first page of a session, bottom of the screen, closable.
   Not a modal: the page stays usable behind it. Uses the page's theme colours. */
.krize[hidden] { display: none; }
.krize { position: fixed; z-index: 60; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px)); box-sizing: border-box; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-top: 5px solid var(--bad); border-radius: 18px; padding: 16px 52px 16px 20px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22); }
.krize h2 { margin: 0 0 8px; font-size: 1.05rem; color: var(--bad); font-family: inherit; }
.krize ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 0.95rem; }
.krize a { color: inherit; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.krize p { margin: 8px 0 0; font-size: 0.85rem; color: var(--muted); }
.krize-x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border-radius: 999px; border: 0; background: transparent;
  color: var(--muted); font: inherit; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.krize-x:hover { background: var(--bad-bg, rgba(0,0,0,0.06)); color: var(--ink); }
.krize-x:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .krize:not([hidden]):not(.closing) { animation: krize-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1) both; animation-delay: 0.3s; }
  .krize.closing { animation: krize-out 0.2s ease-in both; }
}
@keyframes krize-in { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes krize-out { to { opacity: 0; transform: translate(-50%, 12px); } }
@media print { .krize { display: none !important; } }
