/* ============================================================
   MiaoMi — animations.css
   All keyframes & transitions
   Version 1.0
   ============================================================ */

/* ── Boot / Loader ──────────────────────────────────────────── */

/* Full-screen boot loader */
#boot-loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-loader);
  background: var(--bg-void);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#boot-loader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-logo {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  animation: bootFadeIn 0.8s ease 0.3s forwards;
  opacity: 0;
}

.boot-logo span {
  color: var(--orange-fire);
}

.boot-progress-wrap {
  width: 200px;
  height: 1px;
  background: var(--bg-surface-3);
  border-radius: var(--radius-full);
  overflow: hidden;
  animation: bootFadeIn 0.8s ease 0.5s forwards;
  opacity: 0;
}

.boot-progress-bar {
  height: 100%;
  background: var(--orange-fire);
  border-radius: var(--radius-full);
  width: 0%;
  transition: width var(--transition-slow);
  box-shadow: 0 0 8px rgba(255, 85, 0, 0.6);
}

.boot-status {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  min-height: 16px;
  animation: bootFadeIn 0.8s ease 0.7s forwards;
  opacity: 0;
}

/* Page reveal after boot */
.page-reveal {
  animation: pageReveal 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ── Core Keyframes ─────────────────────────────────────────── */

@keyframes bootFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pageReveal {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeLeft {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes fadeRight {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.93); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes scaleOut {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.93); }
}

/* Slide animations */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-100%); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(100%); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideRight {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}

/* Shimmer (skeleton) */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Pulse glow (status dots, orange elements) */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 85, 0, 0.4); }
  50%       { box-shadow: 0 0 0 8px rgba(255, 85, 0, 0); }
}

/* Spin (loading spinner) */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Ticker scroll */
@keyframes tickerScroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* Counter increment flash */
@keyframes counterFlash {
  0%   { color: var(--orange-fire); }
  100% { color: var(--text-primary); }
}

/* Float (for decorative elements) */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

/* Wobble (for interactive feedback) */
@keyframes wobble {
  0%   { transform: rotate(0deg); }
  15%  { transform: rotate(-4deg); }
  30%  { transform: rotate(3deg); }
  45%  { transform: rotate(-2deg); }
  60%  { transform: rotate(1deg); }
  100% { transform: rotate(0deg); }
}

/* Flicker (terminal effect) */
@keyframes flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: 0.4; }
}

/* Typing cursor blink */
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Flip board character */
@keyframes flipBoard {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(-90deg); }
  50.1%{ transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

/* Toast entrance */
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

/* Progress bar fill */
@keyframes progressFill {
  from { width: 0; }
  to   { width: var(--progress, 100%); }
}

/* Gradient shift */
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Waveform bars */
@keyframes waveBar1 { 0%, 100% { height: 4px; }  50% { height: 20px; } }
@keyframes waveBar2 { 0%, 100% { height: 8px; }  50% { height: 28px; } }
@keyframes waveBar3 { 0%, 100% { height: 12px; } 50% { height: 36px; } }
@keyframes waveBar4 { 0%, 100% { height: 6px; }  50% { height: 24px; } }
@keyframes waveBar5 { 0%, 100% { height: 10px; } 50% { height: 32px; } }

/* Stagger helper for lists */
@keyframes staggerFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Utility Animation Classes ──────────────────────────────── */

.anim-fade-in   { animation: fadeIn   var(--transition-normal) forwards; }
.anim-fade-up   { animation: fadeUp   var(--transition-normal) forwards; }
.anim-fade-down { animation: fadeDown var(--transition-normal) forwards; }
.anim-scale-in  { animation: scaleIn  var(--transition-normal) forwards; }

/* Stagger delays */
.anim-delay-1 { animation-delay: 100ms; }
.anim-delay-2 { animation-delay: 200ms; }
.anim-delay-3 { animation-delay: 300ms; }
.anim-delay-4 { animation-delay: 400ms; }
.anim-delay-5 { animation-delay: 500ms; }
.anim-delay-6 { animation-delay: 600ms; }

/* Default: hidden until animated */
[data-animate] {
  opacity: 0;
}

[data-animate="fade-up"] {
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

[data-animate="fade-in"] {
  transition: opacity 0.6s ease;
}

[data-animate="scale-in"] {
  transform: scale(0.95);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

[data-animate].animated {
  opacity: 1;
  transform: none;
}

/* ── Spinner ─────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--orange-fire);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}

.spinner-lg {
  width: 32px;
  height: 32px;
  border-width: 3px;
}

/* ── Live Ticker ─────────────────────────────────────────────── */

.ticker-wrap {
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}

.ticker-track {
  display: inline-flex;
  gap: var(--space-2xl);
  animation: tickerScroll 30s linear infinite;
  will-change: transform;
}

.ticker-wrap:hover .ticker-track {
  animation-play-state: paused;
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.ticker-item::before {
  content: '//';
  color: var(--orange-fire);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ── Waveform (CSS only) ─────────────────────────────────────── */

.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
}

.wave-bar {
  width: 3px;
  background: var(--orange-fire);
  border-radius: var(--radius-full);
  opacity: 0.7;
}

.wave-bar:nth-child(5n+1) { animation: waveBar1 1.2s ease-in-out infinite; }
.wave-bar:nth-child(5n+2) { animation: waveBar2 1.0s ease-in-out infinite 0.1s; }
.wave-bar:nth-child(5n+3) { animation: waveBar3 1.4s ease-in-out infinite 0.2s; }
.wave-bar:nth-child(5n+4) { animation: waveBar4 1.1s ease-in-out infinite 0.15s; }
.wave-bar:nth-child(5n+5) { animation: waveBar5 1.3s ease-in-out infinite 0.05s; }

/* ── Status dot ──────────────────────────────────────────────── */

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-dot.pulse {
  animation: pulseGlow 2s ease-in-out infinite;
}

/* ── Cursor blink ────────────────────────────────────────────── */

.cursor-blink::after {
  content: '|';
  color: var(--orange-fire);
  animation: cursorBlink 1s step-end infinite;
  margin-left: 2px;
}

/* ── Geometric background pattern ───────────────────────────── */

.geo-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.geo-bg::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(255, 85, 0, 0.06) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  border-radius: 50%;
  animation: float 8s ease-in-out infinite;
}

.geo-bg::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(255, 85, 0, 0.04) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  border-radius: 50%;
  animation: float 10s ease-in-out infinite 3s;
}

/* ── Blur transition (for i18n swap) ────────────────────────── */

.lang-transitioning [data-i18n] {
  filter: blur(4px);
  opacity: 0.5;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

[data-i18n] {
  transition: filter 0.15s ease, opacity 0.15s ease;
}

/* ── Reduced motion ──────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .ticker-track { animation: none; }
  .geo-bg::before,
  .geo-bg::after { animation: none; }
}
