/* =============================================================================
   Lysia boot loader — /static/loader.css
   -----------------------------------------------------------------------------
   The brand boot composition (loader.js builds the DOM): a watercolor botanical
   tree that gently breathes, the letterspaced LYSIA wordmark with a slow sheen,
   the italic tagline, a mono status micro-label with three pulsing dots, and a
   thin terracotta progress underline that sweeps. Theme-aware via tokens
   (--ink / --bg), so light/dark re-ink for free.

   style.css still owns the .boot-loader shell (position:fixed; inset:0;
   z-index:var(--z-loader); display:flex; background:var(--bg); the .is-done fade
   and the [hidden] override) — this file only adds the composition chrome and
   must not fight those rules.

   Animation is compositor-friendly only (transform / opacity). Honors
   prefers-reduced-motion: motion off, a still fully-composed state.
   ========================================================================== */

.boot-loader {
  color: var(--ink);
  opacity: 1;
}

/* riso paper grain — pure CSS, no asset */
.boot-loader::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image:
    radial-gradient(currentColor 0.6px, transparent 0.6px),
    radial-gradient(currentColor 0.5px, transparent 0.5px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 5px;
}

/* loader.js bootDone() adds .bl-out, then removes the node after the fade.
   Same shape as style.css's .boot-loader.is-done — both contracts keep working. */
.boot-loader.bl-out { opacity: 0; pointer-events: none; }

/* host: the boot overlay's inner div, or any bare div handed to Loader.mount()
   (import/courses/practice inline busy widgets, overlay.js). background:inherit
   lets the composition sit on the actual paper; min-height keeps inline mounts
   from collapsing to zero inside auto-height status elements. */
.boot-loader-inner,
.bl-host {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 180px;
  background: inherit;
  color: inherit;
  display: grid;
  place-items: center;
  /* terracotta blossom accent, local to the loader — there is no global
     terracotta token (the app --accent is steel-azure). */
  --bl-terra: #c0664a;
}

/* ------------------------------------------------------ composition ------ */
.bl-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.7vh, 20px);
  text-align: center;
  user-select: none;
  padding: 16px;
}

/* the watercolor tree — breathes from its base */
.bl-tree {
  display: block;
  width: auto;
  height: clamp(96px, 22vh, 240px);
  transform-origin: 50% 100%;
  animation: l-breathe 5.2s ease-in-out infinite;
  filter: drop-shadow(0 8px 22px rgba(20, 28, 34, 0.07));
}
/* inline mounts (overlay/practice/courses) get a more compact tree */
.bl-host:not(.boot-loader-inner) .bl-tree { height: clamp(72px, 16vh, 132px); }

/* letterspaced serif wordmark, with a slow diagonal sheen */
.bl-word {
  position: relative;
  font-family: var(--font-head, "Newsreader", Georgia, serif);
  font-weight: 500;
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1;
  letter-spacing: 0.4em;
  text-indent: 0.4em; /* optically recenters the tracked caps */
  color: var(--ink);
  overflow: hidden;
}
.bl-word::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 38%, rgba(255, 255, 255, 0.5) 50%, transparent 62%);
  transform: translateX(-180%) skewX(-14deg);
  animation: l-sweep 4.8s ease-in-out 0.6s infinite;
  pointer-events: none;
  mix-blend-mode: soft-light;
}

.bl-tag {
  font-family: var(--font-head, Georgia, serif);
  font-style: italic;
  font-size: clamp(13px, 1.5vw, 16px);
  color: var(--ink);
  opacity: 0.66;
}

/* mono status micro-label + three pulsing dots. The label IS the status line:
   loader.js setStatus() rewrites it (inline mounts pass {label}). */
.bl-micro {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 2px;
  font-family: var(--font-data, ui-monospace, monospace);
  font-size: 10px;
  letter-spacing: 0.26em;
  text-indent: 0.26em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0.5;
  min-height: 1.2em;
}
.bl-micro-label { white-space: nowrap; }
.bl-dots { display: inline-flex; gap: 4px; }
.bl-dots i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.18;
  animation: l-dot 1.4s ease-in-out infinite;
}
.bl-dots i:nth-child(2) { animation-delay: 0.18s; }
.bl-dots i:nth-child(3) { animation-delay: 0.36s; }

/* thin terracotta progress underline — an indeterminate sweep */
.bl-progress {
  position: relative;
  width: clamp(120px, 22vw, 200px);
  height: 2px;
  margin-top: 2px;
  border-radius: 2px;
  overflow: hidden;
  background: color-mix(in oklch, var(--ink) 14%, transparent);
}
.bl-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 30%;
  border-radius: 2px;
  background: var(--bl-terra);
  animation: l-bar 1.7s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes l-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.028); } }
@keyframes l-dot { 0%, 18% { opacity: 0.18; } 45% { opacity: 1; } 75%, 100% { opacity: 0.18; } }
@keyframes l-bar { 0% { transform: translateX(-110%); } 100% { transform: translateX(420%); } }
@keyframes l-sweep {
  0% { transform: translateX(-180%) skewX(-14deg); }
  100% { transform: translateX(180%) skewX(-14deg); }
}

@media (prefers-reduced-motion: reduce) {
  .bl-tree { animation: none; }
  .bl-word::after { display: none; }
  .bl-dots i { animation: none; opacity: 0.5; }
  .bl-bar { animation: none; width: 100%; }
}

/* =============================================================================
   Blocking wait overlay — /static/overlay.js (.app-overlay)
   -----------------------------------------------------------------------------
   Full-viewport blurred + dimmed backdrop with the bloom loader, shown while
   materials upload / AI classify / ingest commit / rescan are in flight.
   Mirrors style.css's .modal-backdrop recipe (var(--overlay) dim + backdrop
   blur) but sits on the loader tier (--z-loader, 1600 — above sticky 1100,
   modal 1300, toast 1400) so nothing pokes through a wait state. The fixed
   full-inset div is also the click shield. Appended here, NOT in style.css.
   ========================================================================== */

.app-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader, 1600);
  background: var(--overlay, rgba(30, 28, 24, 0.45));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  animation: app-overlay-in 180ms ease-out;
}

/* overlay.js adds .is-hiding for the ~180ms fade-out, then unmounts */
.app-overlay.is-hiding {
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out;
}

/* host handed to Loader.mount() — transparent so the composition sits on the
   theme paper (ink mixing via tokens) while the blurred app shows through */
.app-overlay-stage {
  position: relative;
  width: min(620px, 88vw);
  height: min(420px, 56vh);
  background: transparent;
  color: var(--ink, inherit);
}

/* opts.full (the Generator): the composition takes the whole screen, not a card.
   Loader sizes itself from the host rect, so this is all it needs. */
.app-overlay-stage--full {
  width: 94vw;
  height: 82vh;
}

/* fallback caption when window.Loader is unavailable */
.app-overlay-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-data, ui-monospace, monospace);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--ink, inherit);
}

@keyframes app-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  /* no fade in/out — overlay.js also skips its fade delay */
  .app-overlay { animation: none; }
  .app-overlay.is-hiding { transition: none; }
}
