/* =====================================================
   AstroOracle Matrix — Animations & Effects v2
   Enhanced: Page transitions, splash, micro-interactions
   ===================================================== */

/* === Core Keyframes === */
@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 15px rgba(167, 139, 250, 0.2); }
    50% { box-shadow: 0 0 30px rgba(167, 139, 250, 0.4), 0 0 60px rgba(167, 139, 250, 0.1); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes rotate-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes energy-wave {
    0% { transform: scale(0.8); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 0.2; }
    100% { transform: scale(1.6); opacity: 0; }
}

@keyframes gold-burst {
    0% { transform: scale(0) rotate(0deg); opacity: 1; }
    70% { opacity: 1; }
    100% { transform: scale(2) rotate(180deg); opacity: 0; }
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

@keyframes card-reveal {
    0% { opacity: 0; transform: scale(0.6) rotateY(180deg); }
    60% { transform: scale(1.05) rotateY(10deg); }
    100% { opacity: 1; transform: scale(1) rotateY(0deg); }
}

@keyframes coin-bounce {
    0% { transform: translateY(-200px) rotate(0deg); opacity: 0; }
    40% { transform: translateY(0) rotate(180deg); opacity: 1; }
    55% { transform: translateY(-40px) rotate(270deg); }
    70% { transform: translateY(0) rotate(360deg); }
    80% { transform: translateY(-15px) rotate(405deg); }
    90% { transform: translateY(0) rotate(450deg); }
    100% { transform: translateY(0) rotate(540deg); opacity: 1; }
}

@keyframes line-draw {
    from { width: 0; }
    to { width: 100%; }
}

/* === NEW: Page Slide Transitions === */
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

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

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

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

.slide-in-left { animation: slideInLeft 0.4s var(--ease) forwards; }
.slide-out-left { animation: slideOutLeft 0.3s var(--ease) forwards; }
.slide-in-right { animation: slideInRight 0.4s var(--ease) forwards; }
.slide-out-right { animation: slideOutRight 0.3s var(--ease) forwards; }

/* === NEW: Splash Screen === */
#splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: radial-gradient(ellipse at center, #1a0f3e 0%, #0d0520 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    transition: opacity 0.8s ease, visibility 0.8s;
}

#splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-logo {
    font-size: 5rem;
    filter: drop-shadow(0 0 30px rgba(167, 139, 250, 0.6));
    animation: float 2s ease-in-out infinite, pulse-glow 3s ease-in-out infinite;
}

.splash-title {
    font-family: var(--font-serif);
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #fbbf24, #a78bfa, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 3s linear infinite;
    background-size: 200% 100%;
}

.splash-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.splash-loader {
    width: 200px;
    height: 2px;
    background: rgba(167, 139, 250, 0.2);
    border-radius: 1px;
    overflow: hidden;
    margin-top: 1rem;
}

.splash-loader::after {
    content: '';
    display: block;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, var(--crystal-purple), var(--gold));
    border-radius: 1px;
    animation: loaderSlide 1.5s ease-in-out infinite;
}

@keyframes loaderSlide {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(300%); }
}

/* === NEW: Toast Enhancements === */
.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(167, 139, 250, 0.2);
    font-size: 0.85rem;
    transform: translateX(100px);
    opacity: 0;
    transition: all 0.4s var(--ease);
    margin-bottom: 0.6rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(100px);
    opacity: 0;
}

.toast-success { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); }
.toast-error { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); }
.toast-info { background: rgba(56, 189, 248, 0.15); border-color: rgba(56, 189, 248, 0.3); }
.toast-warning { background: rgba(251, 191, 36, 0.15); border-color: rgba(251, 191, 36, 0.3); }

.toast-icon { font-size: 1.1rem; }
.toast-msg { flex: 1; }

/* === NEW: Button Micro-interactions === */
.btn-primary,
.btn-secondary,
.btn-accent {
    position: relative;
    overflow: hidden;
}

.btn-primary::after,
.btn-accent::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.btn-primary:hover::after,
.btn-accent:hover::after {
    transform: translateX(100%);
}

/* Ripple effect */
.btn-primary:active,
.btn-secondary:active,
.btn-accent:active {
    transform: scale(0.97);
}

/* === NEW: Glass Card Hover Enhancement === */
.glass-card {
    transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease), border-color 0.3s;
}

.glass-card:hover {
    border-color: rgba(167, 139, 250, 0.25);
    box-shadow: 0 8px 40px rgba(88, 28, 135, 0.15);
}

/* === NEW: Module Card 3D Tilt === */
.module-card {
    transition: transform 0.4s var(--ease), box-shadow 0.4s;
    cursor: pointer;
}

.module-card:hover {
    transform: translateY(-6px) rotateX(2deg) rotateY(-2deg);
    box-shadow: 0 20px 60px rgba(88, 28, 135, 0.25);
}

.module-card:hover .mc-icon {
    transform: scale(1.2) rotate(5deg);
    transition: transform 0.4s var(--ease);
}

/* === NEW: Sound Toggle Buttons === */
.sound-controls {
    display: flex;
    gap: 0.3rem;
}

.sound-btn {
    background: transparent;
    border: 1px solid rgba(167, 139, 250, 0.15);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.sound-btn:hover {
    background: rgba(167, 139, 250, 0.1);
    color: var(--text-primary);
}

.sound-btn.muted {
    opacity: 0.4;
}

.sound-btn.active {
    background: rgba(167, 139, 250, 0.15);
    border-color: var(--crystal-purple);
    color: var(--crystal-purple);
}

/* === Utility Animation Classes === */
.animate-float { animation: float 4s ease-in-out infinite; }
.animate-pulse { animation: pulse-glow 3s ease-in-out infinite; }
.animate-spin-slow { animation: rotate-slow 20s linear infinite; }
.animate-twinkle { animation: twinkle 2s ease-in-out infinite; }

.animate-shimmer {
    background: linear-gradient(90deg, transparent 30%, rgba(251, 191, 36, 0.15) 50%, transparent 70%);
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

/* Staggered fade in */
.stagger-in > * {
    opacity: 0;
    transform: translateY(15px);
    animation: viewFadeIn 0.4s var(--ease) forwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-in > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-in > *:nth-child(8) { animation-delay: 0.4s; }

/* === NEW: Typewriter effect for readings === */
@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

.typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--crystal-purple);
    animation: typewriter 2s steps(40) forwards, blink-cursor 0.8s steps(1) infinite;
}

@keyframes blink-cursor {
    0%, 100% { border-color: var(--crystal-purple); }
    50% { border-color: transparent; }
}

/* === NEW: Energy ring animation === */
@keyframes energy-ring-pulse {
    0% { stroke-dashoffset: 283; }
    100% { stroke-dashoffset: 0; }
}

.energy-ring {
    transform: rotate(-90deg);
    transform-origin: center;
}

.energy-ring circle.progress {
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    animation: energy-ring-pulse 2s ease-out forwards;
    stroke-linecap: round;
}
