/* ============================================================
   Kasra Fouladi — Academic personal site
   Shared stylesheet
   ============================================================ */

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

/* ---- Tokens ---- */
:root {
  --bg: #fdfdfc;
  --bg-soft: #f7f5ef;
  --ink: #191919;
  --ink-soft: #494949;
  --ink-mute: #7d7d7d;
  --rule: #e5e1d8;
  --rule-strong: #d4cec1;
  --link: #14417a;
  --link-hover: #0a2547;
  --accent: #8b1a1a;
  --code-bg: #f0eee6;

  --serif: 'Source Serif 4', Georgia, 'Times New Roman', Times, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --fa: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;

  --content: 760px;
  --pad: clamp(1.1rem, 4vw, 2rem);
}

/* ---- Base ---- */
html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.65;
  font-feature-settings: 'kern', 'liga', 'onum';
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Links ---- */
a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
a:hover { color: var(--link-hover); border-bottom-color: currentColor; }

/* ---- Layout ---- */
.page {
  max-width: var(--content);
  margin: 0 auto;
  padding: clamp(1.6rem, 5vw, 3rem) var(--pad) 4rem;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  padding-bottom: 1rem;
  margin-bottom: 2.4rem;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.85rem;
}
.topbar .nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.1rem;
  align-items: baseline;
}
.topbar .nav a { color: var(--ink-soft); border-bottom: none; }
.topbar .nav a:hover { color: var(--link); }
.topbar .nav a.here { color: var(--ink); font-weight: 600; }
.topbar .right { display: flex; align-items: baseline; gap: 0.9rem; }
.lang-toggle {
  display: inline-flex; align-items: baseline; gap: 0.35rem;
  font-family: var(--sans); font-size: 0.82rem;
}
.lang-toggle button {
  background: none; border: none; cursor: pointer;
  padding: 0.1rem 0.35rem; color: var(--ink-mute);
  font: inherit; border-radius: 2px;
}
.lang-toggle button:hover { color: var(--ink); }
.lang-toggle button[aria-pressed="true"] {
  color: var(--ink); font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.lang-toggle .sep { color: var(--rule-strong); }

/* ---- Intro ---- */
.intro { margin-bottom: 3rem; }
.intro h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}
.intro .subtitle { font-size: 1.02rem; color: var(--ink-soft); line-height: 1.55; }
.intro .subtitle a { border-bottom-color: var(--rule-strong); }
.intro .subtitle a:hover { border-bottom-color: var(--link); }
.intro .contact {
  margin-top: 0.9rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--ink-mute);
  line-height: 1.8;
}
.intro .contact a { color: var(--ink-soft); border-bottom: none; }
.intro .contact a:hover { color: var(--link); }
.intro .sep { color: var(--rule-strong); margin: 0 0.45rem; }
.intro .quick-links {
  margin-top: 1rem;
  display: flex; flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  font-size: 0.92rem;
}

/* ---- Sections ---- */
section.s { margin-bottom: 2.8rem; }
section.s > h2 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: 0.015em;
  padding-bottom: 0.5rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}

p.body {
  margin-bottom: 0.9rem;
  color: var(--ink-soft);
  text-align: justify;
  hyphens: auto;
}
p.body strong { color: var(--ink); font-weight: 600; }
p.body em { font-style: italic; }

/* ---- Interests ---- */
.interests { font-size: 0.95rem; color: var(--ink-soft); line-height: 1.8; }
.interests .label { color: var(--ink); font-weight: 600; }

/* ---- News ---- */
.news { font-size: 0.94rem; }
.news-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 1.2rem;
  padding: 0.5rem 0;
  border-bottom: 1px dotted var(--rule);
}
.news-item:last-child { border-bottom: none; }
.news-date {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--ink-mute);
  padding-top: 0.18rem;
  white-space: nowrap;
}
.news-text { color: var(--ink-soft); }
.news-text strong { color: var(--ink); font-weight: 600; }

/* ---- Publications ---- */
.pubs { counter-reset: pub; }
.pub {
  position: relative;
  padding-left: 2.4rem;
  padding-bottom: 1.4rem;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--rule);
  counter-increment: pub;
}
.pub:last-child { border-bottom: none; padding-bottom: 0; }
.pub::before {
  content: "[" counter(pub) "]";
  position: absolute;
  left: 0;
  top: 0.05rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--ink-mute);
}
.pub-title {
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.4;
  margin-bottom: 0.3rem;
  color: var(--ink);
}

/* ---- Row: authors + download/DOI links ---- */
.pub-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  overflow: visible;
  min-height: 3rem;
  padding: 0.3rem 0;
  margin-bottom: 0.15rem;
}
.pub-head .pub-authors {
  font-size: 0.92rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.4;
}
.pub-head .pub-authors em { font-style: normal; color: var(--ink); }
.pub-head .pub-links {
  margin: 0;
  flex-shrink: 0;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.9rem;
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.4;
  overflow: visible;
}
.pub-head .pub-links a {
  border-bottom: none;
  color: var(--link);
}
.pub-head .pub-links a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* FIX: make sure the CV button inside pub-links keeps its full border
   (this rule has higher specificity than `.pub-links a { border-bottom: none }`) */
.pub-head .pub-links .cv-btn {
  border: 1px solid currentColor;
}
.pub-head .pub-links .cv-btn:hover {
  border: 1px solid currentColor;
}

.pub-venue { font-size: 0.9rem; color: var(--ink-mute); font-style: italic; }
.pub-abstract {
  margin-top: 0.7rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
  line-height: 1.7;
  text-align: justify;
  hyphens: auto;
}
.pub-abstract .lead { color: var(--ink); font-weight: 600; }

/* ---- Entry ---- */
.entry { margin-bottom: 1.5rem; }
.entry:last-child { margin-bottom: 0; }
.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.15rem;
}
.entry-title { font-weight: 600; font-size: 1rem; color: var(--ink); }
.entry-date {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-mute);
  white-space: nowrap;
}
.entry-sub {
  font-size: 0.94rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 0.4rem;
}
.entry ul { list-style: none; padding-left: 0; margin-top: 0.4rem; }
.entry ul li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.93rem;
  color: var(--ink-soft);
  line-height: 1.7;
  margin-bottom: 0.2rem;
}
.entry ul li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--ink-mute);
}

/* ---- Courses ---- */
.courses { font-size: 0.92rem; color: var(--ink-soft); line-height: 1.9; }
.courses .grade { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-mute); }

/* ---- Definition list ---- */
.dl {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.55rem 1.4rem;
  font-size: 0.94rem;
}
.dl dt {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 0.15rem;
}
.dl dd { color: var(--ink-soft); line-height: 1.75; }

/* ---- Contact list ---- */
.contact-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.2rem 1.6rem;
  font-size: 0.94rem;
}
.contact-list a,
.contact-list span {
  display: flex;
  gap: 0.7rem;
  align-items: baseline;
  border-bottom: 1px dotted var(--rule);
  padding: 0.5rem 0;
  color: var(--ink-soft);
  border-top: none; border-left: none; border-right: none;
}
.contact-list a:hover { color: var(--link); border-bottom-color: var(--link); }
.contact-list .k {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-mute);
  min-width: 78px;
  letter-spacing: 0.02em;
}
.contact-list .v {
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-all;
}

/* ---- Inline code ---- */
code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.08em 0.35em;
  border-radius: 2px;
  color: var(--ink);
}

/* ---- Footer ---- */
footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--ink-mute);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.8rem 1.5rem;
}
footer a { color: var(--ink-mute); border-bottom: none; }
footer a:hover { color: var(--link); }
footer .links { display: flex; gap: 1rem; flex-wrap: wrap; }

/* ---- Language switching ---- */
html[data-lang="en"] [data-lang-content="fa"] { display: none; }
html[data-lang="fa"] [data-lang-content="en"] { display: none; }

/* ---- RTL / Persian ---- */
html[dir="rtl"] body { font-family: var(--fa); }
html[dir="rtl"] .intro h1,
html[dir="rtl"] section.s > h2 { font-family: var(--fa); font-weight: 700; letter-spacing: 0; }
html[dir="rtl"] p.body,
html[dir="rtl"] .pub-abstract { text-align: right; }
html[dir="rtl"] .news-item { grid-template-columns: 1fr 90px; }
html[dir="rtl"] .news-date { text-align: left; padding-top: 0; }
html[dir="rtl"] .pub { padding-left: 0; padding-right: 2.4rem; }
html[dir="rtl"] .pub::before { left: auto; right: 0; }
html[dir="rtl"] .entry ul li { padding-left: 0; padding-right: 1.1rem; }
html[dir="rtl"] .entry ul li::before { left: auto; right: 0; }

/* ---- CV button (used in topbar, intro, and publication rows) ---- */
.cv-btn{
  display:inline-flex; align-items:center; gap:.4em;
  font-family:"IBM Plex Mono", ui-monospace, monospace;
  font-size:.82rem; font-weight:500; letter-spacing:.02em;
  padding:.38em .8em;
  border:1px solid currentColor; border-radius:5px;
  text-decoration:none; color:inherit;
  line-height:1.1; box-sizing:border-box; vertical-align:middle;
  transition: background-color .15s ease, color .15s ease, transform .15s ease;
  white-space:nowrap;
}
.cv-btn:hover{ background:currentColor; transform: translateY(-1px); }
.cv-btn:hover span{ color:#fdfdfc; }
.cv-btn svg{ width:.95em; height:.95em; flex:0 0 auto; }
.cv-btn--primary{ font-size:.88rem; padding:.5em 1.05em; }

/* ---- Mobile ---- */
@media (max-width: 520px) {
  body { font-size: 16px; }
  .page { padding: 1.4rem 1.1rem 3rem; }
  .intro h1 { font-size: 1.9rem; }
  .news-item { grid-template-columns: 1fr; gap: 0.15rem; }
  .news-date { padding-top: 0; }
  .dl { grid-template-columns: 1fr; gap: 0.15rem 0; }
  .dl dt { padding-top: 0.7rem; }
  .pub { padding-left: 1.7rem; }
  .pub::before { font-size: 0.76rem; }
  .topbar .nav { font-size: 0.8rem; gap: 0.15rem 0.85rem; }
}

.pub-head .pub-links .cv-btn { border: 1px solid currentColor; }
.pub-head .pub-links .cv-btn:hover { border: 1px solid currentColor; }
