/* =========================================================
   RESET & BASE
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* =========================================================
   CSS VARIABLES — DARK (default)
   ========================================================= */
:root {
  --mx: 50vw;
  --my: 40vh;
  --bg:      #030712;
  --bg2:     #0d1117;
  --bg3:     #161b22;
  --card:    #0d1117;
  --card2:   #161b22;
  --border:  rgba(99,102,241,.15);
  --border2: rgba(99,102,241,.35);
  --text:    #e2e8f0;
  --text2:   #94a3b8;
  --text3:   #64748b;
  --primary: #6366f1;
  --primary2:#818cf8;
  --accent:  #06b6d4;
  --green:   #10b981;
  --shadow:  0 25px 50px rgba(0,0,0,.5);
  --glow:    0 0 40px rgba(99,102,241,.2);
  --radius:  1rem;
  --nav-h:   70px;
  --font-en: 'Space Grotesk', sans-serif;
  --font-fa: 'Vazirmatn', 'Space Grotesk', sans-serif;
  --font-code: 'Fira Code', monospace;
}

/* =========================================================
   LIGHT THEME
   ========================================================= */
[data-theme="light"] {
  --bg:      #f0f4f8;
  --bg2:     #e8edf5;
  --bg3:     #dde4ef;
  --card:    #ffffff;
  --card2:   #f8fafc;
  --border:  rgba(99,102,241,.12);
  --border2: rgba(99,102,241,.3);
  --text:    #0f172a;
  --text2:   #334155;
  --text3:   #64748b;
  --shadow:  0 25px 50px rgba(0,0,0,.1);
  --glow:    0 0 40px rgba(99,102,241,.12);
}
[data-theme="light"] #particleCanvas { opacity: .35; }
[data-theme="light"] .pre-bg { background: rgba(240,244,248,.8); }
[data-theme="light"] .pre-terminal { background:#fff; border-color: var(--border); }
[data-theme="light"] .term-body { background: #1e1e2e; }

/* =========================================================
   THEME ICON TOGGLE
   ========================================================= */
.icon-sun { display: none; }
[data-theme="light"] .icon-sun  { display: block; }
[data-theme="light"] .icon-moon { display: none;  }

/* =========================================================
   RTL (PERSIAN)
   ========================================================= */
[dir="rtl"] body { font-family: var(--font-fa); }
[dir="rtl"] .nav-links { flex-direction: row-reverse; }
[dir="rtl"] .hero-left { text-align: right; }
[dir="rtl"] .hero-actions { flex-direction: row-reverse; }
[dir="rtl"] .hero-socials { flex-direction: row-reverse; }
[dir="rtl"] .hero-badge { flex-direction: row-reverse; }
[dir="rtl"] .section-title::after { margin: .5rem auto 0; }
[dir="rtl"] .info-grid { direction: rtl; }
[dir="rtl"] .tc-list li { padding-left: 0; padding-right: 1.4rem; }
[dir="rtl"] .tc-list li::before { left: auto; right: 0; }
[dir="rtl"] .tc-header { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .timeline-item[data-side="left"]  .timeline-card { margin-right: auto; margin-left: 0; }
[dir="rtl"] .timeline-item[data-side="right"] .timeline-card { margin-left: auto; margin-right: 0; }
[dir="rtl"] .contact-grid { direction: rtl; }
[dir="rtl"] .contact-item { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .footer-inner { direction: rtl; }
[dir="rtl"] .btn { flex-direction: row-reverse; }
[dir="rtl"] .btn svg { transform: rotate(180deg); }
[dir="rtl"] .proj-top { flex-direction: row-reverse; }
/* Prevent BiDi overflow in Persian paragraphs */
[dir="rtl"] .about-text p { unicode-bidi: plaintext; }
[dir="rtl"] .project-desc { unicode-bidi: plaintext; }
[dir="rtl"] .contact-intro { unicode-bidi: plaintext; }
[dir="rtl"] .tc-list li { unicode-bidi: plaintext; }

/* =========================================================
   BASE
   ========================================================= */
html { scroll-behavior: smooth; }

body {
  font-family: var(--font-en);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background .3s, color .3s;
}

.cyber-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}
.cyber-grid {
  position: absolute;
  inset: -20%;
  background:
    linear-gradient(rgba(6, 182, 212, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99, 102, 241, .08) 1px, transparent 1px);
  background-size: 34px 34px;
  transform: perspective(600px) rotateX(58deg);
  transform-origin: center top;
  animation: cyberGridDrift 18s linear infinite;
  opacity: .55;
}
.cyber-scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(148, 163, 184, 0.05) 0,
    rgba(148, 163, 184, 0.05) 1px,
    transparent 2px,
    transparent 4px
  );
  mix-blend-mode: soft-light;
  opacity: .35;
}
.cyber-glow {
  position: absolute;
  width: 46vw;
  height: 46vw;
  filter: blur(55px);
  border-radius: 50%;
  animation: cyberPulse 10s ease-in-out infinite;
}
.cyber-glow-1 {
  top: -12vw;
  left: -8vw;
  background: radial-gradient(circle, rgba(99,102,241,.28), rgba(99,102,241,0));
}
.cyber-glow-2 {
  right: -10vw;
  bottom: -16vw;
  background: radial-gradient(circle, rgba(6,182,212,.22), rgba(6,182,212,0));
  animation-delay: 2.4s;
}
.cyber-spotlight {
  position: absolute;
  inset: 0;
  background: radial-gradient(480px circle at var(--mx) var(--my), rgba(16,185,129,.11), transparent 65%);
  transition: background-position .08s;
}

@keyframes cyberGridDrift {
  from { transform: perspective(600px) rotateX(58deg) translateY(0); }
  to { transform: perspective(600px) rotateX(58deg) translateY(34px); }
}
@keyframes cyberPulse {
  0%, 100% { opacity: .7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.08); }
}

::selection { background: var(--primary); color: #fff; }

a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }
svg { display: inline-block; vertical-align: middle; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 2rem; }

/* =========================================================
   CUSTOM CURSOR
   ========================================================= */
.cursor {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  position: fixed; top: 0; left: 0;
  pointer-events: none; z-index: 9999;
  transform: translate(-50%,-50%);
  transition: transform .1s;
}
.cursor-follower {
  width: 32px; height: 32px;
  border: 1.5px solid var(--primary);
  border-radius: 50%;
  position: fixed; top: 0; left: 0;
  pointer-events: none; z-index: 9998;
  transform: translate(-50%,-50%);
  transition: transform .12s ease, opacity .2s;
  opacity: .6;
}
@media (hover: none) { .cursor, .cursor-follower { display: none; } }

/* =========================================================
   PARTICLE CANVAS
   ========================================================= */
#particleCanvas {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: .6;
}

/* =========================================================
   PRELOADER
   ========================================================= */
#preloader {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
}
#matrixCanvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
}
.pre-bg {
  position: absolute; inset: 0;
  background: rgba(3,7,18,.72);
  z-index: 1;
}
.pre-content { position: relative; z-index: 2; width: min(620px, 90vw); }

.pre-terminal {
  background: rgba(13,17,23,.92);
  border: 1px solid rgba(99,102,241,.45);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(99,102,241,.25), 0 0 80px rgba(6,182,212,.1), var(--shadow);
  margin-bottom: 1.5rem;
}
.term-header {
  background: #161b22;
  padding: .65rem 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red    { background: #ff5f57; }
.dot.yellow { background: #ffbd2e; }
.dot.green  { background: #28c840; }
.term-title { font-family: var(--font-code); font-size: .8rem; color: var(--text2); margin-left: .5rem; }
.term-body { padding: 1.4rem 1.6rem; min-height: 220px; }
.term-line {
  font-family: var(--font-code);
  font-size: .85rem;
  color: #c9d1d9;
  margin-bottom: .55rem;
  display: flex; gap: .7rem; align-items: flex-start;
}
.term-line.hidden { display: none; }
.term-line.output { color: var(--green); padding-left: 1.4rem; }
.prompt { color: var(--primary); -webkit-user-select: none; user-select: none; }
.cmd { color: #c9d1d9; }
.cursor-blink::after { content: '█'; animation: blink .7s step-end infinite; color: var(--primary); }
@keyframes blink { 50% { opacity: 0; } }

.pre-progress-wrap { display: flex; align-items: center; gap: 1rem; }
.pre-progress-bar { flex: 1; height: 4px; background: var(--bg3); border-radius: 4px; overflow: hidden; }
.pre-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 4px; transition: width .1s linear; }
.pre-percent { font-family: var(--font-code); font-size: .85rem; color: var(--text2); min-width: 3ch; }

/* =========================================================
   APP WRAPPER
   ========================================================= */
#app { position: relative; z-index: 1; }
#app.hidden { display: none; }

/* =========================================================
   NAVBAR
   ========================================================= */
#navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 800;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2.5rem;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background .3s, border-color .3s;
}
#navbar.scrolled {
  background: rgba(3,7,18,.85);
  border-bottom-color: var(--border);
}
[data-theme="light"] #navbar.scrolled {
  background: rgba(240,244,248,.88);
}

.nav-logo {
  font-family: var(--font-code);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .03em;
}
.logo-bracket { color: var(--primary); }

.nav-links {
  display: flex; gap: 2rem; list-style: none;
}
.nav-link {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text2);
  transition: color .2s;
  position: relative;
}
.nav-link::after {
  content: '';
  position: absolute; bottom: -4px; left: 0; right: 0;
  height: 2px;
  background: var(--primary);
  transform: scaleX(0);
  transition: transform .2s;
  border-radius: 2px;
}
.nav-link:hover, .nav-link.active { color: var(--text); }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }

.nav-controls { display: flex; align-items: center; gap: .6rem; }

.ctrl-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  transition: border-color .2s, color .2s, background .2s, transform .15s;
}
.ctrl-btn svg { width: 16px; height: 16px; stroke: currentColor; }
.ctrl-btn:hover { border-color: var(--primary); color: var(--primary); transform: scale(1.05); }

.lang-btn {
  font-family: var(--font-fa);
  font-size: .95rem;
  font-weight: 600;
  min-width: 44px;
  color: var(--text);
}

.nav-cta {
  padding: .5rem 1.25rem;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  transition: opacity .2s, transform .15s;
}
.nav-cta:hover { opacity: .9; transform: scale(1.03); }

.hamburger {
  display: none; flex-direction: column; gap: 5px; cursor: pointer; padding: 4px;
}
.hamburger span { width: 24px; height: 2px; background: var(--text); border-radius: 2px; transition: .3s; }

/* =========================================================
   SECTIONS
   ========================================================= */
.section { padding: 7rem 0; position: relative; }

.section-header { text-align: center; margin-bottom: 4rem; }

.section-tag {
  display: block;
  font-family: var(--font-code);
  font-size: .875rem;
  color: var(--primary);
  margin-bottom: .75rem;
  letter-spacing: .05em;
}

.section-title {
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  position: relative;
}
.section-title::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(6,182,212,.22) 47%, transparent 58%);
  transform: translateX(-140%);
  animation: titleSweep 5.5s ease-in-out infinite;
  pointer-events: none;
}
.section-title::after {
  content: '';
  display: block;
  width: 60px; height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 4px;
  margin: .6rem auto 0;
}
@keyframes titleSweep {
  0%, 70%, 100% { transform: translateX(-140%); opacity: 0; }
  75% { opacity: 1; }
  88% { transform: translateX(120%); opacity: .9; }
}
.section-sub {
  text-align: center;
  color: var(--text2);
  margin-top: .75rem;
  margin-bottom: 3rem;
  font-size: 1.05rem;
  line-height: 1.7;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .75rem 1.75rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  border: none;
  transition: transform .2s, opacity .2s, box-shadow .2s;
  text-decoration: none;
}
.btn:hover { transform: translateY(-2px); }
.btn svg { width: 16px; height: 16px; transition: transform .2s; }
.btn:hover svg { transform: translateX(3px); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 4px 20px rgba(99,102,241,.35);
}
.btn-primary:hover { box-shadow: 0 6px 30px rgba(99,102,241,.5); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { background: var(--card); border-color: var(--primary); }

.btn-full { width: 100%; justify-content: center; }
.mt-2 { margin-top: 2rem; }

/* gradient text */
.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* =========================================================
   HERO
   ========================================================= */
.hero-section {
  min-height: 100vh;
  display: flex; align-items: center;
  padding-top: var(--nav-h);
}
.hero-grid {
  max-width: 1200px; margin: 0 auto; padding: 0 2rem;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 4rem; align-items: center;
  width: 100%;
}

.hero-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .4rem 1rem;
  background: rgba(99,102,241,.1);
  border: 1px solid var(--border2);
  border-radius: 100px;
  font-family: var(--font-code);
  font-size: .82rem;
  color: var(--primary2);
  margin-bottom: 1.5rem;
}
.badge-dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
}
.badge-dot.pulse { animation: badgePulse 2s ease infinite; }
@keyframes badgePulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,.4); }
  50%      { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

.hero-title { font-size: clamp(2.4rem, 4.5vw, 4rem); font-weight: 800; line-height: 1.0; }
.hero-title .line1 { display: block; color: var(--text); }
.hero-title .line2 { display: block; color: var(--text); }
.hero-title .line3 { display: block; font-size: clamp(1.2rem, 2.5vw, 1.75rem); font-weight: 600; margin-top: .4rem; }

.glitch-text {
  position: relative;
  display: inline-block;
  text-shadow: 0 0 16px rgba(99,102,241,.16);
}
.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
}
.glitch-text::before {
  color: #06b6d4;
  text-shadow: -1px 0 rgba(6,182,212,.7);
  animation: glitchShiftA 4.2s steps(2, end) infinite;
}
.glitch-text::after {
  color: #10b981;
  text-shadow: 1px 0 rgba(16,185,129,.75);
  animation: glitchShiftB 4.2s steps(2, end) infinite;
}

@keyframes glitchShiftA {
  0%, 88%, 100% { opacity: 0; transform: translate3d(0,0,0); clip-path: inset(0 0 0 0); }
  89% { opacity: .9; transform: translate3d(-1px,0,0); clip-path: inset(62% 0 10% 0); }
  90% { opacity: .7; transform: translate3d(1px,0,0); clip-path: inset(16% 0 64% 0); }
  91% { opacity: .9; transform: translate3d(-2px,0,0); clip-path: inset(44% 0 24% 0); }
  92% { opacity: 0; transform: translate3d(0,0,0); clip-path: inset(0 0 0 0); }
}

@keyframes glitchShiftB {
  0%, 88%, 100% { opacity: 0; transform: translate3d(0,0,0); clip-path: inset(0 0 0 0); }
  89% { opacity: .75; transform: translate3d(1px,0,0); clip-path: inset(18% 0 62% 0); }
  90% { opacity: .95; transform: translate3d(-1px,0,0); clip-path: inset(52% 0 20% 0); }
  91% { opacity: .65; transform: translate3d(2px,0,0); clip-path: inset(30% 0 46% 0); }
  92% { opacity: 0; transform: translate3d(0,0,0); clip-path: inset(0 0 0 0); }
}

.hero-sub {
  font-family: var(--font-code);
  font-size: 1rem;
  color: var(--text2);
  margin: 1.25rem 0 2rem;
  min-height: 1.5em;
}

.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 2rem; }

.hero-socials { display: flex; gap: .75rem; }
.social-icon {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text2);
  background: var(--card);
  transition: border-color .2s, color .2s, transform .2s;
}
.social-icon svg { width: 18px; height: 18px; }
.social-icon:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-3px); }

/* Photo */
.hero-right { display: flex; justify-content: center; }
.photo-container { position: relative; width: 380px; height: 380px; }

.photo-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid var(--border);
  animation: ringRotate 20s linear infinite;
  top: 50%; left: 50%; transform: translate(-50%,-50%);
}
.ring1 { width: 320px; height: 320px; border-color: rgba(99,102,241,.25); }
.ring2 { width: 360px; height: 360px; border-color: rgba(6,182,212,.15); animation-direction: reverse; animation-duration: 30s; }
.ring3 { width: 395px; height: 395px; border-color: rgba(99,102,241,.08); animation-duration: 15s; }
@keyframes ringRotate { to { transform: translate(-50%,-50%) rotate(360deg); } }

.photo-hex {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 260px; height: 260px;
  border-radius: 38% 62% 63% 37% / 41% 44% 56% 59%;
  overflow: hidden;
  border: 3px solid var(--primary);
  box-shadow: var(--glow);
  animation: morphBlob 8s ease-in-out infinite;
}
@keyframes morphBlob {
  0%,100% { border-radius: 38% 62% 63% 37% / 41% 44% 56% 59%; }
  33%      { border-radius: 65% 35% 49% 51% / 57% 37% 63% 43%; }
  66%      { border-radius: 42% 58% 71% 29% / 62% 51% 49% 38%; }
}
.hero-photo { width: 100%; height: 100%; object-fit: cover; }

.floating-badge {
  position: absolute;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .5rem .9rem;
  display: flex; align-items: center; gap: .5rem;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  animation: floatBadge 3.5s ease-in-out infinite;
  white-space: nowrap;
}
.fb1 { bottom: 10px; left: -20px; animation-delay: 0s; }
.fb2 { top: 15px; right: -20px; animation-delay: 1.2s; }
.fb3 { top: 50%; right: -30px; transform: translateY(-50%); animation-delay: 2.4s; }
@keyframes floatBadge {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.fb3 { animation: floatBadgeMid 3.5s ease-in-out 2.4s infinite; }
@keyframes floatBadgeMid {
  0%,100% { transform: translateY(-50%); }
  50%      { transform: translateY(calc(-50% - 8px)); }
}
.fb-icon { font-size: 1.25rem; }
.fb-icon {
  font-family: var(--font-code);
  font-size: .75rem;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid rgba(6,182,212,.35);
  border-radius: 6px;
  min-width: 30px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 .35rem;
}
.fb-num { font-weight: 700; color: var(--text); font-size: .95rem; display: block; line-height: 1.1; }
.fb-txt { font-size: .72rem; color: var(--text2); display: block; }

.scroll-indicator {
  position: absolute; bottom: 2.5rem; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  color: var(--text3); font-size: .8rem;
  animation: floatBadge 2.5s ease-in-out infinite;
}
.scroll-mouse {
  width: 22px; height: 36px;
  border: 2px solid var(--text3);
  border-radius: 12px;
  display: flex; justify-content: center; padding-top: 6px;
}
.scroll-wheel {
  width: 4px; height: 8px;
  background: var(--primary);
  border-radius: 4px;
  animation: scrollWheel 1.5s ease-in-out infinite;
}
@keyframes scrollWheel { 0%,100% { transform: translateY(0); opacity:1; } 100% { transform: translateY(10px); opacity:0; } }

/* =========================================================
   ABOUT
   ========================================================= */
.about-section { background: var(--bg2); }
.about-grid {
  display: grid; grid-template-columns: 1.4fr 1fr;
  gap: 4rem; align-items: start;
}
.about-text p {
  color: var(--text2); margin-bottom: 1.25rem; line-height: 1.8;
}
.about-text p strong { color: var(--text); }

.info-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: .75rem; margin: 1.75rem 0;
}
.info-item { display: flex; flex-direction: column; gap: .15rem; }
.info-item-wide { grid-column: 1 / -1; }
.info-label {
  font-family: var(--font-code);
  font-size: .75rem;
  color: var(--primary);
  text-transform: uppercase; letter-spacing: .05em;
}
.info-value { font-size: .9rem; color: var(--text2); }
.info-value a { color: var(--accent); }
.info-value a:hover { text-decoration: underline; }

.about-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.25rem;
  text-align: center;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.stat-card:hover { border-color: var(--primary); transform: translateY(-4px); box-shadow: var(--glow); }
.stat-num {
  font-size: 2.5rem; font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-label { font-size: .8rem; color: var(--text2); margin-top: .25rem; }

/* =========================================================
   SKILLS
   ========================================================= */
.skills-section { background: var(--bg); }
.skills-tabs {
  display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center;
  margin-bottom: 2.5rem;
}
.skill-tab {
  padding: .6rem 1.4rem;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text2);
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: .2s;
  font-family: var(--font-en);
}
[dir="rtl"] .skill-tab { font-family: var(--font-fa); }
.skill-tab.active, .skill-tab:hover {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent; color: #fff;
}
.skills-panels { position: relative; }
.skills-panel { display: none; }
.skills-panel.active { display: block; }

.skill-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.skill-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  transition: .25s;
}
.skill-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--glow); }
.skill-card-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1rem; font-weight: 700;
}
.skill-card-icon img { width: 28px; height: 28px; object-fit: contain; }
.asp-icon {
  background: linear-gradient(135deg,var(--primary),var(--accent));
  color: #fff;
  font-family: var(--font-code);
  font-size: .8rem;
  font-weight: 700;
}
.asp-sm { font-size: .7rem; }
.asp-xs { font-size: .65rem; }
.asp-xxs { font-size: .6rem; }
.asp-astro { background: linear-gradient(135deg,#ff5d01,#ff9a3c); }
.skill-card-info { flex: 1; }
.skill-card-info h4 { font-size: .88rem; font-weight: 600; margin-bottom: .4rem; color: var(--text); }
.skill-bar-wrap { background: var(--bg3); height: 4px; border-radius: 4px; overflow: hidden; }
.skill-bar { height: 100%; width: 0%; border-radius: 4px; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width 1.2s ease; }
.skill-pct { font-size: .75rem; color: var(--text3); margin-top: .25rem; display: block; }

.tech-orbit-wrap { margin-top: 3.5rem; text-align: center; }
.orbit-title { font-size: 1.1rem; font-weight: 600; color: var(--text2); margin-bottom: 1.5rem; }
.tech-tags { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; }
.tech-tag {
  padding: .35rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: var(--font-code);
  font-size: .78rem;
  color: var(--text2);
  transition: .2s;
}
.tech-tag:hover { border-color: var(--primary); color: var(--primary); }

/* =========================================================
   EXPERIENCE
   ========================================================= */
.exp-section { background: var(--bg2); }
.timeline { position: relative; }
.timeline::before {
  content: '';
  position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; background: var(--border);
  transform: translateX(-50%);
}
.timeline-item { position: relative; display: flex; margin-bottom: 3rem; }
.timeline-item[data-side="left"]  { justify-content: flex-end; padding-right: calc(50% + 2rem); }
.timeline-item[data-side="right"] { justify-content: flex-start; padding-left: calc(50% + 2rem); }
.timeline-dot {
  position: absolute; top: 1.5rem; left: 50%;
  width: 14px; height: 14px;
  background: var(--primary);
  border-radius: 50%;
  transform: translateX(-50%);
  border: 2px solid var(--bg2);
  box-shadow: 0 0 0 4px rgba(99,102,241,.25);
}
.timeline-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 460px; width: 100%;
  transition: .25s;
}
.timeline-card:hover { border-color: var(--primary); box-shadow: var(--glow); }
.tc-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; gap: 1rem; }
.tc-role { font-size: 1rem; font-weight: 700; color: var(--text); }
.tc-company { font-size: .85rem; color: var(--primary); margin-top: .2rem; }
.tc-date {
  font-family: var(--font-code);
  font-size: .78rem; color: var(--text3);
  background: var(--bg3); padding: .3rem .7rem; border-radius: 6px;
  white-space: nowrap;
}
.tc-list { list-style: none; margin-bottom: 1rem; }
.tc-list li {
  font-size: .88rem; color: var(--text2);
  padding: .3rem 0 .3rem 1.4rem;
  position: relative;
}
.tc-list li::before { content: '▸'; position: absolute; left: 0; color: var(--primary); }
.tc-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.tc-tags span {
  font-family: var(--font-code); font-size: .72rem;
  padding: .2rem .6rem;
  background: var(--bg3); border-radius: 4px;
  color: var(--accent);
  border: 1px solid var(--border);
}

/* =========================================================
   PROJECTS
   ========================================================= */
.projects-section { background: var(--bg); }
.projects-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1.5rem;
}
.project-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: .3s;
}
.project-card:hover { border-color: var(--primary); transform: translateY(-6px); box-shadow: var(--glow); }
.project-card.featured { grid-column: span 1; }
@media (min-width: 900px) {
  .project-card.featured { grid-column: span 1; }
  .projects-grid { grid-template-columns: 1fr 1fr 1fr; }
}

.project-glow {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(ellipse at top left, rgba(99,102,241,.12), transparent 70%);
  transition: opacity .3s;
  pointer-events: none;
}
.project-card:hover .project-glow { opacity: 1; }

/* Mockup bar */
.proj-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1rem;
}
.proj-mockup {
  display: flex; align-items: center; gap: .5rem;
  background: var(--bg3); border-radius: 6px;
  padding: .3rem .7rem;
}
.proj-mockup.sm { flex: 1; margin-right: .75rem; }
.mockup-dots { display: flex; gap: 4px; }
.mockup-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.mockup-dots span:nth-child(1) { background: #ff5f57; }
.mockup-dots span:nth-child(2) { background: #ffbd2e; }
.mockup-dots span:nth-child(3) { background: #28c840; }
.mockup-domain {
  font-family: var(--font-code); font-size: .72rem;
  color: var(--accent); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.project-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .75rem;
}
.project-icon { font-size: 1.75rem; }
.project-icon-badge {
  font-family: var(--font-code);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--primary2);
  min-width: 46px;
  height: 28px;
  padding: 0 .45rem;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: linear-gradient(135deg, rgba(99,102,241,.18), rgba(6,182,212,.14));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}
.plink {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .8rem; font-weight: 600;
  color: var(--accent);
  border: 1px solid rgba(6,182,212,.25);
  padding: .35rem .8rem; border-radius: 6px;
  transition: .2s;
}
.sm-plink { padding: .3rem .5rem; }
.sm-plink svg { width: 14px; height: 14px; }
.plink svg { width: 13px; height: 13px; }
.plink:hover { background: rgba(6,182,212,.1); border-color: var(--accent); }

.project-title { font-size: 1rem; font-weight: 700; margin-bottom: .6rem; color: var(--text); line-height: 1.3; }
.project-desc { font-size: .85rem; color: var(--text2); line-height: 1.7; margin-bottom: 1rem; }
.project-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.project-tags span {
  font-family: var(--font-code); font-size: .72rem;
  padding: .2rem .6rem;
  background: var(--bg3); border-radius: 4px;
  color: var(--primary2); border: 1px solid var(--border);
}

/* =========================================================
   CONTACT
   ========================================================= */
.contact-section { background: var(--bg2); }
.contact-grid {
  display: grid; grid-template-columns: 1fr 1.4fr;
  gap: 4rem; align-items: start;
}
.contact-intro { color: var(--text2); margin-bottom: 2rem; line-height: 1.8; font-size: 1.05rem; }
.contact-intro strong { color: var(--text); }
.contact-items { display: flex; flex-direction: column; gap: 1rem; }
.contact-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px;
  transition: .2s; cursor: default;
}
a.contact-item { cursor: pointer; }
.contact-item:hover { border-color: var(--primary); transform: translateX(4px); }
[dir="rtl"] .contact-item:hover { transform: translateX(-4px); }
.ci-icon {
  width: 42px; height: 42px; border-radius: 8px;
  background: rgba(99,102,241,.1);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ci-icon svg { width: 18px; height: 18px; stroke: var(--primary); }
.ci-label { display: block; font-size: .75rem; color: var(--text3); }
.ci-value { display: block; font-size: .9rem; color: var(--text); font-weight: 500; }
.ci-meta { display: flex; align-items: center; gap: .65rem; }
.copy-email-btn {
  border: 1px solid var(--border);
  background: rgba(99,102,241,.08);
  color: var(--text2);
  padding: .28rem .55rem;
  border-radius: 8px;
  font-size: .74rem;
  line-height: 1;
  cursor: pointer;
  transition: .2s;
}
.copy-email-btn:hover { color: var(--text); border-color: var(--primary); }
.copy-email-btn.copied {
  color: #ecfdf5;
  border-color: #10b981;
  background: rgba(16,185,129,.24);
}

.contact-form { display: flex; flex-direction: column; gap: 1.25rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-group { position: relative; }
.form-group input, .form-group textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .875rem 1rem;
  color: var(--text);
  font-family: inherit; font-size: .95rem;
  outline: none;
  transition: border-color .2s;
  resize: none;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group input::placeholder, .form-group textarea::placeholder { color: var(--text3); }

/* =========================================================
   FOOTER
   ========================================================= */
.footer {
  background: var(--bg3);
  border-top: 1px solid var(--border);
  padding: 2.5rem 0;
}
.footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 2rem;
  display: flex; flex-direction: column; align-items: center; gap: .6rem;
  text-align: center;
}
.footer-logo {
  font-family: var(--font-code); font-size: 1.4rem; font-weight: 700; color: var(--text);
  margin-bottom: .5rem;
}
.footer-copy { font-size: .875rem; color: var(--text2); }
.footer-copy.small { font-size: .8rem; color: var(--text3); }

.back-to-top {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(13,17,23,.85);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 0 rgba(6,182,212,0);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .25s;
  z-index: 750;
}
.back-to-top svg { width: 18px; height: 18px; }
.back-to-top.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.back-to-top:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 18px rgba(6,182,212,.22);
}

.copy-toast {
  position: fixed;
  left: 50%;
  bottom: 1.3rem;
  transform: translate(-50%, 12px);
  padding: .55rem .9rem;
  border-radius: 999px;
  border: 1px solid rgba(16,185,129,.45);
  background: rgba(6,10,18,.92);
  color: #ecfdf5;
  font-size: .82rem;
  letter-spacing: .02em;
  opacity: 0;
  pointer-events: none;
  transition: .25s;
  z-index: 950;
}
.copy-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* =========================================================
   SCROLL REVEAL
   ========================================================= */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity .7s ease, transform .7s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* ── 1200px ── */
@media (max-width: 1200px) {
  .hero-grid { gap: 2.5rem; }
  .about-grid { gap: 3rem; }
  .contact-grid { gap: 3rem; }
}

/* ── 1024px ── */
@media (max-width: 1024px) {
  .projects-grid { grid-template-columns: 1fr 1fr; gap: 1.25rem; }
  .project-card.featured { grid-column: span 2; }
  .nav-links { gap: 1.25rem; }
}

/* ── 900px ── */
@media (max-width: 900px) {
  /* Hero */
  .hero-section { padding-bottom: 3rem; }
  .hero-grid { grid-template-columns: 1fr; text-align: center; gap: 2rem; padding: 0 1.5rem; }
  .hero-right { display: none; }
  .hero-badge { justify-content: center; }
  .hero-actions { justify-content: center; }
  .hero-socials { justify-content: center; }
  [dir="rtl"] .hero-left { text-align: center; }
  [dir="rtl"] .hero-badge  { flex-direction: row; justify-content: center; }
  [dir="rtl"] .hero-actions { flex-direction: row; justify-content: center; }
  [dir="rtl"] .hero-socials { flex-direction: row; justify-content: center; }

  /* About */
  .about-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .info-grid { grid-template-columns: 1fr 1fr; }

  /* Contact */
  .contact-grid { grid-template-columns: 1fr; gap: 2rem; }

  /* Timeline */
  .timeline::before { left: 20px; transform: none; }
  .timeline-item[data-side="left"],
  .timeline-item[data-side="right"] { justify-content: flex-start; padding-left: 52px; padding-right: 0; }
  .timeline-dot { left: 20px; transform: none; }
  .timeline-card { max-width: 100%; }
  [dir="rtl"] .timeline::before { left: auto; right: 20px; }
  [dir="rtl"] .timeline-item[data-side="left"],
  [dir="rtl"] .timeline-item[data-side="right"] { justify-content: flex-start; padding-right: 52px; padding-left: 0; }
  [dir="rtl"] .timeline-dot { left: auto; right: 20px; }
  [dir="rtl"] .timeline-item[data-side="left"]  .timeline-card,
  [dir="rtl"] .timeline-item[data-side="right"] .timeline-card { margin: 0; }
}

/* ── 768px ── */
@media (max-width: 768px) {
  /* Navbar */
  #navbar { padding: 0 1.25rem; }
  .nav-links {
    display: none;
    position: fixed;
    top: var(--nav-h); left: 0; right: 0;
    background: var(--bg2);
    flex-direction: column;
    padding: 1.5rem 2rem;
    gap: 1.25rem;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(0,0,0,.25);
    z-index: 799;
  }
  .nav-links.open { display: flex; }
  [dir="rtl"] .nav-links { direction: rtl; text-align: right; }
  .hamburger { display: flex; }
  .nav-cta { display: none; }

  /* Hero */
  .hero-actions { flex-direction: column; align-items: center; }
  [dir="rtl"] .hero-actions { flex-direction: column; align-items: center; }
  .hero-actions .btn { width: 100%; max-width: 300px; justify-content: center; }

  /* Projects */
  .projects-grid { grid-template-columns: 1fr; }
  .project-card.featured { grid-column: span 1; }
  .proj-top { flex-wrap: wrap; gap: .5rem; }

  /* Form */
  .form-row { grid-template-columns: 1fr; }
  .ci-meta { flex-wrap: wrap; }
  .copy-email-btn { padding: .35rem .6rem; }

  /* Stats */
  .about-stats { grid-template-columns: 1fr 1fr; gap: 1rem; }

  /* Skills tabs – horizontal scroll */
  .skills-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: .5rem;
  }
  .skills-tabs::-webkit-scrollbar { display: none; }
  .skill-tab { white-space: nowrap; flex-shrink: 0; }

  /* Timeline header */
  .tc-header { flex-direction: column; gap: .5rem; align-items: flex-start; }
  [dir="rtl"] .tc-header { align-items: flex-end; }

  .back-to-top {
    right: 1rem;
    bottom: 1rem;
    width: 40px;
    height: 40px;
  }
}

/* ── 480px ── */
@media (max-width: 480px) {
  :root { --nav-h: 60px; }
  .section { padding: 4rem 0; }
  .container { padding: 0 1rem; }
  .section-header { margin-bottom: 2.5rem; }

  /* Navbar */
  #navbar { padding: 0 1rem; }
  .nav-logo { font-size: 1.05rem; }
  .ctrl-btn { width: 34px; height: 34px; }
  .nav-controls { gap: .35rem; }

  /* Hero */
  .hero-grid { padding: 0 1rem; }
  .hero-title { font-size: 1.9rem; line-height: 1.1; }
  .hero-title .line3 { font-size: 1.05rem; }
  .hero-badge { font-size: .72rem; padding: .35rem .85rem; }
  .hero-sub { font-size: .875rem; }
  .scroll-indicator { display: none; }

  /* About */
  .info-grid { grid-template-columns: 1fr; gap: .6rem; }
  .about-stats { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .stat-card { padding: 1.25rem 1rem; }
  .stat-num { font-size: 2rem; }

  /* Skills */
  .skill-cards-grid { grid-template-columns: 1fr; }

  /* Timeline */
  .timeline-card { padding: 1rem 1.1rem; }
  .tc-role { font-size: .9rem; }
  .tc-list li { font-size: .83rem; }

  /* Projects */
  .project-title { font-size: .95rem; }
  .proj-mockup.sm { max-width: 130px; }
  .mockup-domain { font-size: .65rem; }

  /* Contact */
  .contact-intro { font-size: .95rem; }
  .form-group input, .form-group textarea { font-size: .9rem; }

  /* Footer */
  .footer { padding: 2rem 0; }
  .footer-copy { font-size: .8rem; }
  .footer-copy.small { font-size: .72rem; }
}

/* ── 380px ── */
@media (max-width: 380px) {
  .hero-title { font-size: 1.65rem; }
  .about-stats { grid-template-columns: 1fr; }
  .stat-card { padding: 1rem; }
  .hero-actions .btn { font-size: .875rem; padding: .65rem 1.1rem; }
  .skill-tab { font-size: .82rem; padding: .5rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .glitch-text::before,
  .glitch-text::after { animation: none; opacity: 0; }
}
