/* sadeghr.com — "frontmatter" design */
:root {
  --paper: #E9E5DB;
  --paper-2: #DCD8CD;
  --paper-3: #F0EDE6;
  --ink: #2F3335;
  --ink-2: #474C4D;
  --muted: #5E6365;
  --faint: #A4A39C;
  --rule: #D1CDC2;
  --accent: #46636D;
  --code-bg: #373B3C;
  --code-ink: #E7E1D5;
  --code-dim: #9A9E9C;

  --sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --col: 660px;
  --wide: 1056px;
  --gutter: clamp(20px, 5vw, 64px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #373B3C;
  --paper-2: #2F3335;
  --paper-3: #333738;
  --ink: #E7E1D5;
  --ink-2: #CFCCC4;
  --muted: #A6A8A4;
  --faint: #6F7473;
  --rule: #4A4F50;
  --accent: #B5C8CE;
  --code-bg: #2B2E30;
  --code-ink: #E7E1D5;
  --code-dim: #8D918F;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.75 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--ink); text-decoration-color: var(--faint); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { margin: 0; font-weight: 500; }
::selection { background: var(--paper-2); }

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 6px 10px; font: 14px var(--mono); z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- frame ---------- */
.frame { width: min(100% - 2 * var(--gutter), var(--col)); margin: 0 auto; padding: 48px 0 0; }
.frame.wide { width: min(100% - 2 * var(--gutter), var(--wide)); }
.site-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 12px 24px; font: 14px/1.6 var(--mono); }
.crumbs { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.crumbs a { color: var(--muted); }
.crumbs .home { color: var(--ink); text-decoration: none; font-weight: 500; }
.crumbs .sep { margin: 0 1px; }
.crumbs [aria-current] { color: var(--muted); }
.site-header { row-gap: 10px; }
.site-header .crumbs { flex: 1 1 0; }
.theme-toggle { order: 2; }
.site-header nav { order: 3; flex: 1 1 100%; display: flex; gap: 6px 18px; flex-wrap: wrap; }
.theme-toggle { font: inherit; color: var(--muted); background: none; border: 1px solid var(--rule); border-radius: 5px; padding: 1px 7px; cursor: pointer; }
.theme-toggle:hover { color: var(--ink); border-color: var(--faint); }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover, .site-header nav a[aria-current] { color: var(--ink); }
main { padding: 112px 0 0; }
.site-footer { margin-top: 112px; padding: 0 0 48px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; font: 13px/1.6 var(--mono); color: var(--muted); }
.site-footer p { margin: 0; }
.site-footer .links { display: flex; gap: 16px; }
.site-footer a { color: var(--muted); }

/* ---------- shared pieces ---------- */
.fm { margin: 0; font: 13.5px/1.75 var(--mono); color: var(--muted); white-space: pre-wrap; }
.fm .dash { color: var(--faint); }
.fm .v, .fm .v a { color: var(--ink); }
.fm .v a { color: var(--accent); text-decoration-color: currentColor; }
.page-head h1, .intro h1 { margin-top: 0; font-size: clamp(34px, 6vw, 46px); font-weight: 500; letter-spacing: -0.045em; line-height: 1.04; }
.dek { margin: 18px 0 0; font-size: 19px; line-height: 1.55; color: var(--ink-2); max-width: var(--col); }
.page-head { margin-bottom: 56px; }
.page-head.narrow { max-width: var(--col); }
.h { font: 500 14px/1.5 var(--mono); margin: 0 0 12px; display: flex; gap: 0; align-items: baseline; }
.h .hash { color: var(--faint); white-space: pre; }
.h .more { margin-left: auto; color: var(--muted); font-weight: 400; }
section + section { margin-top: 64px; }
.empty { color: var(--muted); font: 14px var(--mono); }

/* rows: date / title / kind */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.rows a { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr) auto; gap: 16px; align-items: baseline; padding: 12px 0; border-bottom: 1px solid var(--rule); text-decoration: none; }
.rows time, .rows .k { font: 13px/1.6 var(--mono); color: var(--muted); }
.rows .t { font-weight: 500; letter-spacing: -0.01em; }
.rows a:hover .t { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }

/* ---------- prose ---------- */
.cover { margin: 0 0 40px; border-radius: 6px; }
.prose > * { margin: 0 0 22px; }
.prose h2, .prose h3 { font: 500 14px/1.5 var(--mono); margin-top: 48px; }
.prose h2::before { content: "## "; color: var(--faint); white-space: pre; }
.prose h3::before { content: "### "; color: var(--faint); white-space: pre; }
.prose blockquote { margin: 36px 0; font-size: 24px; line-height: 1.4; font-weight: 500; letter-spacing: -0.03em; }
.prose blockquote::before { content: "> "; color: var(--accent); font: 400 24px var(--mono); }
.prose blockquote p { display: inline; margin: 0; }
.prose code { font: 0.86em var(--mono); background: var(--paper-2); padding: 0.1em 0.35em; border-radius: 4px; }
.prose pre { background: var(--code-bg); color: var(--code-ink); padding: 16px 18px; border-radius: 6px; overflow-x: auto; font: 13.5px/1.7 var(--mono); }
.prose pre code { background: none; padding: 0; font: inherit; color: inherit; }
.prose img, .prose figure { margin: 32px 0; border-radius: 6px; }
.prose figure img { margin: 0; }
.prose figcaption { font-size: 14px; color: var(--muted); margin-top: 10px; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li::marker { color: var(--muted); font-family: var(--mono); font-size: 0.85em; }
.prose hr { border: 0; text-align: left; margin: 40px 0; }
.prose hr::after { content: "---"; font-family: var(--mono); color: var(--faint); }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 16px 8px 0; border-bottom: 1px solid var(--rule); }
.prose th { font: 500 13px var(--mono); color: var(--muted); }

.hljs-comment, .hljs-quote { color: var(--code-dim); }
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-attr { color: #9FD0B3; }
.hljs-string, .hljs-template-variable { color: #E3C48E; }
.hljs-number, .hljs-literal, .hljs-title { color: #C9B6E4; }

.pager { margin-top: 72px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.pager a { display: flex; flex-direction: column; gap: 4px; text-decoration: none; font-size: 18px; font-weight: 500; letter-spacing: -0.02em; }
.pager a span { font: 400 14px var(--mono); color: var(--muted); letter-spacing: 0; }
.pager a[rel="next"] { margin-left: auto; text-align: right; }
.pager a:hover { text-decoration: underline; text-decoration-color: var(--faint); }

/* ---------- research ---------- */
.fm-end { margin-top: 56px; }
.year + .year { margin-top: 48px; }
.pubs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.pubs li { display: flex; flex-direction: column; gap: 2px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.pt { font-weight: 500; letter-spacing: -0.01em; line-height: 1.45; text-decoration: none; }
.pt:hover { text-decoration: underline; text-decoration-color: var(--faint); }
.pa { font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.pa strong { font-weight: 500; color: var(--ink); }
.pv { font: 13px/1.7 var(--mono); color: var(--muted); display: flex; flex-wrap: wrap; gap: 0 14px; }
.pn { color: var(--accent); }
.awards { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.awards li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.aw { font: 13px/1.9 var(--mono); color: var(--muted); }
.at { font-weight: 500; line-height: 1.5; display: flex; flex-direction: column; gap: 2px; }
.ad { font-weight: 400; font-size: 15px; color: var(--ink-2); }
.preview.video { aspect-ratio: 16 / 9; }
.play { position: absolute; left: 12px; bottom: 10px; font: 12px/1 var(--mono); color: #E7E1D5; background: rgba(47, 51, 53, 0.85); padding: 6px 8px; border-radius: 4px; }

/* ---------- cards: artifacts and albums ---------- */
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 40px 24px; }
.card a { display: flex; flex-direction: column; gap: 2px; text-decoration: none; }
.preview { display: block; position: relative; aspect-ratio: 16 / 10; overflow: hidden; margin-bottom: 12px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 6px; }
.preview.album { aspect-ratio: 4 / 3; }
.preview iframe { position: absolute; top: 0; left: 0; width: 1280px; height: 800px; border: 0; transform-origin: 0 0; transform: scale(var(--s, 0.25)); pointer-events: none; background: #fff; }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.card-title { font-weight: 500; letter-spacing: -0.01em; line-height: 1.4; }
.card-sub { color: var(--ink-2); font-size: 15px; line-height: 1.5; }
.card time { font: 13px/1.8 var(--mono); color: var(--muted); }
.card a:hover .card-title { text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.card a:hover .preview { border-color: var(--faint); }

.photos { columns: 3 280px; column-gap: 12px; }
.photo { break-inside: avoid; margin: 0 0 12px; }
.photo a { display: block; cursor: zoom-in; }
.photo img { border-radius: 4px; }
.photo figcaption { font-size: 14px; color: var(--muted); margin: 6px 0 4px; }

.lightbox { border: 0; padding: 0; max-width: none; max-height: none; width: 100vw; height: 100dvh; background: rgba(43, 46, 48, 0.97); color: #E7E1D5; }
.lightbox[open] { display: grid; grid-template-rows: 1fr auto; place-items: center; }
.lightbox::backdrop { background: rgba(43, 46, 48, 0.97); }
.lightbox img { max-width: calc(100vw - 7rem); max-height: calc(100dvh - 6rem); object-fit: contain; }
.lb-caption { margin: 0 0 20px; font-size: 14px; min-height: 1.2em; text-align: center; padding: 0 16px; }
.lightbox button { position: absolute; background: none; border: 0; color: inherit; cursor: pointer; padding: 12px 16px; font: 14px var(--mono); }
.lb-close { top: 8px; right: 8px; }
.lb-prev, .lb-next { top: 50%; transform: translateY(-50%); font-size: 36px !important; line-height: 1; }
.lb-prev { left: 4px; }
.lb-next { right: 4px; }

/* ---------- landing ---------- */
body.landing { margin: 0; min-height: 100vh; min-height: 100svh; background: #373B3C; color: #E7E1D5; position: relative; overflow-x: hidden; }
.landing-cover { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 55% 38%; z-index: 0; }
.landing-top, .landing-nav, .landing-quote { position: absolute; z-index: 1; text-shadow: 0 0 14px #2F3335, 0 0 4px #2F3335; }
.landing-top { top: clamp(20px, 4vw, 40px); left: clamp(20px, 4vw, 48px); font: 13px/1.6 var(--mono); color: #CFCCC4; }
.landing-top h1 { font: 500 15px/1.4 var(--sans); color: #E7E1D5; letter-spacing: -0.01em; }
.landing-top p { margin: 2px 0 0; }
.landing-links { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.landing-links a { color: #CFCCC4; text-decoration: underline; text-decoration-color: #6F7473; text-underline-offset: 3px; }
.landing-links a:hover, .landing-links a:focus-visible { color: #F3EFE6; text-decoration-color: #CFCCC4; }
.landing-nav { left: clamp(20px, 4vw, 48px); bottom: clamp(24px, 5vw, 48px); }
.landing-nav ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.landing-nav a { font: 400 15px/1.9 var(--mono); color: #CFCCC4; text-decoration: none; display: inline-block; }
.landing-nav a::before { content: "/"; color: #7C817F; margin-right: 6px; }
.landing-nav a:hover, .landing-nav a:focus-visible { color: #F3EFE6; }
.landing-nav a:focus-visible { outline-color: #E7E1D5; }
.landing-quote { right: clamp(20px, 4vw, 48px); bottom: clamp(24px, 5vw, 48px); margin: 0; max-width: 360px; text-align: right; }
.landing-quote blockquote { margin: 0; font: 400 15px/1.6 var(--sans); color: #E7E1D5; letter-spacing: -0.005em; }
.landing-quote figcaption { margin-top: 10px; font: 13px/1.5 var(--mono); color: #A6A8A4; }
.landing-quote figcaption::before { content: "— "; }
@media (max-width: 720px) {
  body.landing { min-height: 100svh; display: flex; flex-direction: column; justify-content: flex-end; padding: 0 20px 28px; gap: 32px; }
  .landing-cover { object-position: 52% 30%; }
  body.landing::after { content: ""; position: fixed; inset: 45% 0 0 0; background: linear-gradient(to bottom, rgba(55, 59, 60, 0), rgba(55, 59, 60, 0.85) 45%); z-index: 0; pointer-events: none; }
  .landing-nav, .landing-quote { position: relative; left: auto; right: auto; bottom: auto; }
  .landing-quote { order: 1; text-align: left; max-width: none; }
  .landing-nav { order: 2; }
  .landing-top { left: 20px; }
}

@media (max-width: 560px) {
  main { padding-top: 72px; }
  .awards li { grid-template-columns: 1fr; gap: 2px; }
  .site-header nav { gap: 6px 14px; }
  .rows a { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "t t" "d k"; gap: 2px 12px; }
  .rows .t { grid-area: t; }
  .rows time { grid-area: d; }
  .rows .k { grid-area: k; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
