/* ------------------------------------------------------------------
   Kaveh Mousavand — academic site
   Palette:  paper (light blue) #EAF2FA | ink #202325 | slate #34495D | brick #A65A43
   Type:     "Source Serif 4" (display) + "IBM Plex Sans" (body/UI)
   ------------------------------------------------------------------ */

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,400;8..60,500;8..60,600;8..60,700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --paper: #EAF2FA;
  --paper-raised: #F6FAFE;
  --ink: #202325;
  --ink-soft: #565B5F;
  --slate: #34495D;
  --slate-deep: #223140;
  --brick: #A65A43;
  --rule: #C9D9E8;
  --rule-soft: #DCE8F3;
  --max-w: 760px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Clean, non-stretched text wrapping: balance headings, avoid ragged/orphan
   line breaks in body copy, and never justify (justify is what stretches
   text unnecessarily). */
p, li, .lede, .quote-block, .coauthors, .ev-meta, blockquote {
  text-wrap: pretty;
  text-align: left;
  overflow-wrap: break-word;
  hyphens: auto;
}
h1, h2, h3, h4, .subtitle, .ev-title {
  text-wrap: balance;
}

a {
  color: var(--slate);
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
}
a:hover { color: var(--brick); text-decoration-color: var(--brick); }

h1, h2, h3, h4 {
  font-family: "Source Serif 4", Georgia, serif;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

/* ---------- Top nav ---------- */
.topnav {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topnav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.brand {
  font-family: "Source Serif 4", serif;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}
.brand:hover { color: var(--slate); }
.navlinks {
  display: flex;
  gap: 26px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.navlinks a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 500;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
}
.navlinks a:hover,
.navlinks a.active {
  color: var(--ink);
  border-bottom-color: var(--brick);
}
.nav-toggle { display: none; }

/* ---------- Page shell: sidebar + content ---------- */
.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 28px 80px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 56px;
  align-items: start;
}

/* ---------- Sidebar (Enomoto-style: small photo top-left, stacked meta/links) ---------- */
.sidebar {
  position: sticky;
  top: 84px;
  text-align: left;
}
.sidebar img.avatar {
  width: 25vw;
  max-width: 170px;
  min-width: 64px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--rule);
  display: block;
  margin: 0 0 14px;
}
.sidebar h2 {
  font-size: 1.15rem;
  margin: 0 0 3px;
}
.sidebar .role {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 0 0 14px;
  line-height: 1.4;
}
.sidebar .loc {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0 0 2px;
}
.sidebar .loc::before { content: "📍 "; }
.sidebar .org {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0 0 14px;
}
.sidebar .org::before { content: "🏛 "; }

.sidebar-links {
  list-style: none;
  margin: 0 0 20px;
  padding: 14px 0 0;
  border-top: 1px solid var(--rule-soft);
}
.sidebar-links li { margin-bottom: 8px; font-size: 0.84rem; }
.sidebar-links a {
  text-decoration: none;
  color: var(--slate-deep);
}
.sidebar-links a:hover { color: var(--brick); }
.sidebar-links a::before {
  content: "› ";
  color: var(--brick);
}

/* ---------- Content ---------- */
.content { max-width: var(--max-w); }
.content h1 {
  font-size: 2.1rem;
  margin: 0 0 6px;
}
.content .subtitle {
  color: var(--ink-soft);
  font-size: 1.02rem;
  margin: 0 0 30px;
}
.content h2 {
  font-size: 1.32rem;
  margin: 40px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--rule);
}
.content h3 {
  font-size: 1.08rem;
  margin: 26px 0 10px;
}
.content p { margin: 0 0 16px; }
.content ul, .content ol { margin: 0 0 18px; padding-left: 22px; }
.content li { margin-bottom: 6px; }

.lede {
  font-family: "Source Serif 4", serif;
  font-size: 1.12rem;
  line-height: 1.7;
  color: var(--ink);
}

.pub-list { list-style: none; padding: 0; margin: 0 0 20px; counter-reset: pub; }
.pub-list li {
  counter-increment: pub;
  padding: 12px 0 12px 40px;
  border-bottom: 1px solid var(--rule-soft);
  position: relative;
  font-size: 0.97rem;
}
.pub-list li::before {
  content: counter(pub) ".";
  position: absolute;
  left: 0;
  top: 12px;
  color: var(--brick);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}
.pub-list .coauthors { color: var(--ink-soft); font-size: 0.9rem; }

.event-list { list-style: none; padding: 0; margin: 0 0 10px; }
.event-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--rule-soft);
}
.event-list .ev-title { font-weight: 500; color: var(--ink); }
.event-list .ev-meta { color: var(--ink-soft); font-size: 0.9rem; display: block; margin-top: 2px; }

.quote-block {
  border-left: 3px solid var(--brick);
  padding: 4px 0 4px 20px;
  margin: 22px 0;
  font-family: "Source Serif 4", serif;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.7;
}

.section-label {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  margin: 0 0 10px;
}

.divider {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 34px 0;
}

/* ---------- Brick Lodge: clickable topic list + popups ---------- */
.brick-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
}
.brick-list li { margin-bottom: 10px; }
.brick-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  text-decoration: none;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 18px;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.brick-item:hover {
  border-color: var(--brick);
  background: var(--rule-soft);
}
.brick-item::after {
  content: "→";
  color: var(--brick);
  font-size: 1rem;
  margin-left: 12px;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 40, 0.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open {
  display: flex;
}
.modal-box {
  background: var(--paper-raised);
  border-radius: 8px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 28px 30px;
  position: relative;
  box-shadow: 0 12px 40px rgba(20, 30, 40, 0.25);
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: var(--brick); }
.modal-box h3 {
  font-size: 1.2rem;
  margin: 0 0 14px;
  padding-right: 24px;
}
.modal-box p:last-child { margin-bottom: 0; }
.modal-box.wide {
  max-width: 820px;
}

.conjectures-intro {
  font-size: 0.96rem;
  color: var(--ink-soft);
  margin: 0 0 28px;
  max-width: var(--max-w);
}

.conjecture-card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 22px 26px;
  margin: 0 0 22px;
}
.conjecture-card h3 {
  font-size: 1.1rem;
  margin: 0 0 8px;
}
.conjecture-meta {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.conjecture-meta a { white-space: nowrap; }
.conjecture-setting {
  font-size: 0.94rem;
  margin: 0 0 10px;
}
.conjecture-statement {
  background: var(--rule-soft);
  border-left: 3px solid var(--slate);
  padding: 12px 16px;
  margin: 0 0 14px;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink);
}

.info-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--slate);
  border-radius: 4px;
  color: var(--slate-deep);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 13px;
  cursor: pointer;
  font-family: "IBM Plex Sans", sans-serif;
}
.info-toggle:hover { background: var(--slate); color: #fff; }
.info-toggle .chev { transition: transform 0.15s ease; font-size: 0.75rem; }
.info-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }

.info-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
  font-size: 0.94rem;
}
.info-panel[hidden] { display: none; }
.info-panel p { margin: 0 0 12px; }
.info-panel p:last-of-type { margin-bottom: 12px; }

.topic-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.topic-list li a {
  display: inline-block;
  background: var(--rule-soft);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 5px 13px;
  font-size: 0.84rem;
  text-decoration: none;
  color: var(--slate-deep);
}
.topic-list li a:hover {
  background: var(--brick);
  border-color: var(--brick);
  color: #fff;
}
.topics-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.back-link {
  display: inline-block;
  margin-bottom: 22px;
  font-size: 0.92rem;
  text-decoration: none;
  color: var(--ink-soft);
}
.back-link:hover { color: var(--brick); }

.card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 22px 24px;
  margin: 24px 0;
}

.link-grid { list-style: none; padding: 0; margin: 0 0 20px; }
.link-grid li { margin-bottom: 8px; }

.btn {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--slate);
  border-radius: 4px;
  color: var(--slate-deep);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  margin: 4px 10px 4px 0;
}
.btn:hover { background: var(--slate); color: #fff; }

pre, code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.88rem;
}
pre {
  background: var(--slate-deep);
  color: #E7ECF1;
  padding: 16px 18px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 0 0 18px;
}
code.inline {
  background: var(--rule-soft);
  padding: 1px 6px;
  border-radius: 3px;
}

.figure {
  margin: 24px 0;
  text-align: center;
}
.figure img {
  max-width: 100%;
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.figure figcaption {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-top: 8px;
}

footer.site-footer {
  border-top: 1px solid var(--rule);
  text-align: center;
  padding: 26px 20px 40px;
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .sidebar img.avatar { width: 25vw; max-width: 110px; min-width: 64px; margin-bottom: 12px; }
  .sidebar-links { margin-top: 6px; }
  .navlinks { display: none; }
  .nav-toggle {
    display: inline-block;
    background: none;
    border: 1px solid var(--rule);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.85rem;
    color: var(--ink);
    cursor: pointer;
  }
  .topnav-inner.open .navlinks {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    padding: 16px 28px;
    gap: 14px;
  }
}
