/* ===== Tokens ===== */
:root {
  --bg: #0b0f14;
  --bg-elevated: #121820;
  --bg-card: #161d27;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eef6;
  --text-muted: #93a1b5;
  --accent: #5b9dff;
  --accent-2: #7c6cff;
  --accent-soft: rgba(91, 157, 255, 0.12);
  --success: #3dd68c;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --header-h: 72px;
  --font-fa: "Vazirmatn", system-ui, sans-serif;
  --font-en: "Inter", system-ui, sans-serif;
  --max: 1080px;
  --transition: 0.22s ease;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 12px);
}

body {
  font-family: var(--font-fa);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

html[lang="en"] body {
  font-family: var(--font-en);
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

button {
  font: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

/* ===== Layout helpers ===== */
.container {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

.bg-glow {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(91, 157, 255, 0.16), transparent 55%),
    radial-gradient(700px 400px at -10% 30%, rgba(124, 108, 255, 0.12), transparent 50%),
    radial-gradient(600px 360px at 50% 110%, rgba(61, 214, 140, 0.06), transparent 50%);
}

/* ===== Header ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  backdrop-filter: blur(14px);
  background: rgba(11, 15, 20, 0.72);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo {
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: 1.1rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav a {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
}

.nav a:hover,
.nav a.active {
  color: var(--text);
  background: var(--accent-soft);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.lang-btn {
  min-width: 44px;
  height: 36px;
  padding: 0 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-weight: 600;
  font-size: 0.85rem;
  transition: border-color var(--transition), background var(--transition);
}

.lang-btn:hover {
  border-color: rgba(91, 157, 255, 0.45);
  background: var(--accent-soft);
}

.menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  place-items: center;
  flex-direction: column;
  gap: 5px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

/* ===== Hero ===== */
.hero {
  padding: 5.5rem 0 4rem;
}

.hero-layout {
  display: grid;
  grid-template-columns: 1.2fr auto;
  gap: 2.5rem;
  align-items: center;
}

.hero-inner {
  max-width: 720px;
}

.hero-photo-wrap {
  position: relative;
  justify-self: end;
}

.hero-photo-wrap::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(91, 157, 255, 0.45), rgba(124, 108, 255, 0.25), transparent 70%);
  z-index: -1;
  filter: blur(2px);
}

.hero-photo {
  width: min(280px, 42vw);
  height: min(280px, 42vw);
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--bg-card);
}

.hero-eyebrow {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.6rem;
  letter-spacing: 0.02em;
}

.hero-name {
  font-size: clamp(2.2rem, 5vw, 3.4rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 0.65rem;
}

.hero-title {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 1.1rem;
}

.hero-lead {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 52ch;
  margin-bottom: 1.75rem;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 24px rgba(91, 157, 255, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 10px 28px rgba(91, 157, 255, 0.35);
}

.btn-ghost {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: rgba(91, 157, 255, 0.4);
  background: var(--accent-soft);
}

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.socials a {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.socials a:hover {
  color: var(--text);
  border-color: rgba(91, 157, 255, 0.4);
  background: var(--accent-soft);
}

.socials svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ===== Sections ===== */
.section {
  padding: 4.5rem 0;
}

.section-alt {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent);
  border-block: 1px solid var(--border);
}

.section-title {
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  letter-spacing: -0.02em;
  margin-bottom: 2rem;
  position: relative;
  display: inline-block;
}

.section-title::after {
  content: "";
  display: block;
  width: 42%;
  height: 3px;
  margin-top: 0.55rem;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

/* ===== About ===== */
.about-grid {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: 1.4fr 1fr;
  align-items: start;
}

.about-text p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.about-facts {
  display: grid;
  gap: 0.75rem;
}

.about-facts li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.about-facts .label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.about-facts .value {
  font-weight: 600;
  text-align: end;
}

/* ===== Skills ===== */
.skills-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.skill-card {
  padding: 1.2rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.skill-card h3 {
  font-size: 1rem;
  margin-bottom: 0.9rem;
  color: var(--text);
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.skill-tags span {
  font-size: 0.82rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #c9ddff;
  border: 1px solid rgba(91, 157, 255, 0.18);
}

/* ===== Timeline / Experience ===== */
.timeline {
  display: grid;
  gap: 1rem;
  position: relative;
}

.timeline-item {
  position: relative;
  display: block;
  padding: 1.25rem 1.3rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: inherit;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.timeline-item:hover {
  border-color: rgba(91, 157, 255, 0.35);
  transform: translateY(-2px);
}

.timeline-item.is-clickable {
  cursor: pointer;
}

.timeline-item.is-clickable:hover {
  border-color: rgba(91, 157, 255, 0.55);
  box-shadow: 0 10px 28px rgba(91, 157, 255, 0.12);
}

.timeline-item.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.link-hint {
  display: inline-block;
  margin-inline-start: 0.35rem;
  font-size: 0.85em;
  opacity: 0.55;
  transition: opacity var(--transition), transform var(--transition);
}

.is-clickable:hover .link-hint {
  opacity: 1;
  transform: translateY(-1px);
}

.timeline-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}

.timeline-item h3 {
  font-size: 1.05rem;
}

.timeline-item .company {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.timeline-item .period {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.timeline-item p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.timeline-item ul {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.35rem;
}

.timeline-item li {
  position: relative;
  color: var(--text-muted);
  font-size: 0.92rem;
  padding-inline-start: 1rem;
}

.timeline-item li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.65em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.8;
}

/* ===== Education cards ===== */
.cards-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.edu-card {
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.edu-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.3rem;
}

.edu-card .school {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.edu-card .period {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 0.6rem;
}

.edu-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* ===== Projects ===== */
.projects-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.project-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  min-height: 150px;
  color: inherit;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.project-card.no-thumb {
  grid-template-columns: 1fr;
  min-height: 0;
  padding: 1.25rem 1.3rem;
}

.project-card:hover {
  border-color: rgba(91, 157, 255, 0.4);
  transform: translateY(-3px);
}

.project-card.is-clickable {
  cursor: pointer;
}

.project-card.is-clickable:hover {
  border-color: rgba(91, 157, 255, 0.55);
  box-shadow: 0 10px 28px rgba(91, 157, 255, 0.12);
}

.project-card.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.project-thumb {
  width: 120px;
  min-height: 120px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  align-self: stretch;
}

.project-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-thumb-empty {
  background:
    linear-gradient(135deg, rgba(91, 157, 255, 0.18), rgba(124, 108, 255, 0.1));
}

.project-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.project-card h3 {
  font-size: 1.05rem;
  margin-bottom: 0.45rem;
  line-height: 1.35;
}

.project-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  flex: 1;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.project-tags span {
  font-size: 0.78rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
}

.project-action {
  margin-top: 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent);
}

/* ===== Courses ===== */
.course-card {
  display: block;
  padding: 1.25rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: inherit;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.course-card:hover {
  border-color: rgba(91, 157, 255, 0.35);
  transform: translateY(-2px);
}

.course-card.is-clickable {
  cursor: pointer;
}

.course-card.is-clickable:hover {
  border-color: rgba(91, 157, 255, 0.55);
  box-shadow: 0 10px 28px rgba(91, 157, 255, 0.12);
}

.course-card.is-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.course-top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.35rem;
}

.course-card h3 {
  font-size: 1.05rem;
}

.course-card .period {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.course-org {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.course-card p {
  color: var(--text-muted);
  font-size: 0.93rem;
  margin-bottom: 0.85rem;
}

.course-card .project-tags {
  margin-top: auto;
}

/* ===== Contact ===== */
.contact-inner {
  text-align: center;
}

.contact-lead {
  color: var(--text-muted);
  max-width: 48ch;
  margin: -0.5rem auto 1.75rem;
}

.contact-cards {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  max-width: 760px;
  margin-inline: auto;
}

.contact-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1.15rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color var(--transition), transform var(--transition);
}

.contact-card:hover {
  border-color: rgba(91, 157, 255, 0.35);
  transform: translateY(-2px);
}

.contact-card .label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.contact-card .value {
  font-weight: 600;
  word-break: break-word;
}

/* ===== Footer ===== */
.footer {
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
}

.footer-inner {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
}

/* ===== Reveal animation ===== */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

/* ===== Project detail page ===== */
.project-page {
  padding: 2.5rem 0 4rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 1.5rem;
  transition: color var(--transition);
}

.back-link:hover {
  color: var(--accent);
}

.project-hero-cover {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  max-height: 320px;
  background: var(--bg-card);
}

.project-hero-cover img {
  width: 100%;
  height: 320px;
  object-fit: cover;
}

.project-header h1 {
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.project-header-desc {
  color: var(--text-muted);
  max-width: 70ch;
  margin-bottom: 1rem;
}

.project-header .project-tags {
  margin-bottom: 1.25rem;
}

.project-meta {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 2rem;
}

.meta-item {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.meta-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 0.2rem;
}

.meta-value {
  font-weight: 600;
}

.project-report {
  padding: 1.5rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.project-report p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.project-report p:last-child {
  margin-bottom: 0;
}

.project-gallery {
  margin-bottom: 2.5rem;
}

.gallery-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.gallery-item {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.gallery-item figcaption {
  padding: 0.7rem 0.9rem 0.9rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.project-extra-links {
  margin-bottom: 1rem;
}

.project-missing {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--text-muted);
}

.project-missing .btn {
  margin-top: 1.25rem;
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .hero-layout {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  .hero-photo-wrap {
    order: -1;
    justify-self: start;
  }

  .hero-photo {
    width: 160px;
    height: 160px;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .menu-btn {
    display: grid;
  }

  .nav {
    position: fixed;
    inset: var(--header-h) 0 auto 0;
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    background: rgba(11, 15, 20, 0.96);
    border-bottom: 1px solid var(--border);
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    transition: transform var(--transition), opacity var(--transition);
  }

  .nav.open {
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  .nav a {
    padding: 0.85rem 1rem;
    border-radius: 10px;
  }

  body.nav-open {
    overflow: hidden;
  }
}

@media (max-width: 520px) {
  .hero {
    padding-top: 3.5rem;
  }

  .hero-cta {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }

  .project-card {
    grid-template-columns: 1fr;
  }

  .project-thumb {
    width: 100%;
    min-height: 160px;
    height: 160px;
  }

  .project-hero-cover img {
    height: 200px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .btn:hover,
  .timeline-item:hover,
  .project-card:hover,
  .course-card:hover,
  .contact-card:hover {
    transform: none;
  }
}
