/* Layout: one narrow reading column in the manner of an academic personal site.
   Serif throughout, blue links, a rule under the header and nothing else. */
:root {
  --bg: #FDFDFD;
  --ink: #111111;
  --text: #222222;
  --muted: #6B6B6B;
  --rule: #E2E2E2;
  --link: #1A6FD1;
  --photo: #ECECEC;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", "Iowan Old Style", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414; --ink: #F0F0F0; --text: #D6D6D6; --muted: #9A9A9A;
    --rule: #2E2E2E; --link: #7FB2F0; --photo: #2A2A2A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141414; --ink: #F0F0F0; --text: #D6D6D6; --muted: #9A9A9A;
  --rule: #2E2E2E; --link: #7FB2F0; --photo: #2A2A2A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--serif); font-size: 17px; line-height: 1.55;
  border-top: 6px solid var(--ink);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; color: var(--ink); margin: 0; text-wrap: balance; }
p, ul, ol, dl { margin: 0; }
img, video { max-width: 100%; }

.wrap { max-width: 980px; margin-inline: auto; padding-inline: 20px; }
.label { font-size: 0.78rem; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* header */
.bar { border-bottom: 1px solid var(--rule); }
.bar .wrap { display: flex; align-items: baseline; justify-content: space-between; gap: 24px; padding-block: 14px; }
.bar .name { font-size: 1.6rem; color: var(--ink); white-space: nowrap; }
.bar nav { display: flex; gap: 20px; }
.bar nav a { color: var(--ink); font-size: 1.05rem; }
.bar nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 5px; text-decoration-color: var(--rule); }
main.wrap { padding-block: 36px 40px; }

h1 { font-size: 2.6rem; line-height: 1.1; margin-bottom: 28px; }
h2 { font-size: 1.7rem; margin: 36px 0 14px; }
h2:first-child { margin-top: 0; }

/* home */
.about { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 640px) { .about { grid-template-columns: minmax(0, 1fr); } .about .photo { max-width: 300px; } }
.photo { aspect-ratio: 9 / 8; background: var(--photo); display: grid; place-items: center; color: var(--muted); font-size: 0.9rem; }
.photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.about p + p { margin-top: 1em; }

/* work and cv lists */
.entry { margin-bottom: 24px; }
.entry .t { font-weight: 700; color: var(--ink); }
.entry .venue { font-style: italic; }
.entry .links a { margin-right: 6px; }
.more-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; }
.more-btn:hover { text-decoration: underline; }
.more { margin-top: 8px; }
.more p + p { margin-top: 0.8em; }
.cvlist .item { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; margin-bottom: 18px; }
.cvlist .when { color: var(--muted); }
.cvlist .t { font-weight: 700; color: var(--ink); }
.cvlist .role { font-style: italic; }
@media (max-width: 560px) { .cvlist .item { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.points { margin: 4px 0 0; padding-left: 1.2em; }
.points li + li { margin-top: 2px; }
.plain { padding-left: 1.2em; }
.plain li + li { margin-top: 4px; }

/* case study pages */
.case-head { display: grid; gap: 12px; }
.case-head h1 { margin-bottom: 0; }
.back { color: var(--muted); font-size: 0.95rem; }
.dek { font-size: 1.2rem; color: var(--ink); }
.meta { color: var(--muted); font-size: 0.95rem; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.facts-list { margin: 4px 0 0; display: grid; gap: 4px; }
.facts-list div { display: flex; flex-wrap: wrap; gap: 0 8px; }
.facts-list dt { font-weight: 700; color: var(--ink); }
.facts-list dt::after { content: ":"; }
.facts-list dd { margin: 0; }
.note-line { color: var(--muted); font-size: 0.95rem; }
.row { margin-top: 36px; }
.row > .label { font-family: var(--serif); font-size: 1.6rem; color: var(--ink); text-transform: none; letter-spacing: 0; margin-bottom: 12px; }
.row-body { display: grid; gap: 12px; }
.steps { list-style: none; padding: 0; display: grid; gap: 14px; counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 1.8rem minmax(0, 1fr); gap: 8px; }
.steps li::before { content: counter(step) "."; color: var(--muted); }
.steps .when { display: block; color: var(--muted); font-size: 0.92rem; }
.steps h3 { display: inline; font-size: 1.02rem; font-weight: 700; }
.steps h3::after { content: ". "; }
.steps h3 + p { display: inline; }
.results { padding-left: 1.2em; display: grid; gap: 6px; }
.results strong { color: var(--ink); }
.tech { color: var(--muted); }
.figure { margin: 10px 0 4px; }
.figure img, .figure video { display: block; width: 100%; height: auto; border: 1px solid var(--rule); background: var(--bg); }
.figure img { cursor: zoom-in; }
.figure figcaption { font-size: 0.92rem; color: var(--muted); font-style: italic; margin-top: 6px; line-height: 1.45; }
.figure.narrow { max-width: 280px; }
.pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 600px) { .pair { grid-template-columns: minmax(0, 1fr); } }
.next-row { margin-top: 44px; padding-top: 16px; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.next-row a { display: grid; gap: 2px; }
.next-row a.right { text-align: right; margin-left: auto; }

/* footer */
footer.end { border-top: 1px solid var(--rule); padding-block: 20px 44px; }
.contact { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.email { display: inline-flex; align-items: center; gap: 8px; }
.email code { font-family: var(--serif); color: var(--text); user-select: all; }
.copy { font: inherit; font-size: 0.85rem; background: none; border: 1px solid var(--rule); border-radius: 3px; padding: 1px 8px; color: var(--muted); cursor: pointer; }
.copy:hover { color: var(--ink); border-color: var(--muted); }

/* enlarged figure */
.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(12, 12, 12, 0.94); display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 14px); }
.lightbox .lb-top { display: flex; justify-content: flex-end; }
.lightbox button { font: inherit; font-size: 0.9rem; background: #FFFFFF; color: #111111; border: 0; border-radius: 3px; padding: 5px 12px; cursor: pointer; }
.lightbox .lb-body { overflow: auto; display: grid; place-items: start center; min-height: 0; }
.lightbox img { display: block; max-width: min(1600px, 100%); height: auto; }
.lightbox p { font-size: 0.9rem; color: #D6D6D6; text-align: center; font-style: italic; }

/* Experience: one section per employer, pieces of work beneath */
.employer { margin-bottom: 44px; }
.employer h2 { margin-bottom: 4px; }
.employer .roles { font-style: italic; color: var(--muted); margin-bottom: 18px; }
.piece { margin-bottom: 20px; }
.piece .t { font-weight: 700; color: var(--ink); }
.piece .t .when { font-weight: 400; color: var(--muted); margin-left: 8px; }
.piece p + p { margin-top: 6px; }
.piece .links a { margin-right: 6px; }

/* Independent work: paragraphs shown in full, site link beside the title */
.entry .t .site { font-weight: 400; font-size: 0.95rem; margin-left: 10px; }
.entry .more + .links { margin-top: 6px; }

/* Project pages: feature list without numbers */
.features { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.features h3 { display: inline; font-size: 1.02rem; font-weight: 700; }
.features h3::after { content: ". "; }
.features h3 + p { display: inline; }

/* CV page: pdf link and print layout */
.print-only { display: none; }
h1 .pdf { font-size: 1.05rem; margin-left: 12px; vertical-align: middle; }
.foot-link { margin-top: 36px; }
@page { size: A4; margin: 12mm 15mm 13mm; }
@media print {
  .bar, footer, h1, .pdf, .foot-link, .screen-only { display: none !important; }
  .print-only { display: block; }
  span.print-only { display: inline; }
  .cvlist .item.tu-second { margin-top: -3pt; }
  .cvlist .item.tu-second .when { visibility: hidden; }
  .cvlist .item.tu-second .t { display: none; }
  .cvlist .item.tu-second .role { margin-top: 5pt; }
  main.wrap { display: flex; flex-direction: column; }
  main.wrap > .print-head { order: -3; }
  main.wrap > .profile { order: -2; }
  main.wrap > h2.skills, main.wrap > ul.plain { order: -1; }
  main.wrap > h2.skills { margin-top: 0; }
  body { font-size: 9.6pt; line-height: 1.38; color: #000; background: #fff; border-top: 0; }
  .wrap { max-width: none; padding: 0; }
  main.wrap { padding: 0; }
  a { color: inherit; }
  .print-head a { color: #1A6FD1; }
  .print-head { margin-bottom: 10pt; padding-bottom: 6pt; border-bottom: 1px solid #999; }
  .print-head .print-name { font-family: var(--serif); font-size: 22pt; line-height: 1.1; margin-bottom: 4pt; }
  .profile { margin-bottom: 4pt; }
  .print-head p { color: #333; }
  h2 { font-size: 13pt; margin: 9pt 0 4pt; break-after: avoid; }
  .cvlist .item { display: block; position: relative; margin-bottom: 6pt; break-inside: avoid; }
  .cvlist .item .when { position: absolute; right: 0; top: 0; font-style: italic; }
  .cvlist .item .t { padding-right: 110px; }
  .role .role-when { float: right; font-style: italic; color: #555; }
  .points li + li, .plain li + li { margin-top: 1pt; }
  .cvlist .when { color: #555; }
  ul.points, ul.plain { padding-left: 1.1em; }
}

/* Writing */
.writing-intro { color: var(--muted); margin-bottom: 28px; }
.entry .t a { color: var(--link); }
.post { max-width: 720px; }
.post h1 { font-size: 2.1rem; margin: 10px 0 10px; }
.post .meta { margin-bottom: 28px; }
.post .meta a { color: var(--link); }
.post h2 { font-size: 1.3rem; margin: 30px 0 10px; }
.post p + p, .post ul + p, .post p + ul, .post blockquote + p, .post p + blockquote { margin-top: 1em; }
.post ul { padding-left: 1.2em; display: grid; gap: 4px; }
.post blockquote { margin: 1em 0 0; padding-left: 16px; border-left: 2px solid var(--rule); color: var(--muted); font-style: italic; }
.post .flow { font-style: italic; text-align: center; }
.post .standfirst { font-size: 1.15rem; color: var(--ink); font-style: italic; }
.post .post-end { margin-top: 40px; }
.post .figure { max-width: 560px; margin: 1.4em auto 0; }
.post .figure + h2 { margin-top: 34px; }
