/* ==========================================
   Portfolio — Mikhail Ekaterinichev
   Custom Styles
   ========================================== */

/* --- Custom Properties --- */
:root {
    --color-bg: #0a0a0f;
    --color-surface: #12121a;
    --color-accent: #34d399;
    --color-accent-glow: #10b981;
    --color-accent-dim: #065f46;
    --color-warm: #fbbf24;
    --color-text: #e4e4e7;
    --color-text-secondary: #a1a1aa;
    --color-text-muted: #71717a;
    --color-border: rgba(255, 255, 255, 0.08);
}

/* --- Base --- */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
}

::selection {
    background: rgba(52, 211, 153, 0.25);
    color: #fff;
}

/* --- Grain Overlay --- */
.grain-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}

/* --- Gradient Text --- */
.text-gradient {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-warm) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Glow Orbs --- */
.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
}

.glow-orb--accent {
    width: 600px;
    height: 600px;
    top: 10%;
    right: -15%;
    background: radial-gradient(circle, rgba(52, 211, 153, 0.12), transparent 70%);
}

.glow-orb--warm {
    width: 500px;
    height: 500px;
    bottom: 5%;
    left: -10%;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.08), transparent 70%);
}

.glow-orb--section-accent {
    width: 500px;
    height: 500px;
    top: -10%;
    right: -15%;
    background: radial-gradient(circle, rgba(52, 211, 153, 0.06), transparent 70%);
}

.glow-orb--section-warm {
    width: 400px;
    height: 400px;
    bottom: 0;
    left: -10%;
    background: radial-gradient(circle, rgba(251, 191, 36, 0.05), transparent 70%);
}

.glow-orb--contact {
    width: 700px;
    height: 700px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(52, 211, 153, 0.08), transparent 70%);
}

/* --- Navigation --- */
#navbar {
    background: transparent;
}

#navbar.scrolled {
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
}

.nav-link {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    transition: color 0.2s ease;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--color-accent);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 1px;
    background: var(--color-accent);
    transition: width 0.3s ease;
}

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

/* Hamburger */
.hamburger-line {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text-secondary);
    border-radius: 1px;
    transition: all 0.3s ease;
}

#menu-toggle.open .hamburger-line:nth-child(1) {
    transform: translateY(5.5px) rotate(45deg);
}

#menu-toggle.open .hamburger-line:nth-child(2) {
    opacity: 0;
}

#menu-toggle.open .hamburger-line:nth-child(3) {
    transform: translateY(-5.5px) rotate(-45deg);
}

/* Mobile Menu */
.mobile-menu {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.97);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: -1;
}

.mobile-menu.open {
    opacity: 1;
    visibility: visible;
    z-index: 40;
}

.mobile-nav-link {
    font-family: 'Syne', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    transition: color 0.2s ease;
}

.mobile-nav-link:hover {
    color: var(--color-accent);
}

/* --- Hero --- */
#hero-canvas {
    z-index: 1;
}

.hero-label,
#hero h1,
.hero-sub,
.hero-buttons,
.scroll-indicator {
    animation: fadeUp 0.7s ease forwards;
}

.hero-label { animation-delay: 0ms; }
#hero h1 { animation-delay: 150ms; }
.hero-sub { animation-delay: 300ms; }
.hero-buttons { animation-delay: 500ms; }
.scroll-indicator { animation-delay: 1200ms; }

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

/* Scroll indicator bounce */
.scroll-dot {
    animation: scrollBounce 2s ease-in-out infinite;
}

@keyframes scrollBounce {
    0%, 100% { transform: translateY(0); opacity: 0.6; }
    50% { transform: translateY(8px); opacity: 0.2; }
}

/* --- Buttons --- */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 0.9375rem;
    color: #0a0a0f;
    background: var(--color-accent);
    border-radius: 9999px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.btn-primary:hover {
    background: var(--color-accent-glow);
    box-shadow: 0 0 30px rgba(52, 211, 153, 0.3), 0 0 60px rgba(52, 211, 153, 0.1);
    transform: translateY(-2px);
}

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

.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 9999px;
    transition: all 0.3s ease;
    background: transparent;
}

.btn-outline:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.1);
    transform: translateY(-2px);
}

/* --- Glass Cards --- */
.glass-card {
    padding: 2rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    transition: all 0.4s ease;
    position: relative;
    overflow: hidden;
}

.glass-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), rgba(52, 211, 153, 0.06), transparent 40%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.glass-card:hover {
    border-color: rgba(52, 211, 153, 0.2);
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

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

.card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    margin-bottom: 1.25rem;
    position: relative;
}

.card-icon--emerald {
    background: rgba(52, 211, 153, 0.1);
    color: var(--color-accent);
}

.card-icon--blue {
    background: rgba(96, 165, 250, 0.1);
    color: #60a5fa;
}

.card-icon--purple {
    background: rgba(192, 132, 252, 0.1);
    color: #c084fc;
}

.card-icon--warm {
    background: rgba(251, 191, 36, 0.1);
    color: var(--color-warm);
}

/* --- Tech Tags --- */
.tech-tag {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8125rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: rgba(255, 255, 255, 0.02);
    color: var(--color-text-secondary);
    transition: all 0.3s ease;
    position: relative;
}

.tech-tag::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.tech-tag--core::before { background: var(--color-accent); }
.tech-tag--infra::before { background: #60a5fa; }
.tech-tag--lang::before { background: #c084fc; }
.tech-tag--tools::before { background: var(--color-warm); }

.tech-tag:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.05);
    color: var(--color-text);
    transform: translateY(-2px);
}

.tech-tag--core:hover { box-shadow: 0 4px 15px rgba(52, 211, 153, 0.15); }
.tech-tag--infra:hover { box-shadow: 0 4px 15px rgba(96, 165, 250, 0.15); }
.tech-tag--lang:hover { box-shadow: 0 4px 15px rgba(192, 132, 252, 0.15); }
.tech-tag--tools:hover { box-shadow: 0 4px 15px rgba(251, 191, 36, 0.15); }

/* --- Timeline --- */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline__line {
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(to bottom, var(--color-accent), var(--color-accent-dim), transparent);
    opacity: 0.4;
}

.timeline__entry {
    position: relative;
    padding-bottom: 3rem;
}

.timeline__entry:last-child {
    padding-bottom: 0;
}

.timeline__dot {
    position: absolute;
    left: -2rem;
    top: 0.35rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--color-bg);
    border: 2px solid var(--color-accent);
    box-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
    z-index: 1;
    transition: all 0.3s ease;
}

.timeline__entry:hover .timeline__dot {
    background: var(--color-accent);
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.5);
}

.timeline__card {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    transition: all 0.3s ease;
}

.timeline__card:hover {
    border-color: rgba(52, 211, 153, 0.15);
    background: rgba(255, 255, 255, 0.03);
}

.timeline__list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.timeline__list li {
    position: relative;
    padding-left: 1.25rem;
    margin-bottom: 0.5rem;
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
    line-height: 1.6;
}

.timeline__list li::before {
    content: '▹';
    position: absolute;
    left: 0;
    color: var(--color-accent);
}

.timeline__list li:last-child {
    margin-bottom: 0;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.125rem 0.625rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: 4px;
}

.badge--fintech {
    background: rgba(52, 211, 153, 0.1);
    color: var(--color-accent);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.badge--banking {
    background: rgba(96, 165, 250, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(96, 165, 250, 0.2);
}

/* Desktop timeline: alternating */
@media (min-width: 1024px) {
    .timeline {
        padding-left: 0;
    }

    .timeline__line {
        left: 50%;
        transform: translateX(-50%);
    }

    .timeline__entry {
        display: flex;
        width: 100%;
    }

    .timeline__dot {
        left: 50%;
        transform: translateX(-50%);
    }

    .timeline__card {
        width: calc(50% - 2.5rem);
    }

    .timeline__entry:nth-child(odd) {
        justify-content: flex-start;
    }

    .timeline__entry:nth-child(odd) .timeline__card {
        text-align: right;
    }

    .timeline__entry:nth-child(odd) .timeline__list li {
        padding-left: 0;
        padding-right: 1.25rem;
    }

    .timeline__entry:nth-child(odd) .timeline__list li::before {
        left: auto;
        right: 0;
    }

    .timeline__entry:nth-child(odd) .flex {
        justify-content: flex-end;
    }

    .timeline__entry:nth-child(even) {
        justify-content: flex-end;
    }
}

/* --- Contact Cards --- */
.contact-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    color: var(--color-text);
    transition: all 0.3s ease;
    min-width: 200px;
}

.contact-card:hover {
    border-color: rgba(52, 211, 153, 0.3);
    background: rgba(255, 255, 255, 0.05);
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* --- Scroll Animations --- */
.animate {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate.revealed {
    opacity: 1;
    transform: translateY(0);
}

.animate[data-delay="100"] { transition-delay: 100ms; }
.animate[data-delay="150"] { transition-delay: 150ms; }
.animate[data-delay="200"] { transition-delay: 200ms; }
.animate[data-delay="250"] { transition-delay: 250ms; }
.animate[data-delay="300"] { transition-delay: 300ms; }
.animate[data-delay="350"] { transition-delay: 350ms; }
.animate[data-delay="400"] { transition-delay: 400ms; }

/* Timeline animations */
.animate-timeline .timeline__card {
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.animate-timeline .timeline__dot {
    opacity: 0;
    transform: translateX(-50%) scale(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.animate-timeline.revealed .timeline__card {
    opacity: 1;
    transform: translateX(0);
}

.animate-timeline.revealed .timeline__dot {
    opacity: 1;
}

/* Mobile: slide from left */
.animate-timeline .timeline__card {
    transform: translateX(-20px);
}

/* Desktop: alternate slide direction */
@media (min-width: 1024px) {
    .animate-timeline:nth-child(odd) .timeline__card {
        transform: translateX(20px);
    }

    .animate-timeline:nth-child(even) .timeline__card {
        transform: translateX(-20px);
    }

    .animate-timeline.revealed .timeline__dot {
        transform: translateX(-50%) scale(1);
    }
}

/* --- 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-behavior: auto !important;
    }

    .animate,
    .animate-timeline .timeline__card,
    .animate-timeline .timeline__dot {
        opacity: 1;
        transform: none;
    }

    .hero-label,
    #hero h1,
    .hero-sub,
    .hero-buttons,
    .scroll-indicator {
        opacity: 1;
        transform: none;
        animation: none;
    }

    .scroll-dot {
        animation: none;
    }

    #hero-canvas {
        display: none;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}
