/* ============================================================
   Palette
   ============================================================ */
:root {
  --paper: #FFFFFF;
  --paper-2: #F3F2EE;
  --ink: #1A1A1A;
  --ink-2: #3A3A3A;
  --mute: #777777;
  --rule: #D6D4CE;
  --accent: #2E4A7B;
  --accent-hover: #1B3768;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --serif: "Computer Modern Serif", "Latin Modern Roman", Georgia, serif;

  /* Pico-compat tokens (syntax.css + proof-state rules still reference these). */
  --pico-background-color: var(--paper);
  --pico-color: var(--ink);
  --pico-muted-color: var(--mute);
  --pico-muted-border-color: var(--rule);
  --pico-card-background-color: var(--paper-2);
  --pico-code-background-color: var(--paper-2);
  --pico-form-element-background-color: var(--paper-2);
  --pico-primary: var(--accent);
  --pico-primary-hover: var(--accent);
  --pico-secondary: var(--ink-2);
  --pico-contrast: var(--ink);
  --pico-font-family: var(--serif);
  --pico-font-family-monospace: var(--mono);
  --pico-font-size: 16px;
  --pico-border-radius: 0;

  --tone-note:    var(--mute);
  --tone-info:    #3B5C9E;
  --tone-tip:     #3F7A5F;
  --tone-warning: #B07A1A;
  --tone-danger:  #A33A28;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16161A;
    --paper-2: #1F1F23;
    --ink: #E6E6E6;
    --ink-2: #BDBDBD;
    --mute: #8A8A8A;
    --rule: #2F2F33;
    --accent: #8AA8D6;
    --accent-hover: #B0C5E5;

    --tone-note:    var(--mute);
    --tone-info:    #8AA8D6;
    --tone-tip:     #7FBE91;
    --tone-warning: #D6B070;
    --tone-danger:  #D68A7F;
  }
}

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

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.5;
}

code, kbd, samp, pre {
  font-family: var(--mono);
  font-size: 0.95em;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.25;
  margin: 1.4em 0 0.5em;
}

p { margin: 0 0 1em; }

ul, ol { padding-left: 1.5rem; }

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

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

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

/* ============================================================
   Site header — one line, name + nav inline
   ============================================================ */
.site-head {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 1rem;
  font-family: var(--serif);
  font-size: 1rem;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4em;
}
.site-head a {
  color: var(--ink);
  text-decoration: none;
}
.site-head a:hover { color: var(--accent); }
.site-head a.site-name { font-weight: 700; }
.site-head a.current { color: var(--accent); }
.site-head .sep { color: var(--mute); }

/* ============================================================
   HOMEPAGE — single centered column, bio then recent posts
   ============================================================ */
main.home {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
}

.bio { display: flow-root; }
.card {
  float: left;
  width: 180px;
  margin: 0.25rem 1.25rem 0.75rem 0;
}
.card .photo {
  aspect-ratio: 1 / 1;
  width: 100%;
  background: var(--paper-2);
}
.card .photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(1) contrast(1.02);
}
.card .photo img.dither:not([data-dither-source]) {
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.card .photo img.dither[data-dithered="true"] {
  opacity: 1;
}
@media (prefers-color-scheme: dark) {
  .card .photo img { filter: grayscale(1) contrast(0.92) brightness(0.9); }
}
.bio .prose {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.55;
}
.bio .prose p { margin: 0 0 1rem; }
.bio .prose em { font-style: italic; }
.bio .prose a.more { display: inline-block; margin-top: 0.25rem; }

/* Recent posts */
section.log {
  margin-top: 2.5rem;
}
.entries {
  list-style: none;
  padding: 0;
  margin: 0;
}
.entries li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 1.1rem;
  line-height: 1.55;
}
.entries li:first-child { border-top: 1px solid var(--rule); }
.entries .date {
  color: var(--mute);
  font-style: italic;
  font-size: 0.9rem;
  margin-left: 0.4em;
}
.entries .sub {
  display: block;
  font-size: 0.95rem;
  color: var(--mute);
  font-style: italic;
  margin-top: 2px;
}
.log-foot {
  margin-top: 1rem;
  color: var(--mute);
  font-size: 0.95rem;
}

/* ============================================================
   POST / ARTICLE PAGE — single centered column
   ============================================================ */
article.post {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
}
article.post > header {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}
.post-meta {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--mute);
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.post-meta .sep { color: var(--mute); }
.post-meta a { color: var(--mute); text-decoration: none; }
.post-meta a:hover { color: var(--accent); }
.post-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.7rem, 3.5vw, 2.2rem);
  line-height: 1.15;
  margin: 0 0 0.5rem;
}
.post-subtitle {
  font-family: var(--serif);
  font-style: italic;
  color: var(--mute);
  font-size: 1.05rem;
  line-height: 1.4;
  margin: 0;
}

/* Inline series table-of-contents */
nav.series-toc {
  margin: 0 0 2rem;
  padding: 0.4rem 0 0.4rem 0.9rem;
  border-left: 2px solid var(--rule);
  font-size: 0.95rem;
  color: var(--ink-2);
}
nav.series-toc .series-toc-head {
  margin: 0 0 0.4rem;
  color: var(--mute);
}
nav.series-toc .series-toc-head em { font-style: italic; color: var(--ink-2); }
nav.series-toc ol {
  margin: 0;
  padding-left: 1.4rem;
}
nav.series-toc li { margin: 0.1rem 0; line-height: 1.4; }
nav.series-toc li.current { font-weight: 700; color: var(--ink); }
nav.series-toc li a { text-decoration: none; color: var(--ink-2); }
nav.series-toc li a:hover { color: var(--accent); }

/* Body prose */
article.post .prose {
  font-family: var(--serif);
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--ink);
}
article.post .prose > * { max-width: 100%; }
article.post .prose p { margin: 0 0 1rem; }
article.post .prose h1,
article.post .prose h2,
article.post .prose h3,
article.post .prose h4 {
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1.25;
}
article.post .prose h1 { font-size: 1.6rem; margin: 2.2rem 0 0.6rem; }
article.post .prose h2 { font-size: 1.35rem; margin: 1.9rem 0 0.6rem; }
article.post .prose h3 { font-size: 1.15rem; margin: 1.5rem 0 0.4rem; }
article.post .prose h4 { font-size: 1.05rem; margin: 1.3rem 0 0.3rem; }
article.post .prose em { font-style: italic; }
article.post .prose code:not(pre code) {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--paper-2);
  padding: 1px 5px;
}
article.post .prose blockquote {
  margin: 1.5rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-2);
  font-style: italic;
}
article.post .prose pre {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 1.25rem 0;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  border: 1px solid var(--rule);
  background: var(--paper-2);
}
article.post .prose pre code { background: transparent; padding: 0; font-size: inherit; }

/* Lean proof block */
article.post .prose .lean-proof-block {
  border: 1px solid var(--rule);
  margin: 1.25rem 0;
  background: var(--paper-2);
  overflow: hidden;
}
article.post .prose .lean-proof-block > pre.proof-code {
  border: none;
  margin: 0;
  background: transparent;
  padding: 0.9rem 1rem;
}
article.post .prose .lean-proof-block .proof-state {
  border: none;
  border-top: 1px dashed var(--rule);
  background: transparent;
  box-shadow: inset 3px 0 0 var(--accent);
}
article.post .prose .lean-proof-block .proof-state-header,
article.post .prose .lean-proof-block .proof-hypotheses,
article.post .prose .lean-proof-block .proof-case-header,
article.post .prose .lean-proof-block .proof-goal {
  padding-left: 1rem;
  padding-right: 1rem;
}
article.post .prose .lean-proof-block .proof-state-header { border-top: none; }
article.post .prose .lean-proof-block .proof-hyp:nth-child(even) {
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
}
article.post .prose .lean-proof-block .proof-state code {
  background: transparent;
  padding: 0;
}

/* Series prev/next */
.series-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 2.5rem 0 1.5rem;
  font-size: 0.95rem;
}
.series-nav a {
  text-decoration: none;
  display: block;
  font-family: var(--serif);
  line-height: 1.3;
  color: var(--accent);
}
.series-nav a:hover { color: var(--accent-hover); }
.series-nav a.next { text-align: right; }
.series-nav a:only-child.next { grid-column: 2; }
.series-nav a:only-child.prev { grid-column: 1; }
.series-nav .label {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  color: var(--mute);
  margin-bottom: 2px;
}
.series-nav a:hover .label { color: var(--accent-hover); }

/* Footnotes */
article.post .footnotes {
  border-top: 1px solid var(--rule);
  margin-top: 2rem;
  padding-top: 1.25rem;
  font-family: var(--serif);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-2);
}
article.post .footnotes hr { display: none; }
article.post .footnotes::before {
  content: "Notes";
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: 0.95rem;
  color: var(--mute);
  margin-bottom: 0.5rem;
}
article.post .footnotes ol { padding-left: 1.25rem; }
article.post sup.footnote-ref a {
  font-size: 0.78em;
  color: var(--accent);
  text-decoration: none;
}

/* Post footer */
footer.post-foot {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--mute);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
footer.post-foot a { color: var(--mute); }
footer.post-foot a:hover { color: var(--accent); }

/* ============================================================
   PLAIN PAGES (About, Tags, Tag-list)
   ============================================================ */
main.plain {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
}
main.plain h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}
main.plain h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.3rem;
  margin: 1.8rem 0 0.6rem;
}
main.plain p, main.plain li {
  font-size: 1.05rem;
  line-height: 1.55;
}

/* ============================================================
   COLUMNS PAGES (Blog, Blogroll) — single centered column
   ============================================================ */
main.columns {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2rem;
}
main.columns h1 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.9rem;
  line-height: 1.2;
  margin: 0 0 0.75rem;
}
main.columns h2 {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1.3rem;
  margin: 1.8rem 0 0.6rem;
}
main.columns p { font-size: 1.05rem; line-height: 1.55; }

/* Series listing on /blog */
.series-list {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
}
.series-list > li { margin-bottom: 1rem; }
.series-list > li > strong {
  font-family: var(--serif);
  font-size: 1.05rem;
  color: var(--ink);
  display: block;
  margin-bottom: 0.2rem;
}
.series-list ul {
  list-style: disc;
  padding-left: 1.4rem;
  margin: 0.1rem 0;
  font-size: 0.98rem;
}
.series-list ul li { margin: 0.1rem 0; }
.series-list a { text-decoration: none; color: var(--accent); }
.series-list a:hover { color: var(--accent-hover); }

/* Generic post-list (blog index, blogroll) */
.post-list,
.blogroll-posts {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}
.post-list li,
.blogroll-posts li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--rule);
  line-height: 1.35;
}
.post-list li:first-child,
.blogroll-posts li:first-child { border-top: 1px solid var(--rule); }
.post-list a,
.blogroll-posts a {
  font-family: var(--serif);
  font-size: 1.05rem;
  text-decoration: none;
}
.post-list a:hover,
.blogroll-posts a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
.post-date, .blogroll-meta {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--mute);
  margin-left: 0.4em;
}
.post-subtitle {
  display: block;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--mute);
  margin-top: 2px;
}

/* Tags page */
.tag-list ul { list-style: none; padding: 0; }
.tag-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.tag-list li:first-child { border-top: 1px solid var(--rule); }
.tag-list a { text-decoration: none; font-family: var(--serif); font-size: 1.05rem; }
.tag-list a:hover { color: var(--accent-hover); }
.tag-list .count {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--mute);
  margin-left: 0.4em;
}

/* ============================================================
   CALLOUTS
   ============================================================ */
.callout {
  padding: 0.9rem 1.1rem;
}
.callout > p:first-child { margin-top: 0; }
.callout > p:last-child  { margin-bottom: 0; }

/* Margin callouts default to inline-style. */
.callout-margin {
  position: static !important;
  right: auto !important;
  width: auto;
  margin: 1.25rem 0;
  padding: 0.5rem 0 0.5rem 1rem;
  border-left: 2px solid var(--tone-note);
  border-top: none;
  background: transparent;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-2);
  font-style: italic;
}
.callout-margin.callout-note    { border-left-color: var(--tone-note); }
.callout-margin.callout-info    { border-left-color: var(--tone-info); }
.callout-margin.callout-tip     { border-left-color: var(--tone-tip); }
.callout-margin.callout-warning { border-left-color: var(--tone-warning); }
.callout-margin.callout-danger  { border-left-color: var(--tone-danger); }

/* On wide screens, float margin callouts into the right gutter.
   Article column is 720px centered; at 1200+ viewport there's ~240px
   of whitespace per side, enough for a 200px callout. Breakpoint
   matches margin-callouts.js. */
@media (min-width: 1200px) {
  article.post .callout-margin {
    float: right;
    clear: right;
    width: 200px;
    margin: 0.3rem -220px 0.75rem 1rem;
    padding: 0.4rem 0 0.4rem 0;
    border-left: none;
    border-top: 2px solid var(--tone-note);
    background: transparent !important;
    font-style: normal;
    font-size: 0.88rem;
    line-height: 1.45;
  }
  article.post .callout-margin.callout-note    { border-top-color: var(--tone-note); }
  article.post .callout-margin.callout-info    { border-top-color: var(--tone-info); }
  article.post .callout-margin.callout-tip     { border-top-color: var(--tone-tip); }
  article.post .callout-margin.callout-warning { border-top-color: var(--tone-warning); }
  article.post .callout-margin.callout-danger  { border-top-color: var(--tone-danger); }

  article.post .callout-margin + * + .callout-margin { margin-top: 2.5rem; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  .site-head { gap: 0.3em; font-size: 0.95rem; }
  .bio .card {
    float: none;
    width: auto;
    max-width: 200px;
    margin: 0 0 1rem;
  }
  .series-nav { grid-template-columns: 1fr; }
  .series-nav a.next { text-align: left; }
}
