@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: italic; font-weight: 400; font-display: swap; src: url("/fonts/JetBrainsMono-Italic.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/JetBrainsMono-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: italic; font-weight: 600; font-display: swap; src: url("/fonts/JetBrainsMono-SemiBoldItalic.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/SourceSerif4-Regular.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400; font-display: swap; src: url("/fonts/SourceSerif4-It.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/SourceSerif4-Semibold.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 600; font-display: swap; src: url("/fonts/SourceSerif4-SemiboldIt.woff2") format("woff2"); }

:root {
  --bg: #E7F1FE;
  --fg: #000000;
  --accent: #AC8BDB;
  --accent-ink: #0F131B;
  --muted: rgba(0, 0, 0, 0.55);
  --line: rgba(0, 0, 0, 0.16);
  --card: rgba(255, 255, 255, 0.38);
  --card-hover: rgba(255, 255, 255, 0.7);
  --code-bg: rgba(0, 0, 0, 0.05);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-text: "Source Serif 4", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --size-text: 17.5px;
  --leading-text: 1.6;
  --align: justify;
  --w-index: 48rem;
  --w-post: 48rem;
  --toc-w: 12rem;
  --toc-gap: 3rem;
  --radius: 4px;
  --card-h: 120px;
  --card-gap: 7px;
  --card-inset: 0px;
  --card-radius: 0px;
  --card-pad: 15px;
  --card-title: 23.5px;
  --card-sub: 15.5px;
  --card-lines: 3;
  --card-focus: 50%;
  --fade-h: 106px;
  --fade-solid: 53px;
  --fade-blur: 4.5px;
  --fade-tint: 54%;
}

html[data-theme="dark"] {
  --bg: #0F131B;
  --fg: #D4D4D4;
  --accent: #FFFB53;
  --accent-ink: #0F131B;
  --muted: rgba(212, 212, 212, 0.58);
  --line: rgba(212, 212, 212, 0.14);
  --card: rgba(255, 255, 255, 0.018);
  --card-hover: rgba(255, 255, 255, 0.045);
  --code-bg: rgba(255, 255, 255, 0.06);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.75;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .2s ease, color .2s ease;
}
::selection { background: var(--accent); color: var(--accent-ink); }

a { color: inherit; }
img { max-width: 100%; height: auto; display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

.page {
  max-width: var(--w-post);
  margin: 0 auto;
  padding: 7rem 1.25rem 4rem;   /* leaves room for the floating header */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page--wide { max-width: var(--w-index); }
main { flex: 1; }

/* ---------- header ---------- */
/* brand and toggle float at the viewport edges; the page scrolls underneath */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  padding: 1.5rem;               /* with the 20px row below: 68px, the header height of ferris.uldagon.com */
  pointer-events: none;          /* the bar itself is transparent and lets clicks through… */
}
.site-header-inner > * { pointer-events: auto; }   /* …only brand and toggle are interactive */
/* where the text can run into the brand, it blurs and fades out behind a band
   of frosted glass that eases out below the header */
.site-header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--fade-h);
  z-index: -1;
  /* eased (smoothstep) instead of linear, so neither end of the fade shows an edge */
  --fade-mask: linear-gradient(to bottom,
    #000 var(--fade-solid),
    rgba(0, 0, 0, .957) calc(var(--fade-solid) + (100% - var(--fade-solid)) * .125),
    rgba(0, 0, 0, .844) calc(var(--fade-solid) + (100% - var(--fade-solid)) * .25),
    rgba(0, 0, 0, .684) calc(var(--fade-solid) + (100% - var(--fade-solid)) * .375),
    rgba(0, 0, 0, .5) calc(var(--fade-solid) + (100% - var(--fade-solid)) * .5),
    rgba(0, 0, 0, .316) calc(var(--fade-solid) + (100% - var(--fade-solid)) * .625),
    rgba(0, 0, 0, .156) calc(var(--fade-solid) + (100% - var(--fade-solid)) * .75),
    rgba(0, 0, 0, .043) calc(var(--fade-solid) + (100% - var(--fade-solid)) * .875),
    transparent 100%);
  background: color-mix(in srgb, var(--bg) var(--fade-tint), transparent);
  -webkit-backdrop-filter: blur(var(--fade-blur));
  backdrop-filter: blur(var(--fade-blur));
  -webkit-mask-image: var(--fade-mask);
  mask-image: var(--fade-mask);
}
/* Wider screens need the band only while the text column comes closer than 6px to the brand:
   site.js measures that (the theme sets widths and fonts) and sets data-fade. */
@media (min-width: 681px) { html:not([data-fade]) .site-header::before { display: none; } }
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  height: 20px;
  margin: 0 auto;
}
.brand {
  font-size: 1.35em;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand:hover .dot { color: var(--fg); }
.dot { color: var(--accent); }

.nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }
/* same underline as links in the text, and as on uldagon.com and ferris.uldagon.com */
.nav a, .site-footer a {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
/* hovered links are a filled accent block, as on uldagon.com and ferris.uldagon.com */
.nav a:hover, .site-footer a:hover { background: var(--accent); color: var(--accent-ink); }

/* pill switch (dark / light) */
.theme-toggle {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  border: 1.5px solid var(--fg);
  flex: none;
  transition: border-color .15s ease;
}
.theme-toggle .knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--fg);
  transition: transform .2s ease, background-color .2s ease;
}
html[data-theme="dark"] .theme-toggle .knob { transform: translateX(16px); }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:hover .knob { background: var(--accent); }

/* ---------- index ---------- */
.hero { margin-bottom: 2.5rem; }
.hero h1 {
  font-size: 2.4em;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
  margin: 0 0 .75rem;
}
.tagline {
  color: var(--muted);
  max-width: 40rem;
  margin: 0;
  text-align: var(--align);
  hyphens: auto;
}

/* one card per row: square cover on the left, text on the right */
.list {
  /* side length of the square cover; the card is this plus the inset on both sides */
  --cover: calc(var(--card-h) - 2 * var(--card-inset));
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}
@media (max-width: 680px) { .list { --cover: min(calc(var(--card-h) - 2 * var(--card-inset)), 30vw); } }

.card {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  background: var(--card);
  text-decoration: none;
  overflow: hidden;
  transition: border-color .15s ease, background-color .15s ease;
}
.card:hover { border-color: var(--accent); background: var(--card-hover); }
.card-cover {
  position: relative;
  flex: none;
  width: var(--cover);
  min-height: var(--cover);
  margin: var(--card-inset);
  /* flush covers are clipped by the card; inset ones get their own corners */
  border-radius: min(var(--card-radius), calc(var(--card-inset) * 999));
  overflow: hidden;
  background: var(--code-bg);
}
.card-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--card-focus) 50%;
  transition: transform .4s ease;
}
.card:hover .card-cover img { transform: scale(1.03); }
.card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: var(--card-pad);
}
.card-date {
  order: 1;               /* sits below the title and summary */
  font-size: .8em;
  color: var(--muted);
  letter-spacing: .02em;
}
.card-title {
  font-family: var(--font-text);
  font-size: var(--card-title);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -.01em;
  margin: 0;
}
.card:hover .card-title { color: var(--accent); }
.card-sub {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-text);
  font-size: var(--card-sub);
  line-height: 1.5;
  text-align: var(--align);
  hyphens: auto;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--card-lines);
  line-clamp: var(--card-lines);
  overflow: hidden;
}

/* ---------- post ---------- */
.post { position: relative; }
.post-header { margin-bottom: 2rem; }
.post-header h1 {
  font-family: var(--font-text);
  font-size: 2.6em;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.15;
  margin: 0 0 .75rem;
}
.post-sub {
  margin: 0 0 1rem;
  font-family: var(--font-text);
  font-size: 1.25em;
  color: var(--muted);
  text-align: var(--align);
  hyphens: auto;
}
.meta { margin: 0; font-size: .85em; color: var(--muted); }
.sep { margin: 0 .5em; opacity: .6; }

.cover { margin: 0 0 2.25rem; }
.cover img { width: 100%; border-radius: var(--radius); }

/* contents: sticky sidebar left of the column on wide screens, a plain list above the text otherwise */
.toc { font-size: .82em; margin: 0 0 2.5rem; }
.toc-title { display: block; color: var(--muted); margin-bottom: .4rem; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: .3rem 0; line-height: 1.45; }
.toc li.lvl-3 { padding-left: 1rem; }
.toc a { text-decoration: none; color: var(--muted); transition: color .15s ease; }
.toc a:hover, .toc a.is-active { color: var(--accent); }
/* pinned to the left edge of the screen once there is room beside the column */
@media (min-width: 1200px) {
  .toc {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    left: 1.5rem;
    width: var(--toc-w);
    margin: 0;
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
  }
}

.prose {
  font-family: var(--font-text);
  font-size: var(--size-text);
  line-height: var(--leading-text);
  text-align: var(--align);
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}
.prose > * + * { margin-top: 1.25em; }
.prose p { margin: 0; }
.prose p + p { margin-top: 1.25em; }
.prose h2, .prose h3 {
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.25;
  text-align: left;
  hyphens: none;
  margin-top: 2.5em;
  margin-bottom: 0;
}
.prose h2 + *, .prose h3 + * { margin-top: .85em; }
.prose h2 { font-size: 1.45em; }
.prose h3 { font-size: 1.15em; }

.prose a {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.prose a:hover { background: var(--accent); color: var(--accent-ink); }
.prose em { font-style: italic; }
.prose strong { font-weight: 600; }
.prose blockquote {
  margin: 1.5em 0;
  padding: .25em 0 .25em 1.25em;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}
.prose blockquote p + p { margin-top: 1em; }
.prose ul, .prose ol { padding-left: 1.5em; }
.prose li + li { margin-top: .35em; }
.prose img { border-radius: var(--radius); margin: 1.5em auto; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose code {
  font-family: var(--mono);
  font-size: .9em;
  background: var(--code-bg);
  padding: .1em .35em;
  border-radius: 3px;
}
.prose pre {
  font-family: var(--mono);
  background: var(--code-bg);
  padding: 1em 1.25em;
  border-radius: var(--radius);
  overflow-x: auto;
  text-align: left;
  hyphens: none;
  line-height: 1.55;
}
.prose pre code { background: none; padding: 0; font-size: .88em; }
.prose figure { margin: 1.5em 0; }
.prose figcaption { color: var(--muted); font-size: .85em; text-align: center; margin-top: .5em; }
.prose table { border-collapse: collapse; width: 100%; font-size: .92em; text-align: left; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: .5em .6em; vertical-align: top; }

.post-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: .88em;
}
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.pager a { display: flex; flex-direction: column; gap: .2rem; text-decoration: none; }
.pager a:hover { color: var(--accent); }
.pager-next { text-align: right; align-items: flex-end; }
.pager-label { color: var(--muted); font-size: .85em; }
.pager-label::before { content: "← "; }
.pager-next .pager-label::before { content: ""; }
.pager-next .pager-label::after { content: " →"; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-size: .85em;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.footer-left { display: flex; flex-wrap: wrap; align-items: center; }
.site-footer a { color: var(--fg); }
.muted { color: var(--muted); }

@media (max-width: 680px) {
  .page { padding-top: 5.5rem; }
  .brand { font-size: 1.15em; }
  .hero h1 { font-size: 2em; }
  .post-header h1 { font-size: 1.7em; }
  .pager { grid-template-columns: 1fr; }
  .pager-next { text-align: left; align-items: flex-start; }
  .site-footer { flex-direction: column; align-items: flex-start; }
}
