@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #0a0d12;
  --bg-2: #0f141c;
  --surface: rgba(255, 255, 255, .035);
  --surface-2: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .09);
  --line-2: rgba(255, 255, 255, .18);
  --text: #e9edf5;
  --muted: #9aa5b8;
  --accent: #5eead4;
  --accent-2: #60a5fa;
  --accent-3: #c084fc;
  --on-accent: #04211d;
  --glow: rgba(94, 234, 212, .16);
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, .8);
  --radius: 18px;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --sans: "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-2: #ffffff;
  --surface: rgba(255, 255, 255, .8);
  --surface-2: #ffffff;
  --line: rgba(13, 25, 48, .1);
  --line-2: rgba(13, 25, 48, .22);
  --text: #0c1322;
  --muted: #556077;
  --accent: #0f8f80;
  --accent-2: #2563eb;
  --accent-3: #7c3aed;
  --on-accent: #ffffff;
  --glow: rgba(15, 143, 128, .12);
  --shadow: 0 24px 50px -32px rgba(13, 25, 48, .35);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 88px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.85;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html[lang="en"] body { line-height: 1.65; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
svg { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
::selection { background: var(--accent); color: var(--on-accent); }

.skip { position: absolute; inset-inline-start: 16px; top: -60px; z-index: 50; padding: 8px 14px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 600; }
.skip:focus { top: 12px; }

/* ---------- backdrop ---------- */
.bg { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60vw 50vh at 85% -10%, rgba(96, 165, 250, .16), transparent 60%),
    radial-gradient(50vw 50vh at 5% 10%, var(--glow), transparent 60%),
    radial-gradient(50vw 40vh at 50% 110%, rgba(192, 132, 252, .1), transparent 60%);
}
.bg::after { content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
  opacity: .55;
}

/* ---------- header ---------- */
.top { position: sticky; top: 12px; z-index: 20; display: flex; align-items: center; gap: 16px;
  width: min(1120px, calc(100% - 32px)); margin: 12px auto 0; padding: 8px 10px 8px 14px;
  border: 1px solid var(--line); border-radius: 999px;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; font: 800 13px/1 var(--mono);
  color: var(--on-accent); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.nav { display: flex; gap: 2px; margin-inline: auto; }
.nav a { padding: 6px 14px; border-radius: 999px; color: var(--muted); font-size: 14.5px; font-weight: 500; transition: color .2s, background .2s; }
.nav a:hover, .nav a.active { color: var(--text); background: var(--surface-2); }
.top-actions { display: flex; gap: 6px; margin-inline-start: auto; }
.nav + .top-actions { margin-inline-start: 0; }
.chip-btn { display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--text); font: 600 13.5px/1 var(--sans); cursor: pointer; transition: border-color .2s, background .2s; }
.chip-btn:hover { border-color: var(--line-2); background: var(--surface-2); }
.icon-btn { padding: 0; }
.i-sun, .i-moon { display: grid; }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }
.menu-btn { display: none; }

/* ---------- layout ---------- */
main { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.section { padding: 72px 0 8px; }
.section h2 { display: flex; align-items: baseline; gap: 14px; font-size: clamp(26px, 4vw, 38px); font-weight: 800; letter-spacing: -.02em; line-height: 1.3; margin-bottom: 26px; }
.num { font: 500 14px/1 var(--mono); color: var(--accent); }
.sub { color: var(--muted); margin: -14px 0 26px; }
.card { position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); transition: border-color .25s, transform .25s, background .25s; }
.card::before { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), var(--glow), transparent 60%); }
.card:hover { border-color: var(--line-2); }
.card:hover::before { opacity: 1; }

/* ---------- hero ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 40px 48px; align-items: center; padding: 72px 0 24px; }
.badge { display: inline-flex; align-items: center; gap: 9px; padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #34d399; box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }
.hello { color: var(--muted); font-size: 18px; }
h1 { font-size: clamp(44px, 8.4vw, 88px); font-weight: 900; line-height: 1.12; letter-spacing: -.035em; padding-block: .06em;
  background: linear-gradient(100deg, var(--text) 20%, var(--accent) 60%, var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[lang="fa"] h1 { letter-spacing: -.01em; line-height: 1.35; }
.role { margin-top: 6px; font-size: clamp(18px, 2.4vw, 23px); font-weight: 600; }
.role .sep { color: var(--accent); margin: 0 6px; }
.typed { margin-top: 14px; min-height: 1.9em; font-size: 17px; color: var(--accent); font-weight: 500; }
.caret { display: inline-block; width: 9px; height: 1.1em; margin-inline-start: 3px; vertical-align: -0.18em; background: var(--accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.lead { margin-top: 10px; max-width: 56ch; color: var(--muted); font-size: 17px; }
.cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.btn { display: inline-flex; align-items: center; gap: 9px; padding: 11px 20px; border: 1px solid var(--line-2); border-radius: 13px; background: var(--surface); font-weight: 600; font-size: 15px; line-height: 1.5; transition: transform .2s, border-color .2s, background .2s, box-shadow .2s; }
.btn:hover { transform: translateY(-2px); border-color: var(--accent); }
.btn.primary { border-color: transparent; color: var(--on-accent); background: linear-gradient(120deg, var(--accent), var(--accent-2)); box-shadow: 0 12px 30px -12px var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }

.terminal { border: 1px solid var(--line); border-radius: 16px; background: #0b0f15; color: #d7dde8; box-shadow: var(--shadow), 0 0 0 1px rgba(255,255,255,.02), 0 30px 80px -40px var(--accent); font: 13.5px/1.75 var(--mono); overflow: hidden; transform: perspective(1200px) rotateY(-4deg) rotateX(2deg); transition: transform .5s; text-align: left; }
.terminal:hover { transform: none; }
.term-bar { display: flex; align-items: center; gap: 7px; padding: 11px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .03); }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.term-bar i:nth-child(2) { background: #febc2e; }
.term-bar i:nth-child(3) { background: #28c840; }
.term-bar span { margin-left: auto; color: #6b7689; font-size: 12px; }
.term-body { padding: 16px 18px 20px; max-height: 340px; overflow-y: auto; cursor: text; scrollbar-width: thin; scrollbar-color: #2a3442 transparent; }
.t-hint { margin-top: 10px; color: #5eead4; font-family: var(--sans); font-size: 13px; }
.t-err { color: #fca5a5; }
.t-out a { color: #7dd3fc; text-decoration: underline; }
.t-dir { color: #7dd3fc; font-weight: 600; }
.t-key { color: #f1f5fb; display: inline-block; min-width: 13ch; }
.t-out { white-space: pre-wrap; }
.t-out.fa { font-family: var(--sans); font-size: 13.5px; line-height: 1.9; }
.t-line { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.t-line b { color: #5eead4; font-weight: 500; }
.t-line input { flex: 1; min-width: 0; padding: 0; border: 0; outline: 0; background: transparent; color: #f1f5fb; font: inherit; caret-color: #5eead4; }
.t-line input::placeholder { color: #4b5768; }
.terminal:focus-within { transform: none; border-color: rgba(94, 234, 212, .5); }
.t-cmd { color: #f1f5fb; margin-top: 8px; }
.t-cmd:first-child { margin-top: 0; }
.t-cmd b { color: #5eead4; font-weight: 500; margin-right: 6px; }
.t-out { color: #93a0b5; overflow-wrap: anywhere; }
.term-body .caret { background: #5eead4; }

.stats { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.stat { display: flex; flex-direction: column-reverse; gap: 2px; padding: 20px 24px; border-inline-start: 1px solid var(--line); }
.stat:first-child { border-inline-start: 0; }
.stat dd { font-size: clamp(28px, 4vw, 40px); font-weight: 800; line-height: 1.25; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat dt { color: var(--muted); font-size: 14px; }

/* ---------- about ---------- */
.about { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, .9fr); gap: 28px; align-items: start; }
.prose p { font-size: 17.5px; color: var(--text); }
.prose p + p { margin-top: 14px; color: var(--muted); }
.facts { padding: 6px 22px; }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); }
.facts div:first-child { border-top: 0; }
.facts dt { color: var(--muted); font-size: 14.5px; }
.facts dd { font-weight: 600; text-align: end; }

/* ---------- experience ---------- */
.timeline { position: relative; display: grid; gap: 18px; padding-inline-start: 30px; }
.timeline::before { content: ""; position: absolute; inset-block: 8px; inset-inline-start: 7px; width: 2px; background: linear-gradient(var(--accent), var(--accent-2), transparent); border-radius: 2px; }
.timeline > li { padding: 24px 26px; }
.timeline > li::after { content: ""; position: absolute; top: 32px; inset-inline-start: -30px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); border: 3px solid var(--accent); }
.timeline header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 14px; }
.timeline h3 { font-size: 21px; font-weight: 700; line-height: 1.5; }
.org { font-weight: 600; color: var(--accent); }
.org span { color: var(--muted); font-weight: 400; }
.period { flex: none; padding: 3px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.timeline ul li, .nf p { color: var(--muted); }
.timeline ul li { position: relative; padding-inline-start: 20px; margin-top: 6px; }
.timeline ul li::before { content: ""; position: absolute; inset-inline-start: 2px; top: .8em; width: 7px; height: 2px; background: var(--accent); }
.more { display: inline-flex; align-items: center; gap: 6px; margin-top: 16px; color: var(--accent); font-weight: 600; font-size: 14.5px; }
.more svg { transition: transform .2s; }
.more:hover svg { transform: translate(2px, -2px); }
[dir="rtl"] .more svg { transform: scaleX(-1); }
[dir="rtl"] .more:hover svg { transform: scaleX(-1) translate(2px, -2px); }

/* ---------- projects ---------- */
.bento { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
.project { grid-column: span 2; display: flex; flex-direction: column; gap: 8px; padding: 24px; }
.project.featured { grid-column: span 4; background: linear-gradient(135deg, var(--glow), transparent 55%), var(--surface); }
.project:nth-child(2) { grid-column: span 2; }
.project:nth-child(n+3) { grid-column: span 2; }
.project:hover, .repo:hover, .contact-item:hover { transform: translateY(-3px); }
.kind { font: 500 12.5px/1.6 var(--sans); color: var(--accent); }
.project h3 { font-size: 20px; font-weight: 700; line-height: 1.5; }
.project.featured h3 { font-size: 30px; letter-spacing: -.02em; }
.project > p:not(.kind) { color: var(--muted); font-size: 15px; flex: 1; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
[dir="rtl"] .project .tags { justify-content: flex-end; }
.tags li { padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; font: 500 12px/1.7 var(--mono); color: var(--muted); background: var(--surface); }
.tags.big li { padding: 5px 14px; font: 500 14px/1.7 var(--sans); color: var(--text); }
.h-oss { margin: 40px 0 16px; font-size: 20px; font-weight: 700; }
.repos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.repo { display: flex; flex-direction: column; gap: 12px; padding: 20px 22px; }
.repo-name { display: flex; align-items: center; gap: 9px; font: 600 14.5px/1.5 var(--mono); overflow-wrap: anywhere; text-align: left; }
.repo-stars { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; }
.repo-stars svg { color: #f5b942; fill: #f5b942; stroke: none; }
.repo-stars b { color: var(--text); }

/* ---------- skills ---------- */
.skills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.skill-group { padding: 22px; }
.skill-group h3 { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.edu { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 22px 26px; }
.edu strong { font-size: 18px; }
.edu p:not(.period) { color: var(--muted); }

/* ---------- contact ---------- */
.contacts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; font-style: normal; }
.contact-item { display: flex; align-items: center; gap: 14px; padding: 18px 20px; min-width: 0; }
.contact-item > svg { width: 22px; height: 22px; color: var(--accent); }
.contact-item span { display: grid; min-width: 0; }
.contact-item small { color: var(--muted); font-size: 13px; }
.contact-item b { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
[dir="rtl"] .contact-item b[dir="ltr"] { text-align: right; }
.contact-item.accent { border-color: transparent; background: linear-gradient(120deg, var(--accent), var(--accent-2)); color: var(--on-accent); }
.contact-item.accent > svg, .contact-item.accent small { color: inherit; }

.foot { width: min(1120px, calc(100% - 32px)); margin: 72px auto 0; padding: 24px 0 36px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.foot a:hover { color: var(--accent); }

.nf { min-height: 80vh; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; }
.nf-code { font: 800 clamp(80px, 20vw, 180px)/1 var(--mono); background: linear-gradient(120deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent !important; }
.nf h1 { font-size: 32px; }
.nf .btn { margin-top: 12px; }

/* ---------- motion ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s ease, border-color .25s; }
.js .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
  .terminal { transform: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; padding-top: 48px; }
  .terminal { transform: none; }
  .about { grid-template-columns: 1fr; }
  .bento { grid-template-columns: repeat(2, 1fr); }
  .project, .project:nth-child(n) { grid-column: span 1; }
  .project.featured { grid-column: span 2; }
  .repos, .skills, .contacts { grid-template-columns: repeat(2, 1fr); }
  .menu-btn { display: inline-grid; }
  .nav { display: none; position: absolute; top: calc(100% + 8px); inset-inline: 0; flex-direction: column; gap: 2px; margin: 0; padding: 8px;
    border: 1px solid var(--line); border-radius: 20px; background: var(--bg-2); box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav a { padding: 10px 16px; }
  .nav + .top-actions { margin-inline-start: auto; }
}
@media (max-width: 600px) {
  .section { padding-top: 56px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat { padding: 16px 18px; }
  .stat:nth-child(odd) { border-inline-start: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .bento, .repos, .skills, .contacts { grid-template-columns: 1fr; }
  .project.featured { grid-column: span 1; }
  .project.featured h3 { font-size: 24px; }
  .timeline > li { padding: 20px; }
  .cta .btn { flex: 1 1 auto; justify-content: center; }
  .terminal { font-size: 12.5px; }
  .t-line input { font-size: 16px; } /* below 16px iOS zooms the page on focus */
}

@media print {
  .bg, .top, .terminal, .typed, .cta, .badge { display: none !important; }
  :root { --bg: #fff; --text: #000; --muted: #333; --surface: #fff; --line: #ccc; --accent: #0b6; }
  h1 { color: #000; background: none; }
  .js .reveal { opacity: 1; transform: none; }
  .section { padding-top: 24px; }
  .card { box-shadow: none; break-inside: avoid; }
}
