/* EB Garamond variable fonts */
@font-face {
  font-family: 'EB Garamond';
  src: url('fonts/EBGaramond-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'EB Garamond';
  src: url('fonts/EBGaramond-Italic-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

/* Color tokens */
:root {
  --color-bg: #fff;
  --color-text: #1a1a1a;
  --color-accent: #0e7490;
  --color-muted: #555;
  --color-border: #d1d5db;
  --color-code-bg: #f3f4f6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #111;
    --color-text: #e5e5e5;
    --color-accent: #22d3ee;
    --color-muted: #9ca3af;
    --color-border: #374151;
    --color-code-bg: #1f2937;
  }
}

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

/* Body */
body {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  width: min(100%, 60ch);
  margin-inline: auto;
  padding-inline: 1rem;
}

/* Scroll */
html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

/* Typography */
h1 { font-size: 1.8rem; font-weight: 700; margin-block: 1.2rem 0.5rem; }
h2 { font-size: 1.4rem; font-weight: 600; margin-block: 1.2rem 0.4rem; }
h3 { font-size: 1.2rem; font-weight: 600; margin-block: 1rem 0.3rem; }
h4 { font-size: 1.05rem; font-weight: 600; margin-block: 0.8rem 0.2rem; }

a {
  color: var(--color-accent);
  text-decoration-skip-ink: auto;
}

a:hover {
  text-decoration: underline;
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Code */
code, pre {
  font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, monospace;
  font-size: 0.9em;
}

code {
  background: var(--color-code-bg);
  padding: 0.1em 0.3em;
  border-radius: 0.2em;
}

pre {
  background: var(--color-code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 0.3em;
}

pre code {
  background: none;
  padding: 0;
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-bg);
  color: var(--color-accent);
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  z-index: 10000;
}
.skip-link:focus {
  top: 0;
}

/* Navigation */
header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1.5rem;
}

header nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

header nav a {
  text-decoration: none;
  color: var(--color-text);
}

header nav a:hover {
  color: var(--color-accent);
}

/* TOC box */
.toc-box {
  border: 1px solid var(--color-border);
  border-radius: 0.4em;
  padding: 0.75rem 1rem 0.75rem 1rem;
  margin-bottom: 1.5rem;
  background: var(--color-code-bg);
}

.toc-label {
  margin: 0 0 0.4rem;
  font-weight: 600;
  font-size: 0.95rem;
}

nav.toc-box ul {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
}

nav.toc-box ul li {
  margin-block: 0.2rem;
}

nav.toc-box ul li a {
  color: var(--color-accent);
  text-decoration: none;
}

nav.toc-box ul li a:hover {
  text-decoration: underline;
}

/* Headshot */
img.headshot {
  display: block;
  margin-inline: auto;
  max-width: 18rem;
}

figure:has(img.headshot) figcaption {
  display: none;
}

/* Tables */
table {
  border-collapse: collapse;
  margin-inline: auto;
  margin-block: 1.5rem;
  width: 100%;
}

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

th {
  font-weight: 600;
  border-bottom: 2px solid var(--color-border);
}

tbody tr:nth-child(even) {
  background: var(--color-code-bg);
}

/* Back to top button */
.back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9999;
  display: inline-block;
  padding: 0.6rem 0.8rem;
  border-radius: 0.75rem;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  font-size: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  text-decoration: none;
}

.back-to-top:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
}
