/* Layout idea: a datasheet turned into a site. A tab bar on top, a wide frame for the
   hero and cards, a narrow column for reading, hairline rules, and lab rows with a hex
   number in the left gutter and a spec line (board, core, level) under each title. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #161b26;
  --muted: #5a6475;
  --rule: #d6dae2;
  --accent: #2447b3;
  --on-accent: #ffffff;
  --copper: #96561b;
  --font-display: "IBM Plex Sans Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --read: 42rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11141b;
    --surface: #181c26;
    --ink: #e4e7ee;
    --muted: #9aa3b5;
    --rule: #2b3140;
    --accent: #93adff;
    --on-accent: #0f1320;
    --copper: #e0a468;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #11141b;
  --surface: #181c26;
  --ink: #e4e7ee;
  --muted: #9aa3b5;
  --rule: #2b3140;
  --accent: #93adff;
  --on-accent: #0f1320;
  --copper: #e0a468;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
}

.wrap {
  width: min(100% - 2rem, 62rem);
  margin-inline: auto;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: -999rem;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 20;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Header with tabs */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}

/* Phone: name and theme switch on the first row, tabs on the second.
   Wide screens: name, tabs and theme switch on one row. */
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1.5rem;
}

.brand {
  order: 1;
  margin-right: auto;
  padding-block: 0.9rem 0.35rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.tabs {
  order: 3;
  flex-basis: 100%;
  max-width: 100%;
  overflow-x: auto;
}

.theme-toggle {
  order: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

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

.tabs ul {
  display: flex;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tabs a {
  display: block;
  padding-block: 0.7rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 0.975rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--ink);
}

.tabs a[aria-current="page"] {
  border-bottom-color: var(--accent);
  color: var(--ink);
}

@media (min-width: 44rem) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .brand {
    padding-block: 0.9rem;
  }

  .tabs {
    order: 2;
    flex-basis: auto;
  }

  .theme-toggle {
    order: 3;
  }

  .tabs a {
    padding-block: 1.1rem;
  }
}

/* Page frame */
main {
  display: flex;
  flex-direction: column;
  gap: 3.5rem;
  padding-block: 2.75rem 4.5rem;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.1rem, 6.5vw, 3.25rem);
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.2rem;
}

.hero,
.page-head,
.block,
.article {
  display: flex;
  flex-direction: column;
}

.hero,
.page-head {
  gap: 1rem;
  max-width: var(--read);
}

.hero {
  padding-block: 1rem 0.5rem;
}

.article {
  gap: 2.5rem;
}

.block {
  gap: 1.25rem;
}

.eyebrow,
.lead,
.byline,
.sub,
.empty,
.actions,
.page-head p,
.card p {
  margin: 0;
}

.eyebrow {
  color: var(--copper);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.lead {
  color: var(--muted);
  font-size: 1.2rem;
}

.hero .prose {
  font-size: 1.15rem;
}

.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.empty {
  max-width: var(--read);
  padding: 1.25rem;
  border: 1px dashed var(--rule);
  border-radius: 8px;
  color: var(--muted);
}

/* Buttons */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

.btn {
  display: inline-block;
  padding: 0.65rem 1.1rem;
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: var(--ink);
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
}

.btn:hover {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 85%, var(--ink));
}

/* Credentials under the hero, set like the key figures on a datasheet's first page */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.25rem 2rem;
  margin: 0;
  padding-block: 1.5rem;
  border-block: 1px solid var(--rule);
}

.fact {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.fact dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fact dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.2;
}

/* Contact block */
.contact {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: var(--read);
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.contact p {
  margin: 0;
  overflow-wrap: anywhere;
}

/* "How the labs work": numbered because the steps happen in this order */
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1.5rem 2rem;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  counter-increment: step;
}

.step::before {
  content: counter(step, decimal-leading-zero);
  color: var(--copper);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.step p,
.teaser {
  margin: 0;
  color: var(--muted);
}

.teaser {
  max-width: var(--read);
  font-size: 1.1rem;
}

/* Topic labels on labs */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chips li {
  padding: 0.1em 0.5em;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

/* Lab page: text with an "On this page" list. The list sits above the text on a
   phone and beside it on a wide screen. */
.article-body {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.toc {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: var(--read);
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 0.9rem;
}

.toc:has(nav:empty) {
  display: none;
}

.toc-title {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.toc ul {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.toc ul ul {
  padding: 0.35rem 0 0 0.9rem;
}

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

.toc a:hover {
  color: var(--ink);
  text-decoration: underline;
}

@media (min-width: 64rem) {
  .article-body {
    display: grid;
    grid-template-columns: minmax(0, var(--read)) 15rem;
    align-items: start;
    gap: 3.5rem;
  }

  .article-body .prose {
    order: 1;
  }

  .toc {
    position: sticky;
    top: 5rem;
    order: 2;
    padding: 0 0 0 1.25rem;
    border: 0;
    border-left: 1px solid var(--rule);
    border-radius: 0;
  }
}

/* Links to the neighbouring labs */
.pager {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  max-width: 48rem;
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  text-decoration: none;
}

.pager-link:hover {
  border-color: var(--accent);
}

.pager-label {
  color: var(--copper);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 400;
}

/* Copy button on code blocks (added by site.js) */
.codeblock {
  position: relative;
}

.copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid rgb(255 255 255 / 0.25);
  border-radius: 4px;
  background: rgb(255 255 255 / 0.08);
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  cursor: pointer;
}

.copy:hover {
  background: rgb(255 255 255 / 0.18);
}

/* Portrait on the About page */
.portrait {
  width: 9rem;
  height: 9rem;
  border-radius: 50%;
  object-fit: cover;
}

/* Section heading with a full-strength rule, as on a datasheet */
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--ink);
}

.block-head a {
  font-size: 0.95rem;
  white-space: nowrap;
}

.sub {
  padding-top: 0.75rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Cards for the three areas on the home page */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
}

.card:hover {
  border-color: var(--accent);
}

.card h3 a {
  color: var(--ink);
  text-decoration: none;
}

/* The whole card is the link target */
.card h3 a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card p {
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 0.1em 0.6em;
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--copper);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  line-height: 1.5;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

/* Rows for labs and courses */
.entry-list {
  max-width: 48rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.entry {
  display: flex;
  gap: 0.75rem;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--rule);
}

.entry-id {
  flex: 0 0 3.25rem;
  padding-top: 0.2rem;
  color: var(--copper);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.entry-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.entry-body p {
  margin: 0;
  color: var(--muted);
}

.entry h3 a {
  color: var(--ink);
  text-decoration: none;
}

.entry h3 a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  font-size: 0.875rem;
}

.meta div {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.meta dt {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.meta dd {
  margin: 0;
}

/* Long-form text */
.prose {
  max-width: var(--read);
}

.prose > * {
  margin: 0;
}

.prose > * + * {
  margin-top: 1em;
}

.prose > h2 {
  margin-top: 2em;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}

.prose > h2:first-child {
  margin-top: 0;
}

.prose > h3 {
  margin-top: 1.6em;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
}

.prose li + li {
  margin-top: 0.35em;
}

.prose img {
  max-width: 100%;
  height: auto;
}

.prose blockquote {
  padding-left: 1rem;
  border-left: 3px solid var(--copper);
  color: var(--muted);
}

.prose code {
  padding: 0.1em 0.35em;
  border-radius: 3px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

/* Code blocks stay dark in both themes, like a terminal */
.prose pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 6px;
  background: #0d1117;
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.5;
}

.prose pre code {
  padding: 0;
  background: none;
  color: inherit;
  font-size: inherit;
}

.prose table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.prose th,
.prose td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
}

.prose th {
  border-bottom-color: var(--ink);
  font-weight: 600;
}

/* Footer */
.site-footer {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-block: 2rem 2.5rem;
  border-top: 1px solid var(--rule);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1.5rem 2rem;
}

.footer-col {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.site-footer p {
  margin: 0;
}

.footer-name {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

.footer-title {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.footer-col ul {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-col a {
  color: var(--muted);
  text-decoration: none;
}

.footer-col a:hover {
  color: var(--ink);
  text-decoration: underline;
}

.legal {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

.legal ul {
  display: flex;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

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