:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1f2328;
  --muted: #59636e;
  --border: #d0d7de;
  --link: #004D61;
  --link-hover: #00809E; /* brighter --link for hovered links; dark mode overrides below */
  --code-bg: #f6f8fa;
}

/* Dark palette: follows the OS setting unless the toggle has forced light,
   and always applies when the toggle has forced dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1a1a;
    --fg: #F0F0F0;
    --muted: #9198a1;
    --border: #3a3a3a;
    --link: #004D61;
    --link-hover: #006B85;
    --code-bg: #262626;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1a1a;
  --fg: #F0F0F0;
  --muted: #9198a1;
  --border: #3a3a3a;
  --link: #004D61;
  --link-hover: #006B85;
  --code-bg: #262626;
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Avenir Next", Avenir, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-kerning: normal;
  line-height: 1.6;
}

.site-nav {
  max-width: 740px;
  margin: 0 auto;
  padding: 24px 16px 0;
  font-size: 14px;
  color: var(--muted);
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.theme-toggle {
  font: inherit;
  font-size: 13px;
  padding: 2px 10px;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}

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

.site-nav a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

main.markdown-body {
  max-width: 740px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  font-weight: 600;
  line-height: 1.25;
}

.markdown-body h1 {
  font-size: 2em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
  margin: 0 0 16px;
}

.markdown-body h2 {
  font-size: 1.4em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
  margin: 32px 0 16px;
}

.markdown-body h3 {
  font-size: 1.15em;
  margin: 24px 0 8px;
}

.markdown-body p,
.markdown-body ul {
  margin: 0 0 16px;
}

.markdown-body ul {
  padding-left: 1.5em;
}

.markdown-body li {
  margin: 4px 0;
}

.markdown-body a {
  color: var(--link);
  text-decoration: none;
}

.markdown-body a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Profile photo (plus the links on the lines right after it, which join its
   paragraph) floats beside the bio, al-folio style — stacks above the text on
   narrow screens instead. */
.markdown-body p:has(> img) {
  width: 35%;
  max-width: 200px;
  float: right;
  margin: 0 0 16px 24px;
  text-align: center;
}

.markdown-body img {
  display: block;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.markdown-body h2,
.markdown-body hr {
  clear: both;
}

@media (max-width: 640px) {
  .markdown-body p:has(> img) {
    float: none;
    width: 100%;
    max-width: 240px;
    margin: 0 auto 16px;
  }
}

.markdown-body code {
  background: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.markdown-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.markdown-body blockquote {
  margin: 0 0 16px;
  padding: 0 1em;
  color: var(--muted);
  border-left: 0.25em solid var(--border);
}

.markdown-body blockquote p:last-child {
  margin-bottom: 0;
}

.callout {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-left: 0.25em solid var(--callout-border);
  background: var(--callout-bg);
  border-radius: 6px;
}

.callout p,
.callout ul {
  margin: 0 0 8px;
}

.callout > :last-child {
  margin-bottom: 0;
}

.callout-title {
  font-weight: 600;
  color: var(--callout-border);
}

.callout-note {
  --callout-border: #004D61;
  --callout-bg: rgba(0, 77, 97, 0.15);
}

.callout-tip {
  --callout-border: #3E5641;
  --callout-bg: rgba(62, 86, 65, 0.15);
}

.callout-important {
  --callout-border: #8250df;
  --callout-bg: rgba(130, 80, 223, 0.1);
}

.callout-warning {
  --callout-border: #9a6700;
  --callout-bg: rgba(154, 103, 0, 0.1);
}

.callout-caution {
  --callout-border: #cf222e;
  --callout-bg: rgba(207, 34, 46, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .callout-note {
    --callout-border: #004D61;
    --callout-bg: rgba(0, 77, 97, 0.12);
  }

  :root:not([data-theme="light"]) .callout-tip {
    --callout-border: #3E5641;
    --callout-bg: rgba(62, 86, 65, 0.12);
  }

  :root:not([data-theme="light"]) .callout-important {
    --callout-border: #a371f7;
    --callout-bg: rgba(163, 113, 247, 0.12);
  }

  :root:not([data-theme="light"]) .callout-warning {
    --callout-border: #d29922;
    --callout-bg: rgba(210, 153, 34, 0.12);
  }

  :root:not([data-theme="light"]) .callout-caution {
    --callout-border: #f85149;
    --callout-bg: rgba(248, 81, 73, 0.12);
  }
}

:root[data-theme="dark"] .callout-note {
  --callout-border: #004D61;
  --callout-bg: rgba(0, 77, 97, 0.12);
}

:root[data-theme="dark"] .callout-tip {
  --callout-border: #3E5641;
  --callout-bg: rgba(62, 86, 65, 0.12);
}

:root[data-theme="dark"] .callout-important {
  --callout-border: #a371f7;
  --callout-bg: rgba(163, 113, 247, 0.12);
}

:root[data-theme="dark"] .callout-warning {
  --callout-border: #d29922;
  --callout-bg: rgba(210, 153, 34, 0.12);
}

:root[data-theme="dark"] .callout-caution {
  --callout-border: #f85149;
  --callout-bg: rgba(248, 81, 73, 0.12);
}

/* Cards ("::: cards" blocks) for projects and teaching: one per row, with a
   status pill on the meta line and tag pills at the bottom. */
.cards {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
}

.card {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.markdown-body .card h3 {
  margin: 0 0 2px;
  font-size: 1.1em;
}

.markdown-body .card p,
.markdown-body .card ul {
  margin: 0 0 6px;
  font-size: 15px;
}

.markdown-body .card > :last-child {
  margin-bottom: 0;
}

.markdown-body .card-meta {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--muted);
}

.status,
.tag {
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.status {
  color: var(--status);
  border-color: color-mix(in srgb, var(--status) 40%, transparent);
}

.status-review { --status: #9a6700; }
.status-active { --status: #1a7f37; }
.status-done { --status: #00809E; }
.status-other { --status: var(--muted); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .status-review { --status: #d29922; }
  :root:not([data-theme="light"]) .status-active { --status: #3fb950; }
  :root:not([data-theme="light"]) .status-done { --status: #39b4d0; }
}

:root[data-theme="dark"] .status-review { --status: #d29922; }
:root[data-theme="dark"] .status-active { --status: #3fb950; }
:root[data-theme="dark"] .status-done { --status: #39b4d0; }

.markdown-body .cards-empty {
  color: var(--muted);
  font-style: italic;
}

.markdown-body .card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  color: var(--muted);
  background: var(--code-bg);
}

.site-footer {
  max-width: 740px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  font-size: 13px;
  color: var(--muted);
}

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

/* Page weight / CO2e line: smaller and fainter than the footer. */
.site-footer .site-stats {
  margin-top: -8px;
  font-size: 12px;
  opacity: 0.75;
}

.print-button button {
  font: inherit;
  font-size: 14px;
  padding: 6px 14px;
  color: var(--fg);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.print-button button:hover {
  border-color: var(--link);
  color: var(--link);
}

/* Print / "Save as PDF": black on white regardless of the viewer's color
   scheme, compact spacing, and no site chrome. */
@media print {
  @page {
    size: letter;
    margin: 1.5cm;
  }

  :root,
  :root[data-theme] {
    color-scheme: light;
    --bg: #fff;
    --fg: #000;
    --muted: #444;
    --border: #bbb;
    --link: #000;
  }

  body {
    font-size: 10.5pt;
    line-height: 1.4;
  }

  .site-nav,
  .site-footer,
  .print-button {
    display: none;
  }

  main.markdown-body {
    max-width: none;
    padding: 0;
  }

  .markdown-body h1 {
    font-size: 1.8em;
  }

  .markdown-body h2 {
    font-size: 1.2em;
    margin: 20px 0 8px;
    break-after: avoid;
  }

  .markdown-body p,
  .markdown-body ul {
    margin: 0 0 4px;
  }

  /* Each bold-titled line starts a new entry: give it space above and keep
     it with the detail lines that follow. */
  .markdown-body p:has(> strong:first-child) {
    margin-top: 10px;
    break-after: avoid;
  }

  .markdown-body a {
    text-decoration: underline;
  }

  /* Backgrounds are dropped when printing, so render callouts as a plain
     left-bordered block. */
  .callout,
  :root[data-theme] .callout,
  :root:not([data-theme="light"]) .callout {
    --callout-border: #000;
    background: none;
    padding: 4px 12px;
    break-inside: avoid;
  }

  .card {
    break-inside: avoid;
  }
}
