/* ===== Variables ===== */
:root {
  --bg: #0a0f1a;
  --bg-card: #111827;
  --bg-card-hover: #1a2332;
  --border: rgba(148, 163, 184, 0.12);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --accent-glow: rgba(56, 189, 248, 0.15);
  --gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.25s ease;
  --font: 'Vazirmatn', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --header-h: 72px;
  --container-max: 1120px;
  --container-padding: clamp(1.25rem, 5vw, 2rem);
}

/* ===== Reset ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

main {
  overflow-x: clip;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

/* ===== Background ===== */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}

.bg-glow--1 {
  width: 500px;
  height: 500px;
  background: rgba(56, 189, 248, 0.08);
  top: -200px;
  left: -100px;
}

.bg-glow--2 {
  width: 400px;
  height: 400px;
  background: rgba(129, 140, 248, 0.08);
  bottom: -100px;
  right: -100px;
}

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-left: max(var(--container-padding), env(safe-area-inset-left, 0px));
  padding-right: max(var(--container-padding), env(safe-area-inset-right, 0px));
  position: relative;
  z-index: 1;
}

.section {
  padding-block: 5rem;
}

.section__title {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
}

.section__subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 3rem;
  font-size: 1.05rem;
}

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(10, 15, 26, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.logo__bracket {
  color: var(--accent);
}

.nav__links {
  display: flex;
  gap: 2rem;
}

.nav__links a {
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: color var(--transition);
  position: relative;
}

.nav__links a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  inset-inline-start: 0;
  width: 0;
  height: 2px;
  background: var(--gradient);
  transition: width var(--transition);
}

.lang-switch {
  font-weight: 600;
  color: var(--accent) !important;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.6rem !important;
}

.lang-switch[hreflang="en"] {
  font-family: var(--font-mono);
}

.lang-switch[hreflang="fa"] {
  font-family: 'Vazirmatn', Tahoma, sans-serif;
}

.lang-switch::after {
  display: none;
}

html[lang="en"] body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

.nav__links a:hover {
  color: var(--text);
}

.nav__links a:hover::after {
  width: 100%;
}

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

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

.nav__toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav__toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav__toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Hero ===== */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  min-height: 100vh;
  padding-top: var(--header-h);
  padding-bottom: 4rem;
}

.hero > * {
  min-width: 0;
}

.hero__greeting {
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.hero__name {
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  font-weight: 700;
  margin-bottom: 0.25rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__role {
  font-size: clamp(1.25rem, 3vw, 1.75rem);
  color: var(--text-muted);
  font-weight: 400;
  margin-bottom: 1.5rem;
}

.hero__intro {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 540px;
  margin-bottom: 2rem;
  line-height: 1.9;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.75rem;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}

.btn--primary {
  background: var(--gradient);
  color: #0a0f1a;
}

.btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--accent-glow);
}

.btn--outline {
  border-color: var(--border);
  color: var(--text);
  background: transparent;
}

.btn--outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Code window */
.code-window {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  max-width: 100%;
  min-width: 0;
}

.code-window__bar {
  display: flex;
  gap: 8px;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border);
}

.code-window__bar span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #374151;
}

.code-window__bar span:nth-child(1) { background: #ef4444; }
.code-window__bar span:nth-child(2) { background: #eab308; }
.code-window__bar span:nth-child(3) { background: #22c55e; }

.code-window__body {
  padding: 1.5rem;
  font-family: var(--font-mono);
  font-size: clamp(0.7rem, 2.8vw, 0.85rem);
  line-height: 1.8;
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.code-window__body .kw { color: #c084fc; }
.code-window__body .prop { color: #38bdf8; }
.code-window__body .str { color: #86efac; }

/* ===== Skills ===== */
.skills__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 1rem;
}

.skill-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}

.skill-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(56, 189, 248, 0.3);
  transform: translateY(-4px);
}

.skill-card__icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  line-height: 0;
}

.skill-card__icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.skill-card__name {
  font-weight: 500;
  font-size: 0.95rem;
}

/* ===== Projects ===== */
.projects__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.75rem;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.project-card:hover {
  border-color: rgba(56, 189, 248, 0.25);
  transform: translateY(-6px);
  box-shadow: var(--shadow);
}

.project-card__image {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #0d1321;
}

.project-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.project-card:hover .project-card__image img {
  transform: scale(1.05);
}

.project-card__body {
  padding: 1.5rem;
}

.project-card__title {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.project-card__desc {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.75;
}

/* ===== Social ===== */
.social-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  min-width: 0;
}

.social-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-weight: 500;
  transition: var(--transition);
}

.social-link svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.social-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px var(--accent-glow);
}

/* ===== Footer ===== */
.footer {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  position: relative;
  z-index: 1;
}

/* ===== Animations ===== */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero__content,
.hero__visual,
.skill-card,
.project-card,
.social-link {
  animation: fadeUp 0.6s ease backwards;
}

.hero__visual { animation-delay: 0.15s; }

.skill-card:nth-child(1) { animation-delay: 0.05s; }
.skill-card:nth-child(2) { animation-delay: 0.1s; }
.skill-card:nth-child(3) { animation-delay: 0.15s; }
.skill-card:nth-child(4) { animation-delay: 0.2s; }
.skill-card:nth-child(5) { animation-delay: 0.25s; }
.skill-card:nth-child(6) { animation-delay: 0.3s; }
.skill-card:nth-child(7) { animation-delay: 0.35s; }
.skill-card:nth-child(8) { animation-delay: 0.4s; }
.skill-card:nth-child(9) { animation-delay: 0.45s; }
.skill-card:nth-child(10) { animation-delay: 0.5s; }
.skill-card:nth-child(11) { animation-delay: 0.55s; }
.skill-card:nth-child(12) { animation-delay: 0.6s; }

.project-card:nth-child(1) { animation-delay: 0.05s; }
.project-card:nth-child(2) { animation-delay: 0.1s; }
.project-card:nth-child(3) { animation-delay: 0.15s; }
.project-card:nth-child(4) { animation-delay: 0.2s; }
.project-card:nth-child(5) { animation-delay: 0.25s; }
.project-card:nth-child(6) { animation-delay: 0.3s; }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding-top: calc(var(--header-h) + 2rem);
    min-height: auto;
  }

  .hero__intro {
    margin-inline: auto;
  }

  .hero__actions {
    justify-content: center;
  }

  .hero__visual {
    order: -1;
    max-width: 480px;
    margin-inline: auto;
  }
}

@media (max-width: 768px) {
  .nav__toggle {
    display: flex;
  }

  .nav__links {
    position: fixed;
    top: var(--header-h);
    right: 0;
    left: 0;
    flex-direction: column;
    align-items: center;
    gap: 0;
    background: rgba(10, 15, 26, 0.97);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    transform: translateY(-120%);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
  }

  .nav__links.is-open {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }

  .nav__links li {
    width: 100%;
    text-align: center;
  }

  .nav__links a {
    display: block;
    padding: 0.85rem 1rem;
  }

  .section {
    padding-block: 3.5rem;
  }

  .social-link {
    flex: 1 1 calc(50% - 0.5rem);
    justify-content: center;
    min-width: 0;
    padding: 1rem 1rem;
  }
}

@media (max-width: 400px) {
  .social-link {
    flex: 1 1 100%;
  }

  .hero__actions {
    flex-direction: column;
    width: 100%;
  }

  .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

.ltr{
  direction: ltr;
}