/* ==========================================================
   Babak Keshavarz — Portfolio
   ========================================================== */
   * { margin: 0; padding: 0; box-sizing: border-box; }

   :root {
       --primary: #00d4ff;
       --secondary: #7c3aed;
       --accent: #10b981;
       --darker: #050714;
       --light: #f8fafc;
       --gradient: linear-gradient(135deg, #00d4ff, #7c3aed, #10b981);
       --code-bg: rgba(0, 212, 255, 0.1);
   }
   
   body {
       font-family: 'JetBrains Mono', 'Vazirmatn', monospace;
       background: var(--darker);
       color: var(--light);
       overflow-x: hidden;
       line-height: 1.6;
   }
   
   html[dir="rtl"] body { font-family: 'Vazirmatn', 'JetBrains Mono', monospace; }
   
   /* ========== RTL ========== */
   html[dir="rtl"] .nav-links a::before { content: ""; }
   html[dir="rtl"] .nav-links a:hover::before { content: "← "; }
   html[dir="rtl"] .timeline { padding-left: 0; padding-right: 3rem; }
   html[dir="rtl"] .timeline:before { left: auto; right: 0; }
   html[dir="rtl"] .timeline-item { padding-left: 0; padding-right: 2rem; }
   html[dir="rtl"] .timeline-item:before { left: auto; right: -3.5rem; }
   html[dir="rtl"] .timeline-item ul li { padding-left: 0; padding-right: 1.5rem; }
   html[dir="rtl"] .timeline-item ul li:before { left: auto; right: 0; content: "←"; }
   html[dir="rtl"] .expertise-card ul li { padding-left: 0; padding-right: 1.5rem; }
   html[dir="rtl"] .expertise-card ul li:before { left: auto; right: 0; content: "◂"; }
   html[dir="rtl"] .section-title:before { content: "// "; }
   
   /* ========== NAV ========== */
   nav {
       position: fixed; top: 0; width: 100%; padding: 1.5rem 5%;
       background: rgba(10, 14, 39, 0.95); backdrop-filter: blur(10px);
       border-bottom: 1px solid rgba(0, 212, 255, 0.2); z-index: 1000;
       animation: slideDown 0.5s ease;
   }
   @keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
   nav .container { max-width: 1400px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
   .logo { font-size: 1.4rem; font-weight: 700; color: var(--primary); font-family: monospace; }
   .logo:before { content: "$ "; color: var(--accent); }
   .nav-links { display: flex; gap: 2rem; list-style: none; align-items: center; flex-wrap: wrap; }
   .nav-links a { color: var(--light); text-decoration: none; font-weight: 500; font-size: 0.9rem; transition: all 0.3s; }
   .nav-links a:hover { color: var(--primary); }
   .nav-links a::before { content: "> "; opacity: 0; transition: opacity 0.3s; }
   .nav-links a:hover::before { opacity: 1; }
   .lang-btn {
       background: rgba(0, 212, 255, 0.1); border: 1px solid var(--primary);
       color: var(--primary); padding: 0.4rem 0.8rem; border-radius: 5px;
       cursor: pointer; font-family: inherit; font-weight: 700; transition: all 0.3s;
       font-size: 0.85rem;
   }
   .lang-btn:hover { background: var(--primary); color: var(--darker); }
   
   /* ========== HERO ========== */
   .hero { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; padding: 6rem 5% 0; }
   .matrix-bg {
       position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0.03;
       background-image: repeating-linear-gradient(0deg, transparent, transparent 2px, var(--primary) 2px, var(--primary) 4px),
                         repeating-linear-gradient(90deg, transparent, transparent 2px, var(--primary) 2px, var(--primary) 4px);
       animation: matrixScroll 20s linear infinite;
   }
   @keyframes matrixScroll { 0% { transform: translateY(0); } 100% { transform: translateY(50px); } }
   .hero-content { max-width: 1200px; z-index: 1; animation: fadeInUp 1s ease; }
   @keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
   .terminal-prompt { font-size: 1rem; color: var(--accent); margin-bottom: 1rem; font-family: monospace; }
   .hero h1 { font-size: clamp(2rem, 5vw, 4rem); margin-bottom: 1.5rem; font-weight: 800; line-height: 1.2; }
   .gradient-text { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
   .hero .tagline { font-size: clamp(1rem, 2vw, 1.3rem); margin-bottom: 2rem; opacity: 0.9; color: var(--primary); }
   .hero p { font-size: 1.1rem; margin-bottom: 3rem; opacity: 0.8; max-width: 700px; }
   .tech-stack { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 3rem; }
   .tech-badge { padding: 0.5rem 1rem; background: var(--code-bg); border: 1px solid var(--primary); border-radius: 5px; font-size: 0.9rem; color: var(--primary); transition: all 0.3s; }
   .tech-badge:hover { transform: translateY(-3px); box-shadow: 0 5px 20px rgba(0, 212, 255, 0.3); }
   .cta-buttons { display: flex; gap: 1.5rem; flex-wrap: wrap; }
   .cta-buttons--centered { justify-content: center; margin-top: 3rem; }
   .btn { padding: 1rem 2rem; font-size: 1rem; font-weight: 600; border: none; border-radius: 5px; cursor: pointer; transition: all 0.3s; text-decoration: none; display: inline-block; font-family: inherit; }
   .btn-primary { background: var(--primary); color: var(--darker); box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3); }
   .btn-primary:hover { transform: translateY(-3px); box-shadow: 0 15px 40px rgba(0, 212, 255, 0.5); }
   .btn-secondary { background: transparent; color: var(--light); border: 2px solid var(--primary); }
   .btn-secondary:hover { background: rgba(0, 212, 255, 0.1); transform: translateY(-3px); }
   
   /* ========== SECTIONS ========== */
   .expertise, .experience, .contact { padding: 8rem 5%; max-width: 1400px; margin: 0 auto; }
   .services { padding: 8rem 5%; background: rgba(0, 212, 255, 0.02); }
   .section-title { font-size: clamp(2rem, 4vw, 3rem); margin-bottom: 1rem; font-weight: 800; text-align: center; }
   .section-title:before { content: "// "; color: var(--accent); }
   .section-subtitle { text-align: center; font-size: 1.1rem; opacity: 0.7; margin-bottom: 4rem; }
   .expertise-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 2rem; }
   .expertise-card { background: linear-gradient(135deg, rgba(0, 212, 255, 0.05), rgba(124, 58, 237, 0.05)); padding: 2.5rem; border-radius: 10px; border: 1px solid rgba(0, 212, 255, 0.2); transition: all 0.3s; position: relative; overflow: hidden; }
   .expertise-card:before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 3px; background: var(--gradient); transform: scaleX(0); transition: transform 0.3s; }
   .expertise-card:hover:before { transform: scaleX(1); }
   .expertise-card:hover { transform: translateY(-10px); border-color: var(--primary); box-shadow: 0 20px 50px rgba(0, 212, 255, 0.2); }
   .expertise-icon { font-size: 3rem; margin-bottom: 1.5rem; display: block; }
   .expertise-card h3 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--primary); }
   .expertise-card ul { list-style: none; opacity: 0.8; }
   .expertise-card ul li { padding: 0.5rem 0; position: relative; padding-left: 1.5rem; }
   .expertise-card ul li:before { content: "▸"; position: absolute; left: 0; color: var(--accent); }
   
   .services-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 2rem; max-width: 1400px; margin: 0 auto; }
   .service-card { background: rgba(10, 14, 39, 0.6); padding: 2.5rem; border-radius: 10px; border: 1px solid rgba(0, 212, 255, 0.2); transition: all 0.3s; text-align: center; }
   .service-card:hover { transform: translateY(-10px); border-color: var(--accent); }
   .service-icon { font-size: 3.5rem; margin-bottom: 1.5rem; display: block; }
   .service-card h3 { font-size: 1.4rem; margin-bottom: 1rem; color: var(--primary); }
   .service-card p { opacity: 0.8; line-height: 1.8; }
   
   .timeline { position: relative; padding-left: 3rem; }
   .timeline:before { content: ''; position: absolute; left: 0; top: 0; height: 100%; width: 2px; background: var(--gradient); }
   .timeline-item { position: relative; margin-bottom: 3rem; padding-left: 2rem; }
   .timeline-item:before { content: ''; position: absolute; left: -3.5rem; top: 0; width: 15px; height: 15px; border-radius: 50%; background: var(--primary); border: 3px solid var(--darker); box-shadow: 0 0 20px var(--primary); }
   .timeline-item h3 { color: var(--primary); font-size: 1.5rem; margin-bottom: 0.5rem; }
   .timeline-item .role { color: var(--accent); font-size: 1.1rem; margin-bottom: 0.5rem; }
   .timeline-item .period { opacity: 0.6; font-size: 0.9rem; margin-bottom: 1rem; }
   .timeline-item ul { list-style: none; opacity: 0.8; }
   .timeline-item ul li { padding: 0.3rem 0; padding-left: 1.5rem; position: relative; }
   .timeline-item ul li:before { content: "→"; position: absolute; left: 0; color: var(--accent); }
   
   .contact { text-align: center; }
   .contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 2rem; max-width: 1000px; margin: 3rem auto; }
   .contact-card { background: rgba(10, 14, 39, 0.6); padding: 2rem; border-radius: 10px; border: 1px solid rgba(0, 212, 255, 0.2); transition: all 0.3s; }
   .contact-card:hover { border-color: var(--primary); transform: translateY(-5px); }
   .contact-card h3 { color: var(--primary); margin-bottom: 1rem; font-size: 1.2rem; }
   .contact-card a { color: var(--light); text-decoration: none; opacity: 0.8; transition: all 0.3s; }
   .contact-card a:hover { opacity: 1; color: var(--primary); }
   
   .code-block { background: rgba(0, 212, 255, 0.05); border: 1px solid var(--primary); border-radius: 5px; padding: 1.5rem; margin: 2rem auto; font-family: 'JetBrains Mono', monospace; overflow-x: auto; max-width: 800px; text-align: left; }
   .code-line { color: var(--light); opacity: 0.9; }
   .code-comment { color: var(--accent); opacity: 0.7; }
   
   footer { padding: 3rem 5%; text-align: center; border-top: 1px solid rgba(0, 212, 255, 0.2); }
   footer p { opacity: 0.6; font-size: 0.9rem; }
   .footer-note { margin-top: 1rem; opacity: 0.4; }
   
   .particle { position: absolute; background: var(--primary); border-radius: 50%; opacity: 0.1; animation: float 6s ease-in-out infinite; }
   @keyframes float { 0%, 100% { transform: translateY(0) translateX(0); } 50% { transform: translateY(-20px) translateX(10px); } }
   
   /* ========== REVEAL ========== */
   .reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.6s ease, transform 0.6s ease; }
   .reveal.in { opacity: 1; transform: none; }
   @media (prefers-reduced-motion: reduce) {
       .reveal, .reveal.in { opacity: 1; transform: none; transition: none; }
   }
   
   @media (max-width: 768px) {
       .nav-links { gap: 0.8rem; font-size: 0.75rem; justify-content: center; }
       .tech-stack { justify-content: center; }
       .timeline { padding-left: 2rem; }
       html[dir="rtl"] .timeline { padding-right: 2rem; padding-left: 0; }
       .timeline-item { padding-left: 1rem; }
       html[dir="rtl"] .timeline-item { padding-right: 1rem; padding-left: 0; }
       .timeline-item:before { left: -2.5rem; }
       html[dir="rtl"] .timeline-item:before { right: -2.5rem; left: auto; }
   }
   
   /* ==========================================================
      BUILDING — پروژه‌هایی که می‌سازم
      ========================================================== */
   .build {
       position: relative;
       display: flex;
       flex-direction: column;
       text-align: start;
       padding: 1.4rem 1.5rem 1.4rem;
   }
   .build:hover { transform: translateY(-10px); border-color: var(--accent); }
   
   .build__head {
       display: flex;
       align-items: center;
       gap: .6rem;
       margin-bottom: .7rem;
   }
   .build__ic {
       font-size: 1.7rem;
       line-height: 1;
       display: grid;
       place-items: center;
       width: 40px;
       height: 40px;
       border-radius: 10px;
       background: rgba(0, 212, 255, 0.08);
       border: 1px solid rgba(0, 212, 255, 0.25);
       flex: 0 0 auto;
   }
   .build__status {
       font-family: 'JetBrains Mono', monospace;
       font-size: .7rem;
       padding: .2rem .6rem;
       border-radius: 999px;
       border: 1px solid currentColor;
       opacity: .9;
       margin-inline-start: auto;
       direction: ltr;
   }
   .build__status--active  { color: var(--accent); }
   .build__status--planning{ color: #ffa657; }
   .build__status--paused  { color: #71829a; }
   .build__status--done    { color: var(--primary); }
   
   .build__year {
       font-family: 'JetBrains Mono', monospace;
       font-size: .74rem;
       color: #71829a;
       direction: ltr;
       margin-bottom: .4rem;
   }
   .build h3 {
       font-size: 1.05rem;
       color: var(--light);
       margin-bottom: .4rem;
       text-align: start;
   }
   .build p {
       font-size: .88rem;
       opacity: .8;
       margin-bottom: .9rem;
       line-height: 1.7;
       text-align: start;
   }
   .build__tags {
       display: flex;
       flex-wrap: wrap;
       gap: .35rem;
       list-style: none;
       margin-top: auto;
       padding-top: .3rem;
   }
   .build__tags li {
       font-family: 'JetBrains Mono', monospace;
       font-size: .7rem;
       color: var(--primary);
       background: rgba(0, 212, 255, 0.08);
       border: 1px solid rgba(0, 212, 255, 0.25);
       padding: .18rem .5rem;
       border-radius: 4px;
       direction: ltr;
   }
   
   /* Light mode */
   html[data-theme="light"] .build {
       background: #ffffff;
       border-color: rgba(3, 105, 161, 0.15);
       box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
   }
   html[data-theme="light"] .build:hover {
       border-color: var(--primary);
       box-shadow: 0 20px 50px rgba(3, 105, 161, 0.12);
   }
   html[data-theme="light"] .build h3 { color: #0a0e27; }
   html[data-theme="light"] .build p  { color: #4a5568; opacity: 1; }
   html[data-theme="light"] .build__ic {
       background: rgba(3, 105, 161, 0.08);
       border-color: rgba(3, 105, 161, 0.25);
   }
   html[data-theme="light"] .build__year { color: #4a5568; }
   html[data-theme="light"] .build__tags li {
       background: rgba(3, 105, 161, 0.08);
       border-color: rgba(3, 105, 161, 0.25);
   }
   
   /* ==========================================================
      THEME — Light Mode
      ========================================================== */
   html[data-theme="light"] {
       --darker: #eef2f7;
       --primary: #0369a1;
       --secondary: #6d28d9;
       --accent: #047857;
       --light: #0a0e27;
       --gradient: linear-gradient(135deg, #0369a1, #6d28d9, #047857);
       --code-bg: rgba(3, 105, 161, 0.08);
   }
   
   html[data-theme="light"] body {
       background: #eef2f7;
       color: #1a2534;
   }
   
   /* NAV */
   html[data-theme="light"] nav {
       background: rgba(238, 242, 247, 0.96) !important;
       border-bottom: 1px solid rgba(3, 105, 161, 0.15);
   }
   html[data-theme="light"] .nav-links a { color: #1a2534; }
   html[data-theme="light"] .nav-links a:hover { color: var(--primary); }
   html[data-theme="light"] .logo { color: var(--primary); }
   
   /* HERO */
   html[data-theme="light"] .matrix-bg { opacity: 0.04; }
   html[data-theme="light"] .hero h1 { color: #0a0e27; }
   html[data-theme="light"] .hero p { color: #374151; }
   html[data-theme="light"] .tagline { color: var(--primary); opacity: 1; }
   html[data-theme="light"] .terminal-prompt { color: var(--accent); }
   
   /* TECH BADGES */
   html[data-theme="light"] .tech-badge {
       background: rgba(3, 105, 161, 0.08);
       border-color: rgba(3, 105, 161, 0.35);
       color: var(--primary);
   }
   html[data-theme="light"] .tech-badge:hover {
       box-shadow: 0 5px 20px rgba(3, 105, 161, 0.2);
   }
   
   /* BUTTONS */
   html[data-theme="light"] .btn-primary {
       background: var(--primary);
       color: #fff;
       box-shadow: 0 10px 30px rgba(3, 105, 161, 0.25);
   }
   html[data-theme="light"] .btn-primary:hover {
       box-shadow: 0 15px 40px rgba(3, 105, 161, 0.35);
   }
   html[data-theme="light"] .btn-secondary {
       background: transparent;
       color: #0a0e27;
       border-color: var(--primary);
   }
   html[data-theme="light"] .btn-secondary:hover {
       background: rgba(3, 105, 161, 0.08);
   }
   
   /* SECTION TITLES */
   html[data-theme="light"] .section-title,
   html[data-theme="light"] .section-subtitle { color: #0a0e27; }
   html[data-theme="light"] .section-subtitle { opacity: 0.65; }
   
   /* CARDS */
   html[data-theme="light"] .expertise-card,
   html[data-theme="light"] .service-card,
   html[data-theme="light"] .contact-card {
       background: #ffffff;
       border-color: rgba(3, 105, 161, 0.15);
       box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
   }
   html[data-theme="light"] .expertise-card:hover,
   html[data-theme="light"] .service-card:hover,
   html[data-theme="light"] .contact-card:hover {
       border-color: var(--primary);
       box-shadow: 0 20px 50px rgba(3, 105, 161, 0.12);
   }
   html[data-theme="light"] .expertise-card h3,
   html[data-theme="light"] .service-card h3,
   html[data-theme="light"] .contact-card h3 { color: var(--primary); }
   html[data-theme="light"] .expertise-card ul,
   html[data-theme="light"] .service-card p { color: #374151; }
   
   /* TIMELINE */
   html[data-theme="light"] .timeline-item h3 { color: var(--primary); }
   html[data-theme="light"] .timeline-item .role { color: var(--accent); }
   html[data-theme="light"] .timeline-item ul { color: #374151; }
   html[data-theme="light"] .timeline-item:before {
       background: var(--primary);
       border-color: #eef2f7;
       box-shadow: 0 0 20px rgba(3, 105, 161, 0.35);
   }
   
   /* CODE BLOCK */
   html[data-theme="light"] .code-block {
       background: #ffffff;
       border-color: rgba(3, 105, 161, 0.2);
   }
   html[data-theme="light"] .code-line { color: #1a2534; }
   
   /* CONTACT CARDS */
   html[data-theme="light"] .contact-card a { color: #1a2534; }
   html[data-theme="light"] .contact-card a:hover { color: var(--primary); }
   
   /* FOOTER */
   html[data-theme="light"] footer {
       border-top-color: rgba(3, 105, 161, 0.15);
   }
   html[data-theme="light"] footer p { color: #4a5568; opacity: 0.75; }
   
   /* PARTICLES */
   html[data-theme="light"] .particle {
       background: var(--primary);
       opacity: 0.08;
   }
   
   /* ICON BUTTON */
   .icon-btn {
       background: rgba(0, 212, 255, 0.1);
       border: 1px solid rgba(0, 212, 255, 0.3);
       color: var(--primary);
       width: 36px;
       height: 36px;
       border-radius: 5px;
       cursor: pointer;
       font-size: 1rem;
       display: inline-flex;
       align-items: center;
       justify-content: center;
       transition: all 0.3s;
       padding: 0;
       line-height: 1;
   }
   .icon-btn:hover {
       background: var(--primary);
       color: #fff;
       transform: scale(1.08);
   }
   html[data-theme="light"] .icon-btn {
       background: rgba(3, 105, 161, 0.08);
       border-color: rgba(3, 105, 161, 0.3);
       color: var(--primary);
   }
   html[data-theme="light"] .icon-btn:hover {
       background: var(--primary);
       color: #fff;
   }

   /* ==========================================================
   STACK / TOPOLOGY — زیرساختی که می‌سازم
   ========================================================== */
.topo {
    padding: clamp(1rem, 2.6vw, 1.6rem);
    overflow: hidden;
    border-radius: 12px;
    border: 1px solid rgba(0, 212, 255, 0.18);
    background: rgba(10, 14, 39, 0.4);
    margin-top: 1rem;
}
.topo svg {
    width: 100%;
    height: auto;
    display: block;
    direction: ltr;
}
.topo .nd {
    fill: rgba(10, 14, 39, 0.6);
    stroke: rgba(0, 212, 255, 0.3);
    stroke-width: 1.5;
}
.topo .lb {
    fill: #71829a;
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
}
.topo .lb--hi {
    fill: #f8fafc;
}
.topo .wire {
    stroke: rgba(0, 212, 255, 0.18);
    stroke-width: 1.4;
    fill: none;
}
.topo .flow {
    stroke-width: 1.6;
    fill: none;
    stroke-dasharray: 5 9;
    animation: topo-dash 1.6s linear infinite;
}
@keyframes topo-dash {
    to { stroke-dashoffset: -28; }
}
.topo .ico {
    stroke: #10b981;
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (prefers-reduced-motion: reduce) {
    .topo .flow { animation: none; }
}

/* Light theme */
html[data-theme="light"] .topo {
    background: #ffffff;
    border-color: rgba(3, 105, 161, 0.15);
}
html[data-theme="light"] .topo .nd {
    fill: #f7f9fc;
    stroke: rgba(3, 105, 161, 0.25);
}
html[data-theme="light"] .topo .lb {
    fill: #4a5568;
}
html[data-theme="light"] .topo .lb--hi {
    fill: #0a0e27;
}
html[data-theme="light"] .topo .wire {
    stroke: rgba(3, 105, 161, 0.2);
}