/* ===================================================================
   Soheil Saghafi — personal academic site
   Token system:
   Color   — paper #F5F4EF, ink #1E2A22, accent (sage) #5B7052,
             accent-deep #3C4E36, rule #DAD5C7, muted #6B6F63
   Type    — display: 'Source Serif 4' (headings, name)
             body:    'Inter' (paragraphs, nav, UI)
             mono:    'IBM Plex Mono' (labels, eyebrows, dates)
   Layout  — single column, max-width 720px, hairline rules,
             persistent top nav with a left tick-mark on active page
   =================================================================== */

:root {
  --paper: #F5F4EF;
  --paper-raised: #FCFBF8;
  --ink: #1E2A22;
  --muted: #6B6F63;
  --rule: #DAD5C7;
  --accent: #5B7052;
  --accent-deep: #3C4E36;
  --max-w: 720px;
}

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

a {
  color: var(--accent-deep);
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}
a:hover { color: var(--accent); }
a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

h1, h2, h3 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

.eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6em;
}

/* ---------- layout shell ---------- */
.site-header {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 22px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 24px;
}
.site-name {
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
nav.site-nav {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 0.92rem;
}
nav.site-nav a {
  color: var(--muted);
  text-decoration: none;
  position: relative;
  padding-left: 12px;
}
nav.site-nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 6px;
  height: 2px;
  background: var(--rule);
}
nav.site-nav a:hover { color: var(--ink); }
nav.site-nav a.active {
  color: var(--ink);
  font-weight: 600;
}
nav.site-nav a.active::before {
  background: var(--accent);
  width: 8px;
}

main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 56px 24px 96px;
}

.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 40px;
}
.footer-wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--muted);
}
.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--accent-deep); }

/* ---------- home / hero ---------- */
.hero {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  margin-bottom: 48px;
}
.avatar {
  flex: none;
  width: 108px;
  height: 108px;
  border-radius: 50%;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Source Serif 4', serif;
  font-size: 2rem;
  color: var(--muted);
  overflow: hidden;
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}
.hero h1 { font-size: 2rem; margin-bottom: 0.15em; }
.hero .role { color: var(--muted); font-size: 1.02rem; margin-bottom: 0; }

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 8px;
}
.tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent-deep);
  background: rgba(91, 112, 82, 0.08);
  border: 1px solid rgba(91, 112, 82, 0.25);
  padding: 4px 10px;
  border-radius: 3px;
}

section { margin-bottom: 44px; }
section > h2 {
  font-size: 1.3rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 10px;
  margin-bottom: 18px;
}

/* ---------- entry list (publications / teaching / research) ---------- */
.entry {
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 18px;
}
.entry:last-child { border-bottom: none; }
.entry-date {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  color: var(--muted);
  padding-top: 3px;
}
.entry-title {
  font-weight: 600;
  margin: 0 0 4px;
}
.entry-meta {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 6px;
}
.entry-desc { margin: 0; font-size: 0.96rem; }
ul.entry-desc {
  padding-left: 1.15em;
  margin: 6px 0 0;
}
ul.entry-desc li { margin-bottom: 4px; }
ul.entry-desc li:last-child { margin-bottom: 0; }
.entry-links { margin-top: 8px; font-size: 0.88rem; display: flex; gap: 14px; }

.placeholder-note {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent-deep);
  background: rgba(91,112,82,0.07);
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  margin: 0 0 28px;
}

/* ---------- contact ---------- */
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
}
.contact-list li {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.contact-list .label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  width: 92px;
  flex: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .hero { flex-direction: column; align-items: flex-start; }
  .entry { grid-template-columns: 1fr; gap: 4px; }
  .entry-date { padding-top: 0; }
  nav.site-nav { gap: 14px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- research areas: clickable accordion cards ---------- */
.research-accordion {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: var(--paper-raised);
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(30,42,34,0.05), 0 3px 10px rgba(30,42,34,0.03);
  transition: box-shadow 0.2s;
}
.research-accordion:hover {
  box-shadow: 0 2px 4px rgba(30,42,34,0.07), 0 6px 16px rgba(30,42,34,0.05);
}
.research-accordion summary {
  list-style: none;
  cursor: pointer;
  padding: 22px 64px 22px 26px;
  position: relative;
  display: block;
  transition: background 0.15s;
}
.research-accordion summary::-webkit-details-marker { display: none; }
.research-accordion summary:hover { background: rgba(91,112,82,0.045); }
.research-accordion summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.ra-num {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}
.ra-title {
  display: block;
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  font-size: 1.18rem;
  color: var(--ink);
  margin-bottom: 7px;
}
.ra-desc {
  display: block;
  font-size: 0.89rem;
  color: var(--muted);
  max-width: 62ch;
  line-height: 1.55;
}
.ra-chevron {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--paper);
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
}
.ra-chevron::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translate(-65%, -50%) rotate(-45deg);
}
.research-accordion:hover .ra-chevron { border-color: var(--accent); }
.research-accordion[open] .ra-chevron {
  transform: rotate(90deg);
  background: var(--accent);
  border-color: var(--accent);
}
.research-accordion[open] .ra-chevron::before {
  border-color: #fff;
}
.research-accordion[open] summary {
  border-bottom: 1px solid var(--rule);
  background: rgba(91,112,82,0.045);
}
.ra-body {
  padding: 24px 26px 28px;
}
.ra-body p { margin: 0 0 14px; }
.ra-body p:last-child { margin-bottom: 0; }

.ra-project {
  border: 1px solid var(--rule);
  border-radius: 7px;
  background: var(--paper);
  margin-top: 14px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ra-project:first-child {
  margin-top: 0;
}
.ra-project:hover {
  border-color: #C7C0AD;
  box-shadow: 0 1px 2px rgba(30,42,34,0.05), 0 4px 12px rgba(30,42,34,0.04);
}
.ra-project[open] {
  border-color: rgba(91,112,82,0.4);
}
.ra-project-summary {
  list-style: none;
  cursor: pointer;
  padding: 17px 58px 17px 20px;
  position: relative;
  display: flex;
  align-items: center;
  min-height: 24px;
  transition: background 0.15s;
}
.ra-project-summary::-webkit-details-marker { display: none; }
.ra-project-summary:hover { background: rgba(91,112,82,0.045); }
.ra-project-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.ra-project[open] .ra-project-summary {
  background: rgba(91,112,82,0.045);
  border-bottom: 1px solid var(--rule);
}
.ra-project-title {
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  font-size: 1.02rem;
  color: var(--ink);
  line-height: 1.4;
}
.ra-project-chevron {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--rule);
  background: var(--paper-raised);
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
  flex: none;
}
.ra-project-chevron::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translate(-65%, -50%) rotate(-45deg);
  transition: border-color 0.2s;
}
.ra-project:hover .ra-project-chevron { border-color: var(--accent); }
.ra-project[open] .ra-project-chevron {
  transform: translateY(-50%) rotate(90deg);
  background: var(--accent);
  border-color: var(--accent);
}
.ra-project[open] .ra-project-chevron::before {
  border-color: #fff;
}
.ra-project-body {
  padding: 20px 20px 22px;
}
.ra-project-body p:first-child {
  margin-top: 0;
}
.ra-figure {
  margin-top: 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px;
}
.ra-figure video {
  width: 100%;
  max-width: 420px;
  display: block;
  margin: 0 auto;
  border-radius: 4px;
  background: #000;
}
.ra-figure-caption {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 12px 0 0 !important;
  text-align: center;
}

.ra-video-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}
.ra-video-item {
  display: flex;
  flex-direction: column;
}
.ra-video-item video {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  display: block;
  border-radius: 4px;
  background: #000;
  border: 1px solid var(--rule);
}
.ra-video-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin: 12px 0 5px;
  text-align: center;
}
.ra-video-caption {
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0;
  text-align: center;
  max-width: 560px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

@media (max-width: 680px) {
  .ra-video-row {
    grid-template-columns: 1fr;
  }
}

/* ---------- pipeline walkthrough demo ---------- */
.pipeline-demo {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 24px;
  margin-top: 18px;
  box-shadow: 0 1px 3px rgba(30,42,34,0.06), 0 4px 14px rgba(30,42,34,0.04);
}
.pipeline-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.pipeline-dot {
  display: flex;
  align-items: center;
  gap: 7px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 5px 13px 5px 5px;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.pipeline-dot:hover { border-color: var(--accent); }
.pipeline-dot.done {
  border-color: rgba(91,112,82,0.35);
  color: var(--accent-deep);
}
.pipeline-dot.active {
  border-color: var(--accent);
  background: rgba(91,112,82,0.06);
  color: var(--ink);
  font-weight: 600;
}
.pipeline-dot-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--rule);
  color: var(--ink);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  flex: none;
}
.pipeline-dot.done .pipeline-dot-num {
  background: var(--accent-deep);
  color: #fff;
}
.pipeline-dot.active .pipeline-dot-num {
  background: var(--accent);
  color: #fff;
}
.pipeline-panel { min-height: 60px; }
.pipeline-step-title {
  font-family: 'Source Serif 4', serif;
  font-weight: 600;
  font-size: 1.1rem;
  margin: 0 0 8px;
}
.pipeline-step-desc {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 18px;
  max-width: 64ch;
  line-height: 1.6;
}
.pipeline-equation {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.92rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 28px 26px;
  line-height: 1.7;
}
.pipeline-eq-line { white-space: normal; }
.pipeline-eq-sub {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.85rem;
}
#pipeline-canvas {
  width: 100%;
  height: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  display: block;
}
.pipeline-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}
.pipeline-nav button {
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  border-radius: 6px;
  padding: 9px 20px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
#pipeline-prev {
  color: var(--accent-deep);
  background: var(--paper);
  border-color: var(--rule);
}
#pipeline-prev:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(91,112,82,0.06);
}
#pipeline-next {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(30,42,34,0.15);
}
#pipeline-next:hover:not(:disabled) {
  background: var(--accent-deep);
  box-shadow: 0 2px 5px rgba(30,42,34,0.2);
}
.pipeline-nav button:active:not(:disabled) {
  transform: translateY(1px);
}
.pipeline-nav button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.pipeline-nav button:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

@media (max-width: 560px) {
  .pipeline-dot-label { display: none; }
  .pipeline-equation { padding: 20px 16px; font-size: 0.82rem; }
}
