/* ==========================================================================
   donw.io — "Quiet heavy" theme
   Ported from the October 2026 templates: root (less-noise archive),
   post (date only, related reading) and about (CV).
   ========================================================================== */

:root {
  /* palette */
  --canvas: #15171b;
  --paper: #073f75;
  --paper-raised: color-mix(in srgb, var(--paper) 92%, white 8%);
  --ink: #f4fbff;
  --muted: #bfdcf2;
  --line: #7aa5c8;
  --mast-line: #86a8c6;
  --accent: #9cf4f5;
  --hero-bg: #c0f6ff;
  --hero-ink: #063c72;
  --code-bg: #072c50;
  --code-edge: #709fc1;
  --inline-code-bg: #052d54;
  --shadow: 0 20px 60px #0004;

  /* labels */
  --label-size: 12px;
  --label-weight: 950;
  --label-track: .01em;

  /* cards (open layout) */
  --grid-gap: 24px;
  --card-pad: 18px;
  --card-radius: 2px;
  --title-size: 22px;
  --hero-size: 56px;
  --meta-size: 10px;
  --summary-size: 13.5px;
  --first-min: 344px;

  /* article (compact type) */
  --body-size: 14px;
  --body-leading: 1.55;
  --title-max: 38px;
  --section-size: 20px;
  --code-size: 11px;

  --font: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --display: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: Consolas, Menlo, Monaco, "Courier New", monospace;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; }
body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img, svg, video { max-width: 100%; height: auto; }

.site {
  position: relative;
  max-width: 1180px;
  margin: 28px auto 65px;
  padding: 50px clamp(22px, 5.8vw, 70px) 72px; /* same masthead position on every page */
  background: var(--paper);
  background-image:
    linear-gradient(#ffffff0e 1px, transparent 1px),
    linear-gradient(90deg, #ffffff0e 1px, transparent 1px);
  background-size: 26px 26px;
  box-shadow: var(--shadow);
}
.site-page { padding-bottom: 76px; }

/* --------------------------------------------------------------------------
   Masthead (identical on every page)
   -------------------------------------------------------------------------- */
.mast {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--mast-line);
}
.mast .logo {
  font-family: var(--display);
  font-size: 50px;
  letter-spacing: .025em;
  line-height: .95;
  font-weight: 900;
  margin: 0;
  text-decoration: none;
  color: #f7ffff;
}
.mast-right {
  text-align: right;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.55;
  font-weight: 700;
  color: var(--muted);
}
.mast-right strong {
  display: block;
  color: var(--accent);
  font-size: 14px;
  letter-spacing: -.01em;
  font-weight: 700;
}
.mast .toplinks {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px 20px;
  margin: 6px 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  color: #cbe3f6;
}
.mast .toplinks a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.mast .toplinks a:hover { color: #fff; }
.mast .toplinks svg { width: 14px; height: 14px; fill: currentColor; flex: none; }

/* --------------------------------------------------------------------------
   Home: short author note, then the magazine grid
   -------------------------------------------------------------------------- */
.content { padding-top: 24px; }

.mag-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--grid-gap);
}
.post {
  position: relative;
  border: 1px solid var(--line);
  padding: var(--card-pad);
  margin: 0;
  border-radius: var(--card-radius);
  background: var(--paper-raised);
  min-width: 0;
}
.post .meta {
  font-size: var(--meta-size);
  line-height: 1.5;
  letter-spacing: var(--label-track);
  font-weight: var(--label-weight);
  color: var(--muted);
}
.post h2 {
  font-size: var(--title-size);
  line-height: 1.08;
  letter-spacing: -.04em;
  margin: 10px 0 10px;
  font-weight: 900;
}
.post h2 a { text-decoration: none; }
.post a:hover { color: var(--accent); }
.post p { margin: 0; color: var(--muted); font-size: var(--summary-size); line-height: 1.58; }

.thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 0 12px;
  height: 84px;
  border: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
  background: rgba(255, 255, 255, .03);
  border-radius: 2px;
  overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* The first card is the cover feature: double width, double height, light paper. */
.mag-grid .post:first-child {
  grid-column: span 2;
  grid-row: span 2;
  background: var(--hero-bg);
  color: var(--hero-ink);
  padding: calc(var(--card-pad) + 10px);
  min-height: var(--first-min);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.mag-grid .post:first-child .thumb {
  height: 148px;
  flex-shrink: 0;
  background: rgba(6, 60, 114, .04);
  border-color: rgba(6, 60, 114, .18);
}
.mag-grid .post:first-child .meta,
.mag-grid .post:first-child p { color: color-mix(in srgb, var(--hero-ink) 80%, white 20%); }
.mag-grid .post:first-child h2 {
  font-size: clamp(38px, 5vw, var(--hero-size));
  line-height: 1.02;
  max-width: 13ch;
  margin-top: 12px;
}
.mag-grid .post:first-child a:hover { color: var(--paper); }

/* Tag pages share the grid; the strip above it is the only label left. */
.issue-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  margin: 0 0 18px;
  font-size: var(--label-size);
  letter-spacing: var(--label-track);
  font-weight: var(--label-weight);
}
.term-list { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.term-list li { border: 1px solid var(--line); padding: 10px 14px; display: flex; justify-content: space-between; font-weight: 800; font-size: 13px; }
.term-list a { text-decoration: none; }
.term-list .count { color: var(--accent); }

/* --------------------------------------------------------------------------
   Article
   -------------------------------------------------------------------------- */
.article-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 178px;
  gap: 36px;
  align-items: start;
  margin: 26px 0;
}
.article-head h1 {
  font-family: var(--display);
  font-size: clamp(32px, 5vw, var(--title-max));
  line-height: 1.04;
  letter-spacing: .015em;
  max-width: 770px;
  margin: 0;
  font-weight: 900;
}
.meta-panel {
  position: relative;
  align-self: start;
  padding: 5px 0 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-start;
  text-align: right;
  gap: 6px;
}
.meta-panel b { font-size: 12px; }

.rule { height: 0; margin: 0; }

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 710px) minmax(0, 1fr);
  gap: 44px;
}

/* Prose ------------------------------------------------------------------ */
.prose {
  display: flow-root;
  min-width: 0;
  font-size: var(--body-size);
  line-height: var(--body-leading);
  color: #e3eff9;
  overflow-wrap: break-word;
  counter-reset: section -1; /* the "Article" intro heading is 00 */
}
.prose p { margin: 0 0 23px; }
.prose strong { color: white; }
.prose a { color: #aaf6ff; }
.prose a:hover { color: var(--ink); }
.prose hr { border: 0; border-top: 1px solid #6b95b8; margin: 35px 0; }

.prose h2, .prose h3, .prose h4, .prose h5 {
  line-height: 1.19;
  letter-spacing: -.035em;
  color: #fff;
  scroll-margin-top: 32px;
  font-weight: 900;
}
.prose h2 { font-size: var(--section-size); }
.prose h3 { font-size: calc(var(--section-size) * .88); }
.prose h4, .prose h5 { font-size: calc(var(--section-size) * .8); }

/* Primary sections: numbered marker, hard rule above, soft wash behind. */
.prose h2 {
  counter-increment: section;
  display: flex;
  align-items: baseline;
  gap: 15px;
  position: relative;
  margin: 62px 0 19px;
  padding: 10px 18px 10px 0;
  border-top: 3px solid #b9fbff;
  border-bottom: 1px solid #548cb7;
  background: linear-gradient(90deg, rgba(147, 235, 255, .13), rgba(147, 235, 255, .018) 75%, transparent);
  letter-spacing: -.04em;
  text-wrap: balance;
}
.prose > h2:first-child { margin-top: 0; }
.prose h2::before {
  content: counter(section, decimal-leading-zero);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  align-self: center;
  font-size: 11px;
  letter-spacing: 0;
  font-weight: 950;
  min-width: 34px;
  height: 26px;
  color: var(--paper);
  background: #baf8ff;
  margin-left: 12px;
}
.prose h3 {
  margin: 39px 0 19px;
  padding: 8px 0 8px 15px;
  border-left: 4px solid var(--accent);
  background: linear-gradient(90deg, rgba(156, 244, 245, .10), transparent 70%);
}
.prose h4, .prose h5 {
  margin: 32px 0 15px;
  padding-bottom: 6px;
  border-bottom: 1px solid #6a9bbe;
  color: #c5f7ff;
}
.prose :is(h2, h3, h4, h5) + p { margin-top: 0; }

.prose blockquote {
  margin: 29px 0;
  padding: 12px 0 12px 20px;
  border-left: 4px solid var(--accent);
  font-size: calc(var(--body-size) * 1.15);
  font-weight: 750;
}
.prose ul, .prose ol { margin: 6px 0 25px; padding-left: 25px; }
.prose li { margin: 8px 0; }

.prose table { border-collapse: collapse; margin: 0 0 25px; font-size: .95em; }
.prose th, .prose td { border: 1px solid var(--code-edge); padding: 6px 10px; text-align: left; }
.prose th { background: var(--inline-code-bg); }

/* Images, figures and the legacy <center> blocks the posts use for captions */
.prose img { display: inline-block; max-width: 100%; height: auto; object-fit: contain; }
.prose p:has(> img), .prose center { margin: 25px auto; text-align: center; }
.prose center { display: block; max-width: 100%; }
.prose center img { max-height: 490px; }
.prose center p { margin: 0 0 8px; }
.prose center em { color: var(--muted); }
.prose figure { margin: 0; }

.prose iframe { display: block; max-width: 100%; margin: 0 auto; border: 1px solid #739bb9; }
.prose center iframe { display: inline-block; }
.prose .embedded-media { width: 100%; max-width: 640px; margin: 0 auto; aspect-ratio: 16 / 9; }
.prose .embedded-media iframe { display: block; width: 100%; height: 100%; }

/* Code */
.prose pre {
  margin: 26px 0 31px;
  padding: 17px 20px;
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--code-edge);
  background: var(--code-bg);
  line-height: 1.57;
  font-size: var(--code-size);
  font-family: var(--mono);
  color: #def0fb;
  tab-size: 4;
}
.prose code { font-family: var(--mono); }
.prose :not(pre) > code { font-size: .9em; background: var(--inline-code-bg); padding: 2px 4px; }

/* Math (KaTeX auto-render output) */
.prose .katex-display { margin: 12px 0 24px; overflow-x: auto; overflow-y: hidden; }

/* Sidebar: contents, then related reading ---------------------------------- */
.side { padding-top: 4px; min-width: 0; }
.side .group { border-top: 2px solid var(--accent); padding-top: 12px; }
.side h3 { font-size: 12px; margin: 0 0 15px; }
.side nav ul { list-style: none; margin: 0; padding: 0; }
.side nav ul ul { padding-left: 14px; }
.side .group > a, .side nav a {
  display: block;
  font-size: 11px;
  line-height: 1.5;
  font-weight: 800;
  text-decoration: none;
  color: #b9d9ef;
  padding: 6px 7px 6px 14px; /* template has 10px; tightened at Don's request */
  border-bottom: 1px solid #ffffff29;
  border-left: 2px solid transparent;
}
.side .group > a:hover, .side nav a:hover { color: white; border-left-color: var(--accent); background: #ffffff10; }

/* Related reading: compact magazine rhythm, no new visual language. */
.discovery { margin-top: 34px; border-top: 2px solid var(--accent); padding-top: 13px; }
.discovery h3 { font-size: 12px; font-weight: 900; letter-spacing: .015em; margin: 0 0 13px; color: #fff; }
.discovery-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.discovery-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 10px 10px 11px;
  border: 1px solid #719cc0;
  text-decoration: none;
  color: #f4ffff;
  background: rgba(255, 255, 255, .025);
  transition: background .15s, border-color .15s;
}
.discovery-card:hover { background: rgba(255, 255, 255, .09); border-color: #b5eaf4; }
.discovery-card .rec-thumb {
  width: 100%;
  height: 58px;
  object-fit: cover;
  object-position: center;
  display: block;
  margin-bottom: 9px;
  border: 1px solid #729ec1;
}
.discovery-card .rec-eyebrow { font-size: 9px; letter-spacing: .01em; font-weight: 800; color: #aed1e8; margin-bottom: 7px; }
.discovery-card .rec-title { font-size: 12px; line-height: 1.22; letter-spacing: -.01em; font-weight: 900; color: #f6ffff; }
.discovery-card:nth-child(3n + 1) { grid-column: span 2; } /* wide, pair, wide, pair */
.discovery-card:nth-child(1) .rec-thumb { height: 88px; }
.discovery-card:nth-child(1) .rec-title { font-size: 16px; line-height: 1.17; }
.side .discovery-all { display: block; margin-top: 12px; font-size: 11px; font-weight: 800; color: #c6eaff; text-decoration: none; padding: 5px 0; }
.side .discovery-all:hover { text-decoration: underline; }

@media (min-width: 781px) {
  .side {
    position: sticky;
    top: 18px;
    align-self: start;
    max-height: calc(100vh - 36px);
    overflow-y: auto;
    scrollbar-width: thin;
    padding-right: 3px;
  }
}

/* Bottom navigation ------------------------------------------------------ */
.bottom-nav {
  margin: 50px 0 0;
  border-top: 1px solid #90b2ce;
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  font-size: 12px;
  font-weight: 800;
}
.bottom-nav a { color: #e8ffff; text-decoration: none; }
.bottom-nav a:hover { color: var(--accent); }

/* Comments (GitHub issues, rendered client-side) -------------------------- */
.comments { margin-top: 44px; border-top: 1px solid var(--line); padding-top: 18px; }
.comments-title { font-size: var(--label-size); letter-spacing: var(--label-track); font-weight: var(--label-weight); text-transform: uppercase; color: var(--accent); margin: 0 0 14px; }
/* utterances renders into an iframe wrapped in .utterances; align it with the prose column */
.comments .utterances { max-width: none; margin: 0; }
.comments noscript p { font-size: 13px; color: var(--muted); }
.comments noscript a { color: #aaf6ff; }

/* --------------------------------------------------------------------------
   About / CV
   -------------------------------------------------------------------------- */
.about .intro {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  flex-wrap: wrap;
  padding: 35px 0 24px;
}
.about h1 {
  font-family: var(--display);
  font-size: 38px;
  line-height: 1.1;
  font-weight: 900;
  letter-spacing: .015em;
  margin: 0 0 6px;
}
.about .role { font-size: 16px; color: #d9effe; margin: 8px 0; }
.about .intro-meta { font-size: 13px; color: #b6d9ed; margin-top: 7px; }
.about .expertise { font-size: 16px; line-height: 1.55; color: #e1f1fc; margin: 0 0 28px; }
.about .expertise p { margin: 0 0 16px; }
.about .index {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin: 0 0 26px;
  padding: 10px 0;
  border-top: 1px solid #608cb4;
  border-bottom: 1px solid #608cb4;
}
.about .index a { font-size: 12px; font-weight: 700; text-decoration: none; color: #c7e5fa; }
.about .index a:hover { color: #baffff; }
.about section { margin-top: 36px; scroll-margin-top: 28px; }
.about h2 { font-size: 20px; letter-spacing: 0; font-weight: 800; margin: 0 0 13px; }
.about .scroll { width: 100%; overflow-x: auto; }
.about table { width: 100%; border-collapse: collapse; text-align: left; font-size: 13px; line-height: 1.45; }
.about th {
  text-align: left;
  color: #a9d4ed;
  font-size: 12px;
  font-weight: 800;
  padding: 11px 12px 10px 0;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid #82aac5;
  white-space: nowrap;
}
.about td { vertical-align: top; padding: 11px 14px 11px 0; border-bottom: 1px solid #d7eaff25; color: #d9eaf8; }
.about td.project { font-weight: 800; color: #fff; }
.about td.org { width: 24%; font-weight: 700; color: #c7dff1; }
.about td.detail { width: 51%; line-height: 1.55; }
.about .overview td:nth-child(1) { width: 29%; }
.about .overview td:nth-child(2) { width: 25%; }
.about .overview td:nth-child(3) { width: 23%; }
.about .overview td:nth-child(4) { width: 23%; }
.about a:hover { color: #baffff; }
.about .footer { padding-top: 20px; margin-top: 42px; border-top: 1px solid var(--mast-line); color: #b7d8ec; font-size: 12px; }

/* 404 reuses the article head; give it the rule the post template dropped. */
.site:not(.site-page) .rule { height: 1px; background: #8bafcb; margin: 24px 0; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .mag-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mag-grid .post:first-child { grid-column: span 2; grid-row: span 1; min-height: 280px; }
}
@media (max-width: 780px) {
  .site { margin: 0; padding: 28px 22px 55px; box-shadow: none; }
  .mast { flex-wrap: wrap; }
  .mast .logo { font-size: 43px; }
  .mast-right { text-align: left; white-space: normal; }
  .mast .toplinks { justify-content: flex-start; margin-left: 0; gap: 11px; }
  .article-head { grid-template-columns: 1fr; gap: 15px; }
  .meta-panel { padding: 0; align-items: flex-end; text-align: right; }
  .article-head h1 { font-size: clamp(30px, 8vw, var(--title-max)); }
  .article-layout { grid-template-columns: 1fr; }
  .side { display: block; margin-top: 36px; }
  .discovery { margin-top: 24px; }
  .discovery-card:nth-child(3n + 1) { grid-column: span 1; }
}
@media (max-width: 700px) {
  .about .intro { padding-top: 30px; }
  .about table { min-width: 740px; }
  .about .detail-table { min-width: 920px; }
}
@media (max-width: 520px) {
  .mag-grid { grid-template-columns: 1fr; }
  .mag-grid .post:first-child { grid-column: span 1; }
  .mag-grid .post:first-child h2 { max-width: none; }
  .issue-strip { flex-direction: column; }
  .thumb { height: 72px; }
  .mag-grid .post:first-child .thumb { height: 112px; }
  .prose h2 { gap: 9px; padding: 9px 9px 9px 0; margin-top: 46px; }
  .prose h2::before { min-width: 28px; height: 23px; margin-left: 7px; font-size: 10px; }
  .discovery-card:nth-child(1) { grid-column: span 2; }
}
