/**
 * Nabab Vision - UI/UX Enhancements
 * Modern animations, micro-interactions, and visual effects
 */

/* ============================================================
   1. ENTRANCE ANIMATIONS
   ============================================================ */

/* Staggered fade-up animation */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

/* Stagger children with delays */
.stagger-container > * {
    opacity: 0;
    animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stagger-container > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-container > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-container > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-container > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-container > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-container > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-container > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-container > *:nth-child(8) { animation-delay: 0.8s; }

/* Scroll-triggered animations */
.scroll-reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

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

/* Scale reveal on scroll */
.scroll-reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* Left slide reveal */
.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Right slide reveal */
.scroll-reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.scroll-reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* ============================================================
   2. MICRO-INTERACTIONS
   ============================================================ */

/* Enhanced button hover effect */
.btn {
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transform: translate(-50%, -50%);
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn:active::after {
    width: 300px;
    height: 300px;
}

/* Magnetic button effect (subtle) */
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 77, 28, 0.25);
}

.btn-accent:hover {
    box-shadow: 0 12px 32px rgba(255, 77, 28, 0.35),
                    0 0 0 1px rgba(255, 77, 28, 0.5);
}

/* Enhanced card hover */
.project-card,
.service-item,
.stat-item {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.3s ease;
}

.project-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6),
                0 0 0 1px rgba(255, 77, 28, 0.2);
}

/* Service card enhanced hover */
.service-item:hover {
    padding-left: 2rem;
    background: linear-gradient(90deg,
        rgba(255, 77, 28, 0.05) 0%,
        transparent 50%);
}

.service-item:hover .service-icon {
    animation: iconPulse 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes iconPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15) rotate(5deg); }
    100% { transform: scale(1.05); }
}

/* Link hover underline animation */
.nav-link {
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transform: translateX(-50%);
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ============================================================
   3. MODERN VISUAL EFFECTS
   ============================================================ */

/* Glassmorphism effect */
.glass {
    background: rgba(12, 12, 12, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-light {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Noise texture overlay */
.noise-overlay {
    position: relative;
}

.noise-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.04;
    mix-blend-mode: overlay;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.5' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    z-index: 1;
}

/* Gradient border effect */
.gradient-border {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-xl);
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(135deg,
        rgba(255, 77, 28, 0.4) 0%,
        rgba(255, 77, 28, 0.1) 50%,
        rgba(255, 255, 255, 0.05) 100%);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.gradient-border:hover::before {
    opacity: 1;
}

/* Glow effect on hover */
.glow-hover {
    transition: box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.glow-hover:hover {
    box-shadow: 0 0 40px rgba(255, 77, 28, 0.3),
                0 0 80px rgba(255, 77, 28, 0.15);
}

/* Shimmer loading effect */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.simmer-loader {
    background: linear-gradient(
        90deg,
        var(--surface) 0%,
        var(--surface-hover) 20%,
        var(--surface-active) 40%,
        var(--surface-hover) 60%,
        var(--surface) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Spotlight effect */
.spotlight {
    position: relative;
    overflow: hidden;
}

.spotlight::after {
    content: '';
    position: absolute;
    top: var(--y, -50%);
    left: var(--x, -50%);
    width: 500px;
    height: 500px;
    background: radial-gradient(circle,
        rgba(255, 77, 28, 0.15) 0%,
        transparent 60%);
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
}

.spotlight:hover::after {
    opacity: 1;
}

/* ============================================================
   4. PARALLAX EFFECTS
   ============================================================ */

/* Parallax container */
.parallax-slow {
    transform: translateY(calc(var(--scroll) * 0.3px));
    will-change: transform;
}

.parallax-medium {
    transform: translateY(calc(var(--scroll) * 0.5px));
    will-change: transform;
}

.parallax-fast {
    transform: translateY(calc(var(--scroll) * 0.7px));
    will-change: transform;
}

/* Parallax horizontal */
.parallax-x-slow {
    transform: translateX(calc(var(--scroll) * 0.2px));
}

/* ============================================================
   5. TEXT EFFECTS
   ============================================================ */

/* Text gradient animation */
@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.text-gradient-animated {
    background: linear-gradient(90deg,
        var(--accent) 0%,
        var(--accent-hover) 25%,
        #fff 50%,
        var(--accent-hover) 75%,
        var(--accent) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease infinite;
}

/* Typewriter effect */
@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    0%, 100% { border-color: transparent; }
    50% { border-color: var(--accent); }
}

.typewriter {
    overflow: hidden;
    white-space: nowrap;
    border-right: 3px solid var(--accent);
    animation: typewriter 3s steps(40, end),
               blink 0.75s step-end infinite;
}

/* Character reveal animation */
.char-reveal {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: charFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* ============================================================
   6. LOADING STATES
   ============================================================ */

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

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text.large { height: 1.5em; }
.skeleton-text.small { height: 0.75em; }

/* Pulse loader */
@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.pulse-loader {
    position: relative;
    width: 48px;
    height: 48px;
}

.pulse-loader::before,
.pulse-loader::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

.pulse-loader::after {
    animation-delay: 0.75s;
}

/* ============================================================
   7. FLOATING ELEMENTS
   ============================================================ */

@keyframes floatY {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

@keyframes floatRotate {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

.float-y {
    animation: floatY 6s ease-in-out infinite;
}

.float-rotate {
    animation: floatRotate 8s ease-in-out infinite;
}

/* ============================================================
   8. MAGNETIC EFFECT (JS-enhanced)
   ============================================================ */

.magnetic {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================================
   9. CURSOR EFFECTS
   ============================================================ */

/* Custom cursor for specific elements */
.cursor-pointer {
    cursor: pointer;
}

.cursor-none {
    cursor: none;
}

/* ============================================================
   10. SCROLL PROGRESS
   ============================================================ */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    z-index: 10000;
    transition: width 0.1s ease-out;
}

/* ============================================================
   11. HOVER CARD EFFECT
   ============================================================ */

.card-3d {
    perspective: 1000px;
    transform-style: preserve-3d;
}

.card-3d-inner {
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    transform-style: preserve-3d;
}

.card-3d:hover .card-3d-inner {
    transform: rotateY(10deg) rotateX(5deg);
}

/* ============================================================
   12. TEXT SELECTION ENHANCED
   ============================================================ */

::selection {
    background: var(--accent);
    color: var(--primary);
    text-shadow: none;
}

::-moz-selection {
    background: var(--accent);
    color: var(--primary);
}

/* ============================================================
   13. FOCUS VISIBLE ENHANCED
   ============================================================ */

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 4px;
    border-radius: var(--radius-sm);
}

/* ============================================================
   14. IMAGE LAZY LOADING
   ============================================================ */

img[loading="lazy"] {
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

img[loading="lazy"].loaded {
    opacity: 1;
}

/* ============================================================
   15. BACK TO TOP BUTTON
   ============================================================ */

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(255, 77, 28, 0.35);
}

.back-to-top svg {
    width: 24px;
    height: 24px;
    color: var(--primary);
    transition: transform 0.3s ease;
}

.back-to-top:hover svg {
    transform: translateY(-4px);
}

/* ============================================================
   16. RESPONSIVE ENHANCEMENTS
   ============================================================ */

@media (max-width: 768px) {
    .stagger-container > * {
        animation-duration: 0.5s;
    }

    .project-card:hover {
        transform: translateY(-4px) scale(1.01);
    }

    .service-item:hover {
        padding-left: 1.5rem;
    }

    .back-to-top {
        width: 48px;
        height: 48px;
        bottom: 1.5rem;
        right: 1.5rem;
    }
}

/* ============================================================
   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,
    .scroll-reveal-scale,
    .scroll-reveal-left,
    .scroll-reveal-right {
        opacity: 1;
        transform: none;
    }

    .parallax-slow,
    .parallax-medium,
    .parallax-fast {
        transform: none;
    }
}

/* Fix stats text wrap on mobile */
@media (max-width: 768px) {
    .stat-number {
        white-space: nowrap;
    }
    
    .stat-label {
        white-space: nowrap;
    }
}

/* Fix stats display on mobile - prevent text cutoff */
@media (max-width: 768px) {
    .stat-number {
        white-space: nowrap !important;
        overflow: visible !important;
        font-size: clamp(1.5rem, 8vw, 2.5rem) !important;
        word-break: keep-all !important;
        hyphens: none !important;
    }
    
    .stat-label {
        white-space: nowrap !important;
        font-size: clamp(0.75rem, 4vw, 0.9rem) !important;
        word-break: keep-all !important;
    }
    
    .stat-item {
        min-width: unset !important;
        overflow: visible !important;
    }
}
