/**
 * Premium Animations & SVG Effects
 * KHAR_AG Portfolio — Luxury feel
 *
 * @package My_Portfolio
 */

/* ============================================
   NAV ACTIVE INDICATOR (animated underline)
   ============================================ */

.nav-menu a {
    position: relative;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 1px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(255, 95, 31, 0.45);
}

.nav-menu a:hover::after,
.nav-menu .current-menu-item a::after {
    width: 100%;
    left: 0;
}

.nav-menu .current-menu-item a {
    color: var(--color-primary);
}

/* ============================================
   HERO — SVG PARTICLE CANVAS
   ============================================ */

.hero-particles-canvas {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* ============================================
   HERO — ANIMATED GRADIENT ORB
   ============================================ */

.hero-orb {
    position: absolute;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.12;
    animation: orbFloat 20s ease-in-out infinite;
    pointer-events: none;
    z-index: 0;
}

.hero-orb--primary {
    top: 10%;
    left: 15%;
    background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
    animation-duration: 18s;
}

.hero-orb--secondary {
    bottom: 15%;
    right: 10%;
    background: radial-gradient(circle, var(--color-secondary) 0%, transparent 70%);
    animation-duration: 22s;
    animation-direction: reverse;
}

.hero-orb--accent {
    top: 50%;
    left: 50%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--color-accent) 0%, transparent 70%);
    animation-duration: 15s;
    opacity: 0.06;
    transform: translate(-50%, -50%);
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -40px) scale(1.1); }
    50% { transform: translate(-20px, 20px) scale(0.9); }
    75% { transform: translate(15px, 30px) scale(1.05); }
}

/* ============================================
   HERO — TEXT REVEAL ANIMATION
   ============================================ */

.hero-title .line {
    display: block;
    opacity: 0;
    transform: translateY(40px);
    animation: textReveal 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    background: linear-gradient(180deg, #ffffff 20%, #a0a0c0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-title .line:nth-child(1) { animation-delay: 0.2s; }
.hero-title .line:nth-child(2) { animation-delay: 0.4s; }
.hero-title .line:nth-child(3) { animation-delay: 0.6s; }

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

/* Override parent gradient since each .line handles its own */
.hero-title {
    -webkit-text-fill-color: initial;
    background: none;
    -webkit-background-clip: initial;
    background-clip: initial;
}

.hero-subtitle-label {
    opacity: 0;
    animation: fadeSlideDown 0.6s cubic-bezier(0.16, 1, 0.3, 1) 0.05s forwards;
}

.hero-description {
    opacity: 0;
    animation: fadeSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.7s forwards;
}

.hero-lead {
    opacity: 0;
    animation: fadeSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.72s forwards;
}

.hero-model-strip {
    opacity: 0;
    animation: fadeSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.88s forwards;
}

.hero-signal-flow {
    opacity: 0;
    animation: fadeSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.96s forwards;
}

.hero-focus-grid {
    opacity: 0;
    animation: fadeSlideUp 0.75s cubic-bezier(0.16, 1, 0.3, 1) 1.05s forwards;
}

.hero-cta {
    opacity: 0;
    animation: fadeSlideUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) 1.14s forwards;
}

@keyframes fadeSlideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* ============================================
   SECTION DIVIDERS — Animated SVG waves
   ============================================ */

.section-divider-svg {
    position: relative;
    width: 100%;
    height: 80px;
    overflow: hidden;
    line-height: 0;
    z-index: 2;
}

.section-divider-svg svg {
    display: block;
    width: 100%;
    height: 100%;
}

.section-divider-svg .wave-path {
    animation: waveShift 8s ease-in-out infinite alternate;
}

.section-divider-svg .wave-path-2 {
    animation: waveShift 10s ease-in-out infinite alternate-reverse;
    opacity: 0.5;
}

@keyframes waveShift {
    0% { d: path("M0,40 C200,80 400,0 600,40 C800,80 1000,0 1200,40 L1200,80 L0,80 Z"); }
    100% { d: path("M0,40 C200,0 400,80 600,40 C800,0 1000,80 1200,40 L1200,80 L0,80 Z"); }
}

/* Glowing line divider */
.section-glow-line {
    position: relative;
    height: 2px;
    width: 100%;
    overflow: hidden;
}

.section-glow-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--color-primary) 30%,
        var(--color-secondary) 50%,
        var(--color-primary) 70%,
        transparent 100%
    );
    animation: glowSweep 4s ease-in-out infinite;
}

@keyframes glowSweep {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ============================================
   SECTION TRANSITIONS — Staggered reveals
   ============================================ */

.animate-on-scroll {
    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);
}

.animate-on-scroll.fade-in {
    opacity: 1;
    transform: translateY(0);
}

.stagger-1 { transition-delay: 0.1s; }
.stagger-2 { transition-delay: 0.2s; }
.stagger-3 { transition-delay: 0.3s; }
.stagger-4 { transition-delay: 0.4s; }

/* Slide from left */
.animate-slide-left {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-slide-left.fade-in {
    opacity: 1;
    transform: translateX(0);
}

/* Slide from right */
.animate-slide-right {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-slide-right.fade-in {
    opacity: 1;
    transform: translateX(0);
}

/* Scale up entrance */
.animate-scale {
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-scale.fade-in {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   SVG FLOATING SHAPES (decorative bg)
   ============================================ */

.floating-shapes {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.floating-shape {
    position: absolute;
    opacity: 0.04;
    animation: shapeFloat 20s ease-in-out infinite;
}

.floating-shape--1 {
    top: 15%;
    left: 8%;
    animation-duration: 18s;
}

.floating-shape--2 {
    top: 60%;
    right: 5%;
    animation-duration: 24s;
    animation-direction: reverse;
}

.floating-shape--3 {
    bottom: 20%;
    left: 50%;
    animation-duration: 22s;
    animation-delay: -5s;
}

@keyframes shapeFloat {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(15px, -20px) rotate(90deg); }
    50% { transform: translate(-10px, 15px) rotate(180deg); }
    75% { transform: translate(20px, 10px) rotate(270deg); }
}

/* ============================================
   BUTTONS — Premium hover effects
   ============================================ */

.btn-primary::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary), var(--color-primary));
    background-size: 300% 300%;
    border-radius: inherit;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
    animation: gradientShift 3s ease-in-out infinite;
}

.btn-primary:hover::before {
    opacity: 1;
}

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

/* Ripple effect on click */
.btn {
    overflow: hidden;
}

.btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: rippleEffect 0.6s ease-out;
    pointer-events: none;
}

@keyframes rippleEffect {
    to { transform: scale(4); opacity: 0; }
}

/* ============================================
   SKILL BARS — Enhanced animations
   ============================================ */

.skill-progress {
    position: relative;
    overflow: hidden;
}

.skill-progress::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: skillShimmer 2s ease-in-out infinite;
    animation-play-state: paused;
}

.skill-item:hover .skill-progress::before {
    animation-play-state: running;
}

@keyframes skillShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

/* ============================================
   HERO CARDS — Enhanced hover effects
   ============================================ */

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

.hero-card .card-content {
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.hero-card:hover .card-content {
    transform: translateY(-4px);
}

/* ============================================
   TESTIMONIAL — Enhanced style
   ============================================ */

.testimonial-item {
    position: relative;
    overflow: hidden;
}

.testimonial-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary), var(--color-primary));
    background-size: 200% 100%;
    animation: gradientLine 4s ease-in-out infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.testimonial-item:hover::after {
    opacity: 1;
}

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

/* ============================================
   CONTACT FORM — Focus glow
   ============================================ */

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-dim),
                0 0 22px rgba(255, 95, 31, 0.15);
}

/* ============================================
   SECTION LABEL — Animated dot
   ============================================ */

.section-label::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 10px var(--color-primary);
    animation: labelPulse 2s ease-in-out infinite;
}

@keyframes labelPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 10px var(--color-primary); }
    50% { opacity: 0.5; box-shadow: 0 0 20px var(--color-primary), 0 0 40px var(--color-primary); }
}

/* ============================================
   PARALLAX SECTIONS
   ============================================ */

.section-parallax-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* ============================================
   COUNTER ANIMATION (for skills percent)
   ============================================ */

.skill-percent {
    font-variant-numeric: tabular-nums;
}

/* ============================================
   SCROLL PROGRESS INDICATOR
   ============================================ */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 2px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    z-index: 9999;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px var(--color-primary);
}

/* ============================================
   MAGNETIC CURSOR (for buttons)
   ============================================ */

.magnetic-wrap {
    display: inline-flex;
    position: relative;
}

/* ============================================
   ABOUT SECTION — Enhanced image
   ============================================ */

.about-image {
    position: relative;
}

.about-image::after {
    content: '';
    position: absolute;
    inset: -8px;
    border: 1px solid var(--color-border-accent);
    border-radius: calc(var(--radius-lg) + 4px);
    opacity: 0.3;
    animation: borderPulse 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes borderPulse {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 0.1; transform: scale(1.01); }
}

/* ============================================
   FOOTER — Gradient border top
   ============================================ */

.site-footer {
    border-top: none;
    position: relative;
}

.site-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--color-primary) 20%,
        var(--color-secondary) 50%,
        var(--color-primary) 80%,
        transparent 100%
    );
}

/* ============================================
   LOADING SCREEN (optional)
   ============================================ */

.page-transition-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-transition-overlay.loaded {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.page-transition-overlay .loader-logo {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #fff;
    animation: logoPulseLoad 1.2s ease-in-out infinite;
}

.page-transition-overlay .loader-logo .logo-accent {
    color: var(--color-primary);
}

@keyframes logoPulseLoad {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.text-link {
    color: var(--color-primary);
    text-decoration: underline;
    text-decoration-color: rgba(255, 95, 31, 0.4);
    text-underline-offset: 3px;
    transition: all 0.3s ease;
}

.text-link:hover {
    color: var(--color-secondary);
    text-decoration-color: var(--color-secondary);
}

/* ==========================================================================
   AI Pipeline Animation (Volumetric & Clear)
   ========================================================================== */
.ai-pipeline-animation {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    max-width: 750px;
    margin: 5rem auto 4rem;
    padding: 0 1rem;
    position: relative;
}

.pipeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 2;
    width: 140px;
}

.pipeline-icon-wrap {
    width: 76px;
    height: 76px;
    border-radius: 20px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    box-shadow:
        12px 12px 24px rgba(0, 0, 0, 0.06),
        -12px -12px 24px rgba(255, 255, 255, 0.8),
        inset 2px 2px 5px rgba(255, 255, 255, 1),
        inset -2px -2px 5px rgba(0, 0, 0, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-secondary);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .pipeline-icon-wrap {
    background: #1e1e24;
    border-color: #2a2a35;
    box-shadow:
        12px 12px 24px rgba(0, 0, 0, 0.4),
        -12px -12px 24px rgba(255, 255, 255, 0.02),
        inset 2px 2px 5px rgba(255, 255, 255, 0.05),
        inset -2px -2px 5px rgba(0, 0, 0, 0.2);
}

.pipeline-node:hover .pipeline-icon-wrap {
    transform: translateY(-5px);
}

.pipeline-node--center .pipeline-icon-wrap {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #fff;
    border: none;
    box-shadow:
        0 15px 35px rgba(255, 95, 31, 0.35),
        inset 2px 2px 12px rgba(255, 255, 255, 0.5),
        inset -4px -4px 15px rgba(0, 0, 0, 0.2);
    animation: pulse-core 3s infinite alternate;
}

.pipeline-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-text);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.pipeline-desc {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    text-align: center;
    line-height: 1.4;
    margin-top: -8px;
}

.pipeline-track {
    flex-grow: 1;
    height: 8px;
    background: var(--border-color, #e5e7eb);
    border-radius: 4px;
    margin: 34px -25px 0; /* Align with icons vertically, overlap horizontally */
    position: relative;
    z-index: 1;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

[data-theme="dark"] .pipeline-track {
    background: #2a2a35;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.track-data {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 60px;
    background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
    filter: drop-shadow(0 0 8px var(--color-primary));
    animation: data-flow 2s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

.track-data--delayed {
    animation-delay: 1s;
}

@keyframes data-flow {
    0% { left: -60px; opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}

@keyframes pulse-core {
    0% { box-shadow: 0 10px 25px rgba(255, 95, 31, 0.2), inset 2px 2px 10px rgba(255, 255, 255, 0.4); transform: translateY(0); }
    100% { box-shadow: 0 25px 50px rgba(255, 95, 31, 0.6), inset 2px 2px 15px rgba(255, 255, 255, 0.7); transform: translateY(-8px); }
}

/* Rings around center node */
.node-rings {
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.node-ring {
    position: absolute;
    inset: -25px;
    border: 2px dashed var(--color-primary);
    border-radius: 50%;
    opacity: 0.25;
    animation: spin-ring 12s linear infinite;
}

.node-ring:nth-child(2) {
    inset: -50px;
    border: 1px solid var(--color-secondary);
    opacity: 0.15;
    animation: spin-ring 18s linear infinite reverse;
}

@keyframes spin-ring {
    100% { transform: rotate(360deg); }
}

/* Анимация AI Pipeline (Mobile) */
@media screen and (max-width: 768px) {
    .ai-pipeline-animation {
        flex-direction: column !important;
        align-items: center !important;
        gap: 3rem !important;
        margin: 3rem auto !important;
        overflow: hidden !important;
        width: 100% !important;
    }

    .pipeline-node {
        width: 100% !important;
        max-width: 280px !important;
    }

    .pipeline-track {
        width: 4px !important;
        height: 60px !important;
        margin: -2rem auto !important;
        flex-grow: 0 !important;
        top: 0 !important;
    }

    .track-data {
        width: 100% !important;
        height: 30px !important;
        background: linear-gradient(180deg, transparent, var(--color-primary), transparent) !important;
        animation: data-flow-vertical 2s infinite cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .track-data--delayed {
        animation-delay: 1s !important;
    }

    .pipeline-node--center {
        top: 0 !important;
    }
}
