@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #07111f;
  --panel: #0d1b2e;
  --panel2: #10243c;
  --text: #edf5ff;
  --muted: #9db0c8;
  --line: rgba(255, 255, 255, .10);
  --accent: #62d7ff;
  --accent2: #8b7cff;
  --shadow: 0 24px 70px rgba(0, 0, 0, .35);
}

* {
  box-sizing: border-box
}

html {
  scroll-behavior: smooth
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(98, 215, 255, .12), transparent 28%),
    radial-gradient(circle at 92% 18%, rgba(139, 124, 255, .13), transparent 27%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.7;
}

body.light {
  --bg: #f3f7fb;
  --panel: #fff;
  --panel2: #eef5fb;
  --text: #102033;
  --muted: #5d6e82;
  --line: rgba(16, 32, 51, .12);
  --shadow: 0 20px 60px rgba(20, 50, 80, .12);
}

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

.container {
  width: min(1180px, calc(100% - 36px));
  margin: auto
}

.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(7, 17, 31, .82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

body.light .nav {
  background: rgba(243, 247, 251, .88)
}

.nav-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 20px
}

.brand {
  font-weight: 800;
  letter-spacing: -.04em;
  white-space: nowrap
}

.brand span {
  color: var(--accent)
}

.nav-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1
}

.nav-links a {
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  transition: .2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: rgba(255, 255, 255, .06)
}

.page-menu {
  position: relative
}

.page-menu summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.page-menu summary::-webkit-details-marker {
  display: none
}

.page-menu[open] summary {
  color: var(--text)
}

.page-menu-list {
  position: absolute;
  right: 0;
  top: 45px;
  width: 270px;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 3px;
}

.page-menu-list a {
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px
}

.page-menu-list a:hover {
  background: var(--panel2);
  color: var(--text)
}

.actions {
  display: flex;
  gap: 7px
}

.icon-btn,
.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 13px;
  cursor: pointer
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  font-weight: 700
}

.btn.primary {
  background: var(--accent);
  color: #04111c;
  border-color: transparent
}

.hero {
  padding: 82px 0 65px;
  display: grid;
  grid-template-columns: 1.55fr .75fr;
  gap: 45px;
  align-items: center;
}

.eyebrow {
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px
}

.hero h1 {
  font-size: clamp(42px, 7vw, 76px);
  line-height: 1.03;
  letter-spacing: -.055em;
  margin: 12px 0
}

.hero h2 {
  font-size: clamp(19px, 2.4vw, 28px);
  color: var(--muted);
  margin: 0 0 20px
}

.hero p {
  max-width: 780px;
  color: var(--muted);
  font-size: 17px
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 25px
}

.hero-card {
  background: linear-gradient(145deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 25px;
  box-shadow: var(--shadow)
}

.avatar {
  width: 100px;
  height: 100px;
  border-radius: 28px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #06111e;
  font-size: 35px;
  font-weight: 900;
  margin-bottom: 22px
}

.quick {
  display: grid;
  gap: 13px
}

.quick div {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px
}

.quick small {
  color: var(--muted)
}

section {
  padding: 58px 0
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 25px;
  gap: 20px
}

.section-head h3 {
  font-size: 30px;
  margin: 0;
  letter-spacing: -.04em
}

.section-head p {
  margin: 0;
  color: var(--muted)
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px
}

.card {
  background: linear-gradient(145deg, var(--panel), var(--panel2));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px
}

.card h4 {
  margin: 0 0 8px;
  font-size: 18px
}

.card p,
.card li {
  color: var(--muted)
}

.timeline {
  position: relative;
  margin-left: 10px;
  padding-left: 30px;
  border-left: 1px solid var(--line)
}

.item {
  position: relative;
  margin-bottom: 38px
}

.item:before {
  content: "";
  position: absolute;
  left: -37px;
  top: 8px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(98, 215, 255, .12)
}

.item h4 {
  margin: 0;
  font-size: 21px
}

.meta {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700
}

.item p,
.item li {
  color: var(--muted)
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0
}

.tag {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  background: rgba(255, 255, 255, .025)
}

.skill {
  margin: 14px 0
}

.skill-top {
  display: flex;
  justify-content: space-between;
  font-size: 14px
}

.bar {
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .08);
  margin-top: 7px;
  overflow: hidden
}

.bar i {
  display: block;
  height: 100%;
  width: var(--w);
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 99px
}

.project {
  min-height: 270px
}

.project .project-number {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: .12em
}

.metric {
  font-size: 34px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin: 8px 0 12px
}

.project ul {
  padding-left: 18px
}

.project .stack {
  margin-top: 16px
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px
}

.footer {
  padding: 45px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center
}

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: .7s ease
}

.reveal.visible {
  opacity: 1;
  transform: none
}

.back-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 40
}

.back-top.show {
  opacity: 1;
  pointer-events: auto
}

.rtl {
  direction: rtl;
  text-align: right;
  font-family: Vazirmatn, Inter, sans-serif
}

.rtl .timeline {
  margin-left: 0;
  margin-right: 10px;
  padding-left: 0;
  padding-right: 30px;
  border-left: 0;
  border-right: 1px solid var(--line)
}

.rtl .item:before {
  left: auto;
  right: -37px
}

.rtl .nav-links {
  direction: rtl
}

.rtl .quick div {
  direction: rtl
}

.rtl .project ul {
  padding-left: 0;
  padding-right: 18px
}

@media(max-width:1000px) {
  .nav-links {
    display: none
  }

  .hero {
    grid-template-columns: 1fr;
    padding-top: 55px
  }

  .grid {
    grid-template-columns: 1fr 1fr
  }
}

@media(max-width:620px) {
  .container {
    width: calc(100% - 24px)
  }

  .grid,
  .contact-grid {
    grid-template-columns: 1fr
  }

  .hero h1 {
    font-size: 48px
  }

  .hero {
    padding-bottom: 25px
  }

  .section-head {
    display: block
  }

  .nav-inner {
    min-height: 62px
  }

  .page-menu {
    margin-left: auto
  }

  .actions .icon-btn {
    padding: 8px 10px
  }
}

/* ---------- Professional A4 PDF / print layout ---------- */
@page {
  size: A4;
  margin: 11mm 12mm 12mm
}

@media print {

  html,
  body {
    background: #fff !important;
    color: #17202b !important
  }

  body {
    font-family: Inter, Arial, sans-serif !important;
    font-size: 10.1pt;
    line-height: 1.43;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact
  }

  body.rtl {
    font-family: Vazirmatn, Arial, sans-serif !important
  }

  .nav,
  .actions,
  .hero-actions,
  .back-top {
    display: none !important
  }

  .container {
    width: 100%;
    max-width: none
  }

  /* Keep the visual hierarchy, but make the printed document compact and clean. */
  .hero {
    padding: 0 0 7mm;
    display: grid;
    grid-template-columns: 1.65fr .75fr;
    gap: 8mm;
    min-height: 0;
    break-inside: avoid;
    page-break-inside: avoid
  }

  .hero h1 {
    font-size: 29pt;
    line-height: 1.03;
    margin: 1.5mm 0
  }

  .hero h2 {
    font-size: 13pt;
    color: #3f5265;
    margin: 0 0 2.5mm
  }

  .hero p {
    font-size: 9.35pt;
    color: #40505f;
    margin: 0;
    max-width: 170mm
  }

  .eyebrow {
    font-size: 7.7pt;
    letter-spacing: .12em
  }

  .hero-card,
  .card {
    background: #fff !important;
    color: #17202b !important;
    box-shadow: none !important;
    border: 1px solid #d8e0e7 !important;
    border-radius: 6px;
    padding: 3.7mm
  }

  .hero-card {
    border-top: 2.5px solid var(--accent) !important
  }

  .avatar {
    width: 18mm;
    height: 18mm;
    border-radius: 4.5mm;
    font-size: 15pt;
    margin-bottom: 2.5mm
  }

  .quick {
    gap: 1.5mm
  }

  .quick div {
    padding-bottom: 1.1mm;
    border-color: #e0e5ea
  }

  .quick small,
  .card p,
  .card li,
  .item p,
  .item li,
  .section-head p {
    color: #536271 !important
  }

  section {
    padding: 3.8mm 0;
    break-inside: auto;
    page-break-inside: auto
  }

  .section-head {
    margin-bottom: 2.8mm;
    border-bottom: 1px solid #d8e0e7;
    padding-bottom: 1.2mm;
    break-inside: avoid;
    page-break-inside: avoid;
    break-after: avoid;
    page-break-after: avoid
  }

  .section-head h3 {
    font-size: 15.5pt;
    color: #17202b
  }

  /* Critical: don't let a section title become the last item on a page. */
  .section-head+.grid,
  .section-head+.timeline,
  .section-head+.contact-grid {
    break-before: avoid;
    page-break-before: avoid
  }

  .grid {
    gap: 3mm
  }

  .card {
    break-inside: avoid;
    page-break-inside: avoid
  }

  .card h4 {
    font-size: 11.3pt
  }

  .timeline {
    padding-left: 5mm;
    margin-left: 1mm;
    border-color: #dce2e8
  }

  .rtl .timeline {
    padding-left: 0;
    padding-right: 5mm;
    margin-right: 1mm;
    border-color: #dce2e8
  }

  .item {
    margin-bottom: 4.5mm;
    break-inside: avoid;
    page-break-inside: avoid
  }

  .item:before {
    left: -6.8mm;
    width: 2.8mm;
    height: 2.8mm;
    box-shadow: none
  }

  .rtl .item:before {
    left: auto;
    right: -6.8mm
  }

  .tags {
    gap: 1.4mm
  }

  .tag {
    padding: .9mm 1.6mm;
    font-size: 7.7pt;
    border-color: #dce2e8;
    color: #4d5d6c
  }

  .skill {
    margin: 2.3mm 0;
    break-inside: avoid;
    page-break-inside: avoid
  }

  .bar {
    height: 1.3mm;
    background: #e8edf2
  }

  .bar i {
    background: #2d8fba
  }

  .project {
    min-height: 0;
    break-inside: avoid;
    page-break-inside: avoid
  }

  .project .metric {
    font-size: 16.5pt
  }

  .project p,
  .project li {
    font-size: 8.7pt
  }

  .footer {
    display: none
  }

  a {
    color: inherit !important
  }

  .reveal {
    opacity: 1 !important;
    transform: none !important
  }

  #projects .grid {
    grid-template-columns: 1fr 1fr
  }

  #skills .card {
    columns: 2;
    column-gap: 8mm
  }

  #skills .skill {
    break-inside: avoid;
    page-break-inside: avoid
  }

  h1,
  h2,
  h3,
  h4 {
    orphans: 3;
    widows: 3
  }

  p,
  li {
    orphans: 3;
    widows: 3
  }

  /* Correct bidirectional rendering for phone numbers, email and URLs. */
  .ltr-value {
    direction: ltr !important;
    unicode-bidi: isolate;
    text-align: left;
    display: inline-block
  }

  .rtl .ltr-value {
    text-align: left
  }

  /* Combined-CV engineering foundation stays together with the hero. */
  .foundation {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-top: 4mm;
    gap: 2.5mm
  }

  .foundation>div {
    padding: 2.5mm 3mm;
    border-radius: 4px
  }

  .foundation strong {
    font-size: 9.3pt;
    margin-bottom: 1mm
  }

  .foundation span {
    font-size: 8.3pt
  }
}

.language-btn {
  text-decoration: none !important;
  min-width: 40px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
}

.foundation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
  max-width: 780px;
}

.foundation>div {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel2);
}

.foundation strong,
.foundation span {
  display: block
}

.foundation strong {
  font-size: 13px;
  margin-bottom: 4px
}

.foundation span {
  font-size: 12px;
  color: var(--muted)
}

@media(max-width:720px) {
  .foundation {
    grid-template-columns: 1fr
  }
}