:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #4a90d9;
  --primary-bg: #e8f0fe;
  --secondary: #0d47a1;
  --accent: #00bcd4;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-light: #5f6368;
  --text-muted: #9aa0a6;
  --border: #e0e0e0;
  --shadow: 0 2px 12px rgba(26, 115, 232, 0.08);
  --shadow-lg: 0 8px 32px rgba(26, 115, 232, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --dot-color: rgba(26, 115, 232, 0.12);
  --contact-from: #1a73e8;
  --contact-to: #0d47a1;
  --navbar-bg: rgba(255,255,255,0.88);
  --hero-bg: #f0f7ff;
  --hero-bg-end: #dce8f5;
  --hero-glow: rgba(26,115,232,0.08);
  --hero-glow2: rgba(0,188,212,0.06);
  --mobile-nav-bg: rgba(255,255,255,0.98);
  --img-bg: #ffffff;
  --card-border: var(--card-border);
}

.dark-theme {
  --primary: #5b9cf6;
  --primary-dark: #4a8be5;
  --primary-light: #7bb3f8;
  --primary-bg: #1a2744;
  --secondary: #7bb3f8;
  --accent: #26c6da;
  --bg: #0f172a;
  --card-bg: #1e293b;
  --text: #e2e8f0;
  --text-light: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --dot-color: rgba(91, 156, 246, 0.12);
  --contact-from: #1e293b;
  --contact-to: #0f172a;
  --navbar-bg: rgba(15,23,42,0.9);
  --hero-bg: #0f172a;
  --hero-bg-end: #0d1b2a;
  --hero-glow: rgba(91,156,246,0.08);
  --hero-glow2: rgba(38,198,218,0.06);
  --mobile-nav-bg: rgba(15,23,42,0.98);
  --img-bg: #1e293b;
  --card-border: rgba(91,156,246,0.1);
}

[dir="rtl"] {
  --font: 'Vazirmatn', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

/* Animated Background Dots */
.bg-dots {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.bg-dots .dot {
  position: absolute;
  border-radius: 50%;
  background: var(--dot-color);
  animation: floatDot linear infinite;
}

@keyframes floatDot {
  0% { transform: translateY(100vh) scale(0); opacity: 0; }
  15% { opacity: 0.6; }
  85% { opacity: 0.6; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-light);
  font-size: 1rem;
  transition: var(--transition);
  margin-left: 8px;
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Navbar */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--navbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--card-border);
  transition: var(--transition);
}

.navbar.scrolled {
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.nav-brand span {
  color: var(--text);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-light);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  position: relative;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--primary);
  background: var(--primary-bg);
}

/* Language Switcher */
.lang-switcher {
  display: flex;
  gap: 2px;
  background: var(--bg);
  padding: 2px;
  border-radius: var(--radius-sm);
  margin-left: 12px;
}

.lang-btn {
  background: none;
  border: none;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.lang-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Hamburger */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.hamburger span {
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: var(--transition);
}

/* Hero */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 100px 24px 60px;
  background: linear-gradient(135deg, var(--hero-bg) 0%, var(--primary-bg) 50%, var(--hero-bg-end) 100%);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--hero-glow) 0%, transparent 70%);
  border-radius: 50%;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -10%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--hero-glow2) 0%, transparent 70%);
  border-radius: 50%;
}

.hero-content {
  text-align: center;
  position: relative;
  z-index: 1;
  max-width: 800px;
}

.hero-badge {
  display: inline-block;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 20px;
  letter-spacing: 0.5px;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 8px;
  color: var(--text);
}

.hero h1 span {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero .title {
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  color: var(--text-light);
  margin-bottom: 16px;
  font-weight: 400;
}

.hero .subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto 32px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px rgba(26,115,232,0.3);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(26,115,232,0.4);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
}

/* Stats Bar */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Sections */
.section {
  padding: 80px 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-tag {
  display: inline-block;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.section-title {
  font-size: clamp(1.8rem, 3vw, 2.3rem);
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
}

.section-desc {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 600px;
  margin: 0 auto;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: var(--transition);
  border: 1px solid var(--card-border);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.card-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  margin-bottom: 16px;
}

.card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.card p {
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.6;
}

/* Teaching Grid */
.teaching-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.teaching-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  border: 1px solid var(--card-border);
  transition: var(--transition);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.teaching-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.teaching-card .badge {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: var(--radius-sm);
}

.teaching-card h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.teaching-card .count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Projects */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}

.project-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  border: 1px solid var(--card-border);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: var(--transition);
}

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

.project-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.project-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  margin-bottom: 16px;
}

.project-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.project-card p {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.7;
}

/* Work Experience */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--primary-bg);
}

.timeline-item {
  position: relative;
  margin-bottom: 32px;
  padding-left: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -28px;
  top: 6px;
  width: 14px;
  height: 14px;
  background: var(--primary);
  border-radius: 50%;
  border: 3px solid var(--primary-bg);
}

.timeline-item h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.timeline-meta {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 8px;
}

.timeline-item p {
  font-size: 0.88rem;
  color: var(--text-light);
  line-height: 1.7;
}

/* Skills */
.skills-category {
  margin-bottom: 32px;
}

.skills-category h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.skills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-tag {
  background: var(--primary-bg);
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  transition: var(--transition);
  border: 1px solid transparent;
}

.skill-tag:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

/* Contact */
.contact-section {
  background: linear-gradient(135deg, var(--contact-from) 0%, var(--contact-to) 100%);
  color: #fff;
  padding: 80px 24px;
  text-align: center;
  transition: background 0.4s ease;
}

.contact-inner {
  max-width: 700px;
  margin: 0 auto;
}

.contact-section h2 {
  font-size: clamp(1.8rem, 3vw, 2.3rem);
  font-weight: 800;
  margin-bottom: 16px;
}

.contact-section p {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 32px;
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1rem;
}

.contact-item i {
  width: 20px;
  text-align: center;
  opacity: 0.8;
}

.contact-item a {
  color: #fff;
  text-decoration: none;
  opacity: 0.9;
  transition: var(--transition);
}

.contact-item a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Footer */
.footer {
  background: var(--text);
  color: rgba(255,255,255,0.6);
  text-align: center;
  padding: 24px;
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--mobile-nav-bg);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    border-bottom: 1px solid var(--border);
  }

  .nav-links.open { display: flex; }

  .hamburger { display: flex; }

  .lang-switcher { margin-left: auto; }

  .stats-bar { gap: 20px; flex-wrap: wrap; }

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

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

  .section { padding: 60px 16px; }
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* Org teaching list */
.org-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.org-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  border: 1px solid var(--card-border);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--text-light);
}

.org-item:hover {
  transform: translateX(4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-light);
}

.org-item .org-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 6px;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Network projects */
.network-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.network-item {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  border: 1px solid var(--card-border);
  font-size: 0.85rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: var(--transition);
}

.network-item:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
}

.network-item i {
  color: var(--primary);
  font-size: 0.8rem;
}

/* Cert Gallery */
.cert-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.cert-card {
  background: var(--card-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  border: 1px solid var(--card-border);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.cert-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.cert-card .img-wrap {
  width: 100%;
  aspect-ratio: 400 / 520;
  background: var(--img-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.cert-card .img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.3s ease;
  padding: 4px;
}

.cert-card:hover .img-wrap img {
  transform: scale(1.08);
}

.cert-card .cert-info {
  padding: 10px 12px 12px;
}

.cert-card .cert-info h4 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  margin: 0;
}

.cert-card .cert-info .cert-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.cert-none {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Cert Lightbox */
.cert-lightbox {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.92);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

.cert-lightbox.open {
  display: flex;
}

.cert-lightbox .nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: #fff;
  font-size: 2.2rem;
  cursor: pointer;
  background: rgba(255,255,255,0.08);
  border: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 10001;
  backdrop-filter: blur(4px);
}

.cert-lightbox .nav-btn:hover {
  background: rgba(255,255,255,0.18);
}

.cert-lightbox .nav-btn.prev { left: 20px; }
.cert-lightbox .nav-btn.next { right: 20px; }

.cert-lightbox .close-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  background: none;
  border: none;
  opacity: 0.7;
  transition: var(--transition);
  z-index: 10001;
  line-height: 1;
}

.cert-lightbox .close-btn:hover { opacity: 1; }

.cert-lightbox .lb-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 92%;
  max-height: 92%;
}

.cert-lightbox .lb-content img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain;
}

.cert-lightbox .lb-caption {
  color: rgba(255,255,255,0.8);
  font-size: 0.85rem;
  text-align: center;
}

.cert-lightbox .lb-counter {
  color: rgba(255,255,255,0.4);
  font-size: 0.75rem;
  margin-top: -4px;
}

@media (max-width: 1200px) {
  .cert-gallery { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}

@media (max-width: 900px) {
  .cert-gallery { grid-template-columns: repeat(2, 1fr); gap: 14px; }
}

@media (max-width: 500px) {
  .cert-gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cert-card .cert-info { padding: 8px 10px 10px; }
  .cert-card .cert-info h4 { font-size: 0.72rem; }
  .cert-lightbox .nav-btn { width: 36px; height: 36px; font-size: 1.2rem; }
  .cert-lightbox .nav-btn.prev { left: 6px; }
  .cert-lightbox .nav-btn.next { right: 6px; }
}
