:root {
  --paper: #f3f0e8;
  --paper-elevated: #fbfaf6;
  --ink: #161a18;
  --muted: #626964;
  --line: #d7d4ca;
  --accent: #285944;
  --accent-soft: #dce9e0;
  --signal: #b95f35;
  --shadow: 0 22px 70px rgba(22, 26, 24, 0.09);
  --radius: 22px;
  --shell: min(1180px, calc(100% - 40px));
  --header-height: 72px;
}

html[data-theme="dark"] {
  --paper: #111512;
  --paper-elevated: #191e1a;
  --ink: #eef2ed;
  --muted: #a9b1ab;
  --line: #333b35;
  --accent: #9bc7aa;
  --accent-soft: #24382c;
  --signal: #e09a72;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 92% 8%, color-mix(in srgb, var(--accent-soft) 75%, transparent), transparent 29rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  transition: color 180ms ease, background-color 180ms ease;
}

::selection {
  color: var(--paper-elevated);
  background: var(--accent);
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: var(--paper-elevated);
  background: var(--ink);
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.shell {
  width: var(--shell);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  z-index: 100;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: var(--header-height);
  padding-inline: max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(18px);
}

.brand,
.header-actions,
.desktop-nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  width: fit-content;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: var(--paper-elevated);
  background: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.brand-name {
  font-size: 0.93rem;
  font-weight: 750;
  letter-spacing: -0.015em;
}

.desktop-nav {
  gap: 24px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}

.desktop-nav a {
  position: relative;
}

.desktop-nav a::after {
  position: absolute;
  right: 0;
  bottom: -8px;
  left: 0;
  height: 2px;
  content: "";
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 160ms ease;
}

.desktop-nav a:hover,
.desktop-nav a:focus-visible {
  color: var(--ink);
}

.desktop-nav a:hover::after,
.desktop-nav a:focus-visible::after {
  transform: scaleX(1);
}

.header-actions {
  justify-content: flex-end;
  gap: 10px;
}

.icon-button,
.button {
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  color: var(--ink);
  border-color: var(--line);
  background: transparent;
}

.icon-button:hover,
.icon-button:focus-visible,
.button:hover,
.button:focus-visible {
  transform: translateY(-2px);
}

.button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  color: var(--paper-elevated);
  background: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

.button-small {
  min-height: 38px;
  padding: 8px 15px;
  font-size: 0.78rem;
}

.button-ghost {
  color: var(--ink);
  border-color: var(--line);
  background: transparent;
}

.button-ghost:hover,
.button-ghost:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(310px, 0.75fr);
  gap: clamp(42px, 8vw, 110px);
  align-items: center;
  min-height: calc(100svh - var(--header-height));
  padding-block: 76px;
}

.eyebrow,
.card-kicker {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 820px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.35rem, 7.4vw, 7.5rem);
  font-weight: 500;
  letter-spacing: -0.065em;
  line-height: 0.93;
}

.hero-lead {
  max-width: 730px;
  margin: 32px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.tag-list,
.mini-tags,
.tool-strip,
.plain-list,
.achievement-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 38px;
}

.tag-list li,
.mini-tags li,
.tool-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
}

.tag-list li {
  padding: 7px 12px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  background: color-mix(in srgb, var(--paper-elevated) 60%, transparent);
}

.identity-card {
  position: relative;
  overflow: hidden;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 8px);
  background: color-mix(in srgb, var(--paper-elevated) 88%, transparent);
  box-shadow: var(--shadow);
}

.identity-card::before {
  position: absolute;
  top: -85px;
  right: -70px;
  width: 210px;
  height: 210px;
  border: 50px solid var(--accent-soft);
  border-radius: 50%;
  content: "";
}

.portrait-monogram {
  position: relative;
  display: grid;
  width: 118px;
  height: 118px;
  margin-bottom: 58px;
  place-items: center;
  border-radius: 50%;
  color: var(--paper-elevated);
  background: var(--accent);
  box-shadow: inset 0 0 0 12px color-mix(in srgb, var(--paper-elevated) 14%, transparent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.identity-role,
.identity-location {
  color: var(--muted);
}

.identity-role {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.identity-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.25rem;
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.identity-location {
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.quick-facts {
  display: grid;
  gap: 14px;
  margin: 28px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.quick-facts div {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 14px;
}

.quick-facts dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.quick-facts dd {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 650;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  margin-bottom: 112px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper-elevated);
}

.metrics article {
  min-height: 150px;
  padding: 28px;
  border-right: 1px solid var(--line);
}

.metrics article:last-child {
  border-right: 0;
}

.metrics strong {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 4vw, 4.2rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 1;
}

.metrics strong span {
  color: var(--muted);
  font-size: 0.38em;
}

.metrics p {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.section {
  padding-block: 88px;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: grid;
  grid-template-columns: 70px minmax(0, 780px);
  gap: 26px;
  align-items: start;
  margin-bottom: 62px;
}

.section-number {
  margin: 7px 0 0;
  color: var(--signal);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
}

.section-heading h2,
.contact-section h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 5vw, 4.8rem);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1.03;
}

.two-column-copy {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(26px, 6vw, 76px);
  padding-left: 96px;
}

.two-column-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.timeline {
  display: grid;
}

.timeline-item {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 44px;
  padding-block: 38px;
  border-top: 1px solid var(--line);
}

.timeline-item:last-child {
  border-bottom: 1px solid var(--line);
}

.timeline-meta p,
.timeline-meta span {
  margin: 0;
}

.timeline-meta p {
  font-size: 0.84rem;
  font-weight: 750;
}

.timeline-meta span {
  color: var(--muted);
  font-size: 0.78rem;
}

.role-heading {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
}

.timeline-content h3,
.education-card h3,
.project-card h3,
.skills-grid h3 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.role-heading p,
.institution {
  margin: 5px 0 0;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
}

.status-pill {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.achievement-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.achievement-list li {
  position: relative;
  padding-left: 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.achievement-list li::before {
  position: absolute;
  top: 0.73em;
  left: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  content: "";
  background: var(--accent);
}

.compact-copy {
  margin: 8px 0 0;
  color: var(--muted);
}

.education-grid,
.project-grid,
.skills-grid {
  display: grid;
  gap: 18px;
}

.education-grid {
  grid-template-columns: 1.15fr 1fr 1fr;
}

.education-card,
.project-card,
.skills-grid article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper-elevated) 82%, transparent);
}

.education-card {
  min-height: 300px;
  padding: 28px;
}

.featured-card {
  color: var(--paper-elevated);
  border-color: var(--accent);
  background: var(--accent);
}

.featured-card .card-kicker,
.featured-card .institution,
.featured-card p {
  color: color-mix(in srgb, var(--paper-elevated) 78%, transparent);
}

.education-card > p:last-child,
.project-card > p,
.skills-grid p {
  color: var(--muted);
}

.featured-card > p:last-child {
  color: color-mix(in srgb, var(--paper-elevated) 78%, transparent);
}

.plain-list {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.88rem;
}

.plain-list li {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.project-grid {
  grid-template-columns: repeat(3, 1fr);
}

.project-card {
  display: flex;
  min-height: 290px;
  flex-direction: column;
  justify-content: space-between;
  padding: 26px;
}

.project-card-wide {
  grid-column: span 2;
  min-height: 320px;
  color: var(--paper-elevated);
  border-color: var(--ink);
  background: var(--ink);
}

.project-card-wide .card-kicker,
.project-card-wide p {
  color: color-mix(in srgb, var(--paper-elevated) 70%, transparent);
}

.project-card-wide a {
  color: var(--paper-elevated);
  font-size: 0.82rem;
  font-weight: 750;
}

.project-footer {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  justify-content: space-between;
}

.mini-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 26px;
}

.mini-tags li {
  padding: 5px 9px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

.project-card-wide .mini-tags li {
  color: color-mix(in srgb, var(--paper-elevated) 75%, transparent);
  border-color: color-mix(in srgb, var(--paper-elevated) 24%, transparent);
}

.skills-grid {
  grid-template-columns: repeat(2, 1fr);
}

.skills-grid article {
  padding: 26px;
}

.skills-grid p {
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.tool-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 28px;
}

.tool-strip span {
  padding: 9px 13px;
  font-size: 0.75rem;
  font-weight: 700;
}

.contact-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 50px;
  align-items: end;
  margin-top: 88px;
  margin-bottom: 48px;
  padding: clamp(34px, 6vw, 70px);
  border-radius: calc(var(--radius) + 10px);
  color: var(--paper-elevated);
  background: var(--accent);
}

.contact-section .eyebrow {
  color: color-mix(in srgb, var(--paper-elevated) 70%, transparent);
}

.contact-section h2 {
  max-width: 830px;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.contact-section .button {
  color: var(--ink);
  background: var(--paper-elevated);
}

.contact-section .button-ghost {
  color: var(--paper-elevated);
  border-color: color-mix(in srgb, var(--paper-elevated) 46%, transparent);
  background: transparent;
}

.contact-section .button-ghost:hover,
.contact-section .button-ghost:focus-visible {
  color: var(--ink);
  background: var(--paper-elevated);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 30px;
  padding-block: 24px 44px;
  color: var(--muted);
  font-size: 0.76rem;
}

.site-footer p {
  margin: 0;
}

.toast {
  position: fixed;
  z-index: 300;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 11px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--paper-elevated);
  background: var(--ink);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 65%, white);
  outline-offset: 3px;
}

@media (max-width: 980px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .desktop-nav {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 94px;
  }

  .identity-card {
    max-width: 620px;
  }

  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .metrics article:nth-child(2) {
    border-right: 0;
  }

  .metrics article:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .timeline-item {
    grid-template-columns: 180px minmax(0, 1fr);
  }

  .education-grid,
  .project-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .education-card:last-child {
    grid-column: span 2;
    min-height: auto;
  }

  .project-card-wide {
    grid-column: span 2;
  }

  .contact-section {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .contact-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 700px) {
  :root {
    --shell: min(100% - 24px, 1180px);
    --header-height: 64px;
    --radius: 17px;
  }

  .site-header {
    min-height: var(--header-height);
    padding-inline: 12px;
  }

  .brand-name,
  #printResume {
    display: none;
  }

  .hero {
    gap: 38px;
    padding-block: 58px 70px;
  }

  .hero h1 {
    font-size: clamp(3rem, 15vw, 5.1rem);
  }

  .hero-lead {
    margin-top: 24px;
  }

  .identity-card {
    padding: 22px;
  }

  .portrait-monogram {
    width: 92px;
    height: 92px;
    margin-bottom: 38px;
  }

  .metrics {
    margin-bottom: 68px;
  }

  .metrics article {
    min-height: 118px;
    padding: 20px;
  }

  .section {
    padding-block: 62px;
  }

  .section-heading {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    margin-bottom: 38px;
  }

  .section-number {
    font-size: 1.25rem;
  }

  .section-heading h2,
  .contact-section h2 {
    font-size: clamp(2.25rem, 10vw, 3.4rem);
  }

  .two-column-copy {
    grid-template-columns: 1fr;
    gap: 18px;
    padding-left: 0;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-block: 30px;
  }

  .timeline-meta {
    display: flex;
    gap: 10px;
    align-items: baseline;
  }

  .role-heading {
    display: grid;
  }

  .status-pill {
    width: fit-content;
  }

  .education-grid,
  .project-grid,
  .skills-grid {
    grid-template-columns: 1fr;
  }

  .education-card,
  .education-card:last-child,
  .project-card,
  .project-card-wide {
    grid-column: auto;
    min-height: auto;
  }

  .project-card {
    gap: 30px;
  }

  .project-footer {
    display: grid;
    align-items: start;
  }

  .contact-section {
    gap: 34px;
    margin-top: 60px;
    padding: 26px;
  }

  .contact-actions,
  .contact-actions .button {
    width: 100%;
  }

  .site-footer {
    display: grid;
    gap: 6px;
  }
}

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

@media print {
  :root {
    --paper: #fff;
    --paper-elevated: #fff;
    --ink: #111;
    --muted: #444;
    --line: #ccc;
    --accent: #214b3a;
    --accent-soft: #edf3ef;
    --signal: #8a4224;
    --shadow: none;
    --shell: 100%;
  }

  @page {
    size: A4;
    margin: 13mm;
  }

  body {
    background: #fff;
    font-size: 9.4pt;
  }

  .site-header,
  .hero-actions,
  .contact-section,
  .site-footer,
  .toast {
    display: none !important;
  }

  .hero {
    grid-template-columns: 1.55fr 0.7fr;
    min-height: auto;
    padding-block: 0 11mm;
    break-after: avoid;
  }

  .hero h1 {
    font-size: 39pt;
  }

  .hero-lead {
    margin-top: 4mm;
    font-size: 10pt;
  }

  .tag-list {
    margin-top: 5mm;
  }

  .identity-card {
    padding: 5mm;
    box-shadow: none;
  }

  .portrait-monogram {
    width: 24mm;
    height: 24mm;
    margin-bottom: 8mm;
  }

  .metrics {
    margin-bottom: 10mm;
  }

  .metrics article {
    min-height: auto;
    padding: 4mm;
  }

  .metrics strong {
    font-size: 25pt;
  }

  .section {
    padding-block: 8mm;
    break-inside: auto;
  }

  .section-heading {
    margin-bottom: 6mm;
  }

  .section-heading h2 {
    font-size: 25pt;
  }

  .timeline-item,
  .education-card,
  .project-card,
  .skills-grid article {
    break-inside: avoid;
  }

  .timeline-item {
    grid-template-columns: 42mm 1fr;
    gap: 6mm;
    padding-block: 5mm;
  }

  .education-card,
  .project-card,
  .skills-grid article {
    padding: 5mm;
  }

  .project-card,
  .project-card-wide,
  .education-card {
    min-height: auto;
  }
}

/* ============================================================
   Persian language & RTL support (additive — English unchanged)
   ============================================================ */
html[lang="fa"] body {
  font-family: Vazirmatn, Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Persian display text: Georgia's tight tracking breaks Farsi letterforms */
html[lang="fa"] .hero h1,
html[lang="fa"] .identity-card h2,
html[lang="fa"] .metrics strong,
html[lang="fa"] .section-heading h2,
html[lang="fa"] .contact-section h2,
html[lang="fa"] .section-number {
  font-family: "Peyda", Vazirmatn, Georgia, "Times New Roman", serif;
  letter-spacing: normal;
}

html[lang="fa"] .hero h1 {
  line-height: 1.2;
}

html[lang="fa"] .eyebrow,
html[lang="fa"] .card-kicker,
html[lang="fa"] .identity-role,
html[lang="fa"] .quick-facts dt {
  letter-spacing: 0;
}

/* Keep Latin brand marks and software names in the Latin face */
html[lang="fa"] .tool-strip span,
html[lang="fa"] .brand-mark,
html[lang="fa"] .portrait-monogram {
  font-family: Inter, ui-sans-serif, sans-serif;
}

/* --- RTL layout mirroring for physical (non-logical) properties --- */
[dir="rtl"] .two-column-copy {
  padding-left: 0;
  padding-right: 96px;
}

[dir="rtl"] .achievement-list li {
  padding-left: 0;
  padding-right: 20px;
}

[dir="rtl"] .achievement-list li::before {
  left: auto;
  right: 0;
}

[dir="rtl"] .identity-card::before {
  right: auto;
  left: -70px;
}

[dir="rtl"] .toast {
  right: auto;
  left: 20px;
}

[dir="rtl"] .skip-link {
  left: auto;
  right: 12px;
}

[dir="rtl"] .desktop-nav a::after {
  transform-origin: right;
}

@media (max-width: 700px) {
  [dir="rtl"] .two-column-copy {
    padding-right: 0;
  }
}


/* ============================================================
   v2 refinements: language dropdown, fade, identity contacts,
   hero alignment, contact-section fix
   ============================================================ */

/* Smooth cross-fade when switching language (no hard cut) */
body {
  transition: color 180ms ease, background-color 180ms ease, opacity 170ms ease;
}
body.lang-fading {
  opacity: 0;
}

/* Persian body text uses Vazirmatn; titles use Peyda (handled above) */
html[lang="fa"] body {
  font-family: Vazirmatn, Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ---- Language dropdown ---- */
.lang-select {
  position: relative;
}

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease;
}

.lang-trigger:hover,
.lang-trigger:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.lang-flag {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.lang-caret {
  font-size: 0.7rem;
  color: var(--muted);
  transition: transform 160ms ease;
}

.lang-select.open .lang-caret {
  transform: rotate(180deg);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 200;
  min-width: 168px;
  margin: 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper-elevated);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.lang-select.open .lang-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.lang-menu li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 650;
  cursor: pointer;
}

.lang-menu li:hover,
.lang-menu li[aria-selected="true"] {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---- Hero: top-align identity card with the main title ---- */
.hero {
  align-items: start;
}

/* ---- Identity card: circular contact buttons ---- */
.identity-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.id-contact {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper-elevated) 60%, transparent);
  transition: transform 160ms ease, border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.id-contact:hover,
.id-contact:focus-visible {
  transform: translateY(-2px);
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.id-contact svg {
  width: 19px;
  height: 19px;
}

/* ---- Contact section: keep actions bounded so they never overlap the heading ---- */
.contact-section {
  align-items: center;
}

.contact-actions {
  max-width: 360px;
}

@media (max-width: 980px) {
  .contact-actions {
    max-width: none;
  }
}

/* ============================================================
   v3: profile photo, Persian H1 tuning, micro-animations
   ============================================================ */

/* Profile photo in the identity card (shared by light & dark) */
.portrait-monogram.has-photo {
  padding: 0;
  background: none;
  overflow: hidden;
  box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--paper-elevated) 22%, transparent),
              0 10px 30px rgba(0, 0, 0, 0.18);
}

.portrait-monogram.has-photo img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* Persian main title: tighter leading & tracking, a touch bolder & smaller */
html[lang="fa"] .hero h1 {
  font-size: clamp(2.9rem, 6.3vw, 6.2rem);
  font-weight: 650;
  letter-spacing: -0.012em;
  line-height: 1.05;
}

/* ---- Micro-animations ---- */
@media (prefers-reduced-motion: no-preference) {
  .reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
                transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  .reveal.in-view {
    opacity: 1;
    transform: none;
  }
}

/* Subtle hover lift on cards */
.project-card,
.education-card,
.skills-grid article {
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.project-card:not(.project-card-wide):hover,
.education-card:not(.featured-card):hover,
.skills-grid article:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.10);
}

/* Gentle press feedback on all buttons/links with the button style */
.button:active,
.icon-button:active,
.id-contact:active,
.lang-trigger:active {
  transform: translateY(0) scale(0.97);
}

/* Never let reveal hide content in print */
@media print {
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}


/* ============================================================
   v4: snug hero top spacing (fit title + card above the fold)
   ============================================================ */
@media (min-width: 981px) {
  .hero {
    padding-block: 34px 72px;
  }
}

/* English/default: minimal title shrink so title + card group without reflow */
html[lang="en"] .hero h1 {
  font-size: clamp(3rem, 6.4vw, 6.4rem);
}

/* Slightly shorter identity card so it sits with the title */
.portrait-monogram {
  margin-bottom: 40px;
}

/* ============================================================
   v5: print fixes for first page (EN + FA)
   ============================================================ */
@media print {
  /* Hide screen-only chrome that leaks into the printed page */
  .skip-link,
  .identity-contacts,
  .lang-select {
    display: none !important;
  }

  /* Decorative arc overlaps the card text on paper — remove it */
  .identity-card::before {
    display: none !important;
  }

  /* Give the hero two balanced columns and keep the title from overflowing */
  .hero {
    grid-template-columns: 1.45fr 1fr;
    gap: 8mm;
    align-items: start;
    padding-block: 0 8mm;
    break-after: avoid;
  }

  .hero h1 {
    font-size: 25pt;
    line-height: 1.06;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
  }

  html[lang="fa"] .hero h1 {
    font-size: 18pt;
    line-height: 1.4;
    letter-spacing: 0;
  }

  .hero-lead {
    margin-top: 3mm;
    font-size: 9.3pt;
  }

  .identity-card {
    padding: 4mm;
  }

  .identity-card h2 {
    font-size: 15pt;
  }

  .portrait-monogram {
    width: 20mm;
    height: 20mm;
    margin-bottom: 5mm;
  }

  .portrait-monogram.has-photo {
    box-shadow: none;
  }

  .quick-facts {
    margin-top: 5mm;
    padding-top: 4mm;
  }

  .metrics {
    margin-top: 6mm;
  }
}

/* ============================================================
   v6: keep identity-card text above the decorative arc
   ============================================================ */
.identity-card > * {
  position: relative;
  z-index: 1;
}

.identity-card::before {
  z-index: 0;
}

/* ============================================================
   v7: self-hosted Peyda so Persian titles work on any host (Vercel)
   local() lets machines that already have it skip the download.
   ============================================================ */
@font-face {
  font-family: "Peyda";
  src: local("Peyda Regular"), local("Peyda"),
       url("assets/fonts/Peyda-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Peyda";
  src: local("Peyda SemiBold"), local("Peyda-SemiBold"),
       url("assets/fonts/Peyda-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Peyda";
  src: local("Peyda Bold"), local("Peyda-Bold"),
       url("assets/fonts/Peyda-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
