/**
 * PROTOCOL DESIGN SYSTEM v1.0
 * Atomic Design System для Web3 Gaming
 * 
 * Архитектура:
 * 1. Design Tokens
 * 2. Base Styles
 * 3. Atoms
 * 4. Molecules
 * 5. Organisms
 * 6. Animations Library
 */

/* ================================
   1. DESIGN TOKENS
   ================================ */

:root {
    /* Color System */
    --color-bg-deep: #000000;
    --color-bg-elevated: #0a0a15;
    --color-bg-surface: #14141f;
    --color-bg-overlay: rgba(10, 10, 20, 0.3);
    
    /* Primary (Cyan) */
    --color-primary-100: #e6ffff;
    --color-primary-400: #00f5ff;
    --color-primary-600: #0099ff;
    --color-primary-800: #006699;
    
    /* Secondary (Purple) */
    --color-secondary-400: #a855f7;
    --color-secondary-600: #8a2be2;
    --color-secondary-800: #6b21a8;
    
    /* Accent (Pink) */
    --color-accent-400: #ff00aa;
    --color-accent-600: #cc0088;
    --color-accent-800: #990066;
    
    /* Warning (Orange) */
    --color-warning-400: #ff8c00;
    --color-warning-600: #ff6600;
    
    /* Success (Green) */
    --color-success-400: #00ff88;
    --color-success-600: #00cc66;
    
    /* Text - УВЕЛИЧЕННЫЙ КОНТРАСТ */
    --color-text-primary: #ffffff;
    --color-text-secondary: #d0d0d5;
    --color-text-tertiary: #a0a0b0;
    --color-text-inverse: #000000;
    
    /* Borders */
    --color-border-subtle: rgba(255, 255, 255, 0.04);
    --color-border-default: rgba(255, 255, 255, 0.08);
    --color-border-strong: rgba(255, 255, 255, 0.12);
    
    /* Typography Scale */
    --text-xs: 0.75rem;      /* 12px */
    --text-sm: 0.875rem;     /* 14px */
    --text-base: 1rem;       /* 16px */
    --text-lg: 1.125rem;     /* 18px */
    --text-xl: 1.25rem;      /* 20px */
    --text-2xl: 1.5rem;      /* 24px */
    --text-3xl: 1.875rem;    /* 30px */
    --text-4xl: 2.25rem;     /* 36px */
    --text-5xl: 3rem;        /* 48px */
    --text-6xl: 3.75rem;     /* 60px */
    --text-7xl: 4.5rem;      /* 72px */
    --text-8xl: 6rem;        /* 96px */
    --text-9xl: 8rem;        /* 128px */
    
    /* Fluid Typography - УВЕЛИЧЕНО ДЛЯ ЧИТАЕМОСТИ */
    --text-fluid-xs: clamp(0.875rem, 0.5vw + 0.6rem, 1rem);
    --text-fluid-sm: clamp(1rem, 0.6vw + 0.7rem, 1.125rem);
    --text-fluid-base: clamp(1.125rem, 0.8vw + 0.8rem, 1.375rem);
    --text-fluid-lg: clamp(1.375rem, 1vw + 1rem, 1.875rem);
    --text-fluid-xl: clamp(1.75rem, 2vw + 1.2rem, 2.75rem);
    --text-fluid-2xl: clamp(2.25rem, 3vw + 1.75rem, 4.5rem);
    --text-fluid-3xl: clamp(3.5rem, 5vw + 2.5rem, 8rem);
    --text-fluid-hero: clamp(5rem, 10vw + 3rem, 14rem);
    
    /* Spacing Scale */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */
    --space-20: 5rem;     /* 80px */
    --space-24: 6rem;     /* 96px */
    
    /* Border Radius */
    --radius-sm: 0.5rem;   /* 8px */
    --radius-md: 0.75rem;  /* 12px */
    --radius-lg: 1rem;     /* 16px */
    --radius-xl: 1.25rem;  /* 20px */
    --radius-2xl: 1.5rem;  /* 24px */
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 16px 64px rgba(0, 0, 0, 0.4);
    
    /* Glow Shadows */
    --glow-primary: 0 0 40px rgba(0, 245, 255, 0.2);
    --glow-primary-lg: 0 0 60px rgba(0, 245, 255, 0.3);
    --glow-secondary: 0 0 40px rgba(138, 43, 226, 0.2);
    --glow-accent: 0 0 40px rgba(255, 0, 128, 0.2);
    
    /* Animation Curves */
    --ease-snappy: cubic-bezier(0.2, 0.8, 0.2, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* Animation Durations */
    --duration-fast: 150ms;
    --duration-base: 300ms;
    --duration-slow: 500ms;
    --duration-slower: 700ms;
    
    /* Z-Index Scale */
    --z-base: 1;
    --z-dropdown: 10;
    --z-sticky: 20;
    --z-fixed: 30;
    --z-modal: 40;
    --z-popover: 50;
    --z-tooltip: 60;
}

/* ================================
   2. BASE STYLES
   ================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg-deep);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.font-mono {
    font-family: 'JetBrains Mono', 'Monaco', 'Courier New', monospace;
}

/* ================================
   3. ATOMS
   ================================ */

/* Glass Surface */
.surface-glass {
    background: rgba(20, 20, 30, 0.85);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.surface-glass-strong {
    background: rgba(25, 25, 35, 0.95);
    backdrop-filter: blur(50px) saturate(200%);
    -webkit-backdrop-filter: blur(50px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Gradient Text */
.text-gradient-primary {
    background: linear-gradient(135deg, 
        var(--color-primary-400) 0%, 
        var(--color-secondary-600) 50%, 
        var(--color-accent-400) 100%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientFlow 8s var(--ease-smooth) infinite;
}

@keyframes gradientFlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-10);
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-600));
    color: var(--color-text-inverse);
    font-weight: 800;
    font-size: var(--text-lg);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all var(--duration-base) var(--ease-smooth);
    box-shadow: var(--glow-primary-lg);
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3), transparent);
    transform: translateX(-100%) skewX(-15deg);
    transition: transform 600ms var(--ease-smooth);
}

.btn-primary:hover::before {
    transform: translateX(100%) skewX(-15deg);
}

.btn-primary:hover {
    transform: translateY(-4px);
    box-shadow: var(--glow-primary-lg);
}

.btn-primary:active {
    transform: translateY(-2px);
}

/* Input Fields */
.input-crypto {
    width: 100%;
    background: var(--color-bg-overlay);
    border: 1px solid var(--color-border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-6);
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--color-text-primary);
    text-align: center;
    transition: all var(--duration-base) var(--ease-smooth);
    position: relative;
}

.input-crypto::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--radius-lg);
    padding: 1px;
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-600));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity var(--duration-base) var(--ease-smooth);
}

.input-crypto:focus {
    outline: none;
    border-color: var(--color-primary-400);
}

.input-crypto:focus::before {
    opacity: 1;
}

/* ================================
   4. MOLECULES
   ================================ */

/* Protocol Card */
.protocol-card {
    position: relative;
    padding: var(--space-10);
    border-radius: var(--radius-xl);
    background: var(--color-bg-overlay);
    backdrop-filter: blur(60px);
    border: 1px solid var(--color-border-default);
    transition: all var(--duration-slow) var(--ease-smooth);
    transform: translateZ(0);
    will-change: transform;
}

.protocol-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity var(--duration-slower) var(--ease-smooth);
    pointer-events: none;
}

.protocol-card:hover {
    transform: translateY(-12px) translateZ(0);
    border-color: var(--color-border-strong);
}

.protocol-card:hover::before {
    opacity: 1;
}

/* Bet Orb */
.bet-orb {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-border-default);
    cursor: pointer;
    position: relative;
    transition: all var(--duration-base) var(--ease-elastic);
}

.bet-orb::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-600));
    opacity: 0;
    filter: blur(15px);
    transition: opacity var(--duration-base) var(--ease-smooth);
    z-index: -1;
}

.bet-orb:hover {
    transform: scale(1.2) translateY(-8px);
    border-color: var(--color-primary-400);
}

.bet-orb:hover::before {
    opacity: 0.6;
}

.bet-orb.active {
    background: linear-gradient(135deg, var(--color-primary-400), var(--color-secondary-600));
    border-color: transparent;
    animation: orbPulse 2s var(--ease-smooth) infinite;
}

@keyframes orbPulse {
    0%, 100% { box-shadow: var(--glow-primary); }
    50% { box-shadow: var(--glow-primary-lg); }
}

/* Stat Card */
.stat-card {
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    background: var(--color-bg-overlay);
    backdrop-filter: blur(40px);
    border: 1px solid var(--color-border-subtle);
    transition: all var(--duration-base) var(--ease-smooth);
}

.stat-card:hover {
    transform: translateY(-6px);
    border-color: var(--color-border-default);
}

/* ================================
   5. ORGANISMS
   ================================ */

/* Navigation Bar */
.navbar {
    background: var(--color-bg-overlay);
    backdrop-filter: blur(60px) saturate(180%);
    border-bottom: 1px solid var(--color-border-subtle);
}

/* Hero Section */
.hero-title {
    font-size: var(--text-fluid-hero);
    font-weight: 900;
    line-height: 0.85;
    letter-spacing: -0.06em;
}

/* ================================
   6. ANIMATIONS LIBRARY
   ================================ */

/* Reveal on Scroll */
.reveal {
    opacity: 1;
    transform: translateY(0);
    animation: revealIn 0.8s var(--ease-snappy) backwards;
}

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

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

/* Gradient Mesh Background - УПРОЩЕННЫЙ */
.gradient-mesh {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0.3;
    background-image:
        radial-gradient(at 15% 15%, rgba(0, 245, 255, 0.12) 0px, transparent 50%),
        radial-gradient(at 85% 85%, rgba(138, 43, 226, 0.12) 0px, transparent 50%);
    filter: blur(100px);
    animation: meshFloat 40s var(--ease-smooth) infinite;
}

@keyframes meshFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -30px) scale(1.05); }
}

/* Particles */
@keyframes particleFloat {
    0% {
        transform: translate3d(0, 100vh, 0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
        transform: translate3d(var(--drift-x), 90vh, 0) scale(1);
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translate3d(calc(var(--drift-x) * 2), -20vh, 0) scale(0);
        opacity: 0;
    }
}

/* Cursor Trail */
@keyframes cursorTrail {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(0) translateY(-30px);
        opacity: 0;
    }
}

/* Ripple Effect */
@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 0.6;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

/* Shimmer Effect */
@keyframes shimmer {
    0% { transform: translateX(-100%) skewX(-15deg); }
    100% { transform: translateX(200%) skewX(-15deg); }
}

/* Noise Texture */
.noise-texture {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 0.015;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* GPU Acceleration */
.gpu {
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

/* Magnetic Effect */
[data-magnetic] {
    transition: transform var(--duration-base) var(--ease-elastic);
}

/* ================================
   7. UTILITY CLASSES
   ================================ */

.interactive {
    transition: all var(--duration-base) var(--ease-snappy);
    cursor: pointer;
}

.interactive:hover {
    transform: translateY(-6px);
}

.interactive:active {
    transform: translateY(-2px);
}

/* ================================
   8. MOBILE OPTIMIZATIONS
   ================================ */

/* Touch-friendly sizes */
@media (max-width: 768px) {
    :root {
        --text-fluid-hero: clamp(3rem, 8vw + 1rem, 6rem);
        --text-fluid-3xl: clamp(2rem, 4vw + 1rem, 4rem);
    }
    
    /* Увеличиваем bet orbs */
    .bet-orb {
        width: 70px;
        height: 70px;
        min-width: 70px;
        min-height: 70px;
    }
    
    /* Минимум 44px для кнопок */
    .btn-primary,
    button,
    a[role="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Убираем hover на touch */
    @media (hover: none) {
        .interactive:hover,
        .protocol-card:hover,
        .bet-orb:hover {
            transform: none;
        }
        
        [data-magnetic] {
            transform: none !important;
        }
    }
    
    /* Упрощаем glassmorphism */
    .surface-glass,
    .surface-glass-strong {
        backdrop-filter: blur(20px) saturate(150%);
        -webkit-backdrop-filter: blur(20px) saturate(150%);
    }
    
    /* Отключаем частицы */
    #particles {
        display: none;
    }
    
    /* Noise менее заметен */
    .noise-texture {
        opacity: 0.015;
    }
}

@media (max-width: 480px) {
    /* Еще компактнее */
    .bet-orb {
        width: 60px;
        height: 60px;
    }
    
    /* Меньше padding */
    .surface-glass-strong {
        padding: var(--space-6);
    }
    
    /* Упрощенные тени */
    .glow-primary,
    .glow-secondary,
    .glow-tertiary {
        box-shadow: none;
    }
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .gradient-mesh {
        animation: none;
    }
}

/* Safe area для iPhone notch */
@supports (padding-top: env(safe-area-inset-top)) {
    .navbar {
        padding-top: env(safe-area-inset-top);
    }
}

/* ================================
   9. LOADING STATES
   ================================ */

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border-default);
    border-top-color: var(--color-primary-400);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}

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

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-elevated) 0%,
        var(--color-bg-surface) 50%,
        var(--color-bg-elevated) 100%
    );
    background-size: 200% 100%;
    animation: skeleton 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    animation: fadeIn 0.3s ease;
}

/* Button Loading State */
.btn-primary.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.btn-primary.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Success/Error States */
.btn-success {
    background: linear-gradient(135deg, var(--color-success-400), var(--color-success-600)) !important;
    box-shadow: var(--glow-primary) !important;
}

.btn-error {
    background: linear-gradient(135deg, var(--color-accent-400), var(--color-accent-600)) !important;
    box-shadow: var(--glow-accent) !important;
}

