/* =========================================
   Modern UI/UX Design System (2025/2026)
   ========================================= */

:root {
    /* Light Theme Palette */
    --bg-main: #f0f4f8;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-card: rgba(255, 255, 255, 0.9);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --border-color: rgba(15, 23, 42, 0.1);
    
    /* Brand Colors (AI Vibe: Cyan & Purple) */
    --accent-1: #3b82f6;
    --accent-2: #8b5cf6;
    --accent-3: #ec4899;
    --gradient-brand: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    
    --glow-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
    --box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    /* Deep Dark Cyberpunk/AI Theme */
    --bg-main: #050505;
    --bg-glass: rgba(10, 10, 12, 0.6);
    --bg-card: rgba(18, 18, 20, 0.8);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.08);
    
    --accent-1: #00f2fe;
    --accent-2: #4facfe;
    --gradient-brand: linear-gradient(135deg, #00f2fe, #4facfe, #8b5cf6);
    
    --glow-shadow: 0 0 30px rgba(79, 172, 254, 0.4);
    --box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* =========================================
   Global, Typography & Strict Reset
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden !important; /* جلوگیری قطعی از اسکرول افقی در موبایل */
    font-family: 'Vazirmatn', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.7;
    transition: background-color 0.5s ease;
}

/* اعمال صریح فونت وزیر به تمامی المان‌هایی که فونت پیش‌فرض سیستم را می‌گیرند */
button, input, textarea, select, a {
    font-family: 'Vazirmatn', sans-serif;
}

@media (pointer: fine) {
    * { cursor: none !important; }
}

.en-text {
    font-family: 'Poppins', sans-serif !important;
    direction: ltr;
    display: inline-block;
}

.font-bold { font-weight: 700; }

a {
    text-decoration: none;
    color: inherit;
}

ul { list-style: none; }

.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 5%;
}

.section { padding: 100px 0; overflow: hidden; /* جلوگیری از بیرون زدگی محتوا */ }

.section-title {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 60px;
    text-align: center;
}

.text-muted { color: var(--text-secondary); font-size: 0.9rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-4 { margin-top: 1.5rem; }
.w-100 { width: 100%; }

/* =========================================
   Modern Effects (Noise, Gradients, Glass)
   ========================================= */
.noise-bg {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100vh;
    pointer-events: none;
    z-index: 9998;
    opacity: 0.04;
    background: url('data:image/svg+xml,%3Csvg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg"%3E%3Cfilter id="noiseFilter"%3E%3CfeTurbulence type="fractalNoise" baseFrequency="0.65" numOctaves="3" stitchTiles="stitch"/%3E%3C/filter%3E%3Crect width="100%25" height="100%25" filter="url(%23noiseFilter)"/%3E%3C/svg%3E');
}

.gradient-text {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: var(--box-shadow);
}

.scroll-progress {
    position: fixed; top: 0; left: 0;
    height: 4px; width: 100%;
    background: var(--gradient-brand);
    z-index: 10001;
    transform: scaleX(0);
    transform-origin: left center;
    will-change: transform;
}

/* =========================================
   Custom Cursor
   ========================================= */
.cursor-dot, .cursor-outline {
    position: fixed;
    top: 0; left: 0;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    z-index: 10000;
    pointer-events: none;
}
.cursor-dot { width: 8px; height: 8px; background-color: var(--accent-1); }
.cursor-outline { width: 40px; height: 40px; border: 1px solid var(--accent-2); transition: width 0.2s, height 0.2s, background-color 0.2s; }

/* =========================================
   Header & Nav
   ========================================= */
.header {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1000px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 40px;
    z-index: 1000;
    transition: all 0.4s ease;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    padding: 0 30px;
}

.logo { display: inline-flex; align-items: baseline; direction: ltr; unicode-bidi: isolate; font-size: 1.5rem; font-family: 'Poppins', sans-serif !important; font-weight: 800; }
.nav-links { display: flex; gap: 30px; }
.nav-item { font-weight: 500; font-size: 0.95rem; position: relative; padding: 5px 0; }
.nav-item::after {
    content: ''; position: absolute; bottom: 0; left: 0;
    width: 0; height: 2px; background: var(--gradient-brand); transition: width 0.3s ease;
}
.nav-item:hover::after { width: 100%; }

.header-actions { display: flex; align-items: center; gap: 15px; }

.language-switch { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }

.theme-btn {
    background: none; border: none; color: var(--text-primary);
    font-size: 1.2rem; padding: 10px; border-radius: 50%;
    background: rgba(255,255,255,0.05); cursor: pointer;
}

.mobile-menu-btn { display: none; background: none; border: none; color: var(--text-primary); font-size: 1.5rem; cursor: pointer; }

/* Mobile Menu */
.mobile-menu {
    position: fixed; top: 0; right: -100%; width: 300px; height: 100vh;
    background: var(--bg-card); backdrop-filter: blur(20px);
    z-index: 9999; padding: 40px 30px; transition: right 0.4s cubic-bezier(0.77, 0, 0.175, 1);
    border-left: 1px solid var(--border-color);
}
.mobile-menu.active { right: 0; }
.mobile-menu-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100vh;
    background: rgba(0,0,0,0.5); z-index: 9998; opacity: 0; visibility: hidden; transition: all 0.4s;
}
.mobile-menu-overlay.active { opacity: 1; visibility: visible; }
.close-menu-btn { position: absolute; top: 25px; left: 25px; background: none; border: none; color: var(--text-primary); font-size: 1.5rem; cursor: pointer;}
.mobile-nav-links { display: flex; flex-direction: column; gap: 20px; margin-top: 40px; }
.mobile-nav-item { font-size: 1.2rem; font-weight: 600; display: block; padding-bottom: 10px; border-bottom: 1px solid var(--border-color); }

html[dir="ltr"] .mobile-menu {
    right: auto; left: -100%; border-left: 0;
    border-right: 1px solid var(--border-color); transition-property: left;
}
html[dir="ltr"] .mobile-menu.active { left: 0; right: auto; }
html[dir="ltr"] .close-menu-btn { left: auto; right: 25px; }

/* =========================================
   Buttons
   ========================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 12px 28px; border-radius: 30px; font-weight: 600; font-size: 1rem;
    transition: all 0.3s ease; border: none; position: relative; overflow: hidden; cursor: pointer;
}
.btn-glow { background: var(--bg-main); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-glow:hover { border-color: var(--accent-1); box-shadow: var(--glow-shadow); }
.btn-primary { background: var(--gradient-brand); color: #fff; box-shadow: var(--glow-shadow); }
.btn-primary:hover { transform: translateY(-3px) scale(1.02); }

/* =========================================
   Hero Section
   ========================================= */
.hero { min-height: 100vh; display: flex; align-items: center; position: relative; padding-top: 120px; }
.glow-blob { position: absolute; border-radius: 50%; filter: blur(90px); z-index: -1; opacity: 0.5; animation: floatBlob 10s infinite alternate ease-in-out; }
.blob-1 { width: 400px; height: 400px; background: var(--accent-1); top: 10%; right: 10%; }
.blob-2 { width: 350px; height: 350px; background: var(--accent-2); bottom: 10%; left: 5%; animation-delay: -5s; }
@keyframes floatBlob { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(50px, 50px) scale(1.2); } }

.hero-content { display: flex; align-items: center; gap: 60px; }
.hero-text { flex: 1; }
.badge { display: inline-flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 20px; background: rgba(139, 92, 246, 0.1); border: 1px solid rgba(139, 92, 246, 0.3); color: var(--accent-2); font-size: 0.85rem; margin-bottom: 20px; }
.pulse-dot { width: 8px; height: 8px; background: #10b981; border-radius: 50%; box-shadow: 0 0 10px #10b981; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); } 70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); } }

.name { font-size: 48px; line-height: 1.2; margin-bottom: 10px; }
.role { font-size: 30px; margin-bottom: 25px; min-height: 60px; }
.cursor { color: var(--accent-1); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0; } }
.bio { font-size: 1.15rem; color: var(--text-secondary); margin-bottom: 40px; max-width: 550px; }
.highlight-bg { background: rgba(59, 130, 246, 0.15); padding: 0 8px; border-radius: 6px; color: var(--accent-1); font-weight: 600; }

.hero-buttons { display: flex; align-items: center; gap: 30px; }
.social-hero { display: flex; gap: 15px; flex-wrap: wrap; }
.social-icon { width: 45px; height: 45px; display: flex; align-items: center; justify-content: center; border-radius: 50%; border: 1px solid var(--border-color); font-size: 1.2rem; transition: all 0.3s; }
.social-icon:hover { background: var(--accent-1); color: #fff; border-color: var(--accent-1); transform: translateY(-3px);}

.hero-visual { flex: 1; position: relative; display: flex; justify-content: center;}
.image-wrapper { position: relative; width: 400px; height: 400px; }
.profile-img { width: 100%; height: 100%; object-fit: cover; border-radius: 40px; filter: grayscale(20%); box-shadow: var(--glow-shadow); }
.tech-float { position: absolute; width: 60px; height: 60px; background: var(--bg-card); backdrop-filter: blur(10px); border: 1px solid var(--border-color); border-radius: 16px; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--accent-1); box-shadow: var(--box-shadow); animation: float 4s ease-in-out infinite alternate; }
.float-1 { top: -20px; right: -20px; animation-delay: 0s; }
.float-2 { bottom: 40px; left: -30px; animation-delay: 1s; }
.float-3 { bottom: -20px; right: 40px; animation-delay: 2s; }
@keyframes float { 100% { transform: translateY(-20px); } }

/* =========================================
   Bento Box 
   ========================================= */
.bento-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.bento-box { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 30px; padding: 35px; position: relative; overflow: hidden; transition: transform 0.4s; }
.bento-box:hover { transform: translateY(-5px); border-color: rgba(255, 255, 255, 0.2); box-shadow: var(--glow-shadow); }
.bento-large { grid-column: span 2; grid-row: span 2; }
.bento-medium { grid-column: span 2; grid-row: span 1; }
.bento-small { grid-column: span 1; grid-row: span 1; }
.bento-icon-bg { position: absolute; top: -20px; left: -20px; font-size: 8rem; opacity: 0.05; color: var(--text-primary); }
.bento-box h3 { font-size: 1.5rem; margin-bottom: 15px; }
.tech-tags { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 15px; }
.tech-tags span { padding: 8px 16px; background: rgba(255,255,255,0.05); border: 1px solid var(--border-color); border-radius: 20px; font-size: 0.85rem; font-family: 'Poppins', sans-serif !important; }
.credential-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.credential-item { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--border-color); border-radius: 16px; }
.credential-item i { flex: 0 0 34px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--accent-1); background: rgba(59,130,246,0.12); }
.credential-item h4 { color: var(--text-primary); font-size: 0.92rem; line-height: 1.5; margin: 0; }
.credential-item p { color: var(--text-secondary); font-size: 0.78rem; line-height: 1.6; margin: 1px 0 0; }
.credential-primary { grid-column: 1 / -1; border-color: rgba(59,130,246,0.3); }
.stat-box { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.stat-number { font-size: 4rem; font-weight: 800; color: var(--accent-1); line-height: 1; }
.map-box { padding: 0; background: url('https://via.placeholder.com/600x300/1e293b/334155?text=Map') center/cover; }
.map-overlay { position: absolute; bottom: 0; width: 100%; padding: 20px; background: linear-gradient(to top, rgba(0,0,0,0.8), transparent); color: #fff; display: flex; align-items: center; gap: 15px; }

/* =========================================
   Services Section (NEW)
   ========================================= */
.services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; }
.service-card { padding: 40px 30px; text-align: right; transition: transform 0.4s, border-color 0.4s; }
.service-card:hover { transform: translateY(-10px); border-color: var(--accent-1); box-shadow: var(--glow-shadow); }
.service-icon { width: 70px; height: 70px; border-radius: 20px; background: rgba(59, 130, 246, 0.1); color: var(--accent-1); display: flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: 25px; border: 1px solid rgba(59, 130, 246, 0.2); }
.service-card h3 { font-size: 1.4rem; margin-bottom: 15px; }
.service-card p { color: var(--text-secondary); font-size: 0.95rem; }

/* =========================================
   Skills Section (NEW)
   ========================================= */
.skills-wrapper { display: grid; grid-template-columns: 1fr 1.5fr; gap: 60px; padding: 50px; }
.skills-title { font-size: 2.2rem; margin-bottom: 20px; }
.skills-bars { display: flex; flex-direction: column; gap: 25px; justify-content: center; }
.skill-item { width: 100%; }
.skill-info { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 1rem; }
.progress-bg { width: 100%; height: 8px; background: var(--border-color); border-radius: 10px; overflow: hidden; position: relative; }
.progress-bar { height: 100%; width: 0; background: var(--gradient-brand); border-radius: 10px; transition: width 1.5s cubic-bezier(0.1, 0.8, 0.2, 1); }

/* =========================================
   Timeline (Experience)
   ========================================= */
.timeline { position: relative; max-width: 800px; margin: 0 auto; padding-right: 30px; }
.timeline::before { content: ''; position: absolute; top: 0; right: 0; width: 2px; height: 100%; background: var(--border-color); }
.timeline-item { position: relative; margin-bottom: 50px; padding-right: 40px; }
.timeline-dot { position: absolute; right: -6px; top: 20px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent-1); box-shadow: 0 0 15px var(--accent-1); }
.timeline-content { padding: 30px; }
.timeline-date { color: var(--accent-2); font-size: 0.9rem; font-weight: 600; margin-bottom: 10px; display: block; }

/* =========================================
   Projects
   ========================================= */
.modern-projects-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 40px; }
.modern-project-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 24px; padding: 15px; transition: all 0.4s; }
.modern-project-card:hover { transform: translateY(-10px); box-shadow: var(--glow-shadow); border-color: var(--accent-1); }
.project-image-box { position: relative; width: 100%; height: 280px; border-radius: 16px; overflow: hidden; }
.project-image-box img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s; }
.modern-project-card:hover .project-image-box img { transform: scale(1.05); }
.project-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.4); opacity: 0; display: flex; align-items: center; justify-content: center; transition: opacity 0.3s; }
.modern-project-card:hover .project-overlay { opacity: 1; }
.round-btn { width: 60px; height: 60px; border-radius: 50%; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; transform: scale(0.5); transition: transform 0.4s; }
.modern-project-card:hover .round-btn { transform: scale(1); }
.project-details { padding: 25px 15px 10px; }
.project-name { font-size: 1.5rem; margin-bottom: 10px; }
.project-desc { color: var(--text-secondary); margin-bottom: 25px; }
.project-footer { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border-color); padding-top: 20px; flex-wrap: wrap;}
.tech-pill { padding: 5px 12px; background: rgba(255,255,255,0.05); border-radius: 20px; font-size: 0.8rem; border: 1px solid var(--border-color); font-family: 'Poppins', sans-serif !important;}
.github-link { margin-right: auto; display: flex; align-items: center; gap: 8px; font-weight: 600; direction: ltr;}
.project-detail-link { margin-right: auto; display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--accent-1); }
html[dir="ltr"] .project-detail-link { margin-right: 0; margin-left: auto; }
.project-price { width: 100%; color: var(--text-primary); font-weight: 700; margin-bottom: 5px; }
.project-category { color: var(--accent-1); font-size: 0.85rem; font-weight: 700; margin-bottom: 8px; }
.project-name a { color: inherit; }
.projects-empty { grid-column: 1 / -1; padding: 60px 30px; text-align: center; }
.projects-empty i { color: var(--accent-1); font-size: 3rem; margin-bottom: 20px; }
.projects-empty p { color: var(--text-secondary); margin-top: 10px; }
.projects-all-link { display: flex; justify-content: center; margin-top: 42px; }

/* =========================================
   Testimonials (NEW)
   ========================================= */
.testimonials-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 30px; }
.testimonial-card { padding: 40px; position: relative; }
.quote-icon { font-size: 3rem; color: var(--accent-1); opacity: 0.2; position: absolute; top: 30px; right: 30px; }
.testimonial-text { font-size: 1.1rem; font-style: italic; color: var(--text-primary); margin-bottom: 30px; position: relative; z-index: 1; }
.client-info { display: flex; align-items: center; gap: 15px; border-top: 1px solid var(--border-color); padding-top: 20px; }
.client-info img { width: 50px; height: 50px; border-radius: 50%; object-fit: cover; }
.client-info h4 { font-size: 1rem; margin-bottom: 3px; }

/* =========================================
   Footer & Contact Form
   ========================================= */
.modern-footer { border-top: 1px solid var(--border-color); position: relative; padding-bottom: 40px;}
.huge-text { font-size: 4rem; line-height: 1.1; margin-bottom: 20px; font-weight: 900;}
.footer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 80px; margin-bottom: 80px;}
.email-link { font-size: 2rem; font-weight: 700; color: var(--text-primary); display: inline-block; margin-top: 30px; border-bottom: 2px solid var(--accent-1); padding-bottom: 5px;}
.email-link:hover { color: var(--accent-1); }
.footer-form { padding: 40px; }
.input-container { position: relative; margin-bottom: 30px; }
.input-container input, .input-container textarea { width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--border-color); padding: 15px 0; color: var(--text-primary); font-size: 1rem; outline: none; transition: border-color 0.3s; }
.input-container label { position: absolute; right: 0; top: 15px; color: var(--text-secondary); pointer-events: none; transition: all 0.3s; }
html[dir="ltr"] .input-container label { right: auto; left: 0; }
.input-container input:focus, .input-container textarea:focus { border-bottom-color: var(--accent-1); }
.input-container input:focus ~ label, .input-container input:not(:placeholder-shown) ~ label,
.input-container textarea:focus ~ label, .input-container textarea:not(:placeholder-shown) ~ label { top: -10px; font-size: 0.8rem; color: var(--accent-1); }
.honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }
.phone-link { display: block; width: max-content; margin-top: 14px; color: var(--text-secondary); direction: ltr; }
.form-messages { margin-bottom: 24px; }
.form-message { padding: 12px 16px; border-radius: 12px; font-size: 0.9rem; }
.form-message-success { background: rgba(16, 185, 129, 0.14); border: 1px solid rgba(16, 185, 129, 0.35); color: #34d399; }
.form-message-error { background: rgba(239, 68, 68, 0.14); border: 1px solid rgba(239, 68, 68, 0.35); color: #f87171; }
.footer-form button:disabled { opacity: 0.75; cursor: wait; }
.captcha-panel { margin: 0 0 28px; padding: 18px; border: 1px solid var(--border-color); border-radius: 16px; background: rgba(15, 23, 42, 0.32); }
.captcha-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.captcha-heading strong, .captcha-heading span { display: block; }
.captcha-heading strong { color: var(--text-primary); font-size: .95rem; }
.captcha-heading span { margin-top: 3px; color: var(--text-secondary); font-size: .78rem; }
.captcha-refresh { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 8px 12px; border: 1px solid var(--border-color); border-radius: 10px; color: var(--text-primary); background: transparent; cursor: pointer; font: inherit; font-size: .82rem; }
.captcha-refresh:hover { border-color: var(--accent-1); color: var(--accent-1); }
.captcha-refresh.is-loading i { animation: captcha-spin .8s linear infinite; }
.captcha-field { display: grid; grid-template-columns: 180px minmax(0, 1fr); align-items: center; gap: 12px; direction: ltr; }
.captcha-field img.captcha { display: block; width: 180px; height: 60px; border-radius: 10px; border: 1px solid var(--border-color); }
.captcha-field input[name$="_1"] { box-sizing: border-box; width: 100%; min-width: 0; height: 52px; padding: 0 14px; border: 1px solid var(--border-color); border-radius: 10px; color: var(--text-primary); background: rgba(8, 9, 13, .55); font: inherit; direction: ltr; text-align: center; letter-spacing: .14em; outline: none; }
.captcha-field input[name$="_1"]:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(34, 211, 238, .12); }
.captcha-error, .captcha-error .errorlist { margin: 9px 0 0; color: #fb7185; font-size: .82rem; list-style: none; padding: 0; }
@keyframes captcha-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto !important; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
    .reveal { opacity: 1; transform: none; }
    .cursor-dot, .cursor-outline { display: none !important; }
}
.footer-bottom { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-color); padding-top: 30px; color: var(--text-secondary);}

/* =========================================
   Portfolio Detail
   ========================================= */
.project-page { padding-top: 70px; }
.project-detail-hero { padding-bottom: 45px; }
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 35px; }
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--accent-1); }
.breadcrumb i { font-size: 0.65rem; opacity: 0.55; }
.project-detail-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 45px; }
.project-detail-heading h1 { font-size: clamp(2.1rem, 5vw, 4.5rem); line-height: 1.25; margin: 10px 0 18px; }
.project-detail-heading p { max-width: 780px; color: var(--text-secondary); font-size: 1.08rem; line-height: 2; }
.project-detail-category { color: var(--accent-1); font-weight: 800; }
.project-showcase { max-width: 1120px; margin-inline: auto; }
.project-main-image { width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid var(--border-color); border-radius: 24px; background: var(--bg-card); box-shadow: var(--card-shadow); }
.project-main-image img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity 0.2s ease; }
.project-thumbnails { display: flex; gap: 14px; overflow-x: auto; padding: 18px 4px 6px; scrollbar-width: thin; }
.project-thumbnail { flex: 0 0 130px; height: 78px; padding: 3px; border: 2px solid transparent; border-radius: 12px; background: var(--bg-card); cursor: pointer; overflow: hidden; }
.project-thumbnail.active { border-color: var(--accent-1); }
.project-thumbnail img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.project-content-section { padding-top: 35px; }
.project-content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 35px; align-items: start; }
.project-story, .project-facts { padding: 38px; }
.project-story h2, .project-facts h2 { font-size: 1.5rem; margin-bottom: 24px; }
.project-story h2:not(:first-child) { margin-top: 42px; }
.project-rich-text { color: var(--text-secondary); line-height: 2.15; }
.project-rich-text p { margin-bottom: 16px; }
.project-features { display: grid; gap: 15px; }
.project-features li { display: flex; align-items: flex-start; gap: 12px; color: var(--text-secondary); }
.project-features i { color: #10b981; margin-top: 6px; }
.project-technologies { display: flex; flex-wrap: wrap; gap: 10px; }
.project-facts { position: sticky; top: 105px; }
.project-fact { display: flex; gap: 15px; padding: 18px 0; border-bottom: 1px solid var(--border-color); }
.project-fact > i { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px; color: var(--accent-1); background: rgba(79, 172, 254, 0.1); border-radius: 12px; }
.project-fact div { display: flex; flex-direction: column; gap: 5px; }
.project-fact span { color: var(--text-secondary); font-size: 0.82rem; }
.project-fact strong { line-height: 1.65; }
.project-source-link { margin-top: 24px; }
.project-cta { padding-top: 20px; }
.project-cta-card { padding: 35px 40px; display: flex; justify-content: space-between; align-items: center; gap: 30px; }
.project-cta-card p { color: var(--text-secondary); margin-top: 8px; }
.portfolio-index { padding-top: 70px; }
.portfolio-index-hero { padding-bottom: 35px; }
.portfolio-index-heading { max-width: 850px; }
.portfolio-index-heading h1 { font-size: clamp(2.2rem, 6vw, 4.5rem); margin: 12px 0 20px; }
.portfolio-index-heading p { color: var(--text-secondary); font-size: 1.08rem; line-height: 2; }
.portfolio-index-grid-section { padding-top: 35px; }

/* =========================================
   Reveal Animations
   ========================================= */
.reveal { opacity: 0; transform: translateY(50px); transition: all 0.8s cubic-bezier(0.5, 0, 0, 1); }
.reveal.active { opacity: 1; transform: translateY(0); }
.reveal-delay-1 { transition-delay: 0.2s; }
.reveal-delay-2 { transition-delay: 0.4s; }

/* =========================================
   Mobile Responsiveness & Strict Overflow Fix
   ========================================= */
@media (max-width: 1200px) {
    .bento-grid { grid-template-columns: repeat(3, 1fr); }
    .bento-large, .bento-medium { grid-column: span 2; }
    .bento-small { grid-column: span 1; }
    .edu-box { grid-column: span 3; }
}

@media (max-width: 992px) {
    .section { padding: 80px 0; }
    
    /* Strict Header Fix for Mobile */
    .header { width: calc(100% - 30px); padding: 5px 0; }
    .nav-container { padding: 0 15px; }
    .nav-links, .hidden-mobile { display: none; }
    .mobile-menu-btn { display: block; }
    
    .hero-content { flex-direction: column; text-align: center; gap: 40px; padding-top: 40px;}
    .hero-text { order: 2; }
    .hero-visual { order: 1; }
    .hero-buttons { justify-content: center; }
    .bio { margin: 0 auto 40px auto; }
    
    .bento-grid { grid-template-columns: repeat(2, 1fr); }
    .bento-large, .bento-medium, .edu-box { grid-column: span 2; }
    
    .skills-wrapper { grid-template-columns: 1fr; padding: 30px; }
    .footer-grid { flex-direction: column; grid-template-columns: 1fr; gap: 40px; }
    .huge-text, .name { font-size: 30px; }
    .role { font-size: 1.5rem; }
}

@media (max-width: 768px) {
    .section-title { font-size: 2.2rem; margin-bottom: 40px; }
    .image-wrapper { width: 300px; height: 300px; }
    
    .bento-grid, .services-grid, .modern-projects-grid, .testimonials-grid { grid-template-columns: 1fr; }
    .bento-large, .bento-medium, .bento-small, .edu-box { grid-column: span 1; }
    
    .timeline { padding-right: 20px; }
    .timeline-item { padding-right: 30px; }
    
    .footer-bottom { flex-direction: column; gap: 20px; text-align: center; }
    .email-link { font-size: 1.5rem; }
    .project-detail-heading { align-items: flex-start; flex-direction: column; }
    .project-content-grid { grid-template-columns: 1fr; }
    .project-facts { position: static; }
    .project-cta-card { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
    .hero-buttons { flex-direction: column; width: 100%; }
    .btn-large { width: 100%; justify-content: center; }
    .image-wrapper { width: 250px; height: 250px; }
    .tech-float { width: 45px; height: 45px; font-size: 1.2rem; }
    .huge-text { font-size: 2.2rem; }
    .footer-form { padding: 25px; }
    .captcha-heading { align-items: flex-start; flex-direction: column; }
    .captcha-field { grid-template-columns: 1fr; }
    .project-page { padding-top: 50px; }
    .project-detail-heading h1 { font-size: 2rem; }
    .project-main-image { border-radius: 16px; }
    .project-thumbnail { flex-basis: 92px; height: 62px; }
    .project-story, .project-facts { padding: 24px; }
    .project-cta-card { padding: 28px 24px; }
    .skill-info { flex-direction: column; gap: 5px; }
    .credential-list { grid-template-columns: 1fr; }
    .credential-primary { grid-column: auto; }
}

/* Error pages */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-card { width: min(620px, 100%); padding: 55px 35px; text-align: center; }
.error-code { font: 800 clamp(4rem, 16vw, 8rem)/1 'Poppins', sans-serif; margin-bottom: 20px; }
.error-card h1 { font-size: clamp(1.7rem, 5vw, 2.6rem); margin-bottom: 14px; }
.error-card p { color: var(--text-secondary); margin-bottom: 30px; }


/* ───────────────────────────────────────
   Section Subtitle
─────────────────────────────────────── */
.section-subtitle {
    text-align: center;
    font-size: 1.05rem;
    margin-top: -40px;
    margin-bottom: 50px;
    opacity: 0.75;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* ───────────────────────────────────────
   Bento Icon (نسخه معمولی، بدون پس‌زمینه)
─────────────────────────────────────── */
.bento-icon {
    font-size: 2.5rem;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    display: block;
}

/* Neural Network Box Styles */
.nn-box {
    display: flex;
    flex-direction: column;
    padding: 25px;
    background: linear-gradient(180deg, var(--bg-card) 0%, rgba(10, 10, 12, 0.95) 100%);
}

.nn-header {
    margin-bottom: 15px;
    z-index: 2;
}

.canvas-container {
    flex-grow: 1;
    width: 100%;
    min-height: 150px;
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    /* ایجاد یک پس‌زمینه محو برای عمق دادن به شبکه */
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.05) 0%, transparent 70%);
}

#neural-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

/*  */
/* =========================================
   Live Terminal Box
   ========================================= */
.terminal-box {
    background: #0a0a0c !important; /* پس‌زمینه کاملا تاریک شبیه ترمینال */
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.terminal-header {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.term-dots {
    display: flex;
    gap: 8px;
    margin-right: 15px;
}

.term-dots .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.dot.close { background-color: #ff5f56; }
.dot.min { background-color: #ffbd2e; }
.dot.max { background-color: #27c93f; }

.term-title {
    font-size: 0.8rem;
    color: #8b949e;
    font-family: monospace;
}

.terminal-body {
    padding: 20px;
    flex-grow: 1;
    overflow: hidden;
    font-family: 'Courier New', Courier, monospace !important;
    font-size: 0.85rem;
    line-height: 1.6;
    color: #c9d1d9;
    position: relative;
    /* ایجاد هاله تاریک در پایین ترمینال برای محو شدن متن */
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.term-line {
    margin-bottom: 4px;
    opacity: 0.9;
}

.term-line .keyword { color: #ff7b72; }
.term-line .value { color: #79c0ff; }
.term-line .success { color: #3fb950; }
.term-line .warning { color: #d2a8ff; }

.term-cursor {
    display: inline-block;
    width: 8px;
    height: 15px;
    background-color: #c9d1d9;
    vertical-align: middle;
    animation: term-blink 1s step-end infinite;
}

@keyframes term-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}


/*  */
/* =========================================
   Computer Vision Box Styles
   ========================================= */
.cv-box {
    background: #0d1117 !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.cv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.4);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 10;
}

.cv-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-dot {
    width: 8px;
    height: 8px;
    background-color: #ff5f56;
    border-radius: 50%;
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(255, 95, 86, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(255, 95, 86, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 95, 86, 0); }
}

.cv-viewport {
    position: relative;
    flex-grow: 1;
    min-height: 200px;
    background-color: #050505;
    overflow: hidden;
}

/* شبکه پس‌زمینه (Grid) */
.cv-grid {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        linear-gradient(rgba(59, 130, 246, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.1) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.5;
}

/* خط اسکنر */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: #00f2fe;
    box-shadow: 0 0 10px #00f2fe, 0 20px 20px rgba(0, 242, 254, 0.2);
    animation: scan 3s linear infinite;
    z-index: 5;
}

@keyframes scan {
    0% { top: -10%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 110%; opacity: 0; }
}

/* استایل مربع‌های تشخیص (Bounding Boxes) */
.bounding-box {
    position: absolute;
    border: 2px solid;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.05);
    transition: opacity 0.3s ease;
    z-index: 2;
    /* افکت ظاهر شدن ناگهانی */
    animation: pop-in 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.bb-label {
    position: absolute;
    top: -20px;
    left: -2px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.7rem;
    color: #000;
    font-weight: bold;
    white-space: nowrap;
}

@keyframes pop-in {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
/*  */
/* Vector Space Box */
.vector-box {
    background: #0f0f13 !important;
    padding: 0 !important;
    display: flex;
    flex-direction: column;
    position: relative;
}

.vector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: transparent;
    position: absolute;
    width: 100%;
    top: 0;
    z-index: 10;
}

#vector-container {
    flex-grow: 1;
    min-height: 220px;
    background: radial-gradient(circle at center, #1a1a24 0%, #0f0f13 100%);
    overflow: hidden;
}

#vector-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/*  */
/* =========================================
   Fixes & New Sections (Added by Assistant)
   ========================================= */

/* ثابت کردن ارتفاع ترمینال و افزودن اسکرول سفارشی */
.terminal-box {
    height: 350px !important; /* ارتفاع ثابت */
}
.terminal-body {
    overflow-y: auto;
    max-height: calc(100% - 45px); /* کم کردن ارتفاع هدر ترمینال */
}
/* شخصی‌سازی اسکرول‌بار ترمینال */
.terminal-body::-webkit-scrollbar {
    width: 6px;
}
.terminal-body::-webkit-scrollbar-track {
    background: transparent;
}
.terminal-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

/* اصلاحات تراز‌بندی خط زمانی (Timeline) در حالت RTL */
.timeline-item {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: right;
}
.timeline-content {
    width: 100%;
}

/* استایل‌های بخش جدید مقالات (Publications) */
.publications-list {
    display: flex;
    flex-direction: column;
    gap: 25px;
    max-width: 900px;
    margin: 0 auto;
}
.publication-card {
    display: flex;
    gap: 25px;
    padding: 35px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    backdrop-filter: blur(16px);
}
.publication-card:hover {
    transform: translateX(-15px); /* حرکت به سمت راست در حالت RTL */
    border-color: var(--accent-1);
    box-shadow: var(--glow-shadow);
}
.pub-icon {
    font-size: 3rem;
    color: var(--accent-1);
    opacity: 0.8;
    flex-shrink: 0;
}
.pub-content {
    flex-grow: 1;
}
.pub-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.pub-meta {
    font-size: 0.9rem;
    color: var(--accent-2);
    margin-bottom: 15px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}
.pub-meta span {
    background: rgba(139, 92, 246, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}
.pub-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
}

/* رسپانسیو برای مقالات */
@media (max-width: 768px) {
    .publication-card {
        flex-direction: column;
        gap: 15px;
        padding: 25px;
    }
    .publication-card:hover {
        transform: translateY(-10px);
    }
}

/* =========================================
   Light Theme Overrides for Live Models
   (اعمال رنگ‌های روشن برای مدل‌های زنده در تم لایت)
   ========================================= */

/* --- 1. Neural Network Box --- */
body:not([data-theme="dark"]) .nn-box {
    background: linear-gradient(180deg, #ffffff 0%, #f0f4f8 100%) !important;
}
body:not([data-theme="dark"]) .nn-box .canvas-container {
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.08) 0%, transparent 70%) !important;
}

/* --- 2. Live Terminal Box --- */
body:not([data-theme="dark"]) .terminal-box {
    background: #ffffff !important;
    border-color: var(--border-color) !important;
}
body:not([data-theme="dark"]) .terminal-header {
    background: #f8fafc !important;
    border-bottom: 1px solid var(--border-color) !important;
}
body:not([data-theme="dark"]) .terminal-body {
    color: #334155 !important; /* رنگ متن تیره برای خوانایی در تم روشن */
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%) !important;
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%) !important;
}
body:not([data-theme="dark"]) .term-cursor {
    background-color: #334155 !important;
}

/* --- 3. Computer Vision Box --- */
body:not([data-theme="dark"]) .cv-box {
    background: #ffffff !important;
}
body:not([data-theme="dark"]) .cv-header {
    background: #f8fafc !important;
    border-bottom: 1px solid var(--border-color) !important;
}
body:not([data-theme="dark"]) .cv-viewport {
    background-color: #f0f4f8 !important; /* پس‌زمینه روشن برای دوربین */
}
body:not([data-theme="dark"]) .cv-grid {
    /* تیره‌تر کردن خطوط شبکه برای دیده شدن روی پس‌زمینه سفید */
    background-image: 
        linear-gradient(rgba(59, 130, 246, 0.15) 1px, transparent 1px),
        linear-gradient(90deg, rgba(59, 130, 246, 0.15) 1px, transparent 1px) !important;
}
body:not([data-theme="dark"]) .bounding-box {
    background: rgba(59, 130, 246, 0.05) !important;
}

/* --- 4. Vector Space Box --- */
body:not([data-theme="dark"]) .vector-box {
    background: #ffffff !important;
}
body:not([data-theme="dark"]) #vector-container {
    background: radial-gradient(circle at center, #f8fafc 0%, #ffffff 100%) !important;
}
.term-timestamp {
  color: #8b949e;
}
