:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3f1ec;
  --ink: #1c2226;
  --muted: #5a656e;
  --line: #e2ded6;
  --accent: #0d6a6e;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0ef;
  --rust: #a8502a;
  --shadow: 0 1px 2px rgba(20, 30, 35, .05), 0 6px 18px rgba(20, 30, 35, .05);
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --measure: 72ch;
  --wide: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101416;
    --surface: #161b1e;
    --surface-2: #1c2226;
    --ink: #e6e9ea;
    --muted: #9ba7ae;
    --line: #2a3237;
    --accent: #5fc3c0;
    --accent-ink: #0b1213;
    --accent-soft: #15302f;
    --rust: #e08a5f;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #101416;
  --surface: #161b1e;
  --surface-2: #1c2226;
  --ink: #e6e9ea;
  --muted: #9ba7ae;
  --line: #2a3237;
  --accent: #5fc3c0;
  --accent-ink: #0b1213;
  --accent-soft: #15302f;
  --rust: #e08a5f;
  --shadow: none;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.65 var(--sans);
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.22; margin: 0 0 .5em; letter-spacing: -.005em; }
h1 { font-size: clamp(2rem, 4.2vw, 2.85rem); }
h2 { font-size: clamp(1.45rem, 2.6vw, 1.8rem); margin-top: 2.2em; }
h3 { font-size: 1.18rem; margin-top: 1.6em; }
h4 { font-size: 1rem; font-family: var(--sans); font-weight: 600; margin-top: 1.2em; }
p { margin: 0 0 1em; }
ul, ol { padding-left: 1.25em; margin: 0 0 1em; }
li { margin: .25em 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
small, .muted { color: var(--muted); }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: var(--accent-ink); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; top: .5rem; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar { max-width: var(--wide); margin: 0 auto; padding: .7rem 16px; display: flex; align-items: center; gap: 1rem; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.15rem; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { margin-left: auto; display: flex; gap: .15rem; align-items: center; }
.nav a { color: var(--muted); text-decoration: none; padding: .4rem .65rem; border-radius: 6px; font-size: .95rem; }
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--accent-soft); }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--muted); width: 36px; height: 36px; border-radius: 8px; cursor: pointer; display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { color: var(--ink); border-color: var(--muted); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

@media (max-width: 820px) {
  .menu-btn { display: inline-grid; margin-left: auto; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 100%; flex-direction: column; align-items: stretch; background: var(--bg); border-bottom: 1px solid var(--line); padding: .5rem 16px 1rem; }
  .nav.open { display: flex; }
  .nav a { padding: .65rem .75rem; font-size: 1rem; }
}

/* layout */
main { max-width: var(--wide); margin: 0 auto; padding: 2.5rem 16px 4rem; }
.prose { max-width: var(--measure); }
.page-head { margin-bottom: 2rem; max-width: var(--measure); }
.page-head p.lede { font-size: 1.12rem; color: var(--muted); }
.eyebrow { font: 600 .78rem/1 var(--sans); letter-spacing: .09em; text-transform: uppercase; color: var(--rust); margin-bottom: .8rem; }

.hero { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 3rem; align-items: start; }
.hero h1 { margin-bottom: .3rem; }
.hero .role { font-size: 1.1rem; color: var(--muted); margin-bottom: 1.4rem; }
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; gap: 2rem; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem 1.35rem; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }

.facts { list-style: none; padding: 0; margin: 0; font-size: .94rem; }
.facts li { padding: .55rem 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 22px 1fr; gap: .6rem; }
.facts li:last-child { border-bottom: 0; }
.facts svg { width: 18px; height: 18px; color: var(--accent); margin-top: 3px; }

.grid { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid-2 { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }

.project { display: flex; flex-direction: column; }
.project .kicker { font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: .45rem; }
.project h3 { font-size: 1.12rem; margin: 0 0 .5rem; }
.project h3 a { color: var(--ink); text-decoration: none; }
.project h3 a:hover { color: var(--accent); }
.project p { font-size: .95rem; }
.project .links { margin-top: auto; padding-top: .4rem; display: flex; flex-wrap: wrap; gap: .5rem; }

.btn { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; font-weight: 500; padding: .38rem .8rem; border-radius: 7px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; background: var(--surface); }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn svg { width: 15px; height: 15px; }

.tags { display: flex; flex-wrap: wrap; gap: .35rem; margin: .2rem 0 .9rem; padding: 0; list-style: none; }
.tags li { margin: 0; font-size: .78rem; padding: .15rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.news { list-style: none; padding: 0; margin: 0; }
.news li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.news time { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .news li { grid-template-columns: 1fr; gap: .1rem; } }

.callout { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: .9rem 1.1rem; border-radius: 0 8px 8px 0; margin: 1.3rem 0; }
.callout > :last-child { margin-bottom: 0; }

table { width: 100%; border-collapse: collapse; font-size: .94rem; margin: .5rem 0 1.5rem; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
.table-wrap { overflow-x: auto; }

.toc { font-size: .92rem; }
.toc ol { list-style: none; padding: 0; margin: 0; counter-reset: toc; }
.toc li { margin: 0; }
.toc a { display: block; padding: .28rem .6rem; color: var(--muted); text-decoration: none; border-left: 2px solid var(--line); }
.toc a:hover, .toc a.active { color: var(--ink); border-left-color: var(--accent); }
.toc .title { font: 600 .78rem/1 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 .7rem .6rem; }

/* CV */
.cv-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 3rem; }
.cv-layout aside { position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; }
@media (max-width: 900px) { .cv-layout { grid-template-columns: 1fr; gap: 1rem; } .cv-layout aside { position: static; max-height: none; } }
.cv h2 { border-bottom: 1px solid var(--line); padding-bottom: .35rem; margin-top: 2.4rem; }
.cv section:first-of-type h2 { margin-top: 0; }
.entry { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 1.2rem; padding: .9rem 0; border-bottom: 1px dashed var(--line); }
.entry:last-child { border-bottom: 0; }
.entry .when { color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; padding-top: .15rem; }
.entry h3 { font-size: 1.05rem; margin: 0 0 .15rem; font-family: var(--sans); font-weight: 600; }
.entry .where { color: var(--muted); margin-bottom: .45rem; font-size: .95rem; }
.entry ul { margin-bottom: .3rem; }
.entry p, .entry li { font-size: .95rem; }
.entry > div > :last-child { margin-bottom: 0; }
@media (max-width: 600px) { .entry { grid-template-columns: 1fr; gap: .1rem; } }
.cv-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 2rem; }
.cv-contact { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; font-size: .92rem; }
.cv-contact li { margin: 0; }
.skills dt { font-weight: 600; margin-top: .9rem; }
.skills dd { margin: .2rem 0 0; color: var(--ink); font-size: .95rem; }
.compact li { font-size: .93rem; margin: .15rem 0; }
.cols-2 { columns: 2 300px; column-gap: 2.5rem; }
.cols-2 li { break-inside: avoid; }

/* course page */
.materials { list-style: none; padding: 0; margin: 0; }
.materials li { display: grid; grid-template-columns: 44px 1fr auto; gap: 1rem; align-items: center; padding: 1rem 0; border-bottom: 1px solid var(--line); margin: 0; }
.materials .ico { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font: 700 .7rem/1 var(--sans); letter-spacing: .04em; }
.materials h4 { margin: 0 0 .15rem; font-size: 1rem; }
.materials p { margin: 0; font-size: .92rem; color: var(--muted); }
@media (max-width: 600px) { .materials li { grid-template-columns: 44px 1fr; } .materials li .btn { grid-column: 2; justify-self: start; } }

.breadcrumb { font-size: .88rem; color: var(--muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--muted); }

/* footer */
.site-footer { border-top: 1px solid var(--line); margin-top: 2rem; }
.site-footer .bar { flex-wrap: wrap; justify-content: space-between; padding-top: 1.5rem; padding-bottom: 2rem; font-size: .9rem; color: var(--muted); }
.social { display: flex; gap: .4rem; flex-wrap: wrap; }
.social a { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; color: var(--muted); border: 1px solid var(--line); }
.social a:hover { color: var(--accent); border-color: var(--accent); }
.social svg { width: 17px; height: 17px; }

@media print {
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] { --bg: #fff; --surface: #fff; --surface-2: #f3f3f3; --ink: #000; --muted: #444; --line: #ccc; --accent: #0d4f52; --accent-soft: #eef5f5; color-scheme: light; }
  @page { margin: 16mm 15mm; }
  .site-header, .site-footer, .no-print, .cv-layout aside { display: none !important; }
  main { padding: 0; max-width: none; }
  .cv-layout { display: block; }
  body { font-size: 9.5pt; line-height: 1.4; }
  a { color: inherit; text-decoration: none; }
  .cv a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; word-break: break-all; }
  .cv-head { margin-bottom: 1rem; }
  .entry { grid-template-columns: 6.8rem minmax(0, 1fr); gap: .8rem; padding: .4rem 0; }
  .entry h3, .entry .where { break-after: avoid; }
  .entry p, .entry li { font-size: 9.5pt; }
  .entry p { margin-bottom: .45em; }
  .cv h2 { break-after: avoid; margin-top: 1.1rem; font-size: 14pt; }
  th, td { padding: .25rem .4rem; }
  tr { break-inside: avoid; }
  .skills dt { margin-top: .5rem; }
}

/* HPC tutorial */
.hpc-body { min-width: 0; }
.hpc-body pre { overflow-x: auto; background: var(--surface-2); padding: .9rem 1rem; border-radius: 8px; font-size: .85em; line-height: 1.45; }
.hpc-body pre code { background: none; padding: 0; font-size: inherit; }
.hpc-body table { display: block; overflow-x: auto; border-collapse: collapse; margin: 1.1rem 0; }
.hpc-body th, .hpc-body td { border-bottom: 1px solid var(--surface-2); padding: .4rem .7rem; text-align: left; vertical-align: top; }
.hpc-pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; flex-wrap: wrap; }
.hpc-licence { font-size: .85em; margin-top: 1.5rem; opacity: .8; }

/* Contents panels can be hidden, and sub-sections are indented */
.toc .sub a { padding-left: 1.4rem; font-size: .86rem; }
.toc a.active { font-weight: 600; }
.cv-layout.toc-hidden { grid-template-columns: minmax(0, 1fr); }
.cv-layout.toc-hidden aside { display: none; }
[data-toc-toggle] { margin-bottom: 1rem; }
@media (min-width: 901px) { .hpc-body section + section { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 2rem; } }

/* Expected results in the course guides: real output, and real page images */
.hpc-body .output { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; padding: .6rem .8rem .7rem; margin: 1rem 0 1.4rem; min-width: 0; }
.hpc-body .output > p:first-child { margin: 0 0 .4rem; font-family: var(--sans); font-size: .82rem; color: var(--ink); }
.hpc-body .output pre { margin: 0; background: var(--surface); }
.hpc-body .shown { margin: 1rem 0 1.4rem; min-width: 0; }
.hpc-body .shown figure { margin: 0 0 1rem; min-width: 0; }
.hpc-body .shown img { display: block; max-width: 100%; height: auto; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.hpc-body .shown figcaption { margin-top: .35rem; font-family: var(--sans); font-size: .82rem; color: var(--muted); }
.hpc-body .page-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; align-items: start; }
.hpc-body .code-result { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; align-items: start; }
.hpc-body .code-result > div { min-width: 0; }
@media (min-width: 1200px) { .hpc-body .code-result { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* Essays: figures, captions and tables inside the reading column. Scoped to .essay so other pages are untouched. */
.essay figure { margin: 1.6rem 0; }
.essay figure img { display: block; width: 100%; height: auto; border-radius: 6px; background: #fff; border: 1px solid var(--line); }
.essay figcaption { margin-top: .5rem; font-family: var(--sans); font-size: .86rem; line-height: 1.5; color: var(--muted); }
.essay .table-wrap { margin: 1.2rem 0 .4rem; }
.essay table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .88rem; }
.essay th, .essay td { border-bottom: 1px solid var(--line); padding: .45rem .6rem; text-align: left; vertical-align: top; }
.essay th { background: var(--surface-2); }
.essay hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.essay { min-width: 0; }
.essay .table-wrap { max-width: 100%; overflow-x: auto; }
@media (max-width: 600px) { .essay table { font-size: .78rem; } .essay th, .essay td { padding: .35rem .4rem; } }

/* Admin edit bar: shown only in admin mode (site.js) */
.admin-edit { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; max-width: calc(100vw - 32px);
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); box-shadow: 0 4px 16px rgba(0,0,0,.12); font-family: var(--sans); font-size: 13px; }
.admin-edit[hidden] { display: none; }
.admin-edit span:first-child { font-weight: 600; color: var(--rust); }
.admin-edit a { color: var(--accent); }
.admin-src { color: var(--muted); font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
@media print { .admin-edit { display: none !important; } }
