/* ==========================================================================
   parsajafarian.github.io — minimal academic stylesheet

   Layout model: every block sits in a two-column grid —
     [ left margin | main content | figure rail | right margin ]
   Prose lives in .col-main, figures in .col-rail. The rail is simply empty
   on text-only sections, which keeps one consistent left edge down the page.
   ========================================================================== */

/* ---------- Tokens ---------- */

:root {
	--bg: #fcfcfb;
	--bg-soft: #f4f3f0;
	--text: #1b1b1a;
	--muted: #6a6863;
	--faint: #8f8d87;
	--rule: #e2e0da;
	--accent: #b81d3a;
	--accent-soft: rgba(184, 29, 58, 0.09);

	--serif: "Source Serif 4", Charter, "Iowan Old Style", Georgia, serif;
	--sans: Inter, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
	--mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

	--measure: 68rem;
	--rail: 340px;
	--gutter: 2.75rem;
	--gap: 1.05rem;
}

html[data-theme="dark"] {
	--bg: #15161a;
	--bg-soft: #1d1f24;
	--text: #e6e4e0;
	--muted: #9d9b95;
	--faint: #7d7b76;
	--rule: #2c2e35;
	--accent: #ef6b83;
	--accent-soft: rgba(239, 107, 131, 0.14);
}

/* ---------- Base ---------- */

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

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

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font-family: var(--sans);
	font-size: 16px;
	line-height: 1.65;
	font-feature-settings: "kern", "liga";
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

img,
video {
	max-width: 100%;
	height: auto;
	display: block;
}

a {
	color: var(--text);
	text-decoration: underline;
	text-decoration-color: var(--rule);
	text-decoration-thickness: 1px;
	text-underline-offset: 2px;
	transition: color 0.13s ease, text-decoration-color 0.13s ease;
}

a:hover {
	color: var(--accent);
	text-decoration-color: var(--accent);
}

p {
	margin: 0 0 var(--gap);
}

/* Justified prose. Hyphenation is essential here — justifying without it
   opens rivers of whitespace in a column this narrow. */

.lede,
.entry-body p,
.findings li,
.intro-body p,
.justify {
	text-align: justify;
	text-justify: inter-word;
	-webkit-hyphens: auto;
	hyphens: auto;
}

/* ---------- Layout ---------- */

.wrap {
	max-width: var(--measure);
	margin: 0 auto;
	padding: 0 1.5rem;
}

.grid {
	display: grid;
	grid-template-columns: minmax(0, 1fr) var(--rail);
	column-gap: var(--gutter);
	align-items: start;
}

.col-main {
	grid-column: 1;
	min-width: 0;
}

.col-rail {
	grid-column: 2;
	min-width: 0;
}

/* Figures in the rail stack tightly and never inherit the loose block margin. */

.col-rail > figure {
	margin: 0 0 1.15rem;
}

/* Pin rail videos to the still image's aspect ratio so the media column is
   uniform and does not reflow once video metadata loads and replaces the
   poster's dimensions. */

.col-rail video {
	aspect-ratio: 1178 / 698;
	object-fit: cover;
}

.col-rail > figure:last-child,
.col-rail > *:last-child {
	margin-bottom: 0;
}

main {
	padding-bottom: 3rem;
}

/* ---------- Header / nav ---------- */

.site-header {
	border-bottom: 1px solid var(--rule);
	background: var(--bg);
	position: sticky;
	top: 0;
	z-index: 20;
}

.nav {
	display: flex;
	align-items: center;
	gap: 1rem;
	min-height: 3.4rem;
}

.nav-brand {
	font-family: var(--serif);
	font-size: 1.2rem;
	font-weight: 600;
	text-decoration: none;
	letter-spacing: 0.01em;
	margin-right: auto;
	white-space: nowrap;
}

.nav-links {
	display: flex;
	align-items: center;
	gap: 1.1rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

.nav-links a {
	font-size: 0.95rem;
	text-decoration: none;
	color: var(--muted);
}

.nav-links a:hover {
	color: var(--accent);
}

.nav-links a[aria-current="page"] {
	color: var(--text);
	font-weight: 500;
}

.nav-sep {
	width: 1px;
	height: 1.2rem;
	background: var(--rule);
}

.nav-icons {
	display: flex;
	align-items: center;
	gap: 0.8rem;
	list-style: none;
	margin: 0;
	padding: 0;
}

/* The icons carry width/height attributes inline; sizing them here overrides
   all of them at once rather than editing each SVG on every page. */

.nav-icons svg {
	width: 19px;
	height: 19px;
}

.nav-icons a {
	color: var(--muted);
	text-decoration: none;
	display: flex;
	font-size: 0.95rem;
	line-height: 1;
}

.nav-icons a:hover {
	color: var(--accent);
}

.theme-toggle {
	background: none;
	border: 0;
	padding: 0.2rem;
	cursor: pointer;
	color: var(--muted);
	font-size: 0.95rem;
	line-height: 1;
	display: flex;
}

.theme-toggle:hover {
	color: var(--accent);
}

.theme-toggle .icon-dark {
	display: none;
}

html[data-theme="dark"] .theme-toggle .icon-light {
	display: none;
}

html[data-theme="dark"] .theme-toggle .icon-dark {
	display: block;
}

/* ---------- Hero ---------- */

.hero {
	padding: 3.4rem 0 0.5rem;
}

.hero-name {
	font-family: var(--serif);
	font-size: 2.5rem;
	font-weight: 600;
	line-height: 1.12;
	letter-spacing: -0.018em;
	margin: 0 0 0.5rem;
}

.hero-role {
	color: var(--muted);
	font-size: 1rem;
	margin: 0 0 1rem;
	line-height: 1.5;
}

.hero-links {
	display: flex;
	flex-wrap: wrap;
	gap: 0.4rem 1rem;
	font-size: 0.88rem;
	list-style: none;
	margin: 0 0 1.5rem;
	padding: 0;
}

.hero-links a {
	color: var(--muted);
	text-decoration-color: var(--rule);
}

.hero-links a:hover {
	color: var(--accent);
}

.hero-portrait {
	margin: 0;
}

.hero-portrait img {
	width: 100%;
	border-radius: 3px;
	border: 1px solid var(--rule);
}

.hero-portrait figcaption {
	font-size: 0.75rem;
	color: var(--faint);
	line-height: 1.5;
	margin-top: 0.5rem;
}

.lede {
	font-size: 1.05rem;
}

/* ---------- Sections ---------- */

.section {
	padding-top: 2.8rem;
}

.section-label {
	font-size: 0.72rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.13em;
	color: var(--faint);
	margin: 0 0 1.5rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--rule);
}

/* Text-only sections leave the rail empty, so their rule stops at the text
   column rather than overshooting into blank space. */

.section--text .section-label {
	max-width: calc(100% - var(--rail) - var(--gutter));
}

/* ---------- Entries ---------- */

.entry {
	padding-bottom: 2.4rem;
}

.entry + .entry {
	padding-top: 2.4rem;
	border-top: 2px solid var(--faint);
}

.entry:last-child {
	padding-bottom: 0.4rem;
}

.entry-head {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.3rem 1rem;
	margin-bottom: 0.15rem;
}

.entry-title {
	font-size: 1.1rem;
	font-weight: 600;
	margin: 0;
	line-height: 1.4;
	flex: 1 1 auto;
	min-width: 0;
}

.entry-date {
	font-size: 0.8rem;
	color: var(--faint);
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

.entry-org {
	font-size: 0.88rem;
	color: var(--muted);
	margin: 0 0 0.9rem;
}

.entry-org img.logo {
	display: inline-block;
	height: 1.05em;
	width: auto;
	vertical-align: -0.16em;
	margin-right: 0.35rem;
	border-radius: 2px;
}

.entry-body p {
	font-size: 0.95rem;
}

.entry-body > *:last-child {
	margin-bottom: 0;
}

/* Bulleted findings */

.findings {
	list-style: none;
	margin: 0 0 var(--gap);
	padding: 0;
	font-size: 0.93rem;
}

.findings li {
	position: relative;
	padding-left: 1.05rem;
	margin-bottom: 0.5rem;
	line-height: 1.6;
}

.findings li::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0.62em;
	width: 4px;
	height: 4px;
	border-radius: 50%;
	background: var(--accent);
	opacity: 0.65;
}

.findings li:last-child {
	margin-bottom: 0;
}

.num {
	font-variant-numeric: tabular-nums;
	font-weight: 600;
}

/* ---------- Figures & media ---------- */

figure {
	margin: 1.4rem 0;
}

figure img,
figure video {
	width: 100%;
	border: 1px solid var(--rule);
	border-radius: 3px;
	background: var(--bg-soft);
}

figcaption {
	font-size: 0.76rem;
	color: var(--faint);
	line-height: 1.5;
	margin-top: 0.45rem;
}

/* Charts and paper figures carry a baked-in white background. Matting them
   keeps that white reading as a deliberate plate instead of glare in dark mode. */

figure.plate img {
	background: #fff;
	padding: 0.5rem;
}

/* Figures rendered once per theme. Swapping in CSS rather than JS means the
   right one is painted on first load and follows the toggle instantly. */

.figure-themed .fig-dark {
	display: none;
}

html[data-theme="dark"] .figure-themed .fig-light {
	display: none;
}

html[data-theme="dark"] .figure-themed .fig-dark {
	display: block;
}

/* Poster thumbnail card */

.poster-link {
	display: flex;
	gap: 0.85rem;
	align-items: flex-start;
	padding: 0.8rem;
	border: 1px solid var(--rule);
	border-radius: 3px;
	background: var(--bg-soft);
	text-decoration: none;
}

.poster-link:hover {
	border-color: var(--accent);
}

.poster-link img {
	flex: 0 0 62px;
	width: 62px;
	border: 1px solid var(--rule);
	border-radius: 2px;
	background: #fff;
}

.poster-link-text {
	min-width: 0;
}

.poster-link-title {
	display: block;
	font-size: 0.82rem;
	font-weight: 600;
	line-height: 1.4;
	margin-bottom: 0.2rem;
}

.poster-link-meta {
	display: block;
	font-size: 0.75rem;
	color: var(--muted);
	line-height: 1.5;
}

/* ---------- Citation block ---------- */

.citation {
	border-left: 2px solid var(--accent);
	padding: 0.15rem 0 0.15rem 1rem;
	font-size: 0.92rem;
	line-height: 1.6;
}

.citation .venue {
	color: var(--muted);
}

.citation-links {
	margin-bottom: 0;
	font-size: 0.85rem;
	color: var(--muted);
}

.badge {
	display: inline-block;
	font-size: 0.68rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.07em;
	color: var(--accent);
	background: var(--accent-soft);
	padding: 0.12rem 0.4rem;
	border-radius: 2px;
	vertical-align: 0.09em;
	white-space: nowrap;
}

details.bibtex {
	margin-top: 0.7rem;
	font-size: 0.82rem;
}

details.bibtex summary {
	cursor: pointer;
	color: var(--muted);
	list-style: none;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	user-select: none;
}

details.bibtex summary::-webkit-details-marker {
	display: none;
}

details.bibtex summary::before {
	content: "▸";
	font-size: 0.7em;
	transition: transform 0.15s ease;
	display: inline-block;
}

details.bibtex[open] summary::before {
	transform: rotate(90deg);
}

details.bibtex summary:hover {
	color: var(--accent);
}

details.bibtex pre {
	font-family: var(--mono);
	font-size: 0.74rem;
	line-height: 1.55;
	background: var(--bg-soft);
	border: 1px solid var(--rule);
	border-radius: 3px;
	padding: 0.8rem 0.9rem;
	overflow-x: auto;
	margin: 0.6rem 0 0;
	white-space: pre;
	color: var(--muted);
}

/* ---------- Compact rows (education / awards) ---------- */

.rows {
	margin: 0;
	font-size: 0.93rem;
}

.row-item {
	display: flex;
	flex-wrap: wrap;
	gap: 0.2rem 1rem;
	padding: 0.65rem 0;
	border-bottom: 1px solid var(--rule);
}

.row-item:first-child {
	padding-top: 0;
}

.row-item:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.row-main {
	flex: 1 1 60%;
	min-width: 0;
}

.row-main strong {
	font-weight: 600;
}

.row-note {
	display: block;
	color: var(--muted);
	font-size: 0.87rem;
	margin-top: 0.05rem;
}

.row-aside {
	color: var(--faint);
	font-size: 0.82rem;
	text-align: right;
	white-space: nowrap;
	margin-left: auto;
}

/* ---------- Personal list ---------- */

.pursuits {
	list-style: none;
	margin: 0;
	padding: 0;
	font-size: 0.93rem;
}

.pursuits li {
	display: grid;
	grid-template-columns: 9rem minmax(0, 1fr);
	gap: 0 0.8rem;
	padding: 0.6rem 0;
	border-bottom: 1px solid var(--rule);
	line-height: 1.6;
}

.pursuits li:first-child {
	padding-top: 0;
}

.pursuits li:last-child {
	border-bottom: 0;
	padding-bottom: 0;
}

.pursuits .what {
	font-weight: 600;
}

/* ---------- Page-ending call to action ---------- */

.next-link {
	margin-top: 2.6rem;
	padding-top: 1.3rem;
	border-top: 1px solid var(--rule);
	font-size: 0.9rem;
}

/* ---------- CV page ---------- */

.cv-head {
	display: flex;
	align-items: center;
	gap: 1.15rem;
	padding: 3rem 0 1.4rem;
}

.cv-head img {
	flex: 0 0 78px;
	width: 78px;
	height: 78px;
	border-radius: 50%;
	object-fit: cover;
	border: 1px solid var(--rule);
}

.cv-head h1 {
	font-family: var(--serif);
	font-size: 1.75rem;
	font-weight: 600;
	margin: 0 0 0.25rem;
	letter-spacing: -0.01em;
}

.cv-head p {
	margin: 0;
	font-size: 0.88rem;
	color: var(--muted);
}

.cv-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6rem;
	margin-bottom: 1.4rem;
}

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	font-size: 0.85rem;
	padding: 0.42rem 0.85rem;
	border: 1px solid var(--rule);
	border-radius: 3px;
	text-decoration: none;
	color: var(--text);
	background: var(--bg);
	transition: border-color 0.13s ease, color 0.13s ease;
}

.btn:hover {
	border-color: var(--accent);
	color: var(--accent);
}

.btn-primary {
	border-color: var(--accent);
	color: #fff;
	background: var(--accent);
}

.btn-primary:hover {
	color: #fff;
	opacity: 0.87;
}

.pdf-frame {
	width: 100%;
	height: min(1150px, 128vh);
	border: 1px solid var(--rule);
	border-radius: 3px;
	background: var(--bg-soft);
}

.pdf-fallback {
	font-size: 0.85rem;
	color: var(--muted);
	margin-top: 0.7rem;
}

/* ---------- Footer ---------- */

.site-footer {
	border-top: 1px solid var(--rule);
	margin-top: 3rem;
	padding: 1.7rem 0 2.6rem;
	font-size: 0.82rem;
	color: var(--faint);
}

.site-footer a {
	color: var(--muted);
}

.footer-inner {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem 1.2rem;
	align-items: center;
}

.footer-inner .spacer {
	margin-left: auto;
}

/* ---------- Accessibility ---------- */

.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	background: var(--accent);
	color: #fff;
	padding: 0.5rem 0.9rem;
	z-index: 100;
	text-decoration: none;
	border-radius: 0 0 3px 0;
}

.skip-link:focus {
	left: 0;
	color: #fff;
}

:focus-visible {
	outline: 2px solid var(--accent);
	outline-offset: 2px;
	border-radius: 2px;
}

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

	*,
	*::before,
	*::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
	}
}

/* ---------- Responsive ---------- */

/* Rail narrows before it collapses, so figures stay beside prose as long as
   the text column can still hold a comfortable line. */

@media (max-width: 1040px) {
	:root {
		--rail: 280px;
		--gutter: 2.1rem;
	}
}

@media (max-width: 860px) {
	.grid {
		grid-template-columns: minmax(0, 1fr);
	}

	.col-main,
	.col-rail {
		grid-column: 1;
	}

	.col-rail {
		margin-top: 1.5rem;
	}

	/* The rail is gone below this width, so the rule spans the full column again. */
	.section--text .section-label {
		max-width: none;
	}

	.hero-portrait {
		max-width: 300px;
	}

	.hero {
		padding-top: 2.4rem;
	}

	.hero-name {
		font-size: 2.1rem;
	}
}

@media (max-width: 640px) {

	/* Justification needs room; below this width it does more harm than good. */
	.lede,
	.entry-body p,
	.findings li,
	.intro-body p,
	.justify {
		text-align: left;
		hyphens: manual;
	}

	.hero-name {
		font-size: 1.85rem;
	}

	.entry-date {
		font-size: 0.78rem;
	}

	.row-aside {
		text-align: left;
		margin-left: 0;
		flex-basis: 100%;
	}

	.pursuits li {
		grid-template-columns: minmax(0, 1fr);
		gap: 0;
	}

	.nav-brand {
		font-size: 1.05rem;
	}

	.pdf-frame {
		height: 78vh;
	}

	.cv-head {
		padding-top: 2.2rem;
	}
}

@media (max-width: 400px) {
	.nav-links {
		gap: 0.8rem;
	}

	.nav-icons {
		gap: 0.55rem;
	}
}

/* ---------- Print ---------- */

@media print {

	.site-header,
	.site-footer,
	.cv-actions,
	.next-link,
	.theme-toggle {
		display: none;
	}

	body {
		background: #fff;
		color: #000;
		font-size: 11pt;
	}

	a {
		text-decoration: none;
		color: #000;
	}

	.entry {
		break-inside: avoid;
	}
}
