/* ═══════════════════════════════════════════════════════════════════════════════
   Nyano Portal Premium Animations v1.0
   ═══════════════════════════════════════════════════════════════════════════════
   Enhanced animations and effects for premium templates.
   These complement nyano_portal.css and are activated by CSS variables in themes.
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────────
   § Shimmer / Scan Line Effect
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.nyano-shimmer {
  position: relative;
  overflow: hidden;
}

.nyano-shimmer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.08) 25%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(255, 255, 255, 0.08) 75%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: nyano-shimmer var(--anim-shimmer, 3s) ease-in-out infinite;
  pointer-events: none;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Glow Pulse Effect
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-glow-pulse {
  0%, 100% {
    box-shadow: var(--glow-card, 0 12px 48px rgba(14, 165, 233, 0.14));
    opacity: 1;
  }
  50% {
    box-shadow: var(--glow-card-pulse, 0 16px 64px rgba(14, 165, 233, 0.22));
    opacity: 0.95;
  }
}

.nyano-glow-pulse {
  animation: nyano-glow-pulse var(--anim-glow-pulse, 4s) ease-in-out infinite;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Aurora Wave Effect (for Nyano Aurora theme)
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-aurora-wave {
  0% {
    background-position: 0% 50%, 100% 50%, 50% 100%;
    filter: hue-rotate(0deg);
  }
  33% {
    background-position: 100% 50%, 0% 50%, 50% 0%;
    filter: hue-rotate(15deg);
  }
  66% {
    background-position: 50% 0%, 50% 100%, 100% 50%;
    filter: hue-rotate(-10deg);
  }
  100% {
    background-position: 0% 50%, 100% 50%, 50% 100%;
    filter: hue-rotate(0deg);
  }
}

body[data-theme-id="nyano-aurora"]::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 20%, rgba(6, 182, 212, 0.15), transparent 50%),
    radial-gradient(ellipse 60% 40% at 80% 30%, rgba(139, 92, 246, 0.12), transparent 45%),
    radial-gradient(ellipse 70% 45% at 50% 80%, rgba(236, 72, 153, 0.10), transparent 50%);
  animation: nyano-aurora-wave var(--anim-aurora-wave, 20s) ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Nebula Drift Effect (for Nyano Nebula theme)
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-nebula-drift {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.7;
  }
  25% {
    transform: translate(5%, -3%) scale(1.02);
    opacity: 0.8;
  }
  50% {
    transform: translate(-3%, 5%) scale(0.98);
    opacity: 0.65;
  }
  75% {
    transform: translate(-5%, -2%) scale(1.03);
    opacity: 0.75;
  }
}

body[data-theme-id="nyano-nebula"]::before {
  content: "";
  position: fixed;
  top: -20%;
  left: -20%;
  right: -20%;
  bottom: -20%;
  background:
    radial-gradient(ellipse 40% 30% at 25% 25%, rgba(167, 139, 250, 0.20), transparent),
    radial-gradient(ellipse 35% 25% at 75% 35%, rgba(129, 140, 248, 0.18), transparent),
    radial-gradient(ellipse 45% 35% at 50% 75%, rgba(192, 132, 252, 0.15), transparent),
    radial-gradient(ellipse 25% 20% at 70% 60%, rgba(56, 189, 248, 0.10), transparent);
  animation: nyano-nebula-drift var(--anim-nebula-drift, 25s) ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

/* Star field overlay for Nebula */
body[data-theme-id="nyano-nebula"]::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 30% 45%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 55% 15%, rgba(255, 255, 255, 0.7), transparent),
    radial-gradient(1px 1px at 70% 65%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 85% 30%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 20% 80%, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 45% 55%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 90% 85%, rgba(255, 255, 255, 0.5), transparent);
  animation: nyano-twinkle var(--anim-twinkle, 8s) ease-in-out infinite alternate;
  pointer-events: none;
  z-index: 0;
}

@keyframes nyano-twinkle {
  0% { opacity: 0.5; }
  50% { opacity: 0.8; }
  100% { opacity: 0.6; }
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Neon Flicker Effect (for Nyano Neon theme)
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-neon-flicker {
  0%, 100% {
    opacity: 1;
    filter: brightness(1);
  }
  5% {
    opacity: 0.8;
    filter: brightness(0.9);
  }
  10% {
    opacity: 1;
    filter: brightness(1.1);
  }
  15% {
    opacity: 0.95;
    filter: brightness(1);
  }
  50% {
    opacity: 1;
    filter: brightness(1);
  }
  52% {
    opacity: 0.85;
    filter: brightness(0.95);
  }
  54% {
    opacity: 1;
    filter: brightness(1.05);
  }
}

body[data-theme-id="nyano-neon"] .nyano-hero-title,
body[data-theme-id="nyano-neon"] .nyano-brand-name {
  animation: nyano-neon-flicker var(--anim-neon-flicker, 4s) ease-in-out infinite;
  text-shadow: 
    0 0 5px currentColor,
    0 0 10px currentColor,
    0 0 20px currentColor,
    0 0 40px var(--primary, #22d3ee);
}

/* Scan line overlay for Neon */
body[data-theme-id="nyano-neon"]::before {
  content: "";
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
  mix-blend-mode: multiply;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Golden Gleam Effect (for Nyano Obsidian theme)
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-golden-gleam {
  0% {
    background-position: -200% 0;
  }
  50% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

body[data-theme-id="nyano-obsidian"] .nyano-btn-primary::before,
body[data-theme-id="nyano-obsidian"] .nyano-login-btn::before {
  background: linear-gradient(
    110deg,
    transparent 20%,
    rgba(254, 243, 199, 0.25) 35%,
    rgba(254, 243, 199, 0.50) 50%,
    rgba(254, 243, 199, 0.25) 65%,
    transparent 80%
  );
  background-size: 200% 100%;
  animation: nyano-golden-gleam var(--anim-golden-gleam, 5s) ease-in-out infinite;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Frost Crystal Sparkle (for Nyano Frost theme)
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-frost-sparkle {
  0%, 100% {
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

body[data-theme-id="nyano-frost"] .nyano-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 15% 25%, rgba(255, 255, 255, 0.9), transparent 50%),
    radial-gradient(2px 2px at 45% 15%, rgba(255, 255, 255, 0.8), transparent 50%),
    radial-gradient(3px 3px at 75% 35%, rgba(255, 255, 255, 0.95), transparent 50%),
    radial-gradient(2px 2px at 25% 65%, rgba(255, 255, 255, 0.7), transparent 50%),
    radial-gradient(2px 2px at 85% 75%, rgba(255, 255, 255, 0.85), transparent 50%),
    radial-gradient(3px 3px at 55% 85%, rgba(255, 255, 255, 0.9), transparent 50%);
  animation: nyano-frost-sparkle var(--anim-frost-sparkle, 3s) ease-in-out infinite;
  pointer-events: none;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Coral Wave Effect (for Nyano Coral theme)
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-coral-wave {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-5px) rotate(0.5deg);
  }
  75% {
    transform: translateY(5px) rotate(-0.5deg);
  }
}

body[data-theme-id="nyano-coral"] .nyano-carousel-stage {
  animation: nyano-coral-wave var(--anim-coral-wave, 8s) ease-in-out infinite;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Matcha Zen Breathing (for Nyano Matcha theme)
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-zen-breathe {
  0%, 100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.02);
    opacity: 1;
  }
}

body[data-theme-id="nyano-matcha"] .nyano-guide-card {
  animation: nyano-zen-breathe var(--anim-zen-breathe, 6s) ease-in-out infinite;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Card Entrance Animations
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-card-enter {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes nyano-card-enter-stagger {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

body[data-mode="public"] .card,
body[data-mode="portal"] .card {
  animation: nyano-card-enter var(--anim-card-enter, 0.5s) cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

body[data-mode="public"] .card:nth-child(1) { animation-delay: 0ms; }
body[data-mode="public"] .card:nth-child(2) { animation-delay: 80ms; }
body[data-mode="public"] .card:nth-child(3) { animation-delay: 160ms; }
body[data-mode="public"] .card:nth-child(4) { animation-delay: 240ms; }
body[data-mode="public"] .card:nth-child(5) { animation-delay: 320ms; }
body[data-mode="public"] .card:nth-child(6) { animation-delay: 400ms; }

body[data-mode="portal"] .card:nth-child(1) { animation-delay: 0ms; }
body[data-mode="portal"] .card:nth-child(2) { animation-delay: 60ms; }
body[data-mode="portal"] .card:nth-child(3) { animation-delay: 120ms; }
body[data-mode="portal"] .card:nth-child(4) { animation-delay: 180ms; }
body[data-mode="portal"] .card:nth-child(5) { animation-delay: 240ms; }

/* ─────────────────────────────────────────────────────────────────────────────────
   § Hero Title Entrance
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-hero-title-enter {
  from {
    opacity: 0;
    transform: translateY(40px);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

body[data-mode="public"] .nyano-hero-title {
  animation: nyano-hero-title-enter var(--anim-hero-title-enter, 0.8s) cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.2s;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Button Magnetic Hover
   ───────────────────────────────────────────────────────────────────────────────── */
.nyano-btn,
.nyano-login-btn {
  transition: 
    transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 250ms ease,
    background-position 600ms ease;
}

.nyano-btn:hover,
.nyano-login-btn:hover {
  transform: translateY(-3px) scale(1.02);
}

.nyano-btn:active,
.nyano-login-btn:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 100ms;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Chip Entrance Animation
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-chip-pop {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.nyano-chip {
  animation: nyano-chip-pop var(--anim-chip-pop, 0.4s) cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Progress Bar Animation
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-progress-fill {
  from {
    width: 0;
    opacity: 0.5;
  }
  to {
    opacity: 1;
  }
}

@keyframes nyano-progress-shine {
  0% {
    left: -100%;
  }
  50%, 100% {
    left: 100%;
  }
}

.nyano-progress-bar {
  animation: nyano-progress-fill var(--anim-progress-fill, 1s) ease-out both;
  position: relative;
  overflow: hidden;
}

.nyano-progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  animation: nyano-progress-shine var(--anim-progress-shine, 2s) ease-in-out infinite;
  animation-delay: 1s;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Toast Notifications
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-toast-enter {
  from {
    opacity: 0;
    transform: translateY(100%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes nyano-toast-exit {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
}

.nyano-toast.is-show {
  animation: nyano-toast-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.nyano-toast.is-hide {
  animation: nyano-toast-exit 0.2s ease-in both;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Stat Counter Animation
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-stat-count {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nyano-stat-value {
  animation: nyano-stat-count var(--anim-stat-count, 0.6s) cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.3s;
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Scroll-Triggered Fade In (using CSS-only intersection simulation)
   ───────────────────────────────────────────────────────────────────────────────── */
@keyframes nyano-scroll-reveal {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.nyano-scroll-reveal {
  animation: nyano-scroll-reveal var(--anim-scroll-reveal, 0.7s) cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-timeline: view();
  animation-range: entry 0% entry 40%;
}

/* Fallback for browsers without animation-timeline */
@supports not (animation-timeline: view()) {
  .nyano-scroll-reveal {
    animation: nyano-scroll-reveal 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: 0.1s;
  }
}

/* ─────────────────────────────────────────────────────────────────────────────────
   § Reduced Motion Support
   ───────────────────────────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  body[data-theme-id="nyano-aurora"]::before,
  body[data-theme-id="nyano-nebula"]::before,
  body[data-theme-id="nyano-nebula"]::after,
  body[data-theme-id="nyano-neon"]::before,
  body[data-theme-id="nyano-frost"] .nyano-hero::after {
    animation: none !important;
    display: none;
  }
}
