:root {
  --navy-dark: #020c1b;
  --navy: #0a192f;
  --navy-light: #112240;
  --navy-lighter: #233554;
  --slate: #8892b0;
  --slate-light: #a8b2d1;
  --slate-lightest: #ccd6f6;
  --white: #e6f1ff;
  --accent: #64ffda;
  --accent-tint: rgba(100, 255, 218, 0.1);
  --shadow: rgba(2, 12, 27, 0.7);

  --font-sans: "Inter", -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: "Fira Code", "SF Mono", Menlo, Consolas, monospace;

  --fz-xxs: 12px;
  --fz-xs: 13px;
  --fz-sm: 14px;
  --fz-md: 16px;
  --fz-lg: 18px;
  --fz-xl: 20px;
  --fz-heading: 32px;

  --radius: 4px;
  --nav-h: 100px;
  --nav-h-scrolled: 70px;
  --ease: cubic-bezier(0.645, 0.045, 0.355, 1);
  --dur: 250ms;
  --bullet: "▹";
}

/* Persian: RTL font stack (Latin glyphs still fall back to Inter / Fira Code) */
:root[lang="fa"] {
  --font-sans: "Vazirmatn", "Inter", Tahoma, system-ui, sans-serif;
  --font-mono: "Vazirmatn", "Fira Code", Tahoma, monospace;
  --bullet: "◃";
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-h-scrolled);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--navy);
  color: var(--slate);
  font-family: var(--font-sans);
  font-size: var(--fz-xl);
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }

::selection { background: var(--navy-lighter); color: var(--slate-lightest); }

a { color: inherit; text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover, a:focus-visible { color: var(--accent); }
:focus-visible { outline: 2px dashed var(--accent); outline-offset: 3px; }

img, svg { display: block; max-width: 100%; }
img { height: auto; }
ol, ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { margin: 0 0 10px; color: var(--slate-lightest); font-weight: 600; line-height: 1.1; }
p { margin: 0 0 15px; }
.mono { font-family: var(--font-mono); }

.skip {
  position: absolute; inset-inline-start: -9999px; top: 0; z-index: 99;
  padding: 14px 20px; background: var(--accent); color: var(--navy); border-radius: var(--radius);
}
.skip:focus { inset-inline-start: 16px; top: 16px; color: var(--navy); }

/* ink links: animated underline */
.ink { position: relative; display: inline-block; color: var(--accent); }
.ink::after {
  content: ""; position: absolute; inset-inline-start: 0; bottom: 0.1em; width: 0; height: 1px;
  background: var(--accent); opacity: 0.6; transition: width var(--dur) var(--ease);
}
.ink:hover::after, .ink:focus-visible::after { width: 100%; }

/* buttons */
.btn {
  display: inline-block;
  padding: 1.1rem 1.6rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: var(--fz-sm);
  line-height: 1;
  background: transparent;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.btn:hover, .btn:focus-visible {
  color: var(--accent);
  transform: translate(-4px, -4px);
  box-shadow: 4px 4px 0 0 var(--accent);
  outline: none;
}
.btn-sm { padding: 0.75rem 1rem; font-size: var(--fz-xs); }
.btn-lg { padding: 1.25rem 1.75rem; }

/* ---------- nav ---------- */
.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  height: var(--nav-h);
  padding: 0 50px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(10, 25, 47, 0.85);
  backdrop-filter: blur(10px);
  transition: height var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.nav.scrolled { height: var(--nav-h-scrolled); box-shadow: 0 10px 30px -10px var(--shadow); }
.nav.hide { transform: translateY(calc(-1 * var(--nav-h))); box-shadow: none; }

.logo { width: 42px; height: 42px; color: var(--accent); }
.logo svg { width: 100%; height: 100%; transition: transform var(--dur) var(--ease); }
.logo:hover svg { transform: translate(-3px, -3px); }

.nav-right { display: flex; align-items: center; gap: 15px; }
.nav-links { display: flex; align-items: center; }

.lang {
  min-width: 44px; height: 36px; padding: 0 12px;
  border: 1px solid var(--accent); border-radius: var(--radius);
  background: transparent; color: var(--accent);
  font-family: "Vazirmatn", "Fira Code", monospace; font-size: var(--fz-xs); font-weight: 600; line-height: 1;
  cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.lang:hover, .lang:focus-visible { background: var(--accent-tint); }
.lang:lang(en) { font-family: var(--font-mono); font-weight: 500; }
.nav-links ol, .drawer ol { counter-reset: item; }
.nav-links ol { display: flex; }
.nav-links li, .drawer li { counter-increment: item; }
.nav-links li a {
  display: block; padding: 10px;
  font-family: var(--font-mono); font-size: var(--fz-xs); color: var(--slate-lightest);
}
.nav-links li a:hover { color: var(--accent); }
.nav-links li a::before, .drawer li a::before {
  content: "0" counter(item) "."; margin-inline-end: 5px; color: var(--accent);
}

.burger {
  display: none; position: relative; z-index: 30;
  width: 44px; height: 44px; padding: 10px; margin-inline-end: -10px;
  background: none; border: 0; cursor: pointer;
}
.burger span {
  display: block; height: 2px; margin: 6px 0; margin-inline-start: auto;
  background: var(--accent); border-radius: 2px;
  transition: transform var(--dur) var(--ease), width var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.burger span:nth-child(1) { width: 24px; }
.burger span:nth-child(2) { width: 18px; }
.burger span:nth-child(3) { width: 14px; }
.burger[aria-expanded="true"] span:nth-child(1) { width: 24px; transform: translateY(8px) rotate(45deg); }
.burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger[aria-expanded="true"] span:nth-child(3) { width: 24px; transform: translateY(-8px) rotate(-45deg); }

.drawer {
  position: fixed; top: 0; inset-inline-end: 0; bottom: 0; z-index: 25;
  width: min(75vw, 400px);
  padding: 50px 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--navy-light);
  box-shadow: -10px 0 30px -15px var(--shadow);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 300ms var(--ease), visibility 300ms var(--ease);
}
[dir="rtl"] .drawer { transform: translateX(-100%); box-shadow: 10px 0 30px -15px var(--shadow); }
.drawer.open, [dir="rtl"] .drawer.open { transform: none; visibility: visible; }
.drawer nav { display: flex; flex-direction: column; align-items: center; text-align: center; width: 100%; }
.drawer ol { width: 100%; margin-bottom: 30px; }
.drawer li a {
  display: block; padding: 4px 20px 20px;
  color: var(--slate-lightest); font-size: clamp(var(--fz-sm), 4vw, var(--fz-lg));
}
.drawer li a::before { display: block; margin: 0 0 5px; font-family: var(--font-mono); font-size: var(--fz-sm); }
.drawer .btn { padding: 18px 50px; }

main.blur, footer.blur { filter: blur(5px) brightness(0.7); pointer-events: none; user-select: none; }
main, footer { transition: filter 300ms var(--ease); }

/* ---------- side rails ---------- */
.side {
  position: fixed; bottom: 0; z-index: 10; width: 40px;
}
.side-start { inset-inline-start: 40px; }
.side-end { inset-inline-end: 40px; }
.side ul, .side-end { display: flex; flex-direction: column; align-items: center; }
.side ul::after, .side-end::after {
  content: ""; display: block; width: 1px; height: 90px; margin: 0 auto; background: var(--slate-light);
}
.side li:last-of-type { margin-bottom: 20px; }
.side li a { display: block; padding: 10px; }
.side li a svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.side li a:hover, .side-mail:hover { transform: translateY(-3px); }
.side li a, .side-mail { transition: color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.side-mail {
  margin: 20px auto; padding: 10px;
  font-family: var(--font-mono); font-size: var(--fz-xxs); letter-spacing: 0.1em;
  writing-mode: vertical-rl;
}

/* ---------- layout ---------- */
main { padding: 0 150px; max-width: 1600px; margin: 0 auto; }
.section { max-width: 1000px; margin: 0 auto; padding: 100px 0; }
.section.narrow { max-width: 700px; }

.heading {
  display: flex; align-items: center; width: 100%;
  margin: 10px 0 40px;
  font-size: clamp(26px, 5vw, var(--fz-heading)); white-space: nowrap;
  counter-increment: section;
}
main { counter-reset: section; }
.heading::before {
  content: "0" counter(section) ".";
  margin-inline-end: 10px;
  font-family: var(--font-mono); font-weight: 400; color: var(--accent);
  font-size: clamp(var(--fz-md), 3vw, var(--fz-xl));
  position: relative; bottom: 2px;
}
.heading::after {
  content: ""; display: block; position: relative;
  width: 300px; height: 1px; margin-inline-start: 20px; background: var(--navy-lighter);
}

/* ---------- hero ---------- */
.hero {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  max-width: 1000px; margin: 0 auto; padding: var(--nav-h) 0 0;
}
.hero-hi {
  margin: 0 0 30px 4px; color: var(--accent);
  font-size: clamp(var(--fz-sm), 5vw, var(--fz-md));
}
.hero-name { font-size: clamp(40px, 8vw, 80px); margin: 0; }
.hero-tag { font-size: clamp(40px, 8vw, 80px); margin-top: 5px; color: var(--slate); line-height: 0.95; }
.hero-lede { max-width: 540px; margin: 20px 0 0; line-height: 1.5; }
.hero .btn { margin-top: 50px; }

/* ---------- about ---------- */
.about { display: grid; grid-template-columns: 3fr 2fr; gap: 50px; }
.about-text p { line-height: 1.5; }
.skills {
  display: grid; grid-template-columns: repeat(2, minmax(140px, 200px));
  gap: 0 10px; margin-top: 20px; overflow: hidden;
}
.skills li {
  position: relative; margin-bottom: 10px; padding-inline-start: 20px;
  font-family: var(--font-mono); font-size: var(--fz-xs);
}
.skills li::before {
  content: var(--bullet); position: absolute; inset-inline-start: 0; color: var(--accent); font-size: var(--fz-sm); line-height: 12px;
}

.about-pic { position: relative; max-width: 300px; }
.pic {
  position: relative; display: block; width: 100%;
  border-radius: var(--radius); background: var(--accent);
}
.pic img {
  position: relative; border-radius: var(--radius);
  mix-blend-mode: multiply; filter: grayscale(100%) contrast(1);
  transition: filter var(--dur) var(--ease), mix-blend-mode var(--dur) var(--ease);
}
.pic::before, .pic::after {
  content: ""; position: absolute; display: block; width: 100%; height: 100%;
  border-radius: var(--radius); transition: transform var(--dur) var(--ease);
}
.pic::before { top: 0; left: 0; background: var(--navy); mix-blend-mode: screen; z-index: 1; pointer-events: none; }
.pic::after { top: 20px; left: 20px; border: 2px solid var(--accent); z-index: -1; }
.about-pic:hover .pic, .about-pic:focus-within .pic { transform: translate(-4px, -4px); }
.about-pic:hover .pic::after { transform: translate(8px, 8px); }
.about-pic:hover .pic::before { opacity: 0; }
.about-pic:hover .pic img { filter: none; mix-blend-mode: normal; }
.pic { transition: transform var(--dur) var(--ease); }
.pic::before { transition: opacity var(--dur) var(--ease); }

/* ---------- experience tabs ---------- */
.tabs { display: flex; gap: 0; }
.tab-list { position: relative; z-index: 2; width: max-content; padding: 0; margin: 0; display: flex; flex-direction: column; }
.tab-list button {
  display: flex; align-items: center;
  height: 42px; padding: 0 20px 2px; width: 100%;
  background: transparent; border: 0; border-inline-start: 2px solid var(--navy-lighter);
  color: var(--slate); font-family: var(--font-mono); font-size: var(--fz-xs);
  text-align: start; white-space: nowrap; cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab-list button:hover, .tab-list button:focus-visible { background: var(--navy-light); color: var(--accent); outline: none; }
.tab-list button[aria-selected="true"] { color: var(--accent); }
.tab-mark {
  position: absolute; top: 0; inset-inline-start: 0; z-index: 10;
  width: 2px; height: 42px; border-radius: var(--radius); background: var(--accent);
  transition: transform 250ms var(--ease) 100ms;
}
.tab-panels { position: relative; width: 100%; margin-inline-start: 20px; }
.tab-panel { padding: 10px 5px; }
.tab-panel h3 { font-size: var(--fz-xl); font-weight: 500; line-height: 1.3; margin-bottom: 2px; }
.tab-panel .at { color: var(--accent); }
.range { margin-bottom: 25px; color: var(--slate-light); font-size: var(--fz-xs); }
.tab-panel ul li, .feat-desc li {
  position: relative; padding-inline-start: 30px; margin-bottom: 10px; font-size: var(--fz-lg); line-height: 1.5;
}
.tab-panel ul li::before { content: var(--bullet); position: absolute; inset-inline-start: 0; color: var(--accent); }
.tab-panel.enter { animation: fadeUp 300ms var(--ease) both; }

/* ---------- featured ---------- */
.featured > li { margin-bottom: 100px; }
.featured > li:last-child { margin-bottom: 0; }
.feat {
  position: relative;
  display: grid; grid-template-columns: repeat(12, 1fr); align-items: center; gap: 10px;
}
.feat-body {
  position: relative; z-index: 2;
  grid-column: 7 / -1; grid-row: 1 / -1; text-align: end;
}
.feat:nth-of-type(even) .feat-body { grid-column: 1 / 7; text-align: start; }
.feat-over { margin: 10px 0; color: var(--accent); font-size: var(--fz-xs); }
.feat-title { font-size: clamp(24px, 5vw, 28px); color: var(--slate-lightest); margin-bottom: 20px; }
.feat-desc {
  position: relative; z-index: 2;
  padding: 25px; border-radius: var(--radius);
  background: var(--navy-light); box-shadow: 0 10px 30px -15px var(--shadow);
  color: var(--slate-light); font-size: var(--fz-lg); line-height: 1.5;
  transition: box-shadow var(--dur) var(--ease);
}
.feat-desc:hover { box-shadow: 0 20px 30px -15px var(--shadow); }
.feat-desc p { margin: 0; }
.feat-tech {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0 20px;
  margin: 25px 0 10px; font-size: var(--fz-xs); color: var(--slate-light);
}
.feat:nth-of-type(even) .feat-tech { justify-content: flex-start; }
.feat-links { display: flex; justify-content: flex-end; align-items: center; margin-top: 10px; margin-inline-end: -10px; color: var(--slate-lightest); }
.feat:nth-of-type(even) .feat-links { justify-content: flex-start; margin-inline: -10px 0; }
.feat-links a { padding: 10px; }
.feat-links svg, .card-top svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.feat-img {
  grid-column: 1 / 8; grid-row: 1 / -1; position: relative; z-index: 1;
  border-radius: var(--radius); background: var(--accent); box-shadow: 0 10px 30px -15px var(--shadow);
}
.feat:nth-of-type(even) .feat-img { grid-column: 6 / -1; }
.feat-img::before {
  content: ""; position: absolute; inset: 0; z-index: 3;
  background: var(--navy); mix-blend-mode: screen; border-radius: var(--radius);
  transition: opacity var(--dur) var(--ease);
}
.feat-img:hover::before { opacity: 0; }
.feat-img img, .ph {
  width: 100%; border-radius: var(--radius);
  mix-blend-mode: multiply; filter: grayscale(100%) contrast(1) brightness(90%);
  transition: filter var(--dur) var(--ease);
}
.feat-img:hover img, .feat-img:hover .ph { filter: none; mix-blend-mode: normal; }
.ph {
  aspect-ratio: 16 / 10;
  display: grid; place-items: center;
  background:
    linear-gradient(135deg, var(--navy-lighter), var(--navy-light) 60%),
    var(--navy-light);
}
.ph span { font-size: clamp(28px, 4vw, 44px); font-weight: 700; color: var(--slate-lightest); letter-spacing: -0.02em; }

/* ---------- other projects ---------- */
.sub-heading { text-align: center; font-size: clamp(24px, 5vw, var(--fz-heading)); margin: 140px 0 40px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px; position: relative;
}
.card { transition: transform var(--dur) var(--ease); }
.card:hover { transform: translateY(-7px); }
.card-inner {
  display: flex; flex-direction: column; height: 100%;
  padding: 2rem 1.75rem; border-radius: var(--radius);
  background: var(--navy-light); box-shadow: 0 10px 30px -15px var(--shadow);
}
.card:hover .card-inner { box-shadow: 0 20px 30px -15px var(--shadow); }
.card-top { margin-bottom: 35px; color: var(--accent); }
.card-top .folder { width: 40px; height: 40px; stroke-width: 1.5; }
.card h4 { font-size: var(--fz-xl); margin-bottom: 10px; transition: color var(--dur) var(--ease); }
.card:hover h4 { color: var(--accent); }
.card p { font-size: 17px; line-height: 1.5; color: var(--slate-light); }
.card-tech { display: flex; flex-wrap: wrap; gap: 0 15px; margin-top: auto; padding-top: 20px; font-size: var(--fz-xxs); }

/* ---------- contact ---------- */
.contact { max-width: 600px; text-align: center; margin-bottom: 100px; }
.contact-over { color: var(--accent); font-size: var(--fz-md); margin-bottom: 20px; counter-increment: section; }
.contact-over::before { content: "0" counter(section) ". "; }
.contact-title { font-size: clamp(40px, 5vw, 60px); margin-bottom: 20px; }
.contact p { line-height: 1.5; }
.contact .btn { margin-top: 40px; }

.footer { padding: 15px; text-align: center; }
.footer p { margin: 0; font-size: var(--fz-xxs); color: var(--slate); }

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(20px); transition: opacity 600ms var(--ease), transform 600ms var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.hero > * { animation: fadeUp 600ms var(--ease) both; }
.hero > *:nth-child(1) { animation-delay: 100ms; }
.hero > *:nth-child(2) { animation-delay: 200ms; }
.hero > *:nth-child(3) { animation-delay: 300ms; }
.hero > *:nth-child(4) { animation-delay: 400ms; }
.hero > *:nth-child(5) { animation-delay: 500ms; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }

/* ---------- Persian / RTL ---------- */
[lang="fa"] .nav-links li a::before,
[lang="fa"] .drawer li a::before { content: "۰" counter(item, persian) "."; }
[lang="fa"] .heading::before { content: "۰" counter(section, persian) "."; bottom: 0; }
[lang="fa"] .contact-over::before { content: "۰" counter(section, persian) ". "; }
[lang="fa"] body { line-height: 1.6; }
[lang="fa"] h1, [lang="fa"] h2, [lang="fa"] h3, [lang="fa"] h4 { line-height: 1.4; font-weight: 700; }
[lang="fa"] .hero-name, [lang="fa"] .hero-tag { line-height: 1.35; }
[lang="fa"] .hero-name { font-size: clamp(36px, 7vw, 72px); }
[lang="fa"] .hero-tag { font-size: clamp(30px, 6vw, 64px); }
[lang="fa"] .nav-links li a, [lang="fa"] .tab-list button { font-size: var(--fz-sm); }
[lang="fa"] .btn { font-size: var(--fz-md); }
[lang="fa"] .tab-panel ul li, [lang="fa"] .feat-desc, [lang="fa"] .about-text p { line-height: 1.9; }
[lang="fa"] .tab-panel ul li { font-size: var(--fz-md); }
[lang="fa"] .feat-desc, [lang="fa"] .card p { font-size: var(--fz-md); }
[lang="fa"] .feat-over, [lang="fa"] .range { font-size: var(--fz-sm); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  main { padding: 0 100px; }
  .nav { padding: 0 40px; }
  .side-start { inset-inline-start: 20px; }
  .side-end { inset-inline-end: 20px; }
}

@media (max-width: 768px) {
  main { padding: 0 50px; }
  .nav { padding: 0 25px; }
  .nav-links { display: none; }
  .burger { display: block; }
  .side { display: none; }
  .section { padding: 80px 0; }
  .heading::after { width: 100%; }

  .about { grid-template-columns: 1fr; }
  .about-pic { margin: 50px auto 0; width: 70%; }

  .tabs { display: block; }
  .tab-list {
    flex-direction: row; width: calc(100% + 100px); margin-inline-start: -50px; margin-bottom: 30px;
    padding-inline-start: 50px; overflow-x: auto; scrollbar-width: none;
  }
  .tab-list::-webkit-scrollbar { display: none; }
  .tab-list button {
    justify-content: center; min-width: 120px; padding: 0 15px;
    border-inline-start: 0; border-bottom: 2px solid var(--navy-lighter);
  }
  .tab-mark { top: auto; bottom: 0; inset-inline-start: 50px; width: 120px; height: 2px; }
  .tab-panels { margin-inline-start: 0; }

  .feat { box-shadow: 0 10px 30px -15px var(--shadow); }
  .feat-body, .feat:nth-of-type(even) .feat-body {
    grid-column: 1 / -1; padding: 40px 40px 30px; text-align: start; z-index: 5;
  }
  .feat-img, .feat:nth-of-type(even) .feat-img { grid-column: 1 / -1; height: 100%; opacity: 0.25; }
  .feat-img .ph { height: 100%; aspect-ratio: auto; }
  .feat-desc { padding: 20px 0; background: transparent; box-shadow: none; color: var(--slate-lightest); }
  .feat-desc:hover { box-shadow: none; }
  .feat-tech, .feat:nth-of-type(even) .feat-tech { justify-content: flex-start; }
  .feat-links, .feat:nth-of-type(even) .feat-links { justify-content: flex-start; margin-inline: -10px 0; }
  .feat-title { color: var(--white); }
  .featured > li { margin-bottom: 70px; }
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  main { padding: 0 16px; }
  .nav { padding: 0 16px; }
  .hero { padding-top: var(--nav-h-scrolled); }
  .heading::after { margin-inline-start: 10px; }
  .tab-list { width: calc(100% + 32px); margin-inline-start: -16px; padding-inline-start: 16px; }
  .tab-mark { inset-inline-start: 16px; }
  .feat-body, .feat:nth-of-type(even) .feat-body { padding: 30px 25px 20px; }
  .about-pic { width: 85%; }
  .card-inner { padding: 1.5rem 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  .reveal { opacity: 1; transform: none; }
}
