/*
 * Anti-flash baseline — loaded before React/Vite so the page
 * background matches the user's theme immediately on paint.
 * Must stay tiny. No variables, no imports.
 *
 * ─────────────────────────────────────────────────────────────────────
 *  PRE-REACT TYPING DOTS
 * ─────────────────────────────────────────────────────────────────────
 *  Before the React bundle parses, the only thing painted is the
 *  theme-matched background + three small staggered dots at center.
 *  Universal "thinking..." indicator — quiet, branded-neutral, no
 *  positional conflict with SplashScreen's wordmark + bar (the dots
 *  are well above where the real splash content lands).
 *
 *  Lives inside #spa-root so React's createRoot.render() wipes the
 *  dots automatically on mount. SplashScreen's opaque .backdrop
 *  fully covers them, then plays its full intro animation uninterrupted.
 *
 *  Hardcoded colors (not tokens) because this CSS loads before
 *  variables.css. Values mirror --color-contrast.
 * ─────────────────────────────────────────────────────────────────────
 */
html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: #FEFEFF;
  color: #202F39;
}

html[data-theme="dark"],
html[data-theme="dark"] body {
  background-color: #000000;
  color: #f1f5f9;
}

/* ── Pre-React typing dots ─────────────────────────────────────────── */

/* Throttle: dots stay invisible for the first 400ms so fast bundle
   loads never flash the indicator. After 400ms they fade in over
   180ms. Pure CSS so no JS is required for this part. */
.cn-preload-dots {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 10px;
  pointer-events: none;
  opacity: 0;
  animation: cnPreloadDotsFadeIn 180ms ease 400ms forwards;
}

@keyframes cnPreloadDotsFadeIn {
  to { opacity: 1; }
}

.cn-preload-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #202F39;
  opacity: 0.2;
  animation: cnPreloadDot 1.4s ease-in-out infinite;
}

.cn-preload-dots span:nth-child(2) { animation-delay: 0.18s; }
.cn-preload-dots span:nth-child(3) { animation-delay: 0.36s; }

html[data-theme="dark"] .cn-preload-dots span {
  background: #FEFEFF;
}

@keyframes cnPreloadDot {
  0%, 80%, 100% { opacity: 0.15; transform: scale(0.85); }
  40%           { opacity: 0.7;  transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .cn-preload-dots { animation: none; opacity: 1; }
  .cn-preload-dots span { animation: none; opacity: 0.35; }
}

/* ── Long-load error fallback ──────────────────────────────────────── */
/* Triggered by spa-preload.js when React hasn't mounted after the
   error timeout. Ink, like every button in the app (Michael, 2026-11-20:
   "we need to upgrade this page to ink"): the button is the page's ink
   with its paper for words, the link is ink. Hardcoded colors mirror
   --color-contrast and the page background in each look.
   __guards__/preload_error_is_ink holds it. */

.cn-preload-error {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 420px;
  padding: 32px 24px;
  text-align: center;
  font-family: 'Space Grotesk', 'Satoshi', sans-serif;
  color: #202F39;
  animation: cnPreloadErrorFadeIn 220ms ease forwards;
}

@keyframes cnPreloadErrorFadeIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

.cn-preload-error__title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: 0.4px;
}

.cn-preload-error__body {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 24px;
  opacity: 0.75;
}

.cn-preload-error__btn {
  display: inline-block;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: #FEFEFF;
  background: #202F39;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 150ms ease;
}

.cn-preload-error__btn:hover  { background: color-mix(in srgb, #202F39 84%, #FEFEFF); }
.cn-preload-error__btn:active { background: color-mix(in srgb, #202F39 72%, #FEFEFF); }
.cn-preload-error__btn:focus-visible { outline: 2px solid #202F39; outline-offset: 2px; }

.cn-preload-error__contact {
  font-size: 12px;
  margin: 24px 0 0;
  opacity: 0.65;
}

.cn-preload-error__link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cn-preload-error__link:hover { opacity: 0.8; }

html[data-theme="dark"] .cn-preload-error { color: #f1f5f9; }
html[data-theme="dark"] .cn-preload-error__btn { color: #000000; background: #f1f5f9; }
html[data-theme="dark"] .cn-preload-error__btn:hover  { background: color-mix(in srgb, #f1f5f9 84%, #000000); }
html[data-theme="dark"] .cn-preload-error__btn:active { background: color-mix(in srgb, #f1f5f9 72%, #000000); }
html[data-theme="dark"] .cn-preload-error__btn:focus-visible { outline-color: #f1f5f9; }
