/* ========================================
   PHYSICS UI EFFECTS - CSS
   Styles for physics-based interactions
   ======================================== */

/* Ripple animation keyframes */
@keyframes ripple-expand {
    0% {
        transform: scale(0);
        opacity: 0.4;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Base styles for physics-enabled elements */
.physics-enabled {
    will-change: transform;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

/* Magnetic buttons need relative positioning */
.btn,
.btn-primary,
.btn-secondary {
    position: relative;
    will-change: transform;
    transform-style: preserve-3d;
}

/* Cards with tilt effect */
.portfolio-item,
.book-card,
.stat-card,
.project-card {
    will-change: transform;
    transform-style: preserve-3d;
    transition: box-shadow 0.3s ease !important;
}

.portfolio-item:hover,
.book-card:hover,
.stat-card:hover,
.project-card:hover {
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px var(--border-color);
}

[data-theme="dark"] .portfolio-item:hover,
[data-theme="dark"] .book-card:hover,
[data-theme="dark"] .stat-card:hover,
[data-theme="dark"] .project-card:hover {
    box-shadow: 
        0 25px 50px -12px rgba(255, 255, 255, 0.15),
        0 0 0 1px var(--border-color);
}

/* Ripple container */
.physics-ripple {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

/* Nav links with bounce */
.nav-menu a,
.nav-logo {
    will-change: transform;
    display: inline-block;
}

/* Floating highlight text */
.hero-title .highlight {
    display: inline-block;
    will-change: transform;
}

/* Elastic string canvas */
.elastic-string-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* Draggable elements */
.draggable {
    cursor: grab;
    user-select: none;
    touch-action: none;
}

.draggable:active {
    cursor: grabbing;
}

/* Gravity drop elements */
.gravity-drop {
    will-change: transform;
    transform-origin: center center;
}

/* Smooth shadow transitions for tilt effect */
.tilt-shadow {
    transition: box-shadow 0.1s ease-out !important;
}

/* Physics debug overlay (optional) */
.physics-debug {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: #0f0;
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 10px;
    border-radius: 4px;
    z-index: 10000;
    pointer-events: none;
}

.physics-debug p {
    margin: 2px 0;
}

/* Magnetic pull indicator (optional visual feedback) */
.magnetic-indicator {
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    border: 1px dashed var(--border-color);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    transform: translate(-50%, -50%);
}

.magnetic-indicator.active {
    opacity: 0.3;
}

/* Glow effect on magnetic hover */
.btn:hover,
.btn-primary:hover,
.btn-secondary:hover {
    box-shadow: 
        0 0 20px rgba(var(--text-dark-rgb, 0, 0, 0), 0.2),
        0 4px 15px rgba(var(--text-dark-rgb, 0, 0, 0), 0.1);
}

[data-theme="dark"] .btn:hover,
[data-theme="dark"] .btn-primary:hover,
[data-theme="dark"] .btn-secondary:hover {
    box-shadow: 
        0 0 20px rgba(255, 255, 255, 0.15),
        0 4px 15px rgba(255, 255, 255, 0.1);
}

/* Squash and stretch for bounce */
@keyframes squash {
    0%, 100% {
        transform: scaleY(1) scaleX(1);
    }
    50% {
        transform: scaleY(0.9) scaleX(1.1);
    }
}

@keyframes stretch {
    0%, 100% {
        transform: scaleY(1) scaleX(1);
    }
    50% {
        transform: scaleY(1.1) scaleX(0.95);
    }
}

/* Wobble animation for interactive feedback */
@keyframes wobble {
    0%, 100% {
        transform: translateX(0) rotate(0);
    }
    15% {
        transform: translateX(-5px) rotate(-2deg);
    }
    30% {
        transform: translateX(4px) rotate(1.5deg);
    }
    45% {
        transform: translateX(-3px) rotate(-1deg);
    }
    60% {
        transform: translateX(2px) rotate(0.5deg);
    }
    75% {
        transform: translateX(-1px) rotate(-0.25deg);
    }
}

.wobble {
    animation: wobble 0.6s ease-out;
}

/* Jelly hover effect */
@keyframes jelly {
    0%, 100% {
        transform: scale(1, 1);
    }
    25% {
        transform: scale(0.95, 1.05);
    }
    50% {
        transform: scale(1.05, 0.95);
    }
    75% {
        transform: scale(0.98, 1.02);
    }
}

.jelly-hover:hover {
    animation: jelly 0.5s ease;
}

/* Pulse glow for active elements */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--border-color);
    }
    50% {
        box-shadow: 0 0 20px var(--border-color), 0 0 30px var(--border-color);
    }
}

.pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Particle trail effect placeholder */
.particle-trail {
    position: fixed;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dark);
    pointer-events: none;
    opacity: 0.6;
    z-index: 9998;
}

/* Spring bounce entrance */
@keyframes spring-in {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(50px);
    }
    50% {
        transform: scale(1.05) translateY(-10px);
    }
    70% {
        transform: scale(0.98) translateY(5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.spring-in {
    animation: spring-in 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Stagger delay utilities */
.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; }

/* Disable physics animations for reduced motion */
@media (prefers-reduced-motion: reduce) {
    .physics-enabled,
    .btn,
    .btn-primary,
    .btn-secondary,
    .portfolio-item,
    .book-card,
    .stat-card,
    .project-card,
    .nav-menu a,
    .nav-logo,
    .hero-title .highlight {
        will-change: auto !important;
        transform: none !important;
        animation: none !important;
    }
    
    .physics-ripple {
        display: none !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .portfolio-item,
    .book-card,
    .stat-card,
    .project-card {
        transform: none !important;
    }
    
    .btn,
    .btn-primary,
    .btn-secondary {
        transform: none !important;
    }
}
