/* atilavahedian.com */
@font-face { font-family: "Source Serif"; font-style: normal; font-weight: 200 900; font-display: swap; src: url(/assets/fonts/serif.woff2) format("woff2-variations"); }
@font-face { font-family: "Source Serif"; font-style: italic; font-weight: 200 900; font-display: swap; src: url(/assets/fonts/serif-italic.woff2) format("woff2-variations"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url(/assets/fonts/inter.woff2) format("woff2-variations"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 100 800; font-display: swap; src: url(/assets/fonts/mono.woff2) format("woff2-variations"); }

:root {
  --serif: "Source Serif", Georgia, "Times New Roman", serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --bg: #fbf9f5;
  --ink: #1a1917;
  --muted: #6b665f;
  --faint: #a39d93;
  --line: #e6e0d6;
  --soft: #f3eee6;
  --paper: #f5f1ea;
  --accent: #c45f2d;
  --c1: #c45f2d; --c2: #2f5d8a; --c3: #3d7a63; --c4: #c18f2a; --c5: #7b5279; --c6: #8c877e;
  --code-bg: #f3eee6;
  --sel: rgba(196, 95, 45, .18);

  --text: 680px;
  --wide: 1040px;
  --gutter: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141312; --ink: #ece8e1; --muted: #a29c92; --faint: #6f6a62; --line: #2c2a27; --soft: #1d1b19; --paper: #1b1917;
    --accent: #e07a45; --c1: #e07a45; --c2: #6f9fd0; --c3: #6fb293; --c4: #ddb257; --c5: #b58ab2; --c6: #8f8a82;
    --code-bg: #1d1b19; --sel: rgba(224, 122, 69, .28); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141312; --ink: #ece8e1; --muted: #a29c92; --faint: #6f6a62; --line: #2c2a27; --soft: #1d1b19; --paper: #1b1917;
  --accent: #e07a45; --c1: #e07a45; --c2: #6f9fd0; --c3: #6fb293; --c4: #ddb257; --c5: #b58ab2; --c6: #8f8a82;
  --code-bg: #1d1b19; --sel: rgba(224, 122, 69, .28); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 24px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--serif); font-size: 20px; line-height: 1.65;
  font-optical-sizing: auto; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--sel); }
a { color: inherit; text-decoration-line: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--faint); transition: text-decoration-color .15s, color .15s; }
a:hover { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
img, svg { max-width: 100%; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; background: var(--bg); padding: 6px 10px; z-index: 10; font: 600 14px var(--sans); }

/* ---------- chrome ---------- */
.shell { width: min(var(--wide), 100% - 2 * var(--gutter)); margin: 0 auto; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 28px 0 0; font-family: var(--sans); }
.wordmark { font-size: 15px; font-weight: 650; letter-spacing: -.01em; text-decoration: none; display: inline-flex; align-items: center; gap: 10px; }
.wordmark .mark { width: 22px; height: 22px; border-radius: 5px; background: var(--ink); color: var(--bg); display: inline-grid; place-items: center; font: 700 12px/1 var(--sans); letter-spacing: -.02em; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.nav a { font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.nav a:hover { color: var(--ink); background: var(--soft); }
.nav a[aria-current="page"] { color: var(--ink); }
.theme-btn { appearance: none; border: 0; background: none; color: var(--muted); width: 34px; height: 34px; border-radius: 6px; display: inline-grid; place-items: center; cursor: pointer; }
.theme-btn:hover { color: var(--ink); background: var(--soft); }
.theme-btn svg { width: 17px; height: 17px; }

.site-footer { margin-top: 120px; border-top: 1px solid var(--line); padding: 28px 0 56px; font: 400 14px/1.6 var(--sans); color: var(--muted); display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.site-footer nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* ---------- shared bits ---------- */
.kicker { font: 600 12px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.meta { font: 400 14px/1.5 var(--sans); color: var(--muted); }
.meta a { color: var(--muted); }
.meta a:hover { color: var(--ink); }
.dot::before { content: "·"; margin: 0 .5em; color: var(--faint); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 0 0 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.section-head h2 { margin: 0; font: 600 13px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.section-head a { font: 500 14px var(--sans); color: var(--muted); text-decoration: none; }
.section-head a:hover { color: var(--ink); }
.pill { display: inline-flex; align-items: center; gap: 6px; font: 500 13px/1 var(--sans); color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 8px 13px; background: transparent; transition: border-color .15s, background .15s; }
.pill:hover { border-color: var(--ink); background: var(--soft); }
.pill svg { width: 14px; height: 14px; }

/* ---------- home ---------- */
.intro { padding: 112px 0 96px; max-width: 760px; }
.intro h1 { font: 600 clamp(40px, 6.4vw, 64px)/1.02 var(--serif); letter-spacing: -.03em; margin: 0 0 28px; }
.intro .bio { font-size: clamp(20px, 2.3vw, 24px); line-height: 1.5; color: var(--ink); margin: 0 0 18px; letter-spacing: -.005em; }
.intro .bio.muted { color: var(--muted); }
.intro .links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 32px; }
.home-section { margin-top: 24px; margin-bottom: 88px; }

.post-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 44px 36px; }
.post-card { display: block; text-decoration: none; }
.post-card .thumb { aspect-ratio: 16 / 9; border-radius: 6px; overflow: hidden; background: var(--paper); border: 1px solid var(--line); }
.post-card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s cubic-bezier(.2,.7,.2,1); }
.post-card:hover .thumb img { transform: scale(1.02); }
.post-card h3 { font: 600 24px/1.2 var(--serif); letter-spacing: -.015em; margin: 18px 0 8px; }
.post-card:hover h3 { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; text-decoration-color: var(--accent); }
.post-card p { margin: 0 0 10px; color: var(--muted); font-size: 17px; line-height: 1.5; }

.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
.row { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 24px; padding: 22px 0; }
.row .when { font: 400 14px/1.9 var(--sans); color: var(--muted); }
.row h3 { font: 600 21px/1.3 var(--serif); letter-spacing: -.01em; margin: 0 0 6px; }
.row h3 a { text-decoration: none; }
.row h3 a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.row p { margin: 0; font-size: 17px; line-height: 1.55; color: var(--muted); }
.row .actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font: 500 14px var(--sans); }
.row .actions a { color: var(--ink); text-decoration-color: var(--line); }
.row .actions a:hover { text-decoration-color: var(--accent); }
.row .result { font: 400 14px/1.5 var(--sans); color: var(--ink); margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--accent); }
details.bib { margin-top: 10px; font: 500 14px var(--sans); }
details.bib summary { cursor: pointer; color: var(--ink); list-style: none; display: inline; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
details.bib summary::-webkit-details-marker { display: none; }
details.bib pre { margin: 12px 0 0; }

.page-head { padding: 96px 0 56px; max-width: 760px; }
.page-head h1 { font: 600 clamp(38px, 5.4vw, 54px)/1.05 var(--serif); letter-spacing: -.03em; margin: 0 0 18px; }
.page-head p { font-size: 21px; line-height: 1.55; color: var(--muted); margin: 0; }
.group-title { font: 600 13px/1.4 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 56px 0 4px; }

.prose-page { max-width: var(--text); }
.prose-page p { margin: 0 0 1.1em; }
.prose-page h2 { font: 600 26px/1.25 var(--serif); letter-spacing: -.015em; margin: 1.8em 0 .5em; }

/* ---------- article ---------- */
.post-head { width: min(var(--text), 100% - 2 * var(--gutter)); margin: 0 auto; padding: 96px 0 40px; }
.post-head h1 { font: 650 clamp(36px, 5.6vw, 56px)/1.06 var(--serif); letter-spacing: -.03em; margin: 14px 0 20px; text-wrap: balance; }
.post-head .subtitle { font-size: clamp(20px, 2.4vw, 23px); line-height: 1.5; color: var(--muted); margin: 0 0 28px; text-wrap: pretty; }
.post-head .meta { display: flex; flex-wrap: wrap; align-items: center; row-gap: 6px; }
.byline { color: var(--ink); }
.hero { width: min(1180px, 100% - 2 * var(--gutter)); margin: 8px auto 72px; }
.hero img { display: block; width: 100%; height: auto; border-radius: 8px; background: var(--paper); }
:root[data-theme="dark"] .hero img, :root[data-theme="dark"] .post-card .thumb img { filter: brightness(.92); }
.hero figcaption { font: 400 14px/1.5 var(--sans); color: var(--muted); margin-top: 12px; text-align: center; }

.article { position: relative; width: min(var(--text), 100% - 2 * var(--gutter)); margin: 0 auto; counter-reset: sn; }
.article > p, .article li { text-wrap: pretty; hyphens: manual; }
.article p { margin: 0 0 1.15em; }
.article .lede { font-size: 23px; line-height: 1.55; letter-spacing: -.005em; }
.article h2 { font: 650 30px/1.2 var(--serif); letter-spacing: -.02em; margin: 2.1em 0 .6em; text-wrap: balance; }
.article h3 { font: 600 22px/1.3 var(--serif); letter-spacing: -.01em; margin: 1.7em 0 .5em; }
.article h2 a.anchor, .article h3 a.anchor { text-decoration: none; color: var(--faint); margin-left: .3em; opacity: 0; font-weight: 400; }
.article h2:hover a.anchor, .article h3:hover a.anchor { opacity: 1; }
.article ul, .article ol { padding-left: 1.3em; margin: 0 0 1.15em; }
.article li { margin: .3em 0; }
.article li::marker { color: var(--muted); }
.article blockquote { margin: 1.6em 0; padding: 0 0 0 22px; border-left: 2px solid var(--accent); color: var(--muted); font-style: italic; }
.article hr { border: 0; height: 1px; background: var(--line); margin: 3em 0; }
.article strong { font-weight: 650; }
.article code { font: 400 .8em/1 var(--mono); background: var(--code-bg); padding: .15em .35em; border-radius: 4px; }
pre { font: 400 14.5px/1.6 var(--mono); background: var(--code-bg); border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px; overflow-x: auto; margin: 1.6em 0; tab-size: 4; }
pre code { background: none !important; padding: 0 !important; font: inherit !important; }
.table-wrap { overflow-x: auto; margin: 1.8em 0; }
.article table { border-collapse: collapse; width: 100%; font: 400 15px/1.45 var(--sans); font-variant-numeric: tabular-nums; }
.article th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--ink); padding: 8px 12px 8px 0; white-space: nowrap; }
.article td { border-bottom: 1px solid var(--line); padding: 9px 12px 9px 0; vertical-align: top; }

.keynum { margin: 2.2em 0; padding: 26px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 24px; align-items: center; }
.keynum .num { font: 600 clamp(44px, 7vw, 64px)/1 var(--serif); letter-spacing: -.03em; color: var(--accent); font-variant-numeric: tabular-nums; }
.keynum .label { font: 400 16px/1.45 var(--sans); color: var(--muted); }

/* figures */
.fig { margin: 2.6em 0; }
.fig.wide { width: min(var(--wide), 100vw - 2 * var(--gutter)); margin-left: 50%; transform: translateX(-50%); }
.fig > svg, .fig .interactive > svg { display: block; width: 100%; height: auto; overflow: visible; }
.fig svg text { font-family: var(--sans); font-size: 12px; fill: var(--muted); }
.fig svg .lbl-ink { fill: var(--ink); }
.fig svg .lbl-accent { fill: var(--accent); }
.fig figcaption { font: 400 15px/1.55 var(--sans); color: var(--muted); margin-top: 14px; max-width: var(--text); }
.fig.wide figcaption { margin-left: auto; margin-right: auto; }
.fig figcaption strong { color: var(--ink); font-weight: 600; }
.interactive { font-family: var(--sans); font-size: 14px; color: var(--ink); }
.interactive button { font: 500 13px/1 var(--sans); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; cursor: pointer; }
.interactive button:hover { border-color: var(--ink); }
.interactive button[aria-pressed="true"], .interactive button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.interactive input[type="range"] { accent-color: var(--accent); width: 100%; max-width: 360px; }
.interactive label { font: 500 13px var(--sans); color: var(--muted); }
.interactive select { font: 500 13px var(--sans); color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; }

/* sidenotes (Tufte-style, built by build.mjs) */
.sn-ref { cursor: pointer; }
.sn-ref::after { content: attr(data-n); font: 600 .62em/0 var(--sans); vertical-align: super; color: var(--accent); margin-left: 1px; padding: 0 1px; }
.sn-toggle { display: none; }
.sn { display: none; font: 400 14px/1.55 var(--sans); color: var(--muted); }
.sn .sn-n { font-weight: 600; color: var(--accent); margin-right: 4px; }
.sn-toggle:checked + .sn { display: block; margin: .6em 0 .8em; padding: 10px 14px; background: var(--soft); border-radius: 6px; }
@media (min-width: 1240px) {
  .sn, .sn-toggle:checked + .sn { display: block; float: right; clear: right; width: 220px; margin: .25em -260px 1em 0; padding: 0; background: none; border-radius: 0; position: relative; }
  .sn-ref { cursor: default; }
}

/* table of contents */
.toc { display: none; }
@media (min-width: 1300px) {
  .toc { display: block; position: absolute; top: 0; bottom: 0; left: -270px; width: 200px; }
  .toc-inner { position: sticky; top: 40px; font: 400 13px/1.5 var(--sans); }
  .toc-inner p { margin: 0 0 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 11px; color: var(--faint); }
  .toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
  .toc li { margin: 0; }
  .toc a { display: block; padding: 4px 0 4px 14px; margin-left: -1px; border-left: 1px solid transparent; color: var(--muted); text-decoration: none; }
  .toc a:hover { color: var(--ink); }
  .toc a.active { color: var(--ink); border-left-color: var(--accent); }
}

/* references, appendix, citation */
.cite { text-decoration: none; font: 500 .78em var(--sans); color: var(--accent); vertical-align: .08em; }
.references, .appendix { margin-top: 4em; padding-top: 1.4em; border-top: 1px solid var(--line); }
.references h2, .appendix h2, .post-end h2 { font: 600 13px/1.4 var(--sans) !important; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 1.2em !important; }
.references ol { font: 400 15px/1.55 var(--sans); color: var(--muted); padding-left: 1.6em; }
.references li { margin: 0 0 .7em; }
.references li:target { color: var(--ink); }
.appendix { font-size: 18px; }
.post-end { width: min(var(--text), 100% - 2 * var(--gutter)); margin: 4em auto 0; padding-top: 1.4em; border-top: 1px solid var(--line); }
.post-end .links { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 2em; }
.post-end pre { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.next-post { display: block; text-decoration: none; margin-top: 2.4em; padding: 20px 0; border-top: 1px solid var(--line); }
.next-post .meta { margin-bottom: 4px; }
.next-post strong { font: 600 22px/1.3 var(--serif); }
.next-post:hover strong { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 4px; }

/* KaTeX tweaks */
.katex { font-size: 1.06em; }
.katex-display { margin: 1.4em 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  body { font-size: 18.5px; }
  :root { --gutter: 16px; }
  .site-header { padding-top: 18px; }
  .nav a { padding: 6px 7px; font-size: 13.5px; }
  .intro { padding: 64px 0 56px; }
  .page-head, .post-head { padding: 56px 0 32px; }
  .post-grid { grid-template-columns: 1fr; gap: 36px; }
  .row { grid-template-columns: 1fr; gap: 4px; padding: 20px 0; }
  .hero { margin-bottom: 44px; }
  .hero img { border-radius: 4px; }
  .article .lede { font-size: 20.5px; }
  .article h2 { font-size: 26px; }
  .keynum { grid-template-columns: 1fr; }
  pre { font-size: 13px; padding: 14px; }
  .site-footer { margin-top: 80px; }
}

@media print {
  .site-header, .site-footer, .toc, .theme-btn, .post-end .links { display: none !important; }
  .sn { display: block !important; float: none !important; width: auto !important; margin: .5em 0 !important; }
  body { background: #fff; color: #000; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.byline-row { margin: -2px 0 10px; }

/* wide figures never sit beside a margin note; contents fade out while a wide figure passes */
.fig.wide { clear: both; position: relative; z-index: 1; }
.toc-inner { transition: opacity .2s ease; }
.toc.toc-hidden .toc-inner { opacity: 0; pointer-events: none; }
button.pill { cursor: pointer; font-family: var(--sans); }
.inline-email, .footer-email { appearance: none; border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--faint); }
.footer-email { text-decoration: none; color: var(--muted); }
.footer-email:hover, .inline-email:hover { color: var(--ink); text-decoration-color: var(--accent); }
.email-reveal { position: relative; cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: var(--accent); }
.email-tip { position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px); white-space: nowrap; font: 500 14px/1 var(--sans); background: var(--ink); color: var(--bg); padding: 9px 12px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 5; }
.email-tip::after { content: ""; position: absolute; left: 50%; top: 100%; margin-left: -5px; border: 5px solid transparent; border-top-color: var(--ink); }
.email-tip::before { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 10px; }
.email-tip a { color: var(--bg); text-decoration-color: currentColor; }
.email-tip:empty { display: none; }
.email-reveal:hover .email-tip, .email-reveal:focus .email-tip, .email-reveal:focus-within .email-tip, .email-reveal.open .email-tip { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
@media (max-width: 520px) { .email-tip { transform: translate(-60%, 4px); } .email-reveal:hover .email-tip, .email-reveal:focus .email-tip, .email-reveal:focus-within .email-tip, .email-reveal.open .email-tip { transform: translate(-60%, 0); } .email-tip::after { left: 60%; } }

/* superscripts in titles should not open up the line */
h1 sup, h3 sup, .next-post sup { font-size: 0.58em; line-height: 0; vertical-align: 0.75em; }
