@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Vazirmatn:wght@200;300;400;500;600;700&display=swap');

:root {
    --bg: #05070f;
    --bg-2: #0a0c18;
    --card-bg: rgba(15, 18, 35, 0.6);
    --card-bg-hover: rgba(25, 28, 55, 0.8);
    --border: rgba(99, 102, 241, 0.18);
    --border-glow: rgba(168, 85, 247, 0.4);
    --glow: rgba(99, 102, 241, 0.3);
    --accent: #6366f1;
    --accent-2: #a855f7;
    --accent-3: #ec4899;
    --text-primary: #e8eaf6;
    --text-secondary: #a0a4d4;
    --text-muted: #5a5e8a;
    --font-en: 'Poppins', sans-serif;
    --font-fa: 'Vazirmatn', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 18px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --transition: 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    --spring: 0.34, 1.56, 0.64, 1;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-fa);
    overflow-x: hidden;
    opacity: 0;
    transition: opacity 0.6s ease;
    position: relative;
}

body.lang-en { font-family: var(--font-en); direction: ltr; }
body.lang-fa { font-family: var(--font-fa); direction: rtl; }
body.loaded { opacity: 1; }

#transition-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
#transition-overlay.active { opacity: 1; visibility: visible; }

.main-wrapper {
    position: relative;
    z-index: 1;
}

/* ────────── NAV ────────── */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 1.2rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    direction: ltr;
    background: rgba(5, 7, 15, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: padding 0.3s ease;
}

.nav.scrolled { padding: 0.8rem 2rem; background: rgba(5, 7, 15, 0.8); }

.nav-logo {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: 1px;
}
.nav-logo span { color: var(--accent-2); }

/* ────────── HAMBURGER ────────── */

.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 22px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 101;
    padding: 0;
}

.hamburger span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ────────── MENU PANEL ────────── */

.menu-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: min(320px, 80vw);
    height: 100vh;
    background: rgba(5, 7, 15, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--border);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    padding: 2rem;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

body.lang-fa .menu-panel {
    border-left: none;
    border-right: 1px solid var(--border);
}

.menu-panel.open { transform: translateX(0) !important; }

.menu-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-links .nav-link {
    font-size: 1.2rem;
    padding: 0.8rem 1rem;
    display: block;
}

.menu-links .nav-link:hover {
    background: rgba(99, 102, 241, 0.1);
    padding-left: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-xs);
    transition: color 0.3s, background 0.3s, padding 0.3s;
}

.nav-link:hover { color: var(--text-primary); }
.nav-link.active { color: var(--accent-2); }

.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.menu-overlay.open { opacity: 1; visibility: visible; }

/* ────────── LANG SWITCHER ────────── */

.lang-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 4px 6px;
    border-radius: 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    user-select: none;
    transition: border-color 0.3s, transform 0.3s;
    font-family: var(--font-mono);
}

.lang-switcher:hover { border-color: var(--border-glow); }

.lang-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    transition: color 0.3s, background 0.3s;
}

.lang-btn:hover { color: var(--text-primary); }

.lang-btn.active {
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.35);
}

.lang-sep {
    color: var(--text-muted);
    margin: 0 1px;
    user-select: none;
}

/* ────────── HERO ────────── */

.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 6rem 2rem 2rem;
    position: relative;
}

.hero-greeting {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    opacity: 0;
    animation: fadeUp 0.8s 0.2s ease-out forwards;
}

.hero-name {
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 700;
    background: linear-gradient(90deg, #6366f1, #a855f7, #ec4899, #a855f7, #6366f1);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: textShimmer 5s linear infinite, fadeUp 0.8s 0.4s ease-out forwards;
    opacity: 0;
}

.hero-role {
    font-size: clamp(1rem, 3vw, 1.4rem);
    color: var(--accent-2);
    margin-top: 0.5rem;
    font-weight: 500;
    opacity: 0;
    animation: fadeUp 0.8s 0.6s ease-out forwards;
}

.hero-typed-wrap {
    margin-top: 1rem;
    font-family: var(--font-mono);
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    color: var(--text-secondary);
    opacity: 0;
    animation: fadeUp 0.8s 0.8s ease-out forwards;
}

#typed {
    color: var(--accent);
    border-right: 2px solid var(--accent-2);
    padding-right: 4px;
    animation: cursorBlink 0.8s step-end infinite;
}

body.lang-fa #typed { border-right: none; border-left: 2px solid var(--accent-2); padding-right: 0; padding-left: 4px; }

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

.hero-scroll {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 3px;
    opacity: 0;
    animation: fadeUp 0.8s 1.2s ease-out forwards;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.hero-scroll::after {
    content: '';
    width: 1px;
    height: 40px;
    background: linear-gradient(180deg, var(--accent-2), transparent);
    animation: scrollLine 2s ease-in-out infinite;
}

@keyframes scrollLine {
    0% { transform: scaleY(0); transform-origin: top; }
    50% { transform: scaleY(1); transform-origin: top; }
    100% { transform: scaleY(0); transform-origin: bottom; }
}

/* ────────── SECTIONS ────────── */

section {
    padding: 6rem 2rem;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-subtitle {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
}

.section-title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 600;
    color: var(--text-primary);
}

/* ────────── ABOUT ────────── */

.about-content {
    max-width: 700px;
    margin: 0 auto;
    text-align: center;
}

.about-text p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.9;
    margin-bottom: 1.5rem;
}

/* ────────── STATS ────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
    margin: 3rem 0;
}

.stat-card {
    text-align: center;
    padding: 2rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: transform var(--transition), border-color 0.3s;
}

.stat-card:hover { transform: translateY(-5px); border-color: var(--border-glow); }

.stat-number {
    font-size: clamp(2rem, 4vw, 2.8rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: var(--font-mono);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

/* ────────── PROJECTS ────────── */

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: transform var(--transition), box-shadow 0.3s, border-color 0.3s;
    position: relative;
    overflow: hidden;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
    background-size: 200% 100%;
    animation: tabShine 4s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
}

.project-card:hover::before { opacity: 1; }
.project-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 50px rgba(99, 102, 241, 0.15);
    border-color: var(--border-glow);
    background: var(--card-bg-hover);
}

.project-number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--accent);
    margin-bottom: 0.8rem;
}

.project-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.project-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
}

.project-tag {
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--accent-2);
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(168, 85, 247, 0.2);
}

.project-links {
    display: flex;
    gap: 0.8rem;
}

.project-link {
    font-size: 0.85rem;
    color: var(--accent-2);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.3s, gap 0.3s;
}

.project-link:hover { color: var(--accent-3); gap: 0.6rem; }

/* ────────── SKILLS ────────── */

.skills-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.skill-category {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: transform var(--transition), border-color 0.3s;
}

.skill-category:hover { transform: translateY(-5px); border-color: var(--border-glow); }

.skill-category-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-2);
    margin-bottom: 1.2rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
}

.skill-item {
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: var(--radius-xs);
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.3s ease;
    cursor: default;
}

.skill-item:hover {
    background: rgba(168, 85, 247, 0.15);
    border-color: var(--accent-2);
    color: var(--text-primary);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.2);
}

/* ────────── CONTACT ────────── */

.contact-content {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.contact-desc {
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.8;
    margin-bottom: 2rem;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.2rem;
    margin-top: 1rem;
}

body.lang-fa .social-links { direction: ltr; }

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    text-decoration: none;
    transition: transform var(--transition), border-color 0.3s, color 0.3s, box-shadow 0.3s;
}

.social-links a:hover {
    transform: scale(1.15) translateY(-3px);
    border-color: var(--border-glow);
    color: var(--accent-2);
    box-shadow: 0 10px 30px rgba(168, 85, 247, 0.2);
}

.social-links svg { width: 22px; height: 22px; }

/* ────────── FOOTER ────────── */

footer {
    padding: 3rem 2rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    background: rgba(5, 7, 15, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.footer-copyright {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.lang-fa .back-to-top { right: auto; left: 2rem; }

.back-to-top.visible { opacity: 1; visibility: visible; }
.back-to-top:hover {
    transform: translateY(-3px);
    border-color: var(--accent-2);
    box-shadow: 0 8px 20px rgba(168, 85, 247, 0.3);
}

/* ────────── REVEAL ANIMATION ────────── */

.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* ────────── ANIMATIONS ────────── */

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

@keyframes textShimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@keyframes tabShine {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

/* ────────── RESPONSIVE ────────── */

@media (max-width: 768px) {
    .nav { padding: 0.8rem 1rem; }
    .nav-logo { font-size: 1.1rem; }

    section { padding: 4rem 1rem; }
    .hero { padding: 5rem 1rem 2rem; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .skills-container {
        grid-template-columns: 1fr;
    }

    .social-links { gap: 0.8rem; }
    .social-links a { width: 44px; height: 44px; }

    .back-to-top { bottom: 1rem; right: 1rem; width: 40px; height: 40px; }
    body.lang-fa .back-to-top { left: 1rem; }
}

@media (max-width: 480px) {
    .hero-name { font-size: 2.2rem; }
    .section-title { font-size: 1.5rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .project-card { padding: 1.5rem; }
    .menu-panel { width: 85vw; padding: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
