/* Experimental loading screen (Leo 2026-11-07): the Nanani logo in the centre, a thin
   loading line and a few word cards from the course. It covers the account check on
   every refresh and fades into whatever comes next (app, sign-in or welcome).
   Colours are set here, not from styles.css tokens, so it paints before anything else. */
.nn-splash {
  --nn-bg: #f8fafc; --nn-ink: #1a1540; --nn-muted: #64748b; --nn-card: #ffffff;
  --nn-line: #e2e8f0; --nn-accent: #ff6a00; --nn-glow: rgba(59, 42, 110, 0.14);
  --nn-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  position: fixed; inset: 0; z-index: 2147483000;
  display: grid; place-items: center;
  background: var(--nn-bg); color: var(--nn-ink);
  font-family: "Inter", "IBM Plex Sans", "Segoe UI", sans-serif;
  transition: opacity 220ms var(--nn-ease-out);
}
[data-theme="reader"] .nn-splash {
  --nn-bg: #14110d; --nn-ink: #f3eadc; --nn-muted: #b3a48d; --nn-card: #221e18;
  --nn-line: #3a342b; --nn-accent: #e0a45a; --nn-glow: rgba(224, 164, 90, 0.16);
}
.nn-splash.is-leaving { opacity: 0; pointer-events: none; }

.nn-splash-stage { position: relative; display: grid; justify-items: center; gap: 22px; }

.nn-splash-mark {
  position: relative; width: 84px; height: 84px; border-radius: 26px;
  display: grid; place-items: center;
  background: var(--nn-card); border: 1px solid var(--nn-line);
  box-shadow: 0 18px 44px var(--nn-glow), 0 1px 3px rgba(0, 0, 0, 0.05);
  animation: nn-mark-in 520ms var(--nn-ease-out) both, nn-breathe 2.4s ease-in-out 520ms infinite alternate;
}
.nn-splash-mark img { width: 50px; height: 50px; object-fit: contain; }
.nn-splash.is-leaving .nn-splash-mark { transform: scale(1.04); transition: transform 220ms var(--nn-ease-out); animation: none; }

.nn-splash-bar {
  position: relative; width: 88px; height: 3px; border-radius: 3px; overflow: hidden;
  background: var(--nn-line);
  animation: nn-fade-in 400ms ease-out 200ms both;
}
.nn-splash-bar::after {
  content: ""; position: absolute; inset: 0; width: 40%; border-radius: inherit;
  background: var(--nn-accent);
  animation: nn-sweep 1.1s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.nn-splash-note {
  position: absolute; top: calc(100% + 14px); white-space: nowrap;
  margin: 0; font-size: 13px; color: var(--nn-muted);
  opacity: 0; animation: nn-fade-in 400ms ease-out 1600ms forwards;
}

/* Word cards: placed around the logo, they arrive one after another and then drift. */
.nn-splash-cards { position: absolute; inset: 0; pointer-events: none; }
.nn-card {
  position: absolute; left: 50%; top: 50%;
  transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r));
  opacity: 0;
  animation: nn-card-in 560ms var(--nn-ease-out) var(--d) forwards;
}
/* Held, still invisible, until the card typefaces are ready (splash.js). */
.nn-splash-cards.is-waiting .nn-card,
.nn-splash-cards.is-waiting .nn-card-face { animation-play-state: paused; }
.nn-card-face {
  position: relative; display: grid; gap: 1px; padding: 8px 24px 9px 12px; border-radius: 12px;
  background: var(--nn-card); border: 1px solid var(--nn-line);
  box-shadow: 0 10px 26px var(--nn-glow);
  animation: nn-float var(--f) ease-in-out calc(var(--d) + 560ms) infinite alternate;
}
.nn-card strong {
  font-family: "Source Serif 4", "Noto Serif", Georgia, serif;
  font-weight: 600; font-size: 17px; line-height: 1.15; letter-spacing: -0.005em; white-space: nowrap;
}
.nn-card span { font-size: 11px; color: var(--nn-muted); white-space: nowrap; }
.nn-card i {
  position: absolute; top: 9px; right: 9px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--nn-accent); opacity: 0.85;
}

@keyframes nn-mark-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes nn-breathe { from { transform: scale(1); } to { transform: scale(1.035); } }
@keyframes nn-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nn-sweep { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes nn-card-in {
  from { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y) + 10px)) rotate(var(--r)) scale(0.94); }
  to { opacity: 1; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)) scale(1); }
}
@keyframes nn-float { from { transform: translateY(0); } to { transform: translateY(-6px); } }

@media (max-width: 520px) {
  .nn-card:nth-child(n+3) { display: none; }
  .nn-card { --x: var(--xm) !important; --y: var(--ym) !important; }
}

/* Reduced motion: the same screen, only fades. */
@media (prefers-reduced-motion: reduce) {
  .nn-splash-mark { animation: nn-fade-in 200ms ease-out both; }
  .nn-splash-bar::after { animation: none; width: 100%; opacity: 0.5; }
  .nn-card { animation: nn-fade-in 300ms ease-out var(--d) forwards; }
  .nn-card-face { animation: none; }
  .nn-splash.is-leaving .nn-splash-mark { transform: none; }
}
