/* site.css -- a readable default for a Pages site.

   This is deliberately plain: legible measure, honest hierarchy, dark mode,
   no framework. Treat it as the floor, not the ceiling. When the landing page
   needs a real identity, design it with the frontend-design skill and keep
   this file for the article pages. */

:root {
  --ink: #1c1c1c;
  --ink-soft: #4a4a4a;
  --ink-faint: #8a8a8a;
  --bg: #fbfaf7;
  --bg-soft: #f1efe9;
  --rule: #ddd9d0;
  --link: #24506e;
  --measure: 38rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6e3dd;
    --ink-soft: #b6b2aa;
    --ink-faint: #86827a;
    --bg: #16171a;
    --bg-soft: #1e2024;
    --rule: #33353a;
    --link: #8fbcdd;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1.25rem 4rem;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.0625rem/1.65 ui-serif, Georgia, "Times New Roman", serif;
  -webkit-text-size-adjust: 100%;
}

body > * { max-width: var(--measure); margin-inline: auto; }

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

h1, h2, h3, h4 {
  font-family: ui-sans-serif, system-ui, sans-serif;
  line-height: 1.25;
  margin: 2.25rem 0 0.75rem;
}
h1 { font-size: 1.9rem; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

p, ul, ol, blockquote, table, pre { margin: 0 0 1.1rem; }
li { margin: 0.25rem 0; }

blockquote {
  border-left: 3px solid var(--rule);
  margin-left: 0;
  padding-left: 1rem;
  color: var(--ink-soft);
}

code, pre, kbd { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 0.9em; }
code { background: var(--bg-soft); padding: 0.1em 0.3em; border-radius: 3px; }
pre {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
}
pre code { background: none; padding: 0; }

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

table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { border-bottom: 1px solid var(--rule); padding: 0.45rem 0.6rem; text-align: left; }
th { font-family: ui-sans-serif, system-ui, sans-serif; }

/* Wide content should scroll inside itself rather than the page. */
.table-wrap { overflow-x: auto; }

/* --- chrome ------------------------------------------------------------- */

.top-bar, .bottom-bar {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--ink-faint);
  padding: 1rem 0;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}
.top-bar { border-bottom: 1px solid var(--rule); margin-bottom: 1.5rem; }
.bottom-bar { border-top: 1px solid var(--rule); margin-top: 3rem; }
.back-link { text-decoration: none; }

/* --- home --------------------------------------------------------------- */

.site-header { padding: 3rem 0 1.5rem; border-bottom: 1px solid var(--rule); }
.site-title { margin: 0; font-size: 2.2rem; }
.site-tagline { color: var(--ink-soft); font-style: italic; margin: 0.4rem 0 0; }

.entry-list { list-style: none; padding: 0; margin: 2rem auto; }
.entry { padding: 1rem 0; border-bottom: 1px solid var(--rule); }
.entry-title {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  text-decoration: none;
}
.entry-date { display: block; font-size: 0.8rem; color: var(--ink-faint); margin-top: 0.2rem; }
.entry-abstract { color: var(--ink-soft); margin: 0.5rem 0 0; }

/* Card mode: the same container, a different item shape. */
.card-grid:has(.card) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.25rem;
  max-width: 62rem;
  list-style: none;
  padding: 0;
}
.home:has(.card) > * { max-width: 62rem; }

.card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1rem;
  transition: transform 120ms ease, border-color 120ms ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--ink-faint); }
.card-cover { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 3px; margin-bottom: 0.75rem; }
.card-category, .page-category {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.card-title { font-size: 1.05rem; margin: 0.3rem 0; }
.card-date { font-size: 0.8rem; color: var(--ink-faint); }
.card-abstract { font-size: 0.9rem; color: var(--ink-soft); margin: 0.5rem 0 0; }

/* --- article ------------------------------------------------------------ */

.page-header { margin-bottom: 2rem; }
.page-header h1 { margin-top: 0.3rem; }
.page-meta { font-size: 0.85rem; color: var(--ink-faint); margin: 0; }
.page-revised { margin-left: 0.75rem; }

/* --- figures ------------------------------------------------------------ */

/* Rendered diagrams are line art on whatever background the renderer chose.
   Give them room and never let a wide graph push the page sideways.

   A wide graph scaled to fit a narrow column becomes unreadable, so give the
   image a floor and let its own container scroll instead. The paragraph wraps
   the image because Markdown puts it there, which is why the rule targets the
   paragraph rather than a figure element. */
.page-body p:has(> img[src$=".svg"]) {
  overflow-x: auto;
  margin: 1.5rem 0;
}
.page-body img[src$=".svg"] {
  display: block;
  margin: 0 auto;
  min-width: 32rem;
  max-width: 100%;
}

figure { margin: 1.5rem 0; }
figcaption {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
  color: var(--ink-faint);
  text-align: center;
  margin-top: 0.4rem;
}

/* Dark mode and black-on-white line art. The durable fix is to render with a
   transparent background and mid-tone strokes that read on both themes; this
   inversion is the opt-in fallback for figures you cannot re-render, applied
   by writing <img class="diagram" ...> instead of plain Markdown syntax.
   Inverting a diagram that carries meaningful colour will lie about it. */
@media (prefers-color-scheme: dark) {
  .page-body img.diagram { filter: invert(0.92) hue-rotate(180deg); }
}
:root[data-theme="dark"] .page-body img.diagram { filter: invert(0.92) hue-rotate(180deg); }
:root[data-theme="light"] .page-body img.diagram { filter: none; }

/* --- table of contents -------------------------------------------------- */

.toc-state { position: absolute; opacity: 0; pointer-events: none; }
.toc-btn {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font: 600 0.8rem ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  z-index: 10;
}
.toc-panel {
  position: fixed;
  right: 1rem;
  bottom: 3.75rem;
  width: min(20rem, calc(100vw - 2rem));
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  display: none;
  z-index: 10;
}
.toc-state:checked ~ .toc-panel { display: block; }
.toc-header { display: flex; justify-content: space-between; font-family: ui-sans-serif, system-ui, sans-serif; font-size: 0.8rem; color: var(--ink-faint); }
.toc-close { cursor: pointer; }
.toc-list { list-style: none; padding: 0; margin: 0.5rem 0 0; font-size: 0.9rem; }

@media print {
  .top-bar, .bottom-bar, .toc-btn, .toc-panel { display: none; }
  body { color: #000; background: #fff; }
}

/* Build version, on the landing page and in every page footer. Deliberately
   quiet: it matters when you are checking which build you are reading, and
   should not compete with the prose the rest of the time. */
.site-version {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    color: var(--muted, #6b7280);
}
