/* Marginalia — blog template
   Plain CSS, no build. Reading first: a 66-character measure, a modest type scale,
   generous leading, and margins that hold notes on wide screens (hence the name).
   Every colour is a custom property; dark mode follows the system. */

:root {
  --bg:      #FFFDF9;
  --fg:      #1B1B1A;
  --muted:   #6B6864;
  --line:    #E6E2DA;
  --accent:  #B4432B;          /* links, rules, one thing at a time */
  --soft:    #F5F1EA;
  --measure: 40rem;            /* ~66 characters at 1.125rem */
  --wide:    64rem;
  --gutter:  1.25rem;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans:  ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:  ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #151413; --fg: #EDEAE4; --muted: #A09B93; --line: #2A2825; --accent: #E0735A; --soft: #1D1C1A; }
}

/* ---- base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 112.5%; /* 18px */ -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--serif); line-height: 1.6; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; text-underline-offset: .15em; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }

.wrap { max-width: var(--measure); margin-inline: auto; padding-inline: var(--gutter); }
.wrap--wide { max-width: var(--wide); }
.sans { font-family: var(--sans); }
.mono { font-family: var(--mono); font-size: .8125rem; letter-spacing: .02em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---- header / footer ---------------------------------------------- */
.site-header { display: flex; align-items: baseline; justify-content: space-between; gap: 1.5rem; padding: 1.5rem var(--gutter); max-width: var(--wide); margin-inline: auto; font-family: var(--sans); }
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.375rem; letter-spacing: -.01em; color: var(--fg); font-style: italic; }
.site-header nav { display: flex; gap: 1.25rem; font-size: .9375rem; }
.site-header nav a { color: var(--muted); }
.site-header nav a:hover, .site-header nav a[aria-current="page"] { color: var(--fg); text-decoration: none; }
.site-footer { border-top: 1px solid var(--line); margin-top: 5rem; padding: 2rem var(--gutter) 3rem; max-width: var(--wide); margin-inline: auto; font-family: var(--sans); font-size: .875rem; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }

/* ---- type scale ---------------------------------------------------- */
h1, h2, h3 { font-weight: 700; letter-spacing: -.015em; line-height: 1.15; margin: 0; }
h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem; margin-top: 2.5rem; }
h3 { font-size: 1.125rem; margin-top: 2rem; }
p { margin: 1.25rem 0; }
.lead { font-size: 1.25rem; line-height: 1.5; color: var(--muted); }
.kicker { font-family: var(--sans); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 600; }

/* ---- index: the latest, then the list ------------------------------ */
.featured { padding-block: 2rem 1rem; }
.featured h1 { font-size: clamp(2rem, 5vw, 3rem); }
.featured h1 a { color: inherit; }
.list { list-style: none; margin: 2rem 0 0; padding: 0; }
.list li { border-top: 1px solid var(--line); padding: 1.5rem 0; }
.list h2 { font-size: 1.375rem; margin: .25rem 0 .5rem; }
.list h2 a { color: inherit; }
.list p { margin: 0; color: var(--muted); }
.meta { font-family: var(--sans); font-size: .8125rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .5rem 1rem; }

/* ---- article ------------------------------------------------------- */
.article-head { padding-block: 2rem 1rem; }
.article-head h1 { font-size: clamp(2rem, 5vw, 2.75rem); }
.article-head .lead { margin-top: 1rem; }
.byline { display: flex; align-items: center; gap: .75rem; margin-top: 1.5rem; font-family: var(--sans); font-size: .875rem; }
.byline .avatar { width: 2.25rem; height: 2.25rem; border-radius: 50%; background: var(--soft); border: 1px solid var(--line); display: grid; place-items: center; font-size: .625rem; color: var(--muted); }
.prose > *:first-child { margin-top: 0; }
.prose blockquote { margin: 2rem 0; padding-left: 1.25rem; border-left: 2px solid var(--accent); font-style: italic; }
.prose blockquote p { margin: 0; }
.prose pre { font-family: var(--mono); font-size: .8125rem; line-height: 1.55; background: var(--soft); border: 1px solid var(--line); padding: 1rem 1.25rem; border-radius: .375rem; overflow-x: auto; }
.prose code { font-family: var(--mono); font-size: .875em; background: var(--soft); padding: .1em .35em; border-radius: .25rem; }
.prose pre code { background: none; padding: 0; }
.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li { margin: .375rem 0; }
.prose figure { margin: 2rem 0; }
.prose figcaption { font-family: var(--sans); font-size: .8125rem; color: var(--muted); margin-top: .5rem; }
.prose .wide { margin-inline: calc(50% - min(50vw, var(--wide) / 2) + var(--gutter)); }

/* Marginal notes: in the margin on wide screens, inline on narrow */
.note { font-family: var(--sans); font-size: .8125rem; line-height: 1.5; color: var(--muted); }
@media (min-width: 72rem) {
  .prose { position: relative; }
  .note { position: absolute; right: calc(-14rem - 2rem); width: 14rem; margin-top: -1.5rem; }
}
@media (max-width: 71.99rem) {
  .note { display: block; margin: .75rem 0 1.25rem; padding-left: 1rem; border-left: 2px solid var(--line); }
}
.note-ref { font-family: var(--sans); font-size: .75em; color: var(--accent); vertical-align: super; }

.ph { background: var(--soft); border: 1px solid var(--line); border-radius: .375rem; display: grid; place-items: center; color: var(--muted); font-family: var(--mono); font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; aspect-ratio: 16 / 9; }

.article-foot { border-top: 1px solid var(--line); margin-top: 3rem; padding-top: 1.5rem; font-family: var(--sans); font-size: .9375rem; }
.tags { display: flex; flex-wrap: wrap; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1.5rem; }
.tags a { font-family: var(--sans); font-size: .8125rem; padding: .25rem .625rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); }
.tags a:hover { color: var(--fg); border-color: var(--fg); text-decoration: none; }
.author-card { display: grid; grid-template-columns: 3.5rem 1fr; gap: 1rem; align-items: start; padding: 1.25rem; background: var(--soft); border-radius: .5rem; margin-top: 1.5rem; }
.author-card .avatar { width: 3.5rem; height: 3.5rem; border-radius: 50%; background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; font-size: .625rem; color: var(--muted); }
.author-card p { margin: .25rem 0 0; }
.prevnext { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; margin-top: 2rem; }
.prevnext a { display: block; padding: 1rem; border: 1px solid var(--line); border-radius: .5rem; color: var(--fg); }
.prevnext a:hover { border-color: var(--fg); text-decoration: none; }
.prevnext small { display: block; font-family: var(--sans); color: var(--muted); font-size: .75rem; margin-bottom: .25rem; }

/* ---- archive ------------------------------------------------------- */
.year { font-family: var(--sans); font-size: .8125rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 2.5rem 0 .5rem; }
.archive { list-style: none; padding: 0; margin: 0; }
.archive li { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; padding: .625rem 0; border-top: 1px solid var(--line); align-items: baseline; }
.archive time { font-family: var(--sans); font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.archive a { color: var(--fg); }
.archive a:hover { color: var(--accent); }

/* ---- author -------------------------------------------------------- */
.author-head { display: grid; grid-template-columns: 6rem 1fr; gap: 1.5rem; align-items: center; padding-block: 2rem 1rem; }
.author-head .avatar { width: 6rem; height: 6rem; border-radius: 50%; background: var(--soft); border: 1px solid var(--line); display: grid; place-items: center; font-size: .625rem; color: var(--muted); }

/* ---- newsletter (Pro) --------------------------------------------- */
.signup { background: var(--soft); border: 1px solid var(--line); border-radius: .5rem; padding: 1.5rem; font-family: var(--sans); }
.signup form { display: flex; gap: .5rem; margin-top: 1rem; }
.field { font: inherit; font-size: 1rem; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: .375rem; padding: .625rem .875rem; flex: 1; min-width: 0; }
.field:focus { outline: none; border-color: var(--fg); }
.btn { font: inherit; font-family: var(--sans); font-weight: 600; font-size: .9375rem; padding: .625rem 1.125rem; border: 1px solid var(--fg); border-radius: .375rem; background: var(--fg); color: var(--bg); cursor: pointer; }
.btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; color: var(--fg); }
.issues { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.issues li { border-top: 1px solid var(--line); padding: 1rem 0; display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; align-items: baseline; }

/* ---- 404 (Pro) ----------------------------------------------------- */
.oops { text-align: center; padding-block: 5rem 3rem; }
.oops h1 { font-size: clamp(2.5rem, 8vw, 4.5rem); font-style: italic; }
.oops p { color: var(--muted); max-width: 28rem; margin: 1rem auto 2rem; }

@media (max-width: 40rem) {
  .site-header { flex-direction: column; gap: .5rem; }
  .prevnext { grid-template-columns: 1fr; }
  .archive li, .issues li { grid-template-columns: 1fr; gap: .125rem; }
  .signup form { flex-direction: column; }
}
