/* scholarly.css — clean typography for academic texts */

:root {
  --text: var(--ink, #1a1a1a);
  --bg: var(--warm-white, #fafaf8);
  --accent: var(--sea, #2c4a6e);
  --border: var(--grid, #d4d0c8);
  --footnote: #555;
  --code-bg: #f0eeea;
  --max-width: 42rem;
  --font-body: 'Source Serif 4', 'Georgia', serif;
  --font-heading: 'Source Sans 3', 'Helvetica Neue', sans-serif;
  --font-code: 'Source Code Pro', 'Menlo', monospace;
}

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,300;0,8..60,400;0,8..60,600;1,8..60,400&family=Source+Sans+3:wght@400;600&family=Source+Code+Pro:wght@400&display=swap');

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

html {
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  margin: 0;
}

main {
  max-width: calc(var(--max-width) + 3rem);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* — Brand header — */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(250, 248, 244, 0.92);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  max-width: calc(var(--max-width) + 3rem);
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 44px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand-lockup img:first-child {
  width: 32px;
  height: 32px;
  flex: none;
}

.brand-lockup img:last-child {
  width: 200px;
  max-width: min(48vw, 200px);
  height: auto;
  flex: none;
}

/* — Headings — */

h1 {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.25rem;
  color: var(--text);
}

h1 + em, h1 + p > em:first-child {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--footnote);
  margin-bottom: 1.5rem;
}

h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}

h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
  color: var(--text);
}

/* — Paragraphs and prose — */

p {
  margin: 0 0 1rem;
  text-align: left;
  hyphens: auto;
}

/* — Front matter block — */

.front-matter {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--footnote);
  border: 1px solid var(--border);
  background: var(--code-bg);
  padding: 0.75rem 1rem;
  margin: 1rem 0 2rem;
  border-radius: 3px;
}

.front-matter p {
  margin: 0.15rem 0;
}

/* — Blockquotes — */

blockquote {
  margin: 1.25rem 0;
  padding: 0 0 0 1.25rem;
  border-left: 3px solid var(--border);
  color: var(--footnote);
}

/* — Figures — */

figure.essay-figure {
  margin: 2rem 0;
  padding: 0;
  text-align: center;
}

figure.essay-figure svg {
  max-width: 100%;
  height: auto;
}

/* — Lists — */

ul, ol {
  margin: 0.5rem 0 1rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.35rem;
}

/* — Tables — */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.9rem;
}

thead {
  border-bottom: 2px solid var(--text);
}

th {
  font-family: var(--font-heading);
  font-weight: 600;
  text-align: left;
  padding: 0.4rem 0.6rem;
}

td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

/* — Code — */

code {
  font-family: var(--font-code);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

pre {
  background: var(--code-bg);
  padding: 1rem;
  overflow-x: auto;
  border-radius: 3px;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* — Horizontal rules — */

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* — Links — */

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

a:hover {
  color: #1a3555;
}

/* — Footnotes — */

.footnote-ref {
  font-size: 0.75em;
  vertical-align: super;
  line-height: 0;
  text-decoration: none;
}

.footnotes {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--footnote);
}

.footnotes ol {
  padding-left: 1.25rem;
}

.footnotes li {
  margin-bottom: 0.75rem;
}

.footnotes p {
  margin: 0;
}

/* — Emphasis — */

strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

/* — Navigation — */

nav.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem 0.5rem;
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 0.75rem;
}

nav.site-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--min-target, 2.75rem);
  padding: 0.45rem 0.85rem;
  text-decoration: none;
  color: var(--accent);
  border: 1px solid transparent;
  background: transparent;
}

nav.site-nav a:hover {
  color: var(--text);
  border-color: var(--border);
  background: rgba(250, 248, 244, 0.88);
}

/* — Print — */

@media print {
  body {
    font-size: 11pt;
    color: #000;
    background: #fff;
  }
  .site-header, .front-matter {
    display: none;
  }
  h2 {
    border-bottom-color: #000;
    color: #000;
  }
}

/* — Responsive — */

@media (max-width: 600px) {
  .site-header {
    transition: transform 220ms ease;
  }
  .site-header.is-hidden {
    transform: translateY(calc(-100% - 1px));
  }
  html {
    font-size: 16px;
  }
  main {
    padding: 1rem 1rem 3rem;
  }
  .site-header__inner {
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: flex-start;
  }
  .brand-lockup img:last-child {
    width: 170px;
  }
  nav.site-nav {
    justify-content: flex-start;
  }
  h1 {
    font-size: 1.6rem;
  }
  table {
    font-size: 0.8rem;
  }
}
