/* ==========================================================
   Dr Shahab Dean Esmaili — site styles
   Palette: deep indigo ink, cool paper, marigold route accent
   ========================================================== */

:root {
  --paper: #F6F7F9;
  --surface: #FFFFFF;
  --sunk: #ECEFF4;
  --ink: #16213E;
  --ink-2: #4A566E;
  --rule: #D6DCE6;
  --teal: #1C6E6A;
  --marigold: #E9A923;
  --marigold-ink: #6B4A00;
  --marigold-soft: #FBEBC4;
  --on-ink: #F6F7F9;
  --globe-core: #E9EDF4;
  --globe-dot: #2C3D63;
  --globe-arc: #E39B12;
  --gl-solid: #1B2747;
  --gl-tile: #FFFFFF;
  --gl-plane: #FFFFFF;

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.3rem;
  --step-2: clamp(1.6rem, 1.2rem + 1.4vw, 2.25rem);
  --step-3: clamp(2.3rem, 1.4rem + 3.6vw, 4.4rem);

  --gutter: 16px;
  --radius: 10px;
  --header-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F1626;
    --surface: #162036;
    --sunk: #121B2E;
    --ink: #E9EDF5;
    --ink-2: #A9B3C8;
    --rule: #2A3552;
    --teal: #67C7BE;
    --marigold: #F2B84B;
    --marigold-ink: #F7CF7E;
    --marigold-soft: #3A2E12;
    --on-ink: #0F1626;
    --globe-core: #1A2540;
    --globe-dot: #8EA2D0;
    --globe-arc: #F2B84B;
    --gl-solid: #2E3E68;
    --gl-tile: #24304E;
    --gl-plane: #E9EDF5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0F1626;
  --surface: #162036;
  --sunk: #121B2E;
  --ink: #E9EDF5;
  --ink-2: #A9B3C8;
  --rule: #2A3552;
  --teal: #67C7BE;
  --marigold: #F2B84B;
  --marigold-ink: #F7CF7E;
  --marigold-soft: #3A2E12;
  --on-ink: #0F1626;
  --globe-core: #1A2540;
  --globe-dot: #8EA2D0;
  --globe-arc: #F2B84B;
  --gl-solid: #2E3E68;
  --gl-tile: #24304E;
  --gl-plane: #E9EDF5;
  color-scheme: dark;
}

/* Persian */
:root[lang="fa"] {
  --serif: "Vazirmatn", Tahoma, sans-serif;
  --sans: "Vazirmatn", Tahoma, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
:root[lang="fa"] body { line-height: 1.9; }

img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.15; margin: 0; font-weight: 600; letter-spacing: -0.01em; }
:root[lang="fa"] h1, :root[lang="fa"] h2, :root[lang="fa"] h3 { letter-spacing: 0; line-height: 1.4; font-weight: 700; }
h2 { font-size: var(--step-2); margin-bottom: 0.6em; }
h3 { font-size: var(--step-1); }
p { margin: 0 0 1em; }
a { color: var(--teal); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--marigold); outline-offset: 3px; border-radius: 4px; }

.wrap { width: 100%; max-width: 1180px; margin-inline: auto; padding-inline: var(--gutter); }
@media (min-width: 720px) { :root { --gutter: 32px; } }

.skip {
  position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100;
  background: var(--ink); color: var(--on-ink); padding: 10px 16px; border-radius: 8px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px;
  font: 600 1rem/1 var(--sans); text-decoration: none; cursor: pointer;
  border: 1.5px solid transparent; transition: background-color .15s, color .15s, border-color .15s;
}
.btn-sm { min-height: 40px; padding: 0 16px; font-size: 0.9375rem; }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { background: var(--teal); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-accent { background: var(--marigold); color: #1B1405; }
.btn-accent:hover { background: #F5C05A; }

.tool {
  display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 10px;
  border-radius: 999px; border: 1.5px solid var(--rule); background: transparent; color: var(--ink);
  font: 500 0.9375rem/1 var(--sans); cursor: pointer;
}
.tool:hover { border-color: var(--ink); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.tool .i-moon { fill: currentColor; stroke: none; }
.lang-toggle { font-family: "Vazirmatn", var(--sans); }
:root[lang="fa"] .lang-toggle { font-family: "Public Sans", system-ui, sans-serif; }

.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.header-row { height: var(--header-h); display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand-mark {
  flex: none; width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  background: var(--ink); color: var(--marigold); font: 700 0.95rem/1 "Literata", Georgia, serif;
}
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; gap: 4px; margin-inline-start: auto; }
.nav a {
  color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 0.95rem; font-weight: 500;
}
.nav a:hover, .nav a[aria-current="true"] { color: var(--ink); background: var(--sunk); }
.header-tools { display: flex; align-items: center; gap: 8px; }
.menu-toggle { display: none; }

@media (max-width: 1020px) {
  .header-cta { display: none; }
}
@media (max-width: 860px) {
  .menu-toggle { display: inline-grid; }
  .header-tools { margin-inline-start: auto; }
  .nav {
    position: absolute; inset-inline: 0; top: var(--header-h);
    flex-direction: column; gap: 0; padding: 8px var(--gutter) 16px;
    background: var(--paper); border-bottom: 1px solid var(--rule);
    display: none;
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 14px 4px; border-radius: 0; border-bottom: 1px solid var(--rule); font-size: 1.05rem; }
  .nav a:last-child { border-bottom: 0; }
}
@media (max-width: 420px) {
  .brand-name { display: none; }
}

/* ---------- Hero ---------- */
.hero { padding: 40px 0 56px; position: relative; }
.hero-grid { display: grid; gap: 32px; align-items: center; }
@media (min-width: 940px) {
  .hero { padding: 56px 0 72px; }
  .hero-grid { grid-template-columns: 1.02fr 1fr; gap: 48px; }
}

.hero-portrait {
  width: 120px; height: 120px; border-radius: 50%; object-fit: cover; object-position: 50% 30%;
  border: 4px solid var(--surface);
  box-shadow: 0 0 0 2px var(--marigold);
  margin-bottom: 24px;
}
.hero-name {
  font-size: var(--step-3);
  font-weight: 700;
  font-variation-settings: "opsz" 72;
  letter-spacing: -0.025em;
  line-height: 1.02;
  max-width: 12ch;
  text-wrap: balance;
}
:root[lang="fa"] .hero-name { font-weight: 800; line-height: 1.3; letter-spacing: 0; max-width: 14ch; }
.hero-role {
  margin: 18px 0 0; font-family: var(--serif); font-size: var(--step-1); color: var(--ink-2); max-width: 32ch;
}
.hero-lead { margin: 20px 0 0; font-size: 1.12rem; max-width: 46ch; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.hero-facts {
  margin: 36px 0 0; padding-top: 20px; border-top: 1px solid var(--rule);
  display: grid; gap: 14px 28px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.hero-facts div { min-width: 0; }
.hero-facts dt { font-size: var(--step--1); color: var(--ink-2); }
.hero-facts dd { margin: 2px 0 0; font-weight: 600; font-size: 0.97rem; line-height: 1.4; }

/* Globe */
.globe-figure { margin: 0; }
.globe-stage {
  position: relative; width: 100%; max-width: 580px; aspect-ratio: 1 / 1; margin-inline: auto;
  cursor: grab; touch-action: pan-y; user-select: none; -webkit-user-select: none;
}
.globe-stage.is-dragging { cursor: grabbing; }
/* Without WebGL the hero globe area collapses */
:root:not(.gl-on) .globe-figure { display: none; }

/* ---------- 3D layer ----------
   One fixed canvas behind the content. Section backgrounds paint below it,
   text and cards paint above it. */
#gl {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 1; pointer-events: none; display: block;
  opacity: 0; transition: opacity 1s ease;
}
.gl-ready #gl { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #gl { transition: none; } }
main .wrap, .site-footer .wrap { position: relative; z-index: 2; }

.gl-anchor { display: none; }
.gl-on .gl-anchor { display: block; }
.gl-photo .about-photo { opacity: 0; }

.section-head { display: grid; gap: 8px 40px; align-items: center; margin-bottom: 8px; }
.section-head h2 { margin-bottom: 0.3em; }
@media (min-width: 760px) { .section-head { grid-template-columns: 1fr auto; } }
.gl-cap { width: 220px; height: 170px; justify-self: end; }
.gl-tokens { width: 380px; height: 220px; max-width: 100%; justify-self: end; }
.gl-contact { width: 100%; max-width: 340px; aspect-ratio: 1 / 1; margin-top: 32px; }
@media (max-width: 759px) {
  .gl-cap { width: 100%; height: 150px; justify-self: stretch; }
  .gl-tokens { width: 100%; height: 200px; justify-self: stretch; margin-top: 8px; }
  .gl-contact { max-width: 260px; margin-inline: auto; }
}

.globe-labels { position: absolute; inset: 0; pointer-events: none; }
.globe-label {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  margin: -34px 0 0 10px;
  font: 600 0.82rem/1 var(--sans);
  padding: 6px 9px; border-radius: 6px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--rule);
  transition: opacity .25s;
}
.globe-label.is-dest { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.globe-caption {
  max-width: 580px; margin: 8px auto 0; text-align: center; font-size: var(--step--1); color: var(--ink-2);
}
.globe-hint { display: block; opacity: .8; }
@media (pointer: coarse) { .globe-hint { display: none; } }

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
@media (min-width: 940px) { .section { padding: 104px 0; } }
.section-alt { background: var(--sunk); border-block: 1px solid var(--rule); }
.section-lead { color: var(--ink-2); max-width: 60ch; margin-top: -4px; }
.minor-h { font-family: var(--sans); font-size: 1rem; font-weight: 600; margin: 28px 0 12px; letter-spacing: 0; }
.fine-print { font-size: var(--step--1); color: var(--ink-2); margin-top: 20px; max-width: 70ch; }

/* About */
.about-grid { display: grid; gap: 40px; align-items: start; }
@media (min-width: 940px) { .about-grid { grid-template-columns: 1.1fr 0.9fr; gap: 72px; } }
.about-copy p { max-width: 62ch; }
.tags { list-style: none; padding: 0; margin: 0 0 28px; display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--rule);
  font-size: 0.92rem; font-weight: 500;
}

.about-side { position: relative; max-width: 460px; width: 100%; margin-inline: auto; }
.about-photo {
  width: 72%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 35%;
  border-radius: var(--radius);
  margin-inline-start: auto;
  box-shadow: 0 18px 40px -22px rgba(22, 33, 62, .55);
}
/* The record card */
.index-card {
  position: relative; margin-top: -64px; width: 88%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0 20px 14px;
  box-shadow: 0 10px 28px -16px rgba(22, 33, 62, .45);
  transform: rotate(-1.2deg);
}
:root[dir="rtl"] .index-card { transform: rotate(1.2deg); }
.card-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  height: 52px; padding-top: 18px;
  border-bottom: 2px solid var(--marigold);
  font-family: var(--serif); font-weight: 700; font-size: 1.05rem;
}
.card-tag { font-family: var(--sans); font-size: 0.78rem; font-weight: 600; color: var(--marigold-ink); background: var(--marigold-soft); padding: 3px 8px; border-radius: 4px; }
.card-lines { margin: 0; }
.card-lines div {
  display: grid; grid-template-columns: 7.5rem 1fr; gap: 10px; min-height: 38px; align-items: center;
  border-bottom: 1px solid color-mix(in srgb, var(--teal) 20%, transparent);
}
.card-lines div:last-child { border-bottom: 0; }
.card-lines dt { font-size: 0.8rem; color: var(--ink-2); }
.card-lines dd { margin: 0; font-size: 0.93rem; font-weight: 500; line-height: 1.3; padding: 6px 0; }
@media (max-width: 480px) {
  .card-lines div { grid-template-columns: 6rem 1fr; }
  .index-card { width: 96%; }
  .about-photo { width: 80%; }
}

/* Services */
.services { display: grid; gap: 0; border-top: 1px solid var(--rule); }
.service { padding: 26px 0; border-bottom: 1px solid var(--rule); display: grid; gap: 6px; }
.service h3 { font-size: 1.2rem; }
.service p { margin: 0; color: var(--ink-2); max-width: 58ch; }
@media (min-width: 760px) {
  .services { grid-template-columns: 1fr 1fr; column-gap: 56px; }
  .service-lead { grid-column: 1 / -1; grid-template-columns: 1fr 1fr; column-gap: 56px; align-items: baseline; padding: 32px 0; }
  .service-lead h3 { font-size: var(--step-2); }
  .service-lead p { font-size: 1.1rem; color: var(--ink); }
}

/* Test finder */
.finder {
  display: grid; gap: 28px; margin-top: 32px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 14px;
  padding: 24px;
}
@media (min-width: 940px) { .finder { grid-template-columns: 0.9fr 1.1fr; gap: 40px; padding: 36px; } }
.q { border: 0; margin: 0 0 22px; padding: 0; }
.q:last-child { margin-bottom: 0; }
.q legend { font-weight: 600; margin-bottom: 12px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px; border-radius: 999px;
  border: 1.5px solid var(--rule); font-size: 0.95rem; font-weight: 500; line-height: 1.3;
  transition: background-color .15s, border-color .15s;
}
.chip:hover span { border-color: var(--ink-2); }
.chip input:checked + span { background: var(--marigold-soft); border-color: var(--marigold); color: var(--ink); }
.chip input:focus-visible + span { outline: 3px solid var(--marigold); outline-offset: 2px; }

.finder-result { min-width: 0; }
.result-title { font-family: var(--serif); font-size: var(--step-1); margin: 0 0 6px; }
.result-sub { color: var(--ink-2); margin-bottom: 18px; }
.test-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.test {
  border: 1px solid var(--rule); border-radius: 10px; padding: 16px 18px; background: var(--paper);
}
.test.is-top { border-color: var(--marigold); box-shadow: inset 4px 0 0 var(--marigold); }
:root[dir="rtl"] .test.is-top { box-shadow: inset -4px 0 0 var(--marigold); }
.test-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.test-name { font-weight: 700; font-size: 1.05rem; }
.test-badge { font-size: 0.78rem; font-weight: 600; color: var(--marigold-ink); background: var(--marigold-soft); padding: 3px 8px; border-radius: 4px; }
.test dl { margin: 10px 0 0; display: grid; gap: 4px; }
.test dl div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 10px; font-size: 0.92rem; }
.test dt { color: var(--ink-2); }
.test dd { margin: 0; }

/* Route */
.route {
  list-style: none; margin: 32px 0 0; padding: 0; counter-reset: step;
  display: grid; gap: 0;
}
.route li {
  counter-increment: step; position: relative;
  padding: 0 0 28px 64px;
}
:root[dir="rtl"] .route li { padding: 0 64px 28px 0; }
.route-num {
  position: absolute; inset-inline-start: 0; top: -4px; z-index: 1;
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--marigold);
  font: 700 1.05rem/1 var(--serif);
  box-shadow: 0 4px 14px -6px rgba(22, 33, 62, .35);
}
.gl-route .route li::after { display: none; }
.route li::after {
  content: ""; position: absolute; inset-inline-start: 20px; top: 40px; bottom: 0;
  border-inline-start: 2px dashed var(--rule);
}
.route li:last-child::after { display: none; }
.route li:last-child { padding-bottom: 0; }
.route h3 { font-size: 1.15rem; }
.route p { margin: 4px 0 0; color: var(--ink-2); max-width: 46ch; }
@media (min-width: 940px) {
  .route { grid-template-columns: repeat(6, 1fr); gap: 20px; }
  .route li, :root[dir="rtl"] .route li { padding: 64px 0 0; }
  .route-num { top: 0; }
  .route li::after {
    top: 20px; bottom: auto; inset-inline-start: 52px; inset-inline-end: -10px;
    border-inline-start: 0; border-top: 2px dashed var(--rule);
  }
  .route p { font-size: 0.95rem; }
}

/* College */
.college { display: grid; gap: 28px; align-items: start; }
@media (min-width: 940px) { .college { grid-template-columns: 1.1fr 0.9fr; gap: 72px; } }
.college p { max-width: 58ch; }
.college-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--marigold); }
.college-list li { padding: 14px 0; border-bottom: 1px solid var(--rule); font-weight: 500; }

/* Contact */
.section-ink { background: var(--ink); color: var(--on-ink); }
.section-ink a { color: var(--marigold); }
.contact-grid { display: grid; gap: 40px; }
@media (min-width: 940px) { .contact-grid { grid-template-columns: 0.85fr 1.15fr; gap: 72px; } }
.contact-copy p { opacity: .85; max-width: 44ch; }
.contact-links { list-style: none; margin: 28px 0 0; padding: 0; }
.contact-links li {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 16px; padding: 14px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--on-ink) 18%, transparent);
}
.contact-links li span { opacity: .75; }
.contact-links a { font-weight: 600; text-decoration: none; white-space: nowrap; }
@media (max-width: 420px) { .contact-links a { font-size: 0.95rem; } }
.contact-links a:hover { text-decoration: underline; }
.contact-links [dir="ltr"] { unicode-bidi: embed; }

.contact-form { display: grid; gap: 16px; grid-template-columns: 1fr; align-content: start; }
@media (min-width: 600px) { .contact-form { grid-template-columns: 1fr 1fr; } .field-wide { grid-column: 1 / -1; } }
.field { display: grid; gap: 6px; }
.field label { font-size: 0.92rem; font-weight: 500; opacity: .9; }
.field input, .field select, .field textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--ink);
  background: var(--paper); border: 1.5px solid transparent; border-radius: 8px;
  padding: 12px 14px; min-height: 48px;
}
.field textarea { resize: vertical; min-height: 120px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--marigold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--marigold) 40%, transparent); }
.field [aria-invalid="true"] { border-color: #E5484D; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.form-note { margin: 0; font-size: var(--step--1); opacity: .75; }
.form-error { grid-column: 1 / -1; margin: 0; padding: 10px 14px; border-radius: 8px; background: #E5484D; color: #fff; font-weight: 500; }

/* Footer */
.site-footer { padding: 28px 0 40px; border-top: 1px solid var(--rule); font-size: var(--step--1); color: var(--ink-2); }
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 28px; }
.footer-row p { margin: 0; }
.footer-note { max-width: 64ch; }

/* Hero load sequence (single orchestrated moment) */
@media (prefers-reduced-motion: no-preference) {
  .hero-copy > * { animation: rise .7s cubic-bezier(.2,.7,.2,1) both; }
  .hero-copy > :nth-child(2) { animation-delay: .06s; }
  .hero-copy > :nth-child(3) { animation-delay: .12s; }
  .hero-copy > :nth-child(4) { animation-delay: .18s; }
  .hero-copy > :nth-child(5) { animation-delay: .24s; }
  .hero-copy > :nth-child(6) { animation-delay: .30s; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
}


/* ==========================================================
   Hero v2: centred portrait in front of the 3D globe
   ========================================================== */
.hero { padding: 56px 0 88px; overflow: clip; }
.hero-center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.hero-visual {
  position: relative; margin: 0; width: min(100%, 620px);
  --p: 0;  /* scroll progress, set by script.js */
}
.hero-visual .globe-stage { max-width: none; width: 100%; }
.portrait-ring {
  position: absolute; left: 50%; top: 61%;
  width: 40%; aspect-ratio: 1; border-radius: 50%;
  transform: translate(-50%, -50%) scale(calc(1 - var(--p) * 0.22));
  padding: 6px; background: var(--paper);
  box-shadow: 0 0 0 2px var(--marigold), 0 24px 60px -18px rgba(22, 33, 62, .55);
  pointer-events: none; will-change: transform;
}
.portrait-ring::after {          /* thin orbit line around the photo */
  content: ""; position: absolute; inset: -14px; border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--marigold) 70%, transparent);
  animation: orbit 40s linear infinite;
}
@keyframes orbit { to { transform: rotate(360deg); } }
.hero-portrait {
  width: 100%; height: 100%; margin: 0; border: 0; box-shadow: none;
  border-radius: 50%; object-fit: cover; object-position: 50% 32%;
}
.hero-visual .globe-caption { margin-top: 4px; }
.hero-copy { max-width: 760px; margin-top: 8px; transform: translateY(calc(var(--p) * -30px)); }
.hero-name { max-width: none; margin-inline: auto; }
.hero-role, .hero-lead { margin-inline: auto; }
.hero-actions { justify-content: center; }
.hero-facts { text-align: center; }
:root:not(.gl-on) .hero-visual .globe-stage { display: none; }
:root:not(.gl-on) .portrait-ring { position: relative; left: auto; top: auto; transform: none; width: 200px; margin: 20px auto; }
@media (max-width: 600px) {
  .hero { padding-top: 8px; }
  .hero-visual { width: calc(100% + 24px); }
  .portrait-ring { width: 44%; padding: 4px; }
  .hero-facts { grid-template-columns: 1fr; }
}

/* About: photo centred and balanced */
.about-side { max-width: 420px; }
.about-photo { width: min(70%, 280px); height: auto; margin-inline: auto; aspect-ratio: 1 / 1; object-position: 50% 40%; }
.index-card { margin-top: -40px; }
.index-card { margin-inline: auto; }

/* Scroll reveal: content glides in as it enters the screen */
@media (prefers-reduced-motion: no-preference) {
  .js-reveal .reveal { opacity: 0; transform: translateY(28px); transition: opacity .9s cubic-bezier(.2,.7,.2,1), transform .9s cubic-bezier(.2,.7,.2,1); transition-delay: var(--d, 0s); }
  .js-reveal .reveal.in { opacity: 1; transform: none; }
  .portrait-ring::after { animation-play-state: running; }
}
@media (prefers-reduced-motion: reduce) { .portrait-ring::after { animation: none; } }

/* Scroll progress bar under the header */
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 100%; background: var(--marigold); transform-origin: 0 50%; transform: scaleX(var(--sp, 0)); }
:root[dir="rtl"] .progress { transform-origin: 100% 50%; }

/* ---------- Print: a one-page CV ---------- */
@media print {
  :root { --paper: #fff; --surface: #fff; --sunk: #fff; --ink: #000; --ink-2: #333; --rule: #bbb; }
  @page { margin: 16mm; }
  body { font-size: 10.5pt; background: #fff; }
  .site-header, .globe-stage, .globe-caption, .portrait-ring::after, .hero-actions, #tests, #contact .contact-form, .print-cv, .skip, .about-photo { display: none !important; }
  .section, .hero { padding: 14pt 0 !important; }
  .section-alt, .section-ink { background: #fff !important; color: #000 !important; border: 0 !important; }
  .section-ink a { color: #000 !important; }
  .hero-grid, .about-grid, .college, .contact-grid { display: block !important; }
  .hero-portrait { width: 70pt; height: 70pt; box-shadow: none; border: 0; float: right; margin: 0 0 8pt 12pt; }
  .hero-name { font-size: 24pt; max-width: none; }
  .hero-copy > * { animation: none !important; }
  .index-card { transform: none !important; margin: 12pt 0 0 !important; width: 100% !important; box-shadow: none; background: #fff; }
  .route { display: block !important; }
  .route li { padding: 0 0 6pt 30pt !important; }
  .route-num { width: 20pt; height: 20pt; font-size: 9pt; box-shadow: none; }
  #gl, .gl-anchor { display: none !important; }
  .route li::after { display: none; }
  a { color: #000; text-decoration: none; }
  h2 { font-size: 14pt; margin-bottom: 4pt; }
  .services { display: block; }
  .service { padding: 6pt 0; }
  .service-lead h3 { font-size: 12pt !important; }
}

/* Result panel pops when a 3D test tile is clicked */
@media (prefers-reduced-motion: no-preference) {
  .finder-result.pop { animation: pop .6s cubic-bezier(.2,.9,.3,1.3); }
  @keyframes pop { 0% { opacity: .2; transform: translateY(14px) scale(.97); } 100% { opacity: 1; transform: none; } }
  .finder-result.pop .test.is-top { animation: glow 1.4s ease-out; }
  @keyframes glow { 0% { box-shadow: inset 4px 0 0 var(--marigold), 0 0 0 0 color-mix(in srgb, var(--marigold) 60%, transparent); } 100% { box-shadow: inset 4px 0 0 var(--marigold), 0 0 0 14px transparent; } }
}
.gl-tokens { touch-action: manipulation; }


/* ==========================================================
   v10: cinematic polish
   ========================================================== */
:root { --globe-shade: #C4CEE2; --globe-rim: #FFFFFF; --globe-glow: #AFC1EE; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --globe-shade: #0B1222; --globe-rim: #40558C; --globe-glow: #4F6FD0; } }
:root[data-theme="dark"] { --globe-shade: #0B1222; --globe-rim: #40558C; --globe-glow: #4F6FD0; }

/* Loader */
#loader {
  position: fixed; inset: 0; z-index: 200; background: var(--paper);
  display: grid; place-content: center; justify-items: center; gap: 14px;
  transition: opacity .7s ease, visibility .7s;
  animation: loaderOut .01s 5s forwards;          /* safety net if scripts fail */
}
#loader.done { opacity: 0; visibility: hidden; }
@keyframes loaderOut { to { opacity: 0; visibility: hidden; } }
#loaderCanvas { width: 180px; height: 100px; }
.loader-bar { width: 150px; height: 2px; background: var(--rule); border-radius: 2px; overflow: hidden; }
.loader-bar i { display: block; height: 100%; background: var(--marigold); transform-origin: 0 50%; animation: load 1.3s cubic-bezier(.3,.6,.2,1) forwards; }
@keyframes load { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { #loader { display: none; } }

/* Hero entrance waits for the loader */
.js:not(.loaded) .hero-copy > *, .js:not(.loaded) .hero-name .ch { animation-play-state: paused; }
.js:not(.loaded) .hero-visual { opacity: 0; transform: scale(.94); }
.hero-visual { transition: opacity 1.2s ease, transform 1.6s cubic-bezier(.2,.7,.2,1); }

/* Name: letters arrive out of depth */
.hero-name.split { perspective: 900px; animation: none; opacity: 1; }
.hero-name .word { display: inline-block; white-space: nowrap; }
.hero-name .ch {
  display: inline-block; transform-origin: 50% 100%;
  animation: letter .9s cubic-bezier(.2,.75,.25,1) both;
  animation-delay: calc(var(--i) * 38ms + 120ms);
}
@keyframes letter { from { opacity: 0; transform: translate3d(0, 0.5em, -260px) rotateX(-80deg); } to { opacity: 1; transform: none; } }

/* City name under the cursor on the globe */
.globe-label.is-city { background: var(--marigold); color: #1B1405; border-color: var(--marigold); font-size: .76rem; padding: 5px 8px; }

/* Services as glass cards that tilt */
.services { border-top: 0; gap: 16px; margin-top: 28px; }
.service {
  position: relative; overflow: hidden; padding: 26px 24px; align-content: start;
  border: 1px solid var(--rule); border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 68%, transparent);
  -webkit-backdrop-filter: blur(12px) saturate(1.3); backdrop-filter: blur(12px) saturate(1.3);
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .2s ease-out, box-shadow .3s, border-color .3s;
}
.js-reveal .service.reveal.in {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .2s ease-out, opacity .9s, box-shadow .3s, border-color .3s;
}
.service::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: radial-gradient(380px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--marigold) 26%, transparent), transparent 62%);
}
.service:hover::before { opacity: 1; }
.service:hover { box-shadow: 0 28px 60px -32px rgba(22, 33, 62, .55); border-color: color-mix(in srgb, var(--marigold) 55%, var(--rule)); }
.service h3, .service p { position: relative; }
@media (min-width: 760px) {
  .services { grid-template-columns: repeat(3, 1fr); column-gap: 16px; }
  .service-lead { grid-column: span 2; grid-template-columns: 1fr; padding: 30px 28px; }
  .service-lead p { max-width: 52ch; }
}
.finder { background: color-mix(in srgb, var(--surface) 86%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
@media print { #loader { display: none !important; } .service { transform: none; border: 0; padding: 6pt 0; } }

/* v15: contact form confirmation, flexible route length */
.form-ok { grid-column: 1 / -1; margin: 0; padding: 10px 14px; border-radius: 8px; background: #1C7A52; color: #fff; font-weight: 500; }
@media (min-width: 940px) { .route { grid-template-columns: repeat(var(--n, 6), 1fr); row-gap: 36px; } }
