/* =========================================================================
   ehsanmadadi.com — one-page site
   Shares the MCF2 Lab palette and type: deep navy, teal and amber;
   Source Serif 4 headings over Inter body text.
   ========================================================================= */

:root {
  --navy-950: #071427;
  --navy-900: #0a1b33;
  --navy-800: #10284a;
  --navy-700: #183a66;
  --teal: #38b6c9;
  --teal-700: #17707e;      /* teal for small text on white, 5.6:1 */
  --amber: #e9a83a;
  --amber-700: #8f5d0b;     /* amber for small text on white, 5.4:1 */

  --ink: #0f1c2e;
  --text: #253246;
  --muted: #566274;
  --line: #e2e7ef;
  --line-strong: #cfd7e3;
  --bg: #ffffff;
  --bg-alt: #f4f7fb;
  --link: #1c5fb8;
  --link-hover: #0e3f82;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 28, 46, .06), 0 2px 8px rgba(15, 28, 46, .05);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --container: 1120px;
  --header-h: 68px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); }
body { margin: 0; font-family: var(--font-sans); font-size: 17px; line-height: 1.65; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { max-width: 100%; }
img { height: auto; display: block; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-serif); color: var(--ink); line-height: 1.2; font-weight: 600; letter-spacing: -.01em; margin: 0 0 .5em; }
h2 { font-size: clamp(1.7rem, 2.8vw, 2.3rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
.icon { flex: none; vertical-align: -0.2em; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 1rem; top: -60px; z-index: 200; background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: var(--radius-sm); }
.skip-link:focus { top: 1rem; color: #fff; }
main:focus { outline: none; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 24px; }
.section { padding: 96px 0; }
.section--alt { background: var(--bg-alt); }
.section--dark { background: radial-gradient(1000px 420px at 85% -10%, rgba(56, 182, 201, .16), transparent 60%), linear-gradient(160deg, var(--navy-800), var(--navy-950)); color: #d3dceb; }
.section--dark h2 { color: #fff; }

.eyebrow { font-size: .78rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--teal-700); margin: 0 0 .7rem; }
.eyebrow--light { color: var(--teal); }
.section-head { max-width: 760px; margin-bottom: 40px; }
.section-head h2 { margin-bottom: .3em; }
.section-head__lead { font-size: 1.08rem; color: var(--muted); margin: 0; }
.section-head--row { max-width: none; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 32px; flex-wrap: wrap; }
.link-arrow { font-weight: 600; text-decoration: none; display: inline-flex; gap: .35em; align-items: center; }
.link-arrow:hover { text-decoration: underline; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 46px; font: 600 .98rem/1 var(--font-sans); padding: .85em 1.35em; border-radius: 999px; text-decoration: none; border: 1.5px solid transparent; transition: background .2s, color .2s, border-color .2s; cursor: pointer; }
.btn--primary { background: var(--amber); color: var(--navy-950); }
.btn--primary:hover { background: #f2b852; color: var(--navy-950); }
.btn--ghost { color: #fff; border-color: rgba(255, 255, 255, .38); background: rgba(255, 255, 255, .04); }
.btn--ghost:hover { color: #fff; border-color: #fff; background: rgba(255, 255, 255, .1); }

/* ---------- Header ---------- */
.site-header { position: fixed; top: 0; left: 0; right: 0; z-index: 100; height: var(--header-h); transition: background .3s, box-shadow .3s, border-color .3s; border-bottom: 1px solid transparent; }
.site-header.is-scrolled { background: rgba(10, 27, 51, .9); backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px); border-color: rgba(255, 255, 255, .08); box-shadow: 0 6px 24px rgba(0, 0, 0, .18); }
.site-header__inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: #fff; }
.brand:hover { color: #fff; }
.brand__mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(140deg, var(--teal) 0%, #2a8fb0 45%, var(--amber) 130%); color: var(--navy-950); font: 700 .95rem/1 var(--font-serif); letter-spacing: .02em; }
.brand__name { font: 600 1.15rem/1 var(--font-serif); }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 2px; }
.site-nav a { display: block; padding: .5rem .75rem; font-size: .93rem; font-weight: 500; color: #d7e0ee; text-decoration: none; border-radius: 8px; position: relative; transition: color .2s, background .2s; }
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.site-nav a.is-active { color: #fff; }
.site-nav a.is-active::after { content: ""; position: absolute; left: .75rem; right: .75rem; bottom: .2rem; height: 2px; border-radius: 2px; background: var(--amber); }
.site-nav a.nav-cta { margin-left: 8px; background: var(--amber); color: var(--navy-950); padding: .55rem 1.05rem; border-radius: 999px; }
.site-nav a.nav-cta:hover { background: #f2b852; }
.site-nav a.nav-cta.is-active::after { display: none; }
.nav-toggle { display: none; background: none; border: 0; padding: 10px; color: #fff; cursor: pointer; border-radius: 8px; }
.nav-toggle__close { display: none; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .site-nav { position: fixed; inset: var(--header-h) 0 auto 0; background: var(--navy-900); border-bottom: 1px solid rgba(255, 255, 255, .08); padding: 8px 20px 20px; opacity: 0; visibility: hidden; transform: translateY(-6px); transition: opacity .2s, transform .25s var(--ease), visibility .2s; }
  .site-nav ul { flex-direction: column; align-items: stretch; }
  .site-nav a { padding: .85rem .6rem; font-size: 1.02rem; }
  .site-nav a.is-active::after { left: .6rem; right: auto; width: 24px; }
  .site-nav a.nav-cta { margin: 10px 0 0; text-align: center; }
  .nav-open .site-nav { opacity: 1; visibility: visible; transform: none; }
  .nav-open .site-header { background: var(--navy-900); }
  .nav-open .nav-toggle__open { display: none; }
  .nav-open .nav-toggle__close { display: block; }
}

/* ---------- Hero with the live flow field ---------- */
.hero { position: relative; isolation: isolate; overflow: hidden; min-height: min(92vh, 860px); display: flex; align-items: center; padding: calc(var(--header-h) + 56px) 0 88px; color: #d3dceb;
  background: radial-gradient(900px 520px at 80% 20%, rgba(56, 182, 201, .14), transparent 60%), linear-gradient(160deg, var(--navy-800) 0%, var(--navy-950) 75%); }
.hero__flow { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; }
.hero__shade { position: absolute; inset: 0; z-index: -1; pointer-events: none; background: linear-gradient(90deg, rgba(7, 20, 39, .88) 0%, rgba(7, 20, 39, .6) 45%, rgba(7, 20, 39, .05) 85%); }
.hero__inner { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 64px; align-items: center; }
.hero__portrait { grid-column: 2; grid-row: 1; margin: 0; }
.hero__portrait img { width: 100%; aspect-ratio: 432 / 457; object-fit: cover; border-radius: 20px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .14), 0 0 0 8px rgba(255, 255, 255, .04), 0 30px 70px rgba(0, 0, 0, .45); }
.hero__text { grid-column: 1; grid-row: 1; }
.hero h1 { color: #fff; font-size: clamp(2.6rem, 6vw, 4.6rem); font-weight: 700; letter-spacing: -.025em; margin-bottom: .3em; }
.hero__suffix { font-weight: 500; color: #b8c6da; font-size: .55em; letter-spacing: 0; }
.hero__lead { font-size: clamp(1.08rem, 1.6vw, 1.25rem); line-height: 1.6; color: #c8d4e5; max-width: 38em; margin-bottom: 0; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.flow-toggle { position: absolute; z-index: 1; bottom: 16px; right: max(24px, calc((100% - var(--container)) / 2 + 24px)); display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 14px; font: 500 .8rem/1 var(--font-sans); color: #dbe4f1; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .18); border-radius: 999px; cursor: pointer; transition: background .2s, border-color .2s; }
.flow-toggle:hover { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .35); }
.flow-toggle__play, .flow-toggle[aria-pressed="true"] .flow-toggle__pause { display: none; }
.flow-toggle[aria-pressed="true"] .flow-toggle__play { display: block; }

/* ---------- Profile links ---------- */
.profiles { list-style: none; margin: 36px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 22px; }
.profiles a { display: inline-flex; align-items: center; gap: .45em; min-height: 32px; font-size: .95rem; font-weight: 500; text-decoration: none; }
.profiles--light a { color: #c8d4e5; }
.profiles--light a:hover { color: #fff; text-decoration: underline; }
.profiles--stack { flex-direction: column; gap: 4px; margin-top: 8px; }

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 64px; align-items: start; }
.about__text { max-width: 44em; }
.glance { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 26px 10px; margin-top: 34px; }
.glance h3 { margin-bottom: .8em; }
.glance dl { margin: 0; }
.glance dl div { padding: 10px 0; border-top: 1px solid var(--line); }
.glance dt { font-size: .75rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--teal-700); }
.glance dd { margin: 2px 0 0; font-size: .95rem; color: var(--ink); overflow-wrap: anywhere; }
.about__text p { font-size: 1.04rem; }
.tag-list { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 28px 0 0; }
.tag-list li { font-size: .85rem; font-weight: 500; color: var(--navy-700); background: var(--bg-alt); border: 1px solid var(--line); padding: .35em .85em; border-radius: 999px; }

/* ---------- Research ---------- */
.research-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.rcard { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); transition: border-color .2s; }
.rcard:hover { border-color: var(--line-strong); }
.rcard__media { aspect-ratio: 16 / 9; background: var(--navy-950); overflow: hidden; }
.rcard__media img { width: 100%; height: 100%; object-fit: cover; }
.rcard__media--contain { background: #fff; border-bottom: 1px solid var(--line); }
.rcard__media--contain img { object-fit: contain; padding: 8px; }
.rcard__body { display: flex; flex-direction: column; flex: 1; padding: 24px 26px 22px; }
.rcard__body p { color: var(--text); font-size: .98rem; }
.rcard__foot { margin: auto 0 0; padding-top: 6px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .9rem !important; }
.rcard__support { color: var(--amber-700); font-weight: 600; }
.rcard__foot a { font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: .3em; }
.rcard__foot a:hover { text-decoration: underline; }

.funders { margin-top: 48px; display: flex; align-items: center; gap: 20px 36px; flex-wrap: wrap; justify-content: center; }
.funders__label { margin: 0; font-size: .8rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.funders ul { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 20px 36px; flex-wrap: wrap; justify-content: center; }
.funders li { height: 56px; display: flex; align-items: center; }
.funders img { width: auto; max-width: 220px; object-fit: contain; }

/* ---------- Publications ---------- */
.pub-more { display: flex; gap: 24px; flex-wrap: wrap; margin: 0; }
.pubs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.pub { display: grid; grid-template-columns: 72px 1fr; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.pub__year { font: 600 1.05rem/1.5 var(--font-serif); color: var(--teal-700); }
.pub__title { font: 600 1.1rem/1.4 var(--font-serif); margin: 0 0 .3em; }
.pub__title a { color: var(--ink); text-decoration: none; }
.pub__title a:hover { color: var(--link); text-decoration: underline; }
.pub__meta { margin: 0; font-size: .93rem; color: var(--muted); }
.pub__meta strong { color: var(--ink); font-weight: 600; }

/* ---------- Software ---------- */
.sw-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.swcard { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow-sm); border-top: 3px solid var(--teal); }
.swcard h3 { display: flex; align-items: center; gap: .45em; }
.swcard h3 .icon { color: var(--teal-700); }
.swcard p { font-size: .97rem; }
.swcard__links { margin: auto 0 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .92rem; font-weight: 600; }

/* ---------- Path ---------- */
.path { display: grid; grid-template-columns: 1.4fr 1fr; gap: 64px; align-items: start; }
.timeline { list-style: none; margin: 32px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line); }
.timeline__item { position: relative; padding: 0 0 28px 40px; }
.timeline__item::before { content: ""; position: absolute; left: 0; top: 5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--line-strong); }
.timeline__item.is-current::before { border-color: var(--amber); background: var(--amber); box-shadow: 0 0 0 4px rgba(233, 168, 58, .2); }
.timeline__when { display: block; font-size: .82rem; font-weight: 600; letter-spacing: .04em; color: var(--teal-700); margin-bottom: 2px; }
.timeline__what { font: 600 1.08rem/1.4 var(--font-serif); color: var(--ink); margin: 0; }
.timeline__where { margin: 0; color: var(--text); }
.timeline__note { margin: .25em 0 0; font-size: .92rem; color: var(--muted); }
.path__side { display: grid; gap: 24px; }
.side-block { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }
.side-block h3 { margin-bottom: .7em; }
.plain-list { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 8px; font-size: .95rem; }
.plain-list li { display: grid; grid-template-columns: 76px 1fr; gap: 8px; }
.code { font-weight: 600; color: var(--navy-700); font-variant-numeric: tabular-nums; }
.quote { margin: 0 0 16px; padding: 14px 18px; border-left: 3px solid var(--amber); background: #fff; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font: italic 500 1rem/1.55 var(--font-serif); color: var(--ink); }

/* ---------- Contact ---------- */
.contact { display: grid; grid-template-columns: 1.3fr 1fr; gap: 64px; align-items: start; }
.contact__lead { font-size: 1.1rem; color: #c3d0e2; max-width: 34em; }
.contact__email { display: inline-flex; align-items: center; gap: .5em; margin: 8px 0 24px; font: 600 clamp(1.2rem, 2.4vw, 1.6rem)/1.3 var(--font-serif); color: #fff; text-decoration: none; border-bottom: 2px solid var(--amber); padding-bottom: 4px; word-break: break-all; }
.contact__email:hover { color: var(--amber); }
.contact__students { color: #b6c3d6; margin: 0; }
.section--dark a:not(.contact__email):not(.btn) { color: #8fd3df; }
.section--dark a:not(.contact__email):not(.btn):hover { color: #fff; }
.contact__card { background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .1); border-radius: var(--radius); padding: 26px 28px; }
.contact__h { display: flex; align-items: center; gap: .45em; margin: 0 0 6px; font-size: .78rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); }
.contact__card address { font-style: normal; color: #d3dceb; margin-bottom: 22px; line-height: 1.6; }
.contact__card .profiles a { color: #c8d4e5; }

/* ---------- Footer ---------- */
.site-footer { background: var(--navy-950); color: #8796ad; font-size: .88rem; padding: 22px 0; border-top: 1px solid rgba(255, 255, 255, .06); }
.site-footer__inner { display: flex; justify-content: space-between; gap: 8px 24px; flex-wrap: wrap; }
.site-footer p { margin: 0; }
.site-footer a { color: #a9b8cc; }
.site-footer a:hover { color: #fff; }

/* ---------- 404 ---------- */
.notfound { min-height: 70vh; display: flex; align-items: center; padding: 96px 0; }
.notfound h1 { font-size: clamp(2rem, 4vw, 3rem); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .sw-grid { grid-template-columns: 1fr 1fr; }
  .path, .contact, .about { grid-template-columns: 1fr; gap: 40px; }
  .glance { margin-top: 0; }
  .hero__inner { grid-template-columns: minmax(0, 1fr) 220px; gap: 40px; }
}
@media (max-width: 760px) {
  body { font-size: 16px; }
  .section { padding: 68px 0; }
  .hero { min-height: auto; padding: calc(var(--header-h) + 40px) 0 80px; }
  .hero__shade { background: linear-gradient(180deg, rgba(7, 20, 39, .7), rgba(7, 20, 39, .82)); }
  .hero__inner { grid-template-columns: 1fr; gap: 24px; }
  .hero__portrait, .hero__text { grid-column: 1; }
  .hero__portrait { grid-row: 1; width: 112px; }
  .hero__portrait img { border-radius: 50%; aspect-ratio: 1; object-position: 50% 20%; box-shadow: 0 0 0 1px rgba(255, 255, 255, .18), 0 0 0 6px rgba(255, 255, 255, .05); }
  .hero__text { grid-row: 2; }
  .research-grid, .sw-grid { grid-template-columns: 1fr; }
  .pub { grid-template-columns: 1fr; gap: 2px; }
  .hide-sm { display: none; }
  .funders ul { gap: 16px 28px; }
  .funders li { height: 48px; }
  .funders img { max-width: 150px; transform: scale(.85); }
}

/* ---------- Motion preferences and print ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}
@media print {
  .site-header, .flow-toggle, .hero__flow, .hero__shade, .skip-link { display: none !important; }
  .hero, .section--dark, .site-footer { background: none !important; color: #000; min-height: 0; padding: 24px 0; }
  .hero h1, .section--dark h2, .contact__email { color: #000; }
  .hero__lead, .contact__lead, .profiles--light a, .contact__card address { color: #222; }
  .section { padding: 24px 0; }
  .rcard__media { display: none; }
}
