/* Base Styles */
* {
    transition-property: color, background-color, border-color, opacity, transform, box-shadow;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #c7b8d9 0%, #a5b4fc 100%);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #b8a8d0 0%, #8b9cfc 100%);
}

/* Smooth Page Transitions */
.page-transition {
    animation: pageEnter 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* Glass Morphism Utilities */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.glass-dark {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
}

/* Navigation Button States */
.nav-btn {
    position: relative;
    overflow: hidden;
}

.nav-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px -3px rgba(102, 126, 234, 0.4);
    transform: translateY(-1px);
}

.nav-btn:not(.active):hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    transform: translateY(-1px);
}

/* Auth Button Special Styling */
.auth-btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px -3px rgba(245, 87, 108, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px -5px rgba(245, 87, 108, 0.5);
}

.auth-btn:active {
    transform: translateY(0);
}

/* Input Focus Animations */
.input-animate {
    position: relative;
    transition: all 0.3s ease;
}

.input-animate::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.input-animate:focus-within::after {
    width: 100%;
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* === UNIQUE SCHOLAR'S ANIMATIONS === */

/* 1. Floating Mathematical Symbols Background - Enhanced */
.math-symbols-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
    opacity: 0.04;
    background: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(245, 87, 108, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(118, 75, 162, 0.03) 0%, transparent 50%);
}

.math-symbol {
    position: absolute;
    font-family: 'Times New Roman', serif;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: float 20s infinite ease-in-out;
    user-select: none;
    font-style: italic;
    filter: drop-shadow(0 2px 4px rgba(102, 126, 234, 0.2));
}

.math-symbol:nth-child(1) { left: 5%; animation-delay: 0s; top: 100%; font-size: 3rem; }
.math-symbol:nth-child(2) { left: 15%; animation-delay: 2s; top: 100%; font-size: 2rem; }
.math-symbol:nth-child(3) { left: 25%; animation-delay: 4s; top: 100%; font-size: 3.5rem; }
.math-symbol:nth-child(4) { left: 35%; animation-delay: 6s; top: 100%; font-size: 2.2rem; }
.math-symbol:nth-child(5) { left: 45%; animation-delay: 8s; top: 100%; font-size: 3rem; }
.math-symbol:nth-child(6) { left: 55%; animation-delay: 10s; top: 100%; font-size: 2.5rem; }
.math-symbol:nth-child(7) { left: 65%; animation-delay: 12s; top: 100%; font-size: 3rem; }
.math-symbol:nth-child(8) { left: 75%; animation-delay: 14s; top: 100%; font-size: 2rem; }
.math-symbol:nth-child(9) { left: 85%; animation-delay: 16s; top: 100%; font-size: 3.2rem; }
.math-symbol:nth-child(10) { left: 10%; animation-delay: 18s; top: 100%; font-size: 2.8rem; }

@keyframes float {
    0% {
        transform: translateY(0) rotate(0deg) scale(0.8);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
    }
    50% {
        transform: translateY(-50vh) rotate(180deg) scale(1);
    }
    90% {
        opacity: 0.6;
    }
    100% {
        transform: translateY(-120vh) rotate(360deg) scale(0.8);
        opacity: 0;
    }
}

/* Floating particles */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #f5576c 100%);
    border-radius: 50%;
    animation: particleFloat 15s infinite ease-in-out;
    opacity: 0.3;
}

@keyframes particleFloat {
    0%, 100% {
        transform: translateY(0) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.4;
    }
    100% {
        transform: translateY(-100vh) translateX(20px);
    }
}

/* 2. Ink Spread Animation */
.ink-spread {
    position: relative;
    overflow: hidden;
}

.ink-spread::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: inkSpread 1.2s ease-out forwards;
    pointer-events: none;
    z-index: 0;
}

@keyframes inkSpread {
    0% {
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        width: 250%;
        height: 250%;
        opacity: 0;
    }
}

/* 3. Ink Drop Effect */
.ink-drop {
    animation: inkDrop 0.4s ease-out;
}

@keyframes inkDrop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.98);
        border-color: #10b981;
    }
    100% {
        transform: scale(1);
    }
}

/* 4. Elegant Solution Reveal - Enhanced */
.solution-reveal {
    animation: solutionReveal 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    opacity: 0;
    transform: translateY(30px);
}

@keyframes solutionReveal {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95) rotateX(-5deg);
        filter: blur(8px);
    }
    40% {
        opacity: 0.6;
        filter: blur(2px);
        transform: translateY(-5px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1) rotateX(0);
        filter: blur(0);
    }
}

/* Stagger Animation for Cards */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* Magnetic Button Effect */
.magnetic-btn {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.magnetic-btn:hover {
    transform: scale(1.05) translateY(-2px);
}

.magnetic-btn:active {
    transform: scale(0.98) translateY(0);
}

/* Shimmer Effect */
.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255,255,255,0.3) 50%,
        transparent 100%
    );
    transform: rotate(30deg) translateY(-100%) translateX(-100%);
    transition: transform 0.6s;
}

.shimmer:hover::after {
    transform: rotate(30deg) translateY(100%) translateX(100%);
}

/* 5. Parchment Texture Effect */
.parchment-texture {
    background-image: 
        linear-gradient(90deg, rgba(0,0,0,0.015) 1px, transparent 1px),
        linear-gradient(rgba(0,0,0,0.015) 1px, transparent 1px);
    background-size: 24px 24px;
    position: relative;
}

.parchment-texture::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at top left, rgba(255,255,255,0.9) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(255,255,255,0.7) 0%, transparent 50%);
    pointer-events: none;
}

/* 6. Math Ripple Effect on Input Focus */
.math-ripple {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.math-ripple:focus-within {
    border-color: #94a3b8;
    box-shadow: 0 4px 20px -2px rgba(16, 185, 129, 0.08), 0 2px 8px -1px rgba(0, 0, 0, 0.04);
    transform: translateY(-1px);
}

.math-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(16, 185, 129, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    transition: transform 0.8s, opacity 0.8s;
    pointer-events: none;
}

.math-ripple:focus-within::after {
    transform: translate(-50%, -50%) scale(50);
    opacity: 0;
    transition: transform 1s, opacity 1s;
}

/* 7. Paper Fold Effect for History Items */
.paper-fold {
    position: relative;
    transform-style: preserve-3d;
    transition: all 0.3s ease;
}

.paper-fold::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 20px 20px 0;
    border-color: transparent #e2e8f0 transparent transparent;
    transition: all 0.3s ease;
}

.paper-fold:hover {
    transform: translateX(6px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.paper-fold:hover::before {
    border-width: 0 28px 28px 0;
    border-color: transparent #d1fae5 transparent transparent;
}

/* 8. Step Connection Lines */
.step-connector {
    position: relative;
}

.step-connector::before {
    content: '';
    position: absolute;
    left: 2.5rem;
    top: -1.25rem;
    width: 2px;
    height: 1.25rem;
    background: linear-gradient(to bottom, #e2e8f0, #cbd5e1);
    border-radius: 1px;
}

/* 9. Result Glow Effect - Enhanced with Purple/Gold */
.result-glow {
    animation: resultGlow 3s ease-in-out infinite alternate;
    border-color: #667eea !important;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

@keyframes resultGlow {
    from {
        box-shadow: 0 0 5px rgba(102, 126, 234, 0.2), 0 0 10px rgba(245, 87, 108, 0.1);
    }
    to {
        box-shadow: 0 0 30px rgba(102, 126, 234, 0.3), 0 0 60px rgba(245, 87, 108, 0.15);
    }
}

/* Gradient Border Animation */
.gradient-border {
    position: relative;
    background: white;
    border-radius: 1rem;
    z-index: 1;
}

.gradient-border::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #667eea, #f5576c, #667eea, #764ba2);
    background-size: 400%;
    z-index: -1;
    border-radius: 1.1rem;
    animation: gradientRotate 3s linear infinite;
    opacity: 0.5;
}

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

/* Typing indicator for AI feel */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite both;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* 10. Enhanced Step Appearance */
.step-appear {
    opacity: 0;
    transform: translateY(15px);
}

@keyframes stepFadeIn {
    0% {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }
    70% {
        transform: translateY(-2px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Enhanced Focus States - but not for custom components */
input:focus, textarea:focus:not(.no-focus-highlight) {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* No focus highlight class for inputs that have their own container highlight */
.no-focus-highlight {
    outline: none !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

/* Custom Checkbox/Radio */
.custom-check {
    appearance: none;
    width: 1.2rem;
    height: 1.2rem;
    border: 2px solid #cbd5e1;
    border-radius: 0.3rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.custom-check:checked {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}

.custom-check:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
}

/* Auth Card Special Styling */
.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 
        0 20px 40px -15px rgba(0, 0, 0, 0.05),
        0 0 0 1px rgba(102, 126, 234, 0.1);
    transform: translateY(0);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-card:hover {
    transform: translateY(-5px);
    box-shadow: 
        0 30px 60px -20px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(102, 126, 234, 0.2);
}

/* Link Underline Animation */
.link-underline {
    position: relative;
    text-decoration: none;
    color: #667eea;
}

.link-underline::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: -2px;
    left: 0;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s ease;
}

.link-underline:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

/* Print styles */
@media print {
    nav, footer {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .paper-fold {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .math-symbol {
        animation: none;
        opacity: 0.03;
    }
}