/* Alternate layout: simple, modern, no JavaScript, no web fonts, no inline styles (the CSP forbids them).
   One accent colour. Light and dark themes follow the visitor's system setting. */
:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1c1c1e;
  --muted: #6b6b70;
  --line: #e4e4e7;
  --accent: #0b6bcb;
  --accent-soft: #e8f1fc;
  --code-bg: #f3f3f5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .04);
  --measure: 46rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --surface: #1b1b1f;
    --text: #ececef;
    --muted: #a0a0a8;
    --line: #2c2c31;
    --accent: #6cb0ff;
    --accent-soft: #1d2a3a;
    --code-bg: #232328;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 1.0625rem/1.65 var(--font);
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible, .btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; height: auto; border-radius: 8px; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.6em 0 .5em; letter-spacing: -.01em; }
.wrap { width: min(100% - 2.5rem, 70rem); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 0; background: var(--accent); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

/* Header: brand on the left, menu on the right. Wraps on small screens. */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .25rem 1.5rem; padding-block: .75rem; }
.brand { display: flex; flex-direction: column; color: var(--text); line-height: 1.2; }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.brand-tag { font-size: .8125rem; color: var(--muted); }
.menu ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem; }
.menu a { display: block; padding: .45rem .75rem; border-radius: 8px; color: var(--text); font-size: .9375rem; font-weight: 500; }
.menu a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
.menu a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.has-sub { position: relative; }
.has-sub > a::after { content: ""; display: inline-block; margin-left: .4rem; vertical-align: .15em; border: 4px solid transparent; border-top-color: currentColor; border-bottom: 0; opacity: .6; }
.menu .sub {
  display: none; position: absolute; top: 100%; left: 0; z-index: 60; min-width: 15rem;
  flex-direction: column; gap: 0; padding: .35rem; margin-top: .15rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow), 0 8px 24px rgba(0, 0, 0, .08);
}
.menu .has-sub:hover > .sub, .menu .has-sub:focus-within > .sub { display: flex; }

/* Main column */
/* Two columns: posts (wide) and a narrow sidebar of small cards. */
.layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 16rem; gap: 2.5rem; align-items: start; padding-block: 2.5rem 3rem; }
main { min-width: 0; }
.page-title { font-size: clamp(1.75rem, 4vw, 2.5rem); margin: 0 0 .35rem; }
.lead { font-size: 1.1875rem; color: var(--muted); max-width: var(--measure); margin: 0 0 2rem; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0 0 1rem; font-size: .875rem; color: var(--muted); }
.chip { display: inline-block; padding: .1rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .8125rem; font-weight: 500; }
.chip:hover { text-decoration: none; filter: brightness(.96); }

/* Home and archive: a grid of cards */
.cards { display: grid; gap: 1.25rem; }
.page-title + .cards { margin-top: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; }
.card-title { font-size: 1.25rem; margin: 0 0 .35rem; }
.card-title a { color: var(--text); }
.card-title a:hover { color: var(--accent); text-decoration: none; }
/* Cards show up to 36 rem of the story. The padding at the bottom holds the fade, so the fade never covers text that is not cut off. */
.card .prose { font-size: 1rem; flex: 1; max-height: 50rem; padding-bottom: 2.5rem; overflow: hidden; position: relative; }
.card .prose img { display: block; margin-bottom: .75rem; }
.card .prose::after { content: ""; position: absolute; inset: auto 0 0 0; height: 2.5rem; background: linear-gradient(to bottom, transparent, var(--surface)); pointer-events: none; }
.more { margin: 0; font-weight: 600; font-size: .9375rem; }

/* Post and page body */
.post { max-width: var(--measure); }
.post-head { margin-bottom: 1.25rem; }
.prose { overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose p { margin: 0 0 1.1em; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: .25em 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }
.prose blockquote { margin: 1.2em 0; padding: .1em 1.1em; border-left: 3px solid var(--line); color: var(--muted); }
.prose pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; overflow-x: auto; font: .875rem/1.5 var(--mono); }
.prose code { font-family: var(--mono); font-size: .9em; background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
.prose pre code { background: none; padding: 0; font-size: inherit; }
.prose figure { margin: 1.5rem 0; }
.prose figcaption { color: var(--muted); font-size: .875rem; }
.prose iframe { max-width: 100%; border: 0; border-radius: 8px; aspect-ratio: 16 / 9; height: auto; width: 100%; }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: .4rem .7rem; text-align: left; }
.tags { display: flex; flex-wrap: wrap; gap: .4rem; margin: 2rem 0 0; }
.tag { padding: .1rem .6rem; border: 1px solid var(--line); border-radius: 999px; font-size: .8125rem; color: var(--muted); }
.tag::before { content: "#"; opacity: .6; }

/* Previous and next */
.neighbours { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: var(--measure); margin-top: 2.5rem; }
.neighbour { display: flex; flex-direction: column; padding: .9rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); min-width: 0; }
.neighbour:hover { border-color: var(--accent); text-decoration: none; }
.neighbour.right { text-align: right; grid-column: 2; }
.neighbour .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.neighbour .title { font-weight: 600; overflow-wrap: anywhere; }

/* Lists of child pages */
.tiles { list-style: none; margin: 1.5rem 0 0; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); }
.tiles a { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.2rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.tiles a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* Buttons and pager */
.btn { display: inline-block; padding: .55rem 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-weight: 600; font-size: .9375rem; }
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 2rem; }
.pager-count { color: var(--muted); font-size: .875rem; }

/* 404 */
.notfound { text-align: center; margin-inline: auto; padding-block: 2rem; }
.notfound .lead { margin-inline: auto; }
.code404 { font-size: clamp(4rem, 15vw, 7rem); font-weight: 800; line-height: 1; margin: 0; color: var(--accent); opacity: .85; }

/* Sidebar: small cards that match the post cards */
.sidebar { display: grid; gap: 1rem; font-size: .9375rem; }
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); }
.side-card h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 .5rem; }
.side-card ul { list-style: none; margin: 0; padding: 0; }
.side-card li { margin: .3rem 0; }
.side-card li ul { padding-left: .9rem; }
.side-card .count { color: var(--muted); font-size: .8125rem; margin-left: .25rem; }

/* Footer: just the copyright */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding-block: 1.25rem; }
.copyright { margin: 0; color: var(--muted); font-size: .8125rem; }

/* Small screens */
@media (max-width: 40rem) {
  .bar { flex-direction: column; align-items: flex-start; }
  .menu > ul { flex-direction: column; gap: 0; }
  .has-sub { position: static; }
  .has-sub > a::after { display: none; }
  .menu .sub { display: flex; position: static; box-shadow: none; border: 0; padding: 0 0 0 .75rem; margin: 0; min-width: 0; background: none; }
  .neighbours { grid-template-columns: 1fr; }
  .neighbour.right { grid-column: auto; text-align: left; }
  .site-header { position: static; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1.5rem; }
}
@media print {
  .site-header, .site-footer, .sidebar, .neighbours, .pager { display: none; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
}
@media (prefers-reduced-motion: no-preference) {
  .card, .tiles a, .neighbour, .btn, .menu a { transition: border-color .15s, background-color .15s, color .15s; }
}

