/* ==========================================================================
   Dr. Mahdi Kohandani — site styles

   Photographs are never cropped, masked, filtered, rounded or overlaid: only their
   displayed size and position change, and every image keeps its intrinsic ratio.
   Instead of altering photos, the page around them is colour-matched:
     • hero sky   — sampled from the panorama's top edge, so its sky runs into the page
     • stage      — sampled from the portrait's edges (bookshelf above, navy suit below)
     • logo sheet — pure white, so the institutions' white logo grounds disappear
   ========================================================================== */

/* 1. Fonts ---------------------------------------------------------------- */

@font-face {
  font-family: "Source Sans 3";
  src: url("../fonts/SourceSans3-Variable-latin.woff") format("woff");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Libre Baskerville";
  src: url("../fonts/LibreBaskerville-Variable-latin.woff") format("woff");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* 2. Tokens --------------------------------------------------------------- */

:root {
  --paper: #f7f3ea;
  --paper-deep: #efe8da;
  --sheet: #ffffff;
  --ink: #1e2320;
  --ink-soft: #3d443f;
  --muted: #5b625d;
  --green: #1f4a3a;
  --green-deep: #153528;
  --green-soft: #e3ebe4;
  --green-line: rgba(31, 74, 58, 0.32);
  --line: #ddd5c5;
  --error: #8a2a1d;
  --error-bg: #fbeeea;
  --success-bg: #e6efe8;
  --night: #1b201d;
  --on-dark: #f3efe4;
  --on-dark-soft: rgba(243, 239, 228, 0.78);

  /* Portrait stage — sampled from profile.jpg edges. */
  --stage-glow: #4d5b5f;
  --stage-top: #343f46;
  --stage-mid: #141d2a;
  --stage-bottom: #070f20;

  /* Panorama top edge, left → right — sampled from SAM_0817-2.jpg. */
  --sky-0: #b4d2f7;
  --sky-1: #b8d3f7;
  --sky-2: #b0d4fc;
  --sky-3: #bcddfc;
  --sky-4: #d9ebfd;
  --sky-5: #e9f3fd;
  --sky-6: #eff7fe;
  --sky-7: #f6fafd;
  --sky-8: #fdfefe;

  --serif: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --persian: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;

  --gutter: clamp(20px, 4.6vw, 56px);
  --max: 1240px;
  --header-h: 76px;
  --radius: 4px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-soft: 0 1px 2px rgba(30, 35, 32, 0.05), 0 22px 48px -32px rgba(30, 35, 32, 0.38);
}

/* Each language scope picks its own type. CVs and language labels carry their own lang. */
[lang="de"], [lang="en"], [lang="fr"] {
  --serif: "Libre Baskerville", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-family: var(--sans);
}
[lang="fa"] {
  --serif: var(--persian);
  --sans: var(--persian);
  font-family: var(--persian);
}

/* 3. Base ----------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 20px);
}
/* Smooth in-page scrolling starts after load, so arriving at #contact-form (after sending) is a jump. */
@media (prefers-reduced-motion: no-preference) {
  html.smooth-scroll { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.125rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}
body:lang(fa) { line-height: 1.9; }
.cv-content:lang(de), .cv-content:lang(en), .cv-content:lang(fr) { line-height: 1.65; }

img { display: block; max-width: 100%; height: auto; }
figure { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 400; }
p { margin: 0 0 1.1em; text-wrap: pretty; }
a { color: var(--green); text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: #cfe0d2; color: var(--ink); }

:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
.online :focus-visible, .site-footer :focus-visible { outline-color: var(--on-dark); }

.container { width: min(100% - 2 * var(--gutter), var(--max)); margin-inline: auto; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-inline-start: 16px;
  top: -100px;
  z-index: 200;
  padding: 12px 20px;
  background: var(--green);
  color: #fff;
  border-radius: var(--radius);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* 4. Type ----------------------------------------------------------------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 1.1rem;
  color: var(--green);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.16em;
  line-height: 1.35;
  text-transform: uppercase;
}
.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: currentColor;
  flex: none;
  transform-origin: left;
}
[dir="rtl"] .eyebrow::before { transform-origin: right; }
.js .reveal-pending .eyebrow::before { transform: scaleX(0); }
.js .reveal-pending.is-revealed .eyebrow::before { transform: scaleX(1); transition: transform 0.9s var(--ease) 0.3s; }
.eyebrow:lang(fa) { font-size: 0.95rem; letter-spacing: 0; text-transform: none; font-weight: 600; }
.eyebrow--icon::before { display: none; }

.display {
  font-family: var(--serif);
  font-size: clamp(2rem, 1.3rem + 2.5vw, 3.3rem);
  line-height: 1.14;
  letter-spacing: -0.015em;
  margin-bottom: 0.55em;
  text-wrap: balance;
}
.display:lang(fa) { font-weight: 650; letter-spacing: 0; line-height: 1.45; font-size: clamp(1.85rem, 1.25rem + 2.2vw, 2.9rem); }

.lead { font-size: clamp(1.14rem, 1.02rem + 0.42vw, 1.32rem); line-height: 1.6; color: var(--ink-soft); }
.lead:lang(fa) { line-height: 1.95; }

.subhead {
  margin: 2.6rem 0 1.1rem;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.subhead:lang(fa) { font-size: 0.98rem; letter-spacing: 0; text-transform: none; }

.section { padding-block: clamp(76px, 9vw, 140px); }
.section-head { max-width: 780px; margin-bottom: clamp(40px, 5vw, 68px); }
.section-head .lead { margin-bottom: 0; }

/* 5. Buttons -------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  min-height: 46px;
  padding: 0.7em 1.35em;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s, border-color 0.25s, transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.btn--primary { background: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-deep); transform: translateY(-1px); box-shadow: 0 12px 24px -14px rgba(21, 53, 40, 0.65); }
.btn--ghost { background: rgba(255, 255, 255, 0.55); color: var(--green); border-color: var(--green-line); }
.btn--ghost:hover { background: var(--green-soft); border-color: var(--green); }
.btn--large { min-height: 54px; padding: 0.85em 1.6em; font-size: 1.06rem; }
.btn--small { min-height: 40px; padding: 0.5em 1.05em; font-size: 0.95rem; }
.btn--block { width: 100%; }
.btn:lang(fa) { font-weight: 600; }
.btn:active { transform: translateY(0); }

.icon { width: 1.15em; height: 1.15em; flex: none; }
.icon--arrow { transition: transform 0.35s var(--ease); }
.btn:hover .icon--arrow { transform: translateX(3px); }
[dir="rtl"] .icon--arrow { transform: scaleX(-1); }
[dir="rtl"] .btn:hover .icon--arrow { transform: scaleX(-1) translateX(3px); }

/* 6. Header --------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(247, 243, 234, 0.9);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.35s, box-shadow 0.35s, background-color 0.35s, transform 0.4s var(--ease);
}
html:not(.js) .site-header { position: relative; }
/* Small screens: the header steps aside while reading down and returns on the way up. */
.site-header.is-tucked { transform: translateY(-100%); box-shadow: none; }
.site-header.is-scrolled {
  background: rgba(247, 243, 234, 0.94);
  border-bottom-color: var(--line);
  box-shadow: 0 14px 30px -26px rgba(30, 35, 32, 0.5);
}

.header__bar {
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.8vw, 28px);
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-inline-end: auto;
  color: var(--ink);
  text-decoration: none;
  flex: none;
}
.brand__logo { width: 92px; height: auto; }
.brand__text { display: flex; flex-direction: column; line-height: 1.25; }
.brand__name { font-family: var(--serif); font-size: 1rem; white-space: nowrap; }
.brand__name:lang(fa) { font-weight: 700; }
.brand__role { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }

.nav__list {
  display: flex;
  align-items: center;
  gap: clamp(16px, 1.7vw, 28px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav__link {
  position: relative;
  display: inline-block;
  padding: 0.35em 0;
  color: var(--ink);
  font-size: 0.97rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.nav__link::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 2px;
  background: var(--green);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease);
}
[dir="rtl"] .nav__link::after { transform-origin: right; }
.nav__link:hover::after, .nav__link[aria-current]::after { transform: scaleX(1); }
.nav__link[aria-current] { color: var(--green); }
.nav__cta { display: none; }
@media (min-width: 1300px) and (max-width: 1399px) {
  .nav__list { gap: 14px; }
  .header__bar { gap: 14px; }
}
.header__cta { flex: none; white-space: nowrap; }

.lang {
  display: flex;
  flex: none;
  padding: 3px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.lang__option {
  appearance: none;
  min-height: 32px;
  padding: 0.45em 0.85em;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 550;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}
.lang__option:lang(fa) { font-size: 0.9rem; }
.lang__option:hover { background: var(--green-soft); color: var(--green); }
.lang__option[aria-pressed="true"] { background: var(--green); color: #fff; }

.menu-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.menu-toggle__icon { position: relative; width: 18px; height: 12px; }
.menu-toggle__icon span {
  position: absolute;
  inset-inline: 0;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.4s var(--ease), top 0.4s var(--ease);
}
.menu-toggle__icon span:first-child { top: 1px; }
.menu-toggle__icon span:last-child { top: 9px; }
.menu-toggle[aria-expanded="true"] .menu-toggle__icon span:first-child { top: 5px; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle__icon span:last-child { top: 5px; transform: rotate(-45deg); }

.scroll-progress {
  position: absolute;
  inset-inline: 0;
  bottom: -1px;
  height: 2px;
  pointer-events: none;
}
.scroll-progress span {
  display: block;
  height: 100%;
  background: var(--green);
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
}
[dir="rtl"] .scroll-progress span { transform-origin: right; }

/* 7. Hero ----------------------------------------------------------------- */

.hero { position: relative; }

.hero__upper {
  position: relative;
  isolation: isolate;
  padding-block: clamp(28px, 3.4vw, 52px) 0;
}

/* The panorama's own top-edge colours, continued upward and faded into the paper. */
.hero__sky {
  position: absolute;
  inset-block: 0;
  /* Same window as the panorama (max 1440px), so sky and photo read as one picture. */
  left: max(0px, calc(50% - 720px));
  right: max(0px, calc(50% - 720px));
  z-index: -1;
  background: linear-gradient(to right, var(--sky-0), var(--sky-1) 12.5%, var(--sky-2) 25%, var(--sky-3) 37.5%, var(--sky-4) 50%, var(--sky-5) 62.5%, var(--sky-6) 75%, var(--sky-7) 87.5%, var(--sky-8));
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.18) 34%, rgba(0, 0, 0, 0.7) 74%, #000 100%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.18) 34%, rgba(0, 0, 0, 0.7) 74%, #000 100%);
}

.hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(32px, 5.5vw, 88px);
  align-items: end;
}

.hero__copy { padding-bottom: clamp(36px, 4vw, 64px); }
.hero__eyebrow { margin-bottom: 1.2rem; }
.hero__name {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 1.5rem + 3.6vw, 4.6rem);
  line-height: 1.04;
  letter-spacing: -0.028em;
  margin: 0 0 0.3em;
  text-wrap: balance;
}
.hero__name:lang(fa) { font-weight: 700; letter-spacing: 0; line-height: 1.32; font-size: clamp(2.3rem, 1.4rem + 3.2vw, 4rem); }
.hero__role { font-family: var(--serif); font-size: clamp(1.1rem, 1rem + 0.5vw, 1.4rem); color: var(--green); margin-bottom: 1.3rem; }
.hero__role:lang(fa) { font-weight: 600; }
.hero__lead { max-width: 33em; font-size: clamp(1.1rem, 1rem + 0.45vw, 1.28rem); line-height: 1.6; color: var(--ink-soft); }
.hero__lead:lang(fa) { line-height: 1.95; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 1.7rem 0 2.2rem; }

.hero__facts {
  display: grid;
  grid-template-columns: repeat(3, auto);
  justify-content: start;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid rgba(30, 35, 32, 0.15);
}
.fact { padding: 16px 26px 0 0; }
[dir="rtl"] .fact { padding: 16px 0 0 26px; }
.fact + .fact { padding-inline-start: 26px; border-inline-start: 1px solid rgba(30, 35, 32, 0.15); }
.fact__value { display: block; font-family: var(--serif); font-size: 1.32rem; line-height: 1.3; color: var(--ink); white-space: nowrap; }
.fact__value:lang(fa) { font-weight: 700; font-size: 1.15rem; }
.fact__label { display: block; margin-top: 2px; font-size: 0.86rem; line-height: 1.4; color: var(--ink-soft); hyphens: auto; -webkit-hyphens: auto; overflow-wrap: normal; }

.hero__stage {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: clamp(28px, 3.4vw, 52px) clamp(20px, 3vw, 44px) 0;
  background:
    radial-gradient(90% 60% at 50% 22%, var(--stage-glow) 0%, rgba(77, 91, 95, 0) 70%),
    linear-gradient(to bottom, var(--stage-top) 0%, var(--stage-mid) 58%, var(--stage-bottom) 100%);
}
.hero__portrait { width: min(100%, 400px); }
.hero__portrait img { width: 100%; height: auto; }

.hero__panorama { max-width: 1440px; margin-inline: auto; }
.hero__panorama img { width: 100%; height: auto; }
.hero__caption {
  padding: 10px var(--gutter) 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: end;
}

/* Entrance — CSS only, so the hero never depends on JavaScript to appear. */
@media (prefers-reduced-motion: no-preference) {
  .hero__copy > * { animation: rise 0.95s var(--ease) both; }
  .hero__copy > :nth-child(1) { animation-delay: 0.05s; }
  .hero__copy > :nth-child(2) { animation-delay: 0.12s; }
  .hero__copy > :nth-child(3) { animation-delay: 0.2s; }
  .hero__copy > :nth-child(4) { animation-delay: 0.28s; }
  .hero__copy > :nth-child(5) { animation-delay: 0.36s; }
  .hero__copy > :nth-child(6) { animation-delay: 0.44s; }
  .hero__stage { animation: stage-in 1.1s var(--ease) both 0.1s; }
  .hero__portrait { animation: rise-far 1.25s var(--ease) both 0.3s; }
  .hero__sky { animation: fade 1.6s ease both; }
  .hero__panorama { animation: fade 1.4s ease both 0.35s; }
}
@keyframes rise { from { opacity: 0; transform: translate3d(0, 22px, 0); } }
@keyframes rise-far { from { opacity: 0; transform: translate3d(0, 44px, 0); } }
@keyframes stage-in { from { opacity: 0; transform: translate3d(0, 18px, 0); } }
@keyframes fade { from { opacity: 0; } }

/* 8. About ---------------------------------------------------------------- */

.about__grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas: "head body" "why body";
  grid-template-rows: auto 1fr;
  column-gap: clamp(40px, 6vw, 110px);
  align-items: start;
}
.about__head { grid-area: head; }
.about__head .display { margin-bottom: 0; }
.about__body { grid-area: body; }
.about__body > p { max-width: 38em; }
.about__body > p:last-child { margin-bottom: 0; }
.about__why {
  grid-area: why;
  margin-top: clamp(32px, 4vw, 56px);
  padding-top: 1.3rem;
  border-top: 2px solid var(--green);
  font-size: 1.02rem;
  color: var(--ink-soft);
}
.about__why h3 { font-family: var(--serif); font-size: 1.375rem; color: var(--ink); margin-bottom: 0.8rem; }
.about__why h3:lang(fa) { font-weight: 700; }
.about__why p:last-child { margin-bottom: 0; }

/* 9. Online learning ------------------------------------------------------ */

.online { background: var(--green); color: var(--on-dark); padding-block: clamp(64px, 7.5vw, 112px); }
.online .eyebrow { color: #cfe0d3; }
.online .display { color: #fff; }
.online .lead { color: var(--on-dark-soft); }

.features {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(22px, 2.6vw, 40px);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: feature;
}
.feature {
  position: relative;
  padding-top: 28px;
  border-top: 1px solid rgba(243, 239, 228, 0.22);
  counter-increment: feature;
}
.feature::before {
  content: "";
  position: absolute;
  top: -1px;
  inset-inline: 0;
  height: 1px;
  background: var(--on-dark);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.1s var(--ease) 0.2s;
}
[dir="rtl"] .feature::before { transform-origin: right; }
.feature.is-revealed::before, .feature:hover::before { transform: scaleX(1); }
html:not(.js) .feature::before { transform: scaleX(1); }
.feature__num { display: block; margin-bottom: 20px; font-family: var(--serif); font-size: 2.5rem; line-height: 1; color: rgba(243, 239, 228, 0.42); }
.feature__num::before { content: counter(feature, decimal-leading-zero); }
.feature__num:lang(fa)::before { content: counter(feature, persian); }
.feature__title { font-family: var(--serif); font-size: 1.375rem; color: #fff; margin-bottom: 0.5rem; }
.feature__title:lang(fa) { font-weight: 700; }
.feature__text { margin: 0; font-size: 1.02rem; color: var(--on-dark-soft); }

/* 10. Qualifications — a white sheet so the logos' white grounds vanish ----- */

.quals { background: var(--sheet); }

.timeline {
  --period-w: 150px;
  --marker-w: 40px;
  --spine: calc(var(--period-w) + var(--marker-w) / 2);
  --tl: 0;
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}
.timeline::before, .timeline::after {
  content: "";
  position: absolute;
  top: 52px;
  bottom: 52px;
  inset-inline-start: var(--spine);
  width: 1px;
  background: var(--line);
}
.timeline::after {
  width: 2px;
  margin-inline-start: -0.5px;
  background: var(--green);
  transform: scaleY(var(--tl));
  transform-origin: top;
}
html:not(.js) .timeline::after { transform: scaleY(1); }

.milestone {
  display: grid;
  grid-template-columns: var(--period-w) var(--marker-w) 210px minmax(0, 1fr);
  align-items: center;
  padding-block: 22px;
}
.milestone__period { margin: 0; font-family: var(--serif); font-size: 1.05rem; color: var(--green); font-variant-numeric: tabular-nums; white-space: nowrap; }
.milestone__period:lang(fa) { font-weight: 700; font-variant-numeric: normal; }
.milestone__marker {
  position: relative;
  z-index: 1;
  justify-self: center;
  width: 13px;
  height: 13px;
  border: 2px solid var(--green);
  border-radius: 50%;
  background: var(--sheet);
  transition: background-color 0.5s 0.25s, transform 0.5s var(--ease) 0.25s;
}
.milestone.is-revealed .milestone__marker, html:not(.js) .milestone__marker { background: var(--green); }
.milestone__logo { --logo-h: 56px; display: flex; align-items: center; justify-content: flex-start; height: 100px; padding-inline: 24px 12px; }
.milestone__logo img { width: auto; height: auto; max-width: 100%; max-height: var(--logo-h); }
/* Optical sizes: round seals read larger than wide wordmarks at the same height. */
.milestone__logo--tehran, .milestone__logo--allameh { --logo-h: 76px; }
.milestone__logo--heidelberg { --logo-h: 62px; }
.milestone__logo--bamf { --logo-h: 66px; }
.milestone__logo--goethe { --logo-h: 54px; }
.milestone__logo--jena { --logo-h: 50px; }
.milestone__body { padding-inline-start: 22px; }
.milestone__title { font-family: var(--serif); font-size: 1.375rem; line-height: 1.3; margin-bottom: 0.35rem; }
.milestone__title:lang(fa) { font-weight: 700; }
.milestone__text { margin: 0; max-width: 40em; font-size: 1.02rem; color: var(--ink-soft); }

/* 11. CVs ----------------------------------------------------------------- */

.cv { background: var(--paper-deep); }

.cv-viewer__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 32px;
  margin-bottom: 26px;
}
.cv-viewer__note { max-width: 36em; margin: 0; font-size: 0.94rem; color: var(--muted); }

.cv-tabs {
  position: relative;
  display: inline-flex;
  padding: 4px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.cv-tabs[hidden] { display: none; }
.cv-tab {
  position: relative;
  z-index: 1;
  appearance: none;
  min-height: 42px;
  padding: 0 1.3em;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--ink-soft);
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.35s;
}
.cv-tab:hover { color: var(--green); }
.cv-tab[aria-selected="true"] { color: #fff; }
.cv-tabs__indicator {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 0;
  width: var(--w, 0);
  border-radius: 999px;
  background: var(--green);
  transform: translateX(var(--x, 0));
  transition: transform 0.5s var(--ease), width 0.5s var(--ease);
}

.cv-doc {
  margin-bottom: 28px;
  padding: clamp(24px, 5vw, 64px);
  background: var(--sheet);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(30, 35, 32, 0.05), 0 12px 32px -26px rgba(30, 35, 32, 0.3);
}
.cv-doc:last-child { margin-bottom: 0; }
.cv-doc[hidden] { display: none; }
.cv-doc.is-entering { animation: rise 0.6s var(--ease) both; }
.cv-doc__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.cv-doc__lang { font-family: var(--serif); font-size: 1.65rem; }
.cv-doc__badge {
  padding: 0.35em 0.9em;
  border: 1px solid var(--green-line);
  border-radius: 999px;
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.cv-doc__badge:lang(fa) { font-size: 0.86rem; letter-spacing: 0; text-transform: none; }

/* Teacher-authored text: only typography changes here. */
.cv-content { font-size: 1.02rem; color: var(--ink); text-align: left; }
.cv-content > div > div:first-child {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 40px;
  margin-bottom: 0.5em;
  padding: 20px 24px;
  background: var(--paper);
}
.cv-content > div > div:first-child p { margin: 0 0 0.3em; }
.cv-content h4 {
  margin: 2.2em 0 0.9em;
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 1.22rem;
  color: var(--green);
}
.cv-content ul { margin: 0 0 1em; padding: 0; list-style: none; }
.cv-content li { position: relative; margin-bottom: 0.7em; padding-left: 1.4em; }
.cv-content li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.8em;
  width: 0.6em;
  height: 1px;
  background: var(--green);
}
.cv-content strong { font-weight: 650; }
.cv-content li > strong:first-child { color: var(--green); font-variant-numeric: tabular-nums; }
.cv-content em { color: var(--ink-soft); }
.cv-content > div > div:last-child { margin-top: 2em; color: var(--muted); font-size: 0.95rem; }
@media (min-width: 1100px) {
  /* Reads top-to-bottom, then the second column, like a printed CV. Every line stays visible. */
  .cv-content > div { columns: 2; column-gap: 56px; column-rule: 1px solid #eee8dc; }
  .cv-content > div > div:first-child { column-span: all; margin-bottom: 1.4em; }
  .cv-content h4 { break-after: avoid; }
  .cv-content > div > h4:first-of-type { margin-top: 0.6em; }
  .cv-content li, .cv-content p { break-inside: avoid; }
}

/* 12. Heidelberg ---------------------------------------------------------- */

.heidelberg__head {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(28px, 6vw, 100px);
  align-items: end;
  margin-bottom: clamp(48px, 6vw, 84px);
}
.heidelberg__head .display { margin-bottom: 0; }
.heidelberg__head p:last-child { margin-bottom: 0; }

.emoji { display: inline-flex; width: 22px; flex: none; }
.emoji img { width: 100%; height: auto; }

.quote { max-width: 920px; margin: 0 auto clamp(56px, 7vw, 100px); text-align: center; }
.quote::before {
  content: "";
  display: block;
  width: 48px;
  height: 2px;
  margin: 0 auto 28px;
  background: var(--green);
}
.quote blockquote { margin: 0; }
.quote blockquote p {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 1.05rem + 1.6vw, 2.35rem);
  line-height: 1.38;
  color: var(--ink);
  text-wrap: balance;
}
.quote blockquote p:lang(fa) { font-weight: 500; line-height: 1.8; }
.quote figcaption { margin-top: 1.3rem; font-size: 0.86rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.quote figcaption:lang(fa) { letter-spacing: 0; text-transform: none; font-size: 0.98rem; }

.gallery {
  display: flex;
  gap: clamp(16px, 2.2vw, 32px);
  align-items: flex-start;
}
/* flex-grow = aspect ratio, so all photos share one height without any cropping. */
.gallery__item { min-width: 0; flex: 1.3333 1 0; }
.gallery__item--770x557 { flex-grow: 1.3824; }
.gallery__item img { width: 100%; height: auto; }
.gallery__item figcaption {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  font-size: 0.92rem;
  color: var(--muted);
}
.gallery__item figcaption::before { content: ""; width: 18px; height: 1px; background: var(--green); flex: none; transition: width 0.5s var(--ease); }
.gallery__item:hover figcaption::before { width: 36px; }

/* 13. Contact ------------------------------------------------------------- */

.contact { background: var(--paper-deep); }
.contact__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  grid-template-areas: "head form" "steps form" "direct form";
  grid-template-rows: auto auto 1fr;
  column-gap: clamp(40px, 6vw, 100px);
  align-items: start;
}
.contact__head { grid-area: head; }
.contact__head .lead { margin-bottom: 0; }
.contact__form { grid-area: form; }
.contact__steps { grid-area: steps; }
.contact__direct { grid-area: direct; }

.steps { display: grid; gap: 16px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.step { display: grid; grid-template-columns: 42px minmax(0, 1fr); column-gap: 16px; counter-increment: step; }
.step::before {
  content: counter(step);
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--green-line);
  border-radius: 50%;
  background: var(--sheet);
  color: var(--green);
  font-family: var(--serif);
}
.step:lang(fa)::before { content: counter(step, persian); font-weight: 700; }
.step__title { display: block; padding-top: 2px; font-weight: 650; }
.step__text { color: var(--ink-soft); font-size: 1rem; }

.direct { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.direct li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.direct__label { min-width: 4.8em; font-size: 0.88rem; color: var(--muted); }
.direct a { color: var(--ink); font-weight: 600; text-decoration-color: var(--green-line); unicode-bidi: isolate; }
.direct a:hover { color: var(--green); }

.form-card {
  padding: clamp(24px, 4vw, 46px);
  background: var(--sheet);
  border: 1px solid var(--line);
}
.form-card__title { margin-bottom: 0.3rem; font-family: var(--serif); font-size: 1.375rem; }
.form-card__title:lang(fa) { font-weight: 700; }
.form-card__note { margin-bottom: 1.5rem; font-size: 0.9rem; color: var(--muted); }

.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.field { margin-bottom: 20px; }
.field label { display: block; margin-bottom: 8px; font-size: 0.97rem; font-weight: 600; }
.field__mark { color: var(--error); }
.field__hint { margin-inline-start: 4px; font-size: 0.85rem; font-weight: 400; color: var(--muted); }

.field input, .field select, .field textarea {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 0.8em 0.95em;
  border: 1px solid #857d6a;
  border-radius: var(--radius);
  background: #fbf9f4;
  color: var(--ink);
  font-size: 1.02rem;
  outline: 2px solid transparent;
  transition: border-color 0.25s, box-shadow 0.25s, background-color 0.25s;
}
.field textarea { min-height: 150px; resize: vertical; line-height: 1.55; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: 1; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #5f584a; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(31, 74, 58, 0.16);
}
.field :is(input, select, textarea):focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.field [aria-invalid="true"] { border-color: var(--error); background: var(--error-bg); }
.field__error { margin: 0.45em 0 0; font-size: 0.93rem; color: var(--error); }

.select { position: relative; }
.select select { appearance: none; padding-inline-end: 2.8em; cursor: pointer; }
.select::after {
  content: "";
  position: absolute;
  top: 50%;
  inset-inline-end: 1.1em;
  width: 8px;
  height: 8px;
  border-right: 1.6px solid var(--green);
  border-bottom: 1.6px solid var(--green);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.notice { margin-bottom: 22px; padding: 16px 18px; border-radius: var(--radius); font-size: 0.98rem; }
.notice p:last-child { margin-bottom: 0; }
.notice ul { margin: 0.4em 0 0; padding-inline-start: 1.2em; }
.notice--error { background: var(--error-bg); border: 1px solid rgba(138, 42, 29, 0.35); color: var(--error); }
.notice--error a { color: var(--error); }
.notice__title { margin: 0; font-weight: 650; }
.notice--success { background: var(--success-bg); border: 1px solid var(--green-line); color: var(--green-deep); }

.honeypot { position: absolute; inset-inline-start: -10000px; width: 1px; height: 1px; overflow: hidden; }
.btn[aria-busy="true"] { opacity: 0.8; cursor: progress; }

/* 14. Footer — the portrait stage's night tone closes the page ------------- */

.site-footer { padding-block: 76px 30px; background: var(--night); color: var(--on-dark-soft); font-size: 0.97rem; }
.site-footer a { color: var(--on-dark); text-decoration-color: rgba(243, 239, 228, 0.35); }
.site-footer a:hover { color: #fff; text-decoration-color: currentColor; }
.footer__grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
.footer__logo { width: 116px; height: auto; margin-bottom: 22px; }
.footer__name { margin-bottom: 0.4rem; font-family: var(--serif); font-size: 1.5rem; color: #fff; }
.footer__name:lang(fa) { font-weight: 700; }
.footer__statement { max-width: 26em; margin: 0; font-size: 0.92rem; }
.footer__nav ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.footer__nav a { text-decoration: none; }
.footer__nav a:hover { text-decoration: underline; }
.footer__contact { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.footer__contact > a { unicode-bidi: isolate; }
.footer__langs { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; }
.footer__lang {
  appearance: none;
  min-height: 32px;
  padding: 0.35em 0.9em;
  border: 1px solid rgba(243, 239, 228, 0.3);
  border-radius: 999px;
  background: transparent;
  color: var(--on-dark);
  font-size: 0.86rem;
  cursor: pointer;
  transition: background-color 0.25s, color 0.25s, border-color 0.25s;
}
.footer__lang:hover { border-color: var(--on-dark); }
.footer__lang[aria-pressed="true"] { background: var(--on-dark); color: var(--night); }
.footer__bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 28px;
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid rgba(243, 239, 228, 0.14);
  font-size: 0.85rem;
}
.footer__bottom p { margin: 0; }
.to-top { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
.to-top .icon { transition: transform 0.35s var(--ease); }
.to-top:hover .icon { transform: translateY(-3px); }

/* 15. Scroll reveal (only elements still below the fold when the script starts) */

.js .reveal-pending { opacity: 0; transform: translate3d(0, 28px, 0); }
.js .reveal-pending.is-revealed {
  opacity: 1;
  transform: none;
  transition: opacity 0.9s var(--ease), transform 1s var(--ease);
}
.features > .is-revealed:nth-child(2), .gallery > .is-revealed:nth-child(2), .about__body > .is-revealed:nth-child(2) { transition-delay: 0.08s; }
.features > .is-revealed:nth-child(3), .gallery > .is-revealed:nth-child(3), .about__body > .is-revealed:nth-child(3) { transition-delay: 0.16s; }
.features > .is-revealed:nth-child(4), .about__body > .is-revealed:nth-child(4) { transition-delay: 0.24s; }

/* Language change cross-fade (View Transitions API, where supported). */
::view-transition-old(root) { animation: vt-out 0.22s ease both; }
::view-transition-new(root) { animation: vt-in 0.45s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; } }

/* 16. Responsive ---------------------------------------------------------- */

/* Wide but not quite wide enough for the full navigation: it moves into a menu. */
@media (max-width: 1299px) {
  .js .menu-toggle { display: inline-flex; }
  .js .nav {
    position: absolute;
    top: 100%;
    inset-inline: 0;
    max-height: calc(100vh - 100%);
    overflow-y: auto;
    padding: 12px var(--gutter) 28px;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 30px 50px -36px rgba(30, 35, 32, 0.55);
    visibility: hidden;
    opacity: 0;
    transform: translate3d(0, -10px, 0);
    transition: opacity 0.3s, transform 0.45s var(--ease), visibility 0s linear 0.45s;
  }
  .js .nav.is-open { visibility: visible; opacity: 1; transform: none; transition-delay: 0s; }
  .js .nav__list { flex-direction: column; align-items: stretch; gap: 0; width: min(100%, var(--max)); margin-inline: auto; }
  .js .nav__link { display: block; padding: 0.85em 0; border-bottom: 1px solid var(--line); font-size: 1.15rem; }
  .js .nav__link::after { display: none; }
  .js .nav__cta { display: block; padding-top: 18px; }
  .js .nav__cta .btn { width: 100%; }
  html:not(.js) .header__bar { flex-wrap: wrap; padding-block: 12px; }
  html:not(.js) .nav { order: 10; flex-basis: 100%; }
  html:not(.js) .nav__list { flex-wrap: wrap; }
}

@media (max-width: 1180px) {
  .brand__role { display: none; }
}

@media (max-width: 980px) {
  .header__cta { display: none; }
}

/* Header: the language switch gets its own full-width row. */
@media (max-width: 860px) {
  .header__bar { flex-wrap: wrap; column-gap: 12px; row-gap: 8px; padding-top: 10px; min-height: 0; }
  .lang { order: 5; flex-basis: 100%; justify-content: space-between; margin-bottom: 10px; }
  .lang__option { flex: 1 1 0; min-height: 40px; padding-inline: 0.4em; font-size: 0.86rem; }
  .menu-toggle { min-height: 42px; }
  html { scroll-padding-top: 132px; }
}

@media (max-width: 1080px) {
  .hero__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 0.85fr); }
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 44px; }
  .timeline { --period-w: 118px; }
  .milestone { grid-template-columns: var(--period-w) var(--marker-w) 170px minmax(0, 1fr); }
  .footer__grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .footer__brand { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .about__grid { grid-template-columns: 1fr; grid-template-areas: "head" "body" "why"; row-gap: 28px; }
  .contact__grid { grid-template-columns: 1fr; grid-template-areas: "head" "form" "steps" "direct"; row-gap: 36px; }
  .contact__steps .subhead, .contact__direct .subhead { margin-top: 0.4rem; }
  .heidelberg__head { grid-template-columns: 1fr; align-items: start; }
}

@media (max-width: 760px) {
  :root { --header-h: 64px; }
  body { font-size: 1.0625rem; }
  .brand__logo { width: 74px; }

  .hero__grid { grid-template-columns: 1fr; gap: 0; }
  .hero__stage { margin-inline: calc(-1 * var(--gutter)); padding-top: 36px; }
  .hero__portrait { width: min(100%, 360px); }
  .hero__upper { padding-top: 26px; }
  .hero__copy { padding-bottom: 36px; }
  .hero__eyebrow { letter-spacing: 0.1em; }
  .hero__actions { flex-direction: column; align-items: stretch; margin-block: 1.5rem 1.8rem; }
  .hero__actions .btn--ghost { min-height: 0; padding-block: 0.5em; border: 0; background: none; text-decoration: underline; text-underline-offset: 0.25em; }
  .hero__facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .fact { padding-inline-end: 12px; }
  [dir="rtl"] .fact { padding-inline-end: 12px; }
  .fact + .fact { padding-inline-start: 12px; }
  .fact__value { font-size: 1.1rem; }
  .fact__label { font-size: 0.8rem; }
  .hero__caption { text-align: start; }

  .features { grid-template-columns: 1fr; row-gap: 26px; }
  .feature { display: grid; grid-template-columns: 3rem minmax(0, 1fr); column-gap: 10px; padding-top: 20px; }
  .feature__num { grid-row: span 2; margin: 0; font-size: 1.6rem; line-height: 1.3; }

  .timeline { --spine: 13px; }
  .timeline::before, .timeline::after { top: 40px; bottom: 40px; }
  .milestone {
    grid-template-columns: 26px minmax(0, 1fr);
    grid-template-areas: "marker period" "marker logo" "marker body";
    align-items: start;
    column-gap: 14px;
    padding-block: 24px;
  }
  .milestone__marker { grid-area: marker; margin-top: 8px; }
  .milestone__period { grid-area: period; }
  .milestone__logo { grid-area: logo; height: auto; margin-block: 12px 10px; padding: 0; }
  .milestone__logo img { max-width: min(100%, 170px); }
  .milestone__body { grid-area: body; padding: 0; }

  .cv-viewer__bar { flex-direction: column; align-items: stretch; }
  .cv-tabs { display: flex; }
  .cv-tabs[hidden] { display: none; }
  .cv-tab { flex: 1 1 0; padding: 0 0.5em; }
  .cv-content > div > div:first-child { grid-template-columns: 1fr; padding: 16px 18px; }

  .gallery { flex-direction: column; gap: 32px; }
  .gallery__item { flex: none; width: 100%; }

  .field-row { grid-template-columns: 1fr; }
  .footer__grid { grid-template-columns: 1fr; gap: 32px; }
  .footer__bottom { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
  .header__bar { column-gap: 10px; }
  .brand { gap: 10px; }
  .brand__name { font-size: 0.95rem; }
  .menu-toggle { width: 44px; padding: 0; justify-content: center; }
  .menu-toggle__label {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (max-width: 370px) {
  .hero__facts { grid-template-columns: 1fr; }
  .fact, [dir="rtl"] .fact, .fact + .fact {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
    padding: 10px 0;
    border-inline-start: 0;
    border-bottom: 1px solid rgba(30, 35, 32, 0.12);
  }
  .fact__label { margin: 0; }
}

@media (max-width: 359px) {
  .brand__text { display: none; }
}

/* 17. Motion preferences and print ---------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
  .js .reveal-pending { opacity: 1; transform: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

@media print {
  .site-header, .hero__sky, .hero__actions, .contact__form, .site-footer, .cv-tabs, .skip-link { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .section { padding-block: 24pt; }
  .online { background: #fff; color: var(--ink); }
  .online .display, .feature__title, .feature__text, .online .lead { color: var(--ink); }
  .cv-doc[hidden] { display: block !important; }
  .cv-doc { box-shadow: none; break-inside: auto; }
  .js .reveal-pending { opacity: 1 !important; transform: none !important; }
}
