/* =============================================================
   Mehman Ismayilli — academic site
   Design system

   Palette : cool paper + dark ink, Oxford-blue accent, dark-green link ink
   Type    : Fraunces (display) / IBM Plex Sans (body) / IBM Plex Mono (data)
   Motif   : supply–demand / best-response coordinate plane, marked equilibrium
   ============================================================= */

:root {
  /* ---- colour ---- */
  --paper:        #f5f7fa;
  --surface:      #ffffff;
  --ink:          #04182f;   /* near-black Oxford navy, fountain-pen ink */
  --ink-soft:     #3f4d63;   /* body copy */
  --muted:        #66738c;   /* captions, meta */
  --line:         #e2e7ef;   /* hairlines */
  --line-strong:  #c8d2e1;
  --accent:       #002147;   /* Oxford blue — graphic marker */
  --accent-ink:   #2f6157;   /* link text — light dark greenish */
  --accent-wash:  rgba(0, 33, 71, 0.08);
  --accent-bright:#1d4e89;   /* lighter Oxford blue — home link accent */
  --amber:        #b4690e;   /* secondary signal (urgency / warnings) */
  --amber-wash:   rgba(180, 105, 14, 0.09);

  /* ---- type ---- */
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body:    "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* ---- metrics ---- */
  --container: 1080px;
  --gutter: clamp(1.25rem, 5vw, 4rem);
  --radius: 14px;
}

/* ---------------------------------------------------------- reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "cv05";
}

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent); color: #fff; }

main { display: block; }

/* ---------------------------------------------------------- layout */
.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------------------------------------------------------- header / nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease;
}
.site-header[data-scrolled="true"] { border-bottom-color: var(--line); }

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  height: 68px;
}
.brand {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.18rem;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
}
.brand .brand-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  transform: translateY(-1px);
}
/* brand acts as the labelled "Home" link — a colourful pill */
.brand--home {
  padding: 0.34rem 0.85rem 0.34rem 0.7rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent-bright) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-bright) 30%, transparent);
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.brand--home .brand-dot {
  width: 9px; height: 9px;
  background: var(--accent-bright);
  transform: translateY(-1px);
}
.brand--home .brand-name { color: var(--accent-bright); font-weight: 600; }
.brand--home:hover {
  background: color-mix(in srgb, var(--accent-bright) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent-bright) 55%, transparent);
  box-shadow: 0 4px 14px -6px color-mix(in srgb, var(--accent-bright) 60%, transparent);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.6rem;
  font-size: 0.92rem;
  list-style: none;
  padding: 0;
}
.nav-links a {
  position: relative;
  color: var(--ink-soft);
  padding-block: 0.3rem;
  transition: color 0.18s ease;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: 0;
  height: 1.5px;
  background: var(--accent);
  transition: right 0.22s ease;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after { right: 0; }

.nav-toggle { display: none; }

/* ---------------------------------------------------------- hero */
.hero {
  padding-top: clamp(2.25rem, 5vw, 4rem);
  padding-bottom: clamp(2.25rem, 4.5vw, 3.75rem);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: center;
}
.hero-role {
  margin-bottom: 1.1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.hero-role::before {
  content: "";
  width: 22px; height: 1px;
  background: var(--line-strong);
}
.hero h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.7rem, 6vw, 4.6rem);
  line-height: 0.98;
  letter-spacing: -0.03em;
  margin-bottom: 0.7rem;
}
.hero h1 .equil {
  color: var(--accent);
  font-style: italic;
}

/* hero role / title line — highlighted under the name */
.hero-title {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.25rem, 2.5vw, 1.7rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink);
  max-width: 26ch;
  margin-bottom: 1.5rem;
}
.hero-mark {
  background: var(--accent-wash);
  color: var(--accent-ink);
  padding: 0.04em 0.34em;
  border-radius: 6px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.hero-title a {
  color: var(--accent-ink);
  box-shadow: inset 0 -1px 0 var(--accent-wash);
  transition: box-shadow 0.2s ease;
}
.hero-title a:hover { box-shadow: inset 0 -1.4em 0 var(--accent-wash); }
.hero-lede {
  font-size: 1.12rem;
  color: var(--ink-soft);
  max-width: none;
  margin-bottom: 1.8rem;
  text-align: justify;
  hyphens: auto;
}
.hero-lede a {
  color: var(--accent-ink);
  box-shadow: inset 0 -1px 0 var(--accent-wash);
  transition: box-shadow 0.2s ease;
}
.hero-lede a:hover { box-shadow: inset 0 -1.6em 0 var(--accent-wash); }

.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.93rem;
  font-weight: 500;
  font-family: var(--body);
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.btn:hover { transform: translateY(-2px); border-color: var(--accent); }
.btn--primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.btn--primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn .arrow { transition: transform 0.18s ease; }
.btn:hover .arrow { transform: translateX(3px); }

/* hero figure: photo framed by the coordinate motif */
.hero-figure { position: relative; justify-self: center; }
.hero-photo {
  position: relative;
  z-index: 2;
  width: clamp(190px, 24vw, 270px);
  aspect-ratio: 1 / 1.12;
  object-fit: cover;
  object-position: top;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 18px 50px -28px rgba(15, 27, 48, 0.4);
}
.hero-motif {
  position: absolute;
  inset: -14% -18% -14% -16%;
  z-index: 1;
  overflow: visible;
}

/* ---------------------------------------------------------- section frame */
.section { padding-block: clamp(2.25rem, 4.5vw, 3.5rem); }
.section + .section { padding-top: 0; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.1rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--line);
}
.section-head h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.7rem, 3vw, 2.3rem);
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.section-head .count { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.section-link {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.section-link .arrow { transition: transform 0.18s ease; }
.section-link:hover .arrow { transform: translateX(3px); }

/* ---------------------------------------------------------- research / index list */
.research-list { display: grid; gap: 0; }
.research-item {
  display: grid;
  grid-template-columns: 118px 1fr auto;
  gap: 1.5rem;
  align-items: start;
  padding: 1.15rem 0.5rem 1.15rem 0.75rem;
  border-top: 1px solid var(--line);
  position: relative;
  transition: background 0.2s ease, padding-left 0.2s ease;
}
.research-item:last-child { border-bottom: 1px solid var(--line); }
.research-item::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 3px; height: 0;
  background: var(--accent);
  transform: translateY(-50%);
  transition: height 0.22s ease;
}
a.research-item:hover { background: var(--accent-wash); padding-left: 1.4rem; }
a.research-item:hover::before { height: calc(100% - 2.2rem); }

.research-tag {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-ink);
  padding-top: 0.35rem;
}
.research-tag .dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 0.45rem;
  vertical-align: middle;
}
.research-tag[data-kind="experimental"] { color: var(--ink-soft); }
.research-tag[data-kind="experimental"] .dot { background: var(--ink-soft); }

.research-body h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.28rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}
.research-body p { color: var(--ink-soft); font-size: 0.98rem; max-width: none; text-align: justify; hyphens: auto; }
.research-body .with { color: var(--muted); font-style: italic; }
.research-go {
  align-self: center;
  font-family: var(--mono);
  font-size: 1.2rem;
  color: var(--line-strong);
  transition: color 0.2s ease, transform 0.2s ease;
}
a.research-item:hover .research-go { color: var(--accent); transform: translateX(4px); }

/* ---------------------------------------------------------- card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
a.card:hover {
  transform: translateY(-3px);
  border-color: var(--line-strong);
  box-shadow: 0 16px 40px -30px rgba(15, 27, 48, 0.45);
}
.card .card-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-ink);
}
.card h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
}
.card p { color: var(--ink-soft); font-size: 0.95rem; text-align: justify; hyphens: auto; }
.card .card-foot {
  margin-top: auto;
  padding-top: 0.4rem;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

/* ---------------------------------------------------------- prose (subpages) */
.page-hero { padding-top: clamp(2.5rem, 5vw, 4rem); padding-bottom: 1rem; }
.page-hero h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.2rem, 4.5vw, 3.4rem);
  letter-spacing: -0.025em;
  line-height: 1.02;
  margin-block: 0.6rem 0.8rem;
}
.page-hero p { color: var(--ink-soft); max-width: none; font-size: 1.08rem; text-align: justify; hyphens: auto; }

.prose { max-width: none; }
.prose > * + * { margin-top: 1.1rem; }
.prose p, .prose li { color: var(--ink-soft); }
.prose p, .prose li { text-align: justify; hyphens: auto; }
.prose h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.6rem;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin-top: 2.4rem;
}
.prose h3 {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  margin-top: 1.8rem;
}
.prose h4 {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1.6rem;
}
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-top: 0.35rem; }
.prose li::marker { color: var(--accent); }
.prose ol li::marker { color: var(--muted); font-family: var(--mono); font-size: 0.85em; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose em { font-style: italic; }
.prose a {
  color: var(--accent-ink);
  box-shadow: inset 0 -1px 0 var(--accent-wash);
  transition: box-shadow 0.2s ease;
}
.prose a:hover { box-shadow: inset 0 -1.6em 0 var(--accent-wash); }
.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--accent-wash);
  color: var(--accent-ink);
  padding: 0.12em 0.4em;
  border-radius: 5px;
}
.prose pre {
  background: var(--ink);
  color: #e7ecf5;
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.6;
}
.prose pre code { background: none; color: inherit; padding: 0; }
.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1.1rem;
  color: var(--muted);
  font-style: italic;
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin-block: 2rem; }
.prose img { border-radius: var(--radius); border: 1px solid var(--line); }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 0.6rem 0.5rem; text-align: left; }
.prose th { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.note {
  border-left: 2px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
}

.backlink {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  display: inline-flex;
  gap: 0.4rem;
}

/* ---------------------------------------------------------- footer */
.site-footer {
  margin-top: clamp(3rem, 7vw, 6rem);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2rem;
  padding-block: 2.6rem;
}
.footer-brand .brand { font-size: 1.4rem; }
.footer-brand p { color: var(--muted); font-size: 0.9rem; margin-top: 0.4rem; max-width: 30ch; }
.footer-links { display: flex; gap: 2.5rem; flex-wrap: wrap; }
.footer-col h4 {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.8rem;
}
.footer-col a {
  display: block;
  color: var(--ink-soft);
  font-size: 0.92rem;
  padding-block: 0.25rem;
  transition: color 0.16s ease;
}
.footer-col a:hover { color: var(--accent-ink); }
.footer-base {
  border-top: 1px solid var(--line);
  padding-block: 1.2rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ---------------------------------------------------------- motif animation */
.motif-axis { stroke: var(--line-strong); stroke-width: 1; }
.motif-grid { stroke: var(--line); stroke-width: 0.6; }
.motif-curve { fill: none; stroke-width: 1.6; stroke-linecap: round; }
.motif-demand { stroke: var(--ink-soft); }
.motif-supply { stroke: var(--accent); }
.motif-eq-line { stroke: var(--line-strong); stroke-width: 0.8; stroke-dasharray: 3 3; }
.motif-eq { fill: var(--accent); stroke: var(--surface); stroke-width: 2.5; }
.motif-label { font-family: var(--mono); font-size: 9px; fill: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .motif-curve {
    stroke-dasharray: 320;
    stroke-dashoffset: 320;
    animation: draw 1.3s ease forwards;
  }
  .motif-supply { animation-delay: 0.15s; }
  .motif-eq {
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    animation: pop 0.5s ease 1.25s forwards;
  }
  .motif-eq-line { opacity: 0; animation: fade 0.6s ease 1.3s forwards; }
  .motif-label { opacity: 0; animation: fade 0.6s ease 1.45s forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
  @keyframes pop {
    0% { opacity: 0; transform: scale(0); }
    70% { opacity: 1; transform: scale(1.35); }
    100% { opacity: 1; transform: scale(1); }
  }
  @keyframes fade { to { opacity: 1; } }

  .reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.6s ease, transform 0.6s ease; }
  .reveal.in { opacity: 1; transform: none; }
}

/* ---------------------------------------------------------- responsive */
@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2.5rem; }
  .hero-figure { order: -1; justify-self: start; }
  .research-item { grid-template-columns: 1fr; gap: 0.5rem; }
  .research-tag { padding-top: 0; }
  .research-go { display: none; }

  .nav-links {
    position: fixed;
    inset: 68px 0 auto 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 0.5rem var(--gutter) 1.5rem;
    transform: translateY(-130%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .nav-links[data-open="true"] { transform: translateY(0); }
  .nav-links a { width: 100%; padding-block: 0.85rem; border-bottom: 1px solid var(--line); font-size: 1.05rem; }
  .nav-toggle {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 38px; height: 38px;
    background: none;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    cursor: pointer;
  }
  .nav-toggle span { height: 1.5px; background: var(--ink); transition: transform 0.25s ease, opacity 0.2s ease; }
  .nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }
}

/* focus visibility */
a:focus-visible, .btn:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------------------------------------------------------- lectures (course pages) */
.feature {
  display: block;
  margin: 0 0 2.5rem;
  padding: 1.25rem 1.4rem;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-left-color: var(--accent);
  border-radius: 4px;
  text-decoration: none;
  transition: border-color 0.15s ease;
}
.feature:hover { border-color: var(--accent); }
.feature-label { display: block; font-weight: 600; font-size: 1.05rem; color: var(--ink); }
.feature-note { display: block; margin-top: 0.4rem; font-size: 0.92rem; color: var(--muted); line-height: 1.55; }

.toc { width: 100%; border-collapse: collapse; margin: 1rem 0 2rem; font-size: 0.95rem; }
.toc th, .toc td { text-align: left; vertical-align: top; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line); }
.toc thead th {
  border-bottom-width: 2px;
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.toc-day { white-space: nowrap; font-weight: 600; }
.toc-links { white-space: nowrap; }
.toc-links a { display: inline-block; }
