/* danial-safaei.github.io: the only stylesheet.
   Layout: one centred reading column; the home page opens with text beside a round photo.
   Colours follow the reader's light or dark system setting. No JavaScript is needed. */

@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-latin-wght-italic.woff2") format("woff2");
  font-weight: 200 900;
  font-style: italic;
  font-display: swap;
}

:root {
  /* colour */
  --bg: #ffffff;
  --fg: #1c1f24;
  --muted: #5a6271;
  --rule: #e3e7ed;
  --link: #1d57a5;
  --link-hover: #0f3d78;
  --tint: #f3f5f8;
  /* type */
  --serif: "Source Serif 4", "Iowan Old Style", "Sitka Text", Cambria, Georgia, serif;
  --step-0: 1.0625rem;   /* body, 17px */
  --step--1: 0.9375rem;  /* details, links under a paper */
  --step--2: 0.8125rem;  /* labels */
  --step-1: 1.3125rem;   /* section headings */
  --step-3: 2.25rem;     /* name */
  /* layout */
  --column: 48rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --fg: #e5e7eb;
    --muted: #a0a8b4;
    --rule: #2b3038;
    --link: #8ab4f5;
    --link-hover: #b6cff9;
    --tint: #1b1e23;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a;
  --fg: #e5e7eb;
  --muted: #a0a8b4;
  --rule: #2b3038;
  --link: #8ab4f5;
  --link-hover: #b6cff9;
  --tint: #1b1e23;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: var(--step-0);
  line-height: 1.6;
  font-kerning: normal;
  text-rendering: optimizeLegibility;
}

.wrap {
  max-width: var(--column);
  margin: 0 auto;
  padding-block: 3.25rem 2.5rem;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  padding-left: max(1.25rem, env(safe-area-inset-left, 0px));
  padding-right: max(1.25rem, env(safe-area-inset-right, 0px));
}

p { margin: 0 0 0.9rem; }
p:last-child { margin-bottom: 0; }

/* links */
a {
  color: var(--link);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: var(--rule);
  text-decoration-color: color-mix(in srgb, var(--link) 38%, transparent);
}
a:hover { color: var(--link-hover); text-decoration-color: currentColor; }
a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 2px;
}
.plain-links a { text-decoration: none; }
.plain-links a:hover { text-decoration: underline; text-decoration-color: currentColor; }

/* headings */
h1, h2, h3 { font-weight: 600; text-wrap: balance; }
h1 {
  font-size: var(--step-3);
  line-height: 1.15;
  letter-spacing: -0.012em;
  margin: 0;
}
h2 {
  font-size: var(--step-1);
  line-height: 1.3;
  margin: 2.75rem 0 1rem;
}
.label {
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 2rem 0 1rem;
}

/* home: opening block */
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "text photo";
  gap: 1.25rem 2.75rem;
  align-items: start;
}
.intro-text { grid-area: text; min-width: 0; }
.intro-photo { grid-area: photo; margin: 0.4rem 0 0; }
.intro-photo img {
  display: block;
  width: 11rem;
  height: 11rem;
  max-width: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--tint);
}
.role {
  color: var(--muted);
  margin: 0.45rem 0 1.35rem;
}
.profile-links {
  list-style: none;
  padding: 0;
  margin: 1.35rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.2rem;
}
.nowrap { white-space: nowrap; }

/* dated lists: news, writing */
.dated {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.55rem;
}
.dated li {
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  gap: 1.25rem;
}
.dated time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* publications */
.pubs {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.6rem;
}
.pub-title {
  font-weight: 600;
  line-height: 1.4;
  margin: 0;
}
.pub-authors,
.pub-venue {
  margin: 0.2rem 0 0;
  color: var(--muted);
}
.me { color: var(--fg); font-weight: 600; }
.pub-venue em { color: var(--fg); }
.pub-links {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 1.1rem;
  font-size: var(--step--1);
}
.pub-note {
  margin: 0.4rem 0 0;
  font-size: var(--step--1);
  max-width: 40rem;
}

details.more { margin-top: 2rem; }
details.more > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.15rem 0;
}
details.more > summary:hover { color: var(--link-hover); }
details.more > summary:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
  border-radius: 2px;
}
details.more[open] > summary { margin-bottom: 1rem; }
.pubs-compact {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.9rem;
  font-size: var(--step--1);
}
.pubs-compact .pub-title { font-weight: 400; }

/* footer */
.site-footer {
  margin-top: 3.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: var(--step--1);
}
.site-footer p { margin: 0 0 0.35rem; }

/* inner pages: a slim header with the way home */
.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem 1.5rem;
  padding-bottom: 1rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule);
}
.site-header .home {
  color: var(--fg);
  font-weight: 600;
  font-size: 1.125rem;
  text-decoration: none;
}
.site-nav {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.35rem;
}
.site-nav a[aria-current="page"] { color: var(--fg); }

/* CV */
.cv-head .role { margin-bottom: 0.6rem; }
.cv-contact {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 1.2rem;
  color: var(--muted);
}
.cv-row {
  display: grid;
  grid-template-columns: 10.25rem minmax(0, 1fr);
  gap: 0.15rem 1.5rem;
  margin: 0 0 1.1rem;
}
.cv-when {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cv-what p { margin: 0; }
.cv-what p + p { margin-top: 0.15rem; }
.cv-what ul {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
}
.cv-what li + li { margin-top: 0.25rem; }
.cv-note { color: var(--muted); }
.cv .pubs { gap: 1.1rem; }

/* writing */
.lede { color: var(--muted); margin: 0.5rem 0 2rem; }
.post-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.5rem;
}
.post-list time {
  display: block;
  color: var(--muted);
  font-size: var(--step--1);
}
.post-list .post-link { font-weight: 600; }
.post-list p { margin: 0.25rem 0 0; }

.post { max-width: 40rem; }
.post h1 { font-size: 2rem; }
.post-date { color: var(--muted); margin: 0.6rem 0 2rem; }
.post h2 { margin-top: 2.25rem; }
.post ol,
.post ul { padding-left: 1.35rem; margin: 0 0 1rem; }
.post li + li { margin-top: 0.35rem; }
.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0 1.5rem;
}
.post table {
  border-collapse: collapse;
  width: 100%;
  font-size: var(--step--1);
}
.post th,
.post td {
  text-align: left;
  vertical-align: top;
  padding: 0.5rem 1rem 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.post th { font-weight: 600; }
.post-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
  color: var(--muted);
}

/* small screens */
@media (max-width: 40rem) {
  :root { --step-3: 2rem; }
  .wrap { padding-block: 2rem 2rem; }
  .intro {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "photo" "text";
  }
  .intro-photo { margin: 0; }
  .intro-photo img { width: 7rem; height: 7rem; }
  .cv-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 26rem) {
  .dated li { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

/* print: the CV and posts print cleanly */
@media print {
  :root,
  :root:not([data-theme="light"]),
  :root[data-theme="dark"] {
    --bg: #ffffff;
    --fg: #000000;
    --muted: #3d3d3d;
    --rule: #bbbbbb;
    --link: #000000;
    --link-hover: #000000;
    color-scheme: light;
  }
  body { font-size: 10.5pt; line-height: 1.45; }
  .wrap { max-width: none; padding: 0; }
  .site-header, .site-footer, .no-print { display: none; }
  a { text-decoration: none; }
  h2 { break-after: avoid; margin-top: 1.4rem; }
  .cv-row:not(:has(ul)), .pubs > li { break-inside: avoid; }
}
