/* ==========================================
   ADVANCED ANIMATIONS - 1000X UPGRADE
   ========================================== */

/* Keyframe Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-5deg) scale(0.95);
    }

    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* Advanced Floating Animation */
@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-12px) rotate(1deg);
    }

    50% {
        transform: translateY(-6px) rotate(-1deg);
    }

    75% {
        transform: translateY(-18px) rotate(0.5deg);
    }
}

@keyframes floatSlow {

    0%,
    100% {
        transform: translateY(0) translateX(0);
    }

    33% {
        transform: translateY(-8px) translateX(4px);
    }

    66% {
        transform: translateY(-4px) translateX(-4px);
    }
}

/* Mystical Glow Pulse */
@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(184, 160, 96, 0.3),
            0 0 40px rgba(184, 160, 96, 0.1),
            inset 0 0 20px rgba(184, 160, 96, 0.05);
    }

    50% {
        box-shadow: 0 0 40px rgba(184, 160, 96, 0.5),
            0 0 80px rgba(184, 160, 96, 0.2),
            inset 0 0 40px rgba(184, 160, 96, 0.1);
    }
}

@keyframes runeGlow {

    0%,
    100% {
        text-shadow: 0 0 20px rgba(184, 160, 96, 0.8),
            0 0 40px rgba(184, 160, 96, 0.4),
            0 0 60px rgba(184, 160, 96, 0.2);
    }

    50% {
        text-shadow: 0 0 30px rgba(184, 160, 96, 1),
            0 0 60px rgba(184, 160, 96, 0.6),
            0 0 100px rgba(184, 160, 96, 0.3);
    }
}

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: -200% center;
    }

    100% {
        background-position: 200% center;
    }
}

@keyframes shimmerText {
    0% {
        background-position: -100% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* Ethereal Sparkle */
@keyframes sparkle {

    0%,
    100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }

    50% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }
}

/* Nordic Mist Drift */
@keyframes mistDrift {
    0% {
        transform: translateX(-5%) translateY(0);
        opacity: 0.3;
    }

    50% {
        transform: translateX(5%) translateY(-10px);
        opacity: 0.5;
    }

    100% {
        transform: translateX(-5%) translateY(0);
        opacity: 0.3;
    }
}

@keyframes mistDriftReverse {
    0% {
        transform: translateX(5%) translateY(0);
        opacity: 0.2;
    }

    50% {
        transform: translateX(-5%) translateY(10px);
        opacity: 0.4;
    }

    100% {
        transform: translateX(5%) translateY(0);
        opacity: 0.2;
    }
}

/* Aurora Borealis Effect */
@keyframes aurora {

    0%,
    100% {
        background-position: 0% 50%;
        opacity: 0.3;
    }

    50% {
        background-position: 100% 50%;
        opacity: 0.5;
    }
}

/* Breathing/Pulsing */
@keyframes breathe {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.02);
        opacity: 0.9;
    }
}

/* Quill Writing */
@keyframes quillWrite {
    0% {
        width: 0;
        opacity: 1;
    }

    100% {
        width: 100%;
        opacity: 1;
    }
}

/* Letter Reveal */
@keyframes letterReveal {
    0% {
        opacity: 0;
        transform: translateY(20px) rotateX(-90deg);
        filter: blur(4px);
    }

    100% {
        opacity: 1;
        transform: translateY(0) rotateX(0);
        filter: blur(0);
    }
}

/* Magical Border */
@keyframes magicalBorder {

    0%,
    100% {
        border-color: rgba(184, 160, 96, 0.3);
    }

    50% {
        border-color: rgba(184, 160, 96, 0.8);
    }
}

/* Fog/Mist Movement */
@keyframes fogLayer1 {
    0% {
        transform: translateX(0) translateY(0) scale(1);
    }

    50% {
        transform: translateX(-3%) translateY(2%) scale(1.02);
    }

    100% {
        transform: translateX(0) translateY(0) scale(1);
    }
}

@keyframes fogLayer2 {
    0% {
        transform: translateX(0) translateY(0) scale(1);
    }

    50% {
        transform: translateX(4%) translateY(-2%) scale(1.03);
    }

    100% {
        transform: translateX(0) translateY(0) scale(1);
    }
}

@keyframes fogLayer3 {
    0% {
        transform: translateX(0) translateY(0) scale(1);
        opacity: 0.4;
    }

    50% {
        transform: translateX(-2%) translateY(3%) scale(1.01);
        opacity: 0.6;
    }

    100% {
        transform: translateX(0) translateY(0) scale(1);
        opacity: 0.4;
    }
}

/* Fire Flicker */
@keyframes fireFlicker {

    0%,
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }

    25% {
        opacity: 0.9;
        transform: scale(1.02) rotate(0.5deg);
    }

    50% {
        opacity: 1;
        transform: scale(0.98) rotate(-0.5deg);
    }

    75% {
        opacity: 0.95;
        transform: scale(1.01) rotate(0.25deg);
    }
}

/* Snow Fall */
@keyframes snowfall {
    0% {
        transform: translateY(-100vh) translateX(0) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) translateX(100px) rotate(360deg);
        opacity: 0.3;
    }
}

/* Rune Rotation */
@keyframes runeRotate {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ====================
   SCROLL ANIMATIONS
   ==================== */

[data-animate] {
    opacity: 0;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.8s cubic-bezier(0.4, 0, 0.2, 1),
        filter 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-animate].animate-in {
    opacity: 1;
}

[data-animate="fade-up"] {
    transform: translateY(60px);
    filter: blur(2px);
}

[data-animate="fade-up"].animate-in {
    transform: translateY(0);
    filter: blur(0);
}

[data-animate="fade-down"] {
    transform: translateY(-60px);
    filter: blur(2px);
}

[data-animate="fade-down"].animate-in {
    transform: translateY(0);
    filter: blur(0);
}

[data-animate="fade-left"] {
    transform: translateX(-60px);
    filter: blur(2px);
}

[data-animate="fade-left"].animate-in {
    transform: translateX(0);
    filter: blur(0);
}

[data-animate="fade-right"] {
    transform: translateX(60px);
    filter: blur(2px);
}

[data-animate="fade-right"].animate-in {
    transform: translateX(0);
    filter: blur(0);
}

[data-animate="scale"] {
    transform: scale(0.85);
    filter: blur(4px);
}

[data-animate="scale"].animate-in {
    transform: scale(1);
    filter: blur(0);
}

[data-animate="rotate"] {
    transform: rotate(-8deg) scale(0.9);
    filter: blur(2px);
}

[data-animate="rotate"].animate-in {
    transform: rotate(0) scale(1);
    filter: blur(0);
}

/* Stagger Delays */
[data-delay="100"] {
    transition-delay: 0.1s;
}

[data-delay="200"] {
    transition-delay: 0.2s;
}

[data-delay="300"] {
    transition-delay: 0.3s;
}

[data-delay="400"] {
    transition-delay: 0.4s;
}

[data-delay="500"] {
    transition-delay: 0.5s;
}

[data-delay="600"] {
    transition-delay: 0.6s;
}

[data-delay="700"] {
    transition-delay: 0.7s;
}

[data-delay="800"] {
    transition-delay: 0.8s;
}

/* Stagger Grid Animation */
.stagger>*:nth-child(1) {
    transition-delay: 0.05s;
}

.stagger>*:nth-child(2) {
    transition-delay: 0.1s;
}

.stagger>*:nth-child(3) {
    transition-delay: 0.15s;
}

.stagger>*:nth-child(4) {
    transition-delay: 0.2s;
}

.stagger>*:nth-child(5) {
    transition-delay: 0.25s;
}

.stagger>*:nth-child(6) {
    transition-delay: 0.3s;
}

.stagger>*:nth-child(7) {
    transition-delay: 0.35s;
}

.stagger>*:nth-child(8) {
    transition-delay: 0.4s;
}

/* ====================
   MICRO-INTERACTIONS
   ==================== */

/* Button Magnetic Effect */
.btn {
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
    border-radius: 50%;
    z-index: 0;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(184, 160, 96, 0.2);
}

.btn:active {
    transform: translateY(-1px) scale(0.98);
}

/* Ripple Effect */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: rippleEffect 0.6s linear;
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Card Hover Effects */
.card-hover {
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-hover:hover {
    transform: translateY(-12px) rotateX(5deg);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(184, 160, 96, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Glowing Border on Hover */
.glow-border {
    position: relative;
}

.glow-border::after {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(135deg,
            var(--color-gold) 0%,
            var(--color-arcane) 50%,
            var(--color-frost) 100%);
    z-index: -1;
    opacity: 0;
    filter: blur(10px);
    transition: opacity 0.5s;
}

.glow-border:hover::after {
    opacity: 0.6;
    animation: glowPulse 2s ease-in-out infinite;
}

/* ====================
   TEXT ANIMATIONS
   ==================== */

/* Typewriter Effect */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--color-gold);
    white-space: nowrap;
    animation: typewriter 4s steps(40, end), blinkCursor 0.75s step-end infinite;
}

@keyframes typewriter {
    from {
        width: 0;
    }

    to {
        width: 100%;
    }
}

@keyframes blinkCursor {

    from,
    to {
        border-color: transparent;
    }

    50% {
        border-color: var(--color-gold);
    }
}

/* Letter by Letter Reveal */
.letter-reveal span {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px) rotateX(-90deg);
    filter: blur(4px);
    animation: letterReveal 0.6s forwards;
}

/* Gradient Text Animation */
.animated-gradient-text {
    background: linear-gradient(90deg,
            var(--color-gold) 0%,
            var(--color-frost) 25%,
            var(--color-gold) 50%,
            var(--color-arcane) 75%,
            var(--color-gold) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmerText 5s linear infinite;
}

/* ====================
   LOADING ANIMATIONS
   ==================== */

/* Runic Spinner */
.loader-runic {
    width: 60px;
    height: 60px;
    border: 2px solid transparent;
    border-top-color: var(--color-gold);
    border-radius: 50%;
    animation: runeRotate 1.5s linear infinite;
    position: relative;
}

.loader-runic::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 2px solid transparent;
    border-top-color: var(--color-frost);
    border-radius: 50%;
    animation: runeRotate 2s linear infinite reverse;
}

.loader-runic::after {
    content: '';
    position: absolute;
    inset: 12px;
    border: 2px solid transparent;
    border-top-color: var(--color-arcane);
    border-radius: 50%;
    animation: runeRotate 1s linear infinite;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg,
            var(--color-dusk) 0%,
            var(--color-twilight) 50%,
            var(--color-dusk) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

/* ====================
   ATMOSPHERIC EFFECTS
   ==================== */

/* Particle Container */
.particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 1;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, var(--color-gold) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat 8s infinite;
}

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }

    10% {
        opacity: 0.8;
    }

    90% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;
        transform: translateY(-20vh) scale(1);
    }
}

/* Frost Particles */
.frost-particle {
    background: radial-gradient(circle, var(--color-frost) 0%, transparent 70%);
    animation: snowfall 15s linear infinite;
}

/* Mist Layers */
.mist-layer {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 0%, var(--color-void) 70%);
    pointer-events: none;
}

.mist-layer-1 {
    animation: mistDrift 20s ease-in-out infinite;
}

.mist-layer-2 {
    animation: mistDriftReverse 25s ease-in-out infinite;
}

/* Aurora Effect */
.aurora-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: linear-gradient(180deg,
            transparent 0%,
            rgba(90, 110, 184, 0.05) 30%,
            rgba(122, 168, 192, 0.08) 50%,
            rgba(184, 160, 96, 0.03) 70%,
            transparent 100%);
    animation: aurora 15s ease-in-out infinite;
    pointer-events: none;
}

/* Vignette Effect */
.vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 40%, var(--color-void) 100%);
    pointer-events: none;
}

/* ====================
   PARALLAX HELPERS
   ==================== */

[data-parallax] {
    will-change: transform;
    transition: transform 0.1s linear;
}

[data-parallax="slow"] {
    --parallax-speed: 0.3;
}

[data-parallax="medium"] {
    --parallax-speed: 0.5;
}

[data-parallax="fast"] {
    --parallax-speed: 0.8;
}

/* ====================
   CURSOR EFFECTS
   ==================== */

.custom-cursor {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-gold);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transition: width 0.2s, height 0.2s, border-color 0.2s;
    transform: translate(-50%, -50%);
    mix-blend-mode: difference;
}

.custom-cursor.hover {
    width: 50px;
    height: 50px;
    border-color: var(--color-frost);
}

.custom-cursor-dot {
    width: 6px;
    height: 6px;
    background: var(--color-gold);
    border-radius: 50%;
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
}

/* ====================
   SPECIAL EFFECTS
   ==================== */

/* Rune Circle */
.rune-circle {
    position: relative;
}

.rune-circle::before {
    content: '';
    position: absolute;
    inset: -20px;
    border: 1px solid var(--color-gold);
    border-radius: 50%;
    opacity: 0.3;
    animation: runeRotate 30s linear infinite;
}

.rune-circle::after {
    content: '';
    position: absolute;
    inset: -40px;
    border: 1px dashed var(--color-frost);
    border-radius: 50%;
    opacity: 0.2;
    animation: runeRotate 45s linear infinite reverse;
}

/* Enchanted Border */
.enchanted-border {
    position: relative;
    overflow: hidden;
}

.enchanted-border::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-gold), transparent);
    animation: enchantedLine 3s linear infinite;
}

@keyframes enchantedLine {
    0% {
        left: -100%;
    }

    100% {
        left: 100%;
    }
}

/* Norse Symbol Decoration */
.norse-deco {
    position: relative;
}

.norse-deco::before,
.norse-deco::after {
    content: '✦';
    position: absolute;
    color: var(--color-gold);
    opacity: 0.6;
    font-size: 0.8em;
}

.norse-deco::before {
    left: -20px;
    animation: floatSlow 4s ease-in-out infinite;
}

.norse-deco::after {
    right: -20px;
    animation: floatSlow 4s ease-in-out infinite reverse;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}