/**
 * XAVI PROTOCOL Premium Animation System
 * "Confident and deliberate" — luxury watch commercial, not Nickelodeon
 * Version: 2.0.0
 */

/* ============================================
   TIMING VARIABLES
   ============================================ */
:root {
    /* Premium easing curves */
    --ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Duration scale */
    --duration-fast: 0.2s;
    --duration-normal: 0.4s;
    --duration-slow: 0.8s;
    --duration-entrance: 1s;
}

/* ============================================
   1. PAGE LOAD SEQUENCE
   ============================================ */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes revealWord {
    from { 
        opacity: 0; 
        transform: translateY(40px) rotateX(10deg); 
        filter: blur(4px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) rotateX(0deg); 
        filter: blur(0); 
    }
}

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

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

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

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

/* Navbar entrance */
.navbar {
    animation: slideDown 0.6s var(--ease-premium) 0.1s both;
}

/* Hero word-by-word reveal */
.hero-word {
    display: inline-block;
    opacity: 0;
    animation: revealWord 0.8s var(--ease-premium) forwards;
}

.hero-word:nth-child(1) { animation-delay: 0.5s; }
.hero-word:nth-child(2) { animation-delay: 0.58s; }
.hero-word:nth-child(3) { animation-delay: 0.66s; }

/* Hero elements staggered */
.hero-eyebrow {
    opacity: 0;
    animation: fadeSlideLeft 0.8s var(--ease-premium) 0.3s forwards;
}

.hero-subtitle {
    opacity: 0;
    animation: slideUp 0.6s var(--ease-premium) 0.8s forwards;
}

.hero-buttons {
    opacity: 0;
    animation: slideUp 0.6s var(--ease-premium) 0.9s forwards;
}

.hero-pill {
    opacity: 0;
    animation: slideUp 0.6s var(--ease-premium) 1s forwards;
}

/* Mascot entrance */
.hero-mascot {
    opacity: 0;
    animation: scaleIn 1.2s var(--ease-premium) 0.6s forwards;
}

/* Stats bar entrance */
.stats-bar {
    opacity: 0;
    animation: slideUp 0.8s var(--ease-premium) 1.2s forwards;
}

/* ============================================
   2. SCROLL-TRIGGERED REVEALS
   ============================================ */
.scroll-reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s var(--ease-premium), 
                transform 0.8s var(--ease-premium);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children in grids */
.scroll-reveal-stagger.revealed > *:nth-child(1) { transition-delay: 0s; }
.scroll-reveal-stagger.revealed > *:nth-child(2) { transition-delay: 0.1s; }
.scroll-reveal-stagger.revealed > *:nth-child(3) { transition-delay: 0.2s; }
.scroll-reveal-stagger.revealed > *:nth-child(4) { transition-delay: 0.3s; }
.scroll-reveal-stagger.revealed > *:nth-child(5) { transition-delay: 0.4s; }
.scroll-reveal-stagger.revealed > *:nth-child(6) { transition-delay: 0.5s; }
.scroll-reveal-stagger.revealed > *:nth-child(7) { transition-delay: 0.6s; }
.scroll-reveal-stagger.revealed > *:nth-child(8) { transition-delay: 0.7s; }
.scroll-reveal-stagger.revealed > *:nth-child(9) { transition-delay: 0.8s; }
.scroll-reveal-stagger.revealed > *:nth-child(10) { transition-delay: 0.9s; }
.scroll-reveal-stagger.revealed > *:nth-child(11) { transition-delay: 1s; }
.scroll-reveal-stagger.revealed > *:nth-child(12) { transition-delay: 1.1s; }

/* Section title with extending line */
.section-title-animated {
    opacity: 0;
    transform: translateX(-40px);
    transition: all 0.8s var(--ease-premium);
}

.section-title-animated::after {
    content: '';
    display: block;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--xavi-purple-primary), var(--xavi-gold));
    margin-top: 12px;
    border-radius: 2px;
    transition: width 0.8s var(--ease-premium) 0.3s;
}

.section-title-animated.revealed {
    opacity: 1;
    transform: translateX(0);
}

.section-title-animated.revealed::after {
    width: 80px;
}

/* ============================================
   3. STAT COUNTER ANIMATION
   ============================================ */
.stat-bar {
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--xavi-purple-primary), var(--xavi-gold));
    border-radius: 1px;
    margin-top: 8px;
    transition: width 1.5s var(--ease-premium) 0.5s;
}

.stat-item.revealed .stat-bar {
    width: 100%;
}

/* ============================================
   4. CARD INTERACTIONS - Magnetic Tilt & Glow
   ============================================ */
.xavi-card {
    --mouse-x: 50%;
    --mouse-y: 50%;
    transition: transform 0.6s var(--ease-premium),
                border-color 0.4s ease,
                box-shadow 0.4s ease;
}

/* Spotlight glow follows cursor */
.xavi-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    opacity: 0;
    transition: opacity 0.4s ease;
    background: radial-gradient(
        300px circle at var(--mouse-x) var(--mouse-y),
        rgba(123, 45, 142, 0.12),
        transparent 60%
    );
    pointer-events: none;
    z-index: 1;
}

.xavi-card:hover::after {
    opacity: 1;
}

/* Rotating gradient border on hover */
@property --card-border-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

.xavi-card-glow::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    padding: 1px;
    background: conic-gradient(
        from var(--card-border-angle, 0deg),
        transparent 40%,
        var(--xavi-purple-mid) 50%,
        var(--xavi-gold) 55%,
        transparent 60%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.xavi-card-glow:hover::before {
    opacity: 1;
    animation: rotateBorder 3s linear infinite;
}

@keyframes rotateBorder {
    to { --card-border-angle: 360deg; }
}

/* ============================================
   5. BUTTON ANIMATIONS
   ============================================ */

/* Primary button shimmer */
.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -75%;
    width: 50%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.15),
        transparent
    );
    transform: skewX(-20deg);
    transition: left 0.6s ease;
}

.btn-primary:hover::after {
    left: 125%;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(212, 160, 57, 0.4),
                0 0 60px rgba(212, 160, 57, 0.15);
}

.btn-primary:active {
    transform: translateY(-1px) scale(0.98);
    transition-duration: 0.1s;
}

/* Secondary button fill */
.btn-secondary {
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn-secondary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    background: rgba(155, 77, 202, 0.12);
    transition: width 0.4s var(--ease-premium);
    z-index: -1;
    border-radius: 12px;
}

.btn-secondary:hover::before {
    width: 100%;
}

.btn-secondary:hover {
    border-color: var(--xavi-purple-light);
    color: var(--xavi-white);
    transform: translateY(-2px);
}

/* Copy button flash */
.copy-btn.copied {
    color: var(--xavi-success);
    animation: copyFlash 0.4s ease;
}

@keyframes copyFlash {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* ============================================
   6. HERO ROTATING TEXT
   ============================================ */
.rotating-text-container {
    display: inline-block;
    height: 1.2em;
    overflow: hidden;
    vertical-align: bottom;
}

.rotating-text {
    display: block;
    color: var(--xavi-purple-light);
    transition: transform 0.5s var(--ease-premium),
                opacity 0.5s var(--ease-premium);
}

/* ============================================
   7. MASCOT ANIMATIONS
   ============================================ */
@keyframes premiumFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-8px) rotate(0.5deg); }
    75% { transform: translateY(-4px) rotate(-0.5deg); }
}

.mascot-float {
    animation: premiumFloat 6s ease-in-out infinite;
}

/* Glow pulse behind mascot */
@keyframes glowPulse {
    0%, 100% { opacity: 0.1; transform: scale(1); }
    50% { opacity: 0.2; transform: scale(1.05); }
}

.mascot-glow {
    position: absolute;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--xavi-purple-primary) 0%, transparent 70%);
    border-radius: 50%;
    z-index: -1;
    animation: glowPulse 4s ease-in-out infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Concentric rings */
@keyframes ringExpand {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.15; }
    100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

.mascot-ring {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    border: 1px solid rgba(123, 45, 142, 0.15);
    top: 50%;
    left: 50%;
    z-index: -1;
}

.mascot-ring:nth-child(1) { animation: ringExpand 4s ease-out infinite; }
.mascot-ring:nth-child(2) { animation: ringExpand 4s ease-out 1s infinite; }
.mascot-ring:nth-child(3) { animation: ringExpand 4s ease-out 2s infinite; }

/* ============================================
   8. NAVBAR ANIMATIONS
   ============================================ */
.navbar {
    transition: padding 0.4s var(--ease-premium),
                background 0.4s var(--ease-premium),
                box-shadow 0.4s var(--ease-premium);
}

.navbar.scrolled {
    padding-top: 12px;
    padding-bottom: 12px;
    background: rgba(10, 10, 15, 0.95);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

/* Nav link underline draw */
.navbar-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--xavi-gold);
    border-radius: 1px;
    transition: width 0.3s var(--ease-premium);
}

.navbar-link:hover::after,
.navbar-link.active::after {
    width: 100%;
}

/* Mobile menu */
.mobile-menu {
    transform: translateX(100%);
    transition: transform 0.5s var(--ease-premium);
}

.mobile-menu.open {
    transform: translateX(0);
}

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

.mobile-menu.open .nav-link:nth-child(1) { animation: slideIn 0.4s var(--ease-premium) 0.1s forwards; }
.mobile-menu.open .nav-link:nth-child(2) { animation: slideIn 0.4s var(--ease-premium) 0.15s forwards; }
.mobile-menu.open .nav-link:nth-child(3) { animation: slideIn 0.4s var(--ease-premium) 0.2s forwards; }
.mobile-menu.open .nav-link:nth-child(4) { animation: slideIn 0.4s var(--ease-premium) 0.25s forwards; }
.mobile-menu.open .nav-link:nth-child(5) { animation: slideIn 0.4s var(--ease-premium) 0.3s forwards; }

/* ============================================
   9. ROADMAP TIMELINE
   ============================================ */
.timeline-line {
    width: 0;
    transition: width 1.5s var(--ease-premium);
}

.timeline.revealed .timeline-line {
    width: 100%;
}

.timeline-node {
    opacity: 0;
    transform: scale(0);
    transition: all 0.5s var(--ease-bounce);
}

.timeline.revealed .timeline-node:nth-child(1) { transition-delay: 0.2s; }
.timeline.revealed .timeline-node:nth-child(2) { transition-delay: 0.35s; }
.timeline.revealed .timeline-node:nth-child(3) { transition-delay: 0.5s; }
.timeline.revealed .timeline-node:nth-child(4) { transition-delay: 0.65s; }
.timeline.revealed .timeline-node:nth-child(5) { transition-delay: 0.8s; }

.timeline.revealed .timeline-node {
    opacity: 1;
    transform: scale(1);
}

/* Current node breathing */
@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.6); opacity: 0; }
}

.timeline-node.current::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--xavi-purple-light);
    animation: breathe 2s ease-in-out infinite;
}

/* ============================================
   10. CONTRACT ROW ANIMATIONS
   ============================================ */
.contract-row:nth-child(odd) {
    opacity: 0;
    transform: translateX(-30px);
}

.contract-row:nth-child(even) {
    opacity: 0;
    transform: translateX(30px);
}

.contracts.revealed .contract-row {
    opacity: 1;
    transform: translateX(0);
    transition: all 0.6s var(--ease-premium);
}

.contracts.revealed .contract-row:nth-child(1) { transition-delay: 0.1s; }
.contracts.revealed .contract-row:nth-child(2) { transition-delay: 0.2s; }
.contracts.revealed .contract-row:nth-child(3) { transition-delay: 0.3s; }
.contracts.revealed .contract-row:nth-child(4) { transition-delay: 0.4s; }
.contracts.revealed .contract-row:nth-child(5) { transition-delay: 0.5s; }

/* Address expand on hover */
.contract-address {
    max-width: 140px;
    transition: max-width 0.4s var(--ease-premium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.contract-row:hover .contract-address {
    max-width: 320px;
}

/* ============================================
   11. STATUS BADGE ANIMATIONS
   ============================================ */
@keyframes livePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6); }
    50% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
}

.badge-live::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--xavi-success);
    display: inline-block;
    margin-right: 6px;
    animation: livePulse 2s ease-in-out infinite;
}

/* Featured shimmer */
@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 200%; }
}

.badge-featured {
    position: relative;
    overflow: hidden;
}

.badge-featured::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 160, 57, 0.2), transparent);
    animation: shimmer 3s ease infinite;
}

/* ============================================
   12. SMOOTH SCROLL + PARALLAX
   ============================================ */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

/* ============================================
   13. LOADING SCREEN
   ============================================ */
.loader {
    position: fixed;
    inset: 0;
    background: var(--xavi-black);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: transform 0.8s var(--ease-premium),
                opacity 0.8s var(--ease-premium);
}

.loader.done {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.loader-ring {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 2px solid var(--xavi-border);
    border-top-color: var(--xavi-purple-mid);
    border-right-color: var(--xavi-gold);
    animation: loaderSpin 1.2s linear infinite;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes loaderSpin {
    to { transform: rotate(360deg); }
}

.loader-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
}

.loader-letters {
    margin-top: 24px;
}

.loader-letters span {
    display: inline-block;
    opacity: 0;
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.3em;
    color: var(--xavi-white);
    animation: letterReveal 0.4s var(--ease-premium) forwards;
}

.loader-letters span:nth-child(1) { animation-delay: 0.3s; }
.loader-letters span:nth-child(2) { animation-delay: 0.4s; }
.loader-letters span:nth-child(3) { animation-delay: 0.5s; }
.loader-letters span:nth-child(4) { animation-delay: 0.6s; }

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

/* ============================================
   14. MICRO-INTERACTIONS
   ============================================ */

/* Link underline draw */
.text-link {
    position: relative;
}

.text-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1.5px;
    background: var(--xavi-gold);
    transition: width 0.3s var(--ease-premium);
}

.text-link:hover::after {
    width: 100%;
}

/* Icon rotate on card hover */
.xavi-card:hover .icon-box {
    transform: rotate(-5deg) scale(1.05);
    background: rgba(123, 45, 142, 0.2);
    border-color: rgba(155, 77, 202, 0.4);
}

.icon-box {
    transition: all 0.4s var(--ease-premium);
}

/* Focus ring */
:focus-visible {
    outline: 2px solid var(--xavi-purple-light);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Selection highlight */
::selection {
    background: rgba(123, 45, 142, 0.4);
    color: var(--xavi-white);
}

/* ============================================
   15. AMBIENT BACKGROUND
   ============================================ */
.ambient-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: -5;
}

.ambient-orb-1 {
    width: 400px;
    height: 400px;
    background: var(--xavi-purple-deep);
    opacity: 0.07;
    top: 10%;
    right: -5%;
    animation: orbFloat1 25s ease-in-out infinite;
}

.ambient-orb-2 {
    width: 350px;
    height: 350px;
    background: var(--xavi-purple-primary);
    opacity: 0.05;
    bottom: 20%;
    left: -5%;
    animation: orbFloat2 30s ease-in-out infinite;
}

.ambient-orb-3 {
    width: 250px;
    height: 250px;
    background: var(--xavi-gold);
    opacity: 0.03;
    top: 50%;
    left: 40%;
    animation: orbFloat3 20s ease-in-out infinite;
}

@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(-40px, 60px); }
    66% { transform: translate(30px, -40px); }
}

@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0); }
    33% { transform: translate(50px, -30px); }
    66% { transform: translate(-30px, 50px); }
}

@keyframes orbFloat3 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(40px, -40px); }
}

/* ============================================
   16. PAGE TRANSITIONS
   ============================================ */
.page-transition {
    animation: pageOut 0.3s var(--ease-smooth) forwards;
}

@keyframes pageOut {
    to { opacity: 0; transform: scale(0.98); }
}

/* ============================================
   17. REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .scroll-reveal {
        opacity: 1;
        transform: none;
    }
    
    .mascot-float {
        animation: none;
    }
    
    .ambient-orb {
        animation: none;
    }
    
    .loader {
        display: none;
    }
}
