/* Thirai Boot Module — base styles (spec: Thirai Boot Module.md, "CSS Responsibilities").
   Loaded before the kernel; must stand on its own with no dependency on thirai-base.css,
   though it reuses the same --thirai-* custom-property names so a booted app and its
   splash screen read as one visual system rather than two. Theme overrides (light/dark/
   auto) live in themes/*.css and only ever touch color tokens, never layout. */

:root {
  --thirai-boot-bg: #f6f5f2;
  --thirai-boot-surface: #ffffff;
  --thirai-boot-ink: #1f2430;
  --thirai-boot-muted: #6b7280;
  --thirai-boot-accent: #8a3324;
  --thirai-boot-border: #e3e0d8;
  --thirai-boot-track: #e3e0d8;
  --thirai-boot-fade-ms: 300ms;
}

#thirai-boot {
  position: fixed;
  inset: 0;
  z-index: 2147483647; /* always above application content, including framework error panels */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--thirai-boot-bg);
  color: var(--thirai-boot-ink);
  font-family: Georgia, "Times New Roman", serif;
  opacity: 1;
  transition: opacity var(--thirai-boot-fade-ms) ease;
}

#thirai-boot.thirai-boot-hidden {
  opacity: 0;
  pointer-events: none;
}

#thirai-boot.thirai-boot-blur {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#thirai-boot .boot-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  width: min(90vw, 22rem);
  padding: 2rem 1.5rem;
  text-align: center;
  box-sizing: border-box;
}

#thirai-boot img[data-logo] {
  width: 3.5rem;
  height: 3.5rem;
  object-fit: contain;
}
#thirai-boot img[data-logo]:not([src]) { display: none; }

#thirai-boot h1[data-title] {
  margin: 0;
  /* Explicit border/padding reset: a host page may load its own generic h1 { border-bottom }
     chrome (e.g. thirai-base.css) alongside boot.css -- Boot must never inherit styling
     from whatever else happens to be on the page (Design Principles: dependency-free). */
  border: none;
  padding: 0;
  font-size: 1.4rem;
  font-weight: normal;
  letter-spacing: 0.01em;
}
#thirai-boot h1[data-title]:empty { display: none; }

#thirai-boot h2[data-subtitle] {
  margin: 0;
  font-size: 0.95rem;
  font-weight: normal;
  color: var(--thirai-boot-muted);
}
#thirai-boot h2[data-subtitle]:empty { display: none; }

#thirai-boot p[data-message] {
  margin: 0.25rem 0 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--thirai-boot-muted);
  transition: opacity 150ms ease;
}
#thirai-boot p[data-message].thirai-boot-message-swap { opacity: 0; }

#thirai-boot [data-animation] {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2rem;
  min-height: 2rem;
}

#thirai-boot .progress {
  width: 100%;
  height: 0.35rem;
  border-radius: 999px;
  background: var(--thirai-boot-track);
  overflow: hidden;
}
#thirai-boot [data-progress] {
  height: 100%;
  width: 0%;
  background: var(--thirai-boot-accent);
  border-radius: inherit;
  transition: width 200ms ease;
}
#thirai-boot [data-progress-text] {
  font-size: 0.75rem;
  color: var(--thirai-boot-muted);
  font-family: ui-monospace, "Courier New", monospace;
}

/* ---- Animation bases (JS mounts/unmounts the markup; CSS drives the motion) ---- */

#thirai-boot .thirai-anim-spinner {
  width: 1.5rem; height: 1.5rem;
  border-radius: 50%;
  border: 2px solid var(--thirai-boot-border);
  border-top-color: var(--thirai-boot-accent);
  animation: thirai-boot-spin 800ms linear infinite;
}

#thirai-boot .thirai-anim-dots { display: flex; gap: 0.35rem; }
#thirai-boot .thirai-anim-dots span {
  width: 0.45rem; height: 0.45rem; border-radius: 50%;
  background: var(--thirai-boot-accent);
  animation: thirai-boot-pulse-dot 1000ms ease-in-out infinite;
}
#thirai-boot .thirai-anim-dots span:nth-child(2) { animation-delay: 120ms; }
#thirai-boot .thirai-anim-dots span:nth-child(3) { animation-delay: 240ms; }

#thirai-boot .thirai-anim-pulse {
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: var(--thirai-boot-accent);
  animation: thirai-boot-pulse-ring 1200ms ease-out infinite;
}

#thirai-boot .thirai-anim-orbit {
  position: relative; width: 1.6rem; height: 1.6rem;
  animation: thirai-boot-spin 1400ms linear infinite;
}
#thirai-boot .thirai-anim-orbit span {
  position: absolute; top: 0; left: 50%;
  width: 0.4rem; height: 0.4rem; margin-left: -0.2rem;
  border-radius: 50%; background: var(--thirai-boot-accent);
}

#thirai-boot .thirai-anim-typing {
  font-family: ui-monospace, "Courier New", monospace;
  font-size: 0.85rem; color: var(--thirai-boot-accent);
}
#thirai-boot .thirai-anim-typing::after {
  content: "";
  display: inline-block; width: 0.5em;
  animation: thirai-boot-caret 900ms steps(1) infinite;
}

#thirai-boot .thirai-anim-progress {
  position: relative;
  width: 100%; height: 0.3rem;
  border-radius: 999px;
  background: var(--thirai-boot-track);
  overflow: hidden;
}
#thirai-boot .thirai-anim-progress span {
  position: absolute; top: 0; left: 0; height: 100%; width: 40%;
  border-radius: inherit;
  background: var(--thirai-boot-accent);
  animation: thirai-boot-sweep 1100ms ease-in-out infinite;
}
@keyframes thirai-boot-sweep {
  0% { left: -40%; }
  100% { left: 100%; }
}

@keyframes thirai-boot-spin { to { transform: rotate(360deg); } }
@keyframes thirai-boot-pulse-dot {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}
@keyframes thirai-boot-pulse-ring {
  0% { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.6); opacity: 0; }
}
@keyframes thirai-boot-caret {
  0%, 50% { content: "_"; } 51%, 100% { content: ""; }
}

/* ---- Template variants (structure is shared; these only restyle it) ---- */

#thirai-boot.thirai-boot-minimal .boot-container { gap: 0.5rem; width: min(80vw, 16rem); }
#thirai-boot.thirai-boot-minimal h1[data-title] { font-size: 1.1rem; }
#thirai-boot.thirai-boot-minimal p[data-message],
#thirai-boot.thirai-boot-minimal .progress { display: none; }

#thirai-boot.thirai-boot-enterprise .boot-container {
  background: var(--thirai-boot-surface);
  border: 1px solid var(--thirai-boot-border);
  border-radius: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

#thirai-boot.thirai-boot-terminal {
  background: #0b0f0c;
  color: #8fe38f;
}
#thirai-boot.thirai-boot-terminal .boot-container {
  align-items: flex-start; text-align: left; width: min(90vw, 26rem);
  font-family: ui-monospace, "Courier New", monospace;
}
#thirai-boot.thirai-boot-terminal h1[data-title],
#thirai-boot.thirai-boot-terminal h2[data-subtitle] { color: #8fe38f; }
#thirai-boot.thirai-boot-terminal p[data-message] { color: #5fbf5f; }
#thirai-boot.thirai-boot-terminal p[data-message]::before { content: "> "; }
#thirai-boot.thirai-boot-terminal .progress { background: #163318; }
#thirai-boot.thirai-boot-terminal [data-progress] { background: #5fbf5f; }

#thirai-boot.thirai-boot-glass .boot-container {
  background: color-mix(in srgb, var(--thirai-boot-surface) 55%, transparent);
  border: 1px solid color-mix(in srgb, var(--thirai-boot-border) 70%, transparent);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
}

/* ---- Responsive ---- */
@media (max-width: 420px) {
  #thirai-boot .boot-container { width: min(94vw, 20rem); padding: 1.5rem 1rem; }
}
