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

@font-face {
  font-family: "JetBrainsMonoCustom";
  src: url("/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  size-adjust: 80%;
}

:root {
  --color-accent: #c24030;
  --color-header: #c8102e;
  --color-bg: #fffcfc;
  --color-text: #1a1a1a;
  --color-text-strong: #000;

  /* Gray scale (consolidated from 10 values) */
  --color-gray-600: #666;   /* muted text — merges #888, #666, #7a7a7a */
  --color-gray-500: #888;   /* placeholder/hint text only */
  --color-gray-400: #999;   /* borders, media placeholder */
  --color-gray-300: #aaa;   /* dashed separators */
  --color-gray-200: #bbb;   /* solid borders */
  --color-gray-100: #ccc;   /* pill borders */
  --color-gray-50:  #e8e8e8; /* progress track, lightest */

  /* Semantic */
  --color-code-bg: #faebd7;
  --color-embed-bg: #f6f0ec;
  --color-archived-bg: #fff1bf;
  --color-error: #b7140d;
  --color-error-text: #5b0000;

  /* Fonts */
  --font-body: Georgia, "Times New Roman", "Noto Serif", serif;
  --font-mono: "JetBrainsMonoCustom", monospace;

  /* Spacing scale (names the existing px values) */
  --space-1: 4px;
  --space-2: 6px;
  --space-3: 8px;
  --space-4: 10px;
  --space-5: 12px;
  --space-6: 24px;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1em;
  line-height: 1.5;
  background: var(--color-bg);
}

h1,h2,h3,h4,h5,h6 {
  margin-block: 0 0.2em;
  color: var(--color-text);
}

a {
  text-decoration: underline;
  text-decoration-color: transparent;
  color: var(--color-accent);
  transition: text-decoration-color 150ms ease, color 150ms ease;
}

a:hover { text-decoration-color: var(--color-accent); }

#TableOfContents {
  margin-bottom: var(--space-4);
}

#TableOfContents > ul {
  counter-reset: toc-l1;
  list-style: none;
  margin: 0;
  padding: 0;
}

#TableOfContents > ul > li {
  counter-increment: toc-l1;
  counter-reset: toc-l2;
}

#TableOfContents > ul > li > ul {
  list-style: none;
  margin: 0;
  padding: 0;
  padding-left: 1.4em;
}

#TableOfContents > ul > li > ul > li {
  counter-increment: toc-l2;
  counter-reset: toc-l3;
}

#TableOfContents > ul > li > ul > li > ul {
  list-style: none;
  margin: 0;
  padding: 0;
  padding-left: 1.4em;
}

#TableOfContents > ul > li > ul > li > ul > li {
  counter-increment: toc-l3;
}

#TableOfContents li {
  margin: 0;
  padding: 0.1em 0;
}

#TableOfContents > ul > li > a::before {
  content: counter(toc-l1) ". ";
}

#TableOfContents > ul > li > ul > li > a::before {
  content: counter(toc-l1) "." counter(toc-l2) " ";
}

#TableOfContents > ul > li > ul > li > ul > li > a::before {
  content: counter(toc-l1) "." counter(toc-l2) "." counter(toc-l3) " ";
}

#TableOfContents a {
  color: var(--color-text-strong);
  background-image: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  text-decoration: none;
  font-family: var(--font-mono);
}

#TableOfContents a:hover {
  text-decoration: underline;
  text-decoration-color: var(--color-text-strong);
}

.article-banner-stack {
  --banner-warning-bg: #fbe64d;
  --banner-warning-fg: #1f1a05;
  --banner-danger-bg: #000000;
  --banner-danger-fg: #ffffff;
  position: relative;
  z-index: 11;
  margin: calc(-1 * var(--article-shell-pad-top, 0px)) 0 var(--space-4);
}

.article-banner {
  position: relative;
  isolation: isolate;
  margin: 0;
  padding: 0.35rem 0;
  font-size: 0.95em;
  font-weight: 400;
  line-height: 1.2;
  box-shadow: 0 0 0 100vmax var(--banner-row-bg, transparent);
  clip-path: inset(0 -100vmax);
}

.article-banner--warning {
  --banner-row-bg: var(--banner-warning-bg);
  background: var(--banner-warning-bg);
  color: var(--banner-warning-fg);
}

.article-banner--danger {
  --banner-row-bg: var(--banner-danger-bg);
  background: var(--banner-danger-bg);
  color: var(--banner-danger-fg);
}

.article-header {
  --header-bg: var(--color-bg);
  --article-title-size: 1.7em;
  --article-title-line: 1.12;
  position: sticky;
  top: 0;
  z-index: 10;
  margin-bottom: var(--space-1);
  padding-top: 0.35em;
  transform: translateZ(0);
  color: var(--color-bg);
}

.article-header::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--article-shell-pad-top, 1em));
  left: -50vw;
  right: -50vw;
  bottom: -4px;
  background: var(--color-header);
  z-index: -1;
}

.article-header::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -50vw;
  right: -50vw;
  height: 1px;
  background: var(--color-header);
  pointer-events: none;
}

.article-header a {
  color: var(--color-bg);
}

.article-header-main {
  position: relative;
  padding-bottom: 0.15em;
}

.article-title-row {
  min-width: 0;
  margin-bottom: 0.4em;
}

.article-title-row h1 {
  margin: 0;
  font-size: var(--article-title-size);
  line-height: var(--article-title-line);
  overflow-wrap: anywhere;
  color: var(--color-bg);
}


.link-favicon {
  display: inline;
  width: auto;
  height: 0.8em;
  vertical-align: -0.08em;
  margin-right: 0.15em;
}

.page-wrap { overflow-x: clip; }

.author-link {
  color: inherit;
  text-decoration: none;
}

.author-link:hover {
  text-decoration: none;
  color: inherit;
}

.author-icon {
  display: inline;
  width: auto;
  height: 1.3em;
  vertical-align: -0.3em;
  margin-right: 0.15em;
}

.article-meta {
  margin-top: var(--space-6);
  margin-bottom: var(--space-4);
}

.article-meta p {
  margin: 0;
  overflow-wrap: anywhere;
}

.article-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.article-meta-line-main {
  min-width: 0;
}

main.content.article-shell article :is(h2, h3, h4, h5, h6) {
  margin-block: 1.5em 0.3em;
}

main.content.article-shell article :is(h2, h3, h4, h5, h6) + p {
  margin-top: 0.15em;
}

/* Sticky section headings — each heading pushes out the previous one */
.article-section::after {
  content: "";
  display: block;
  height: 1.5em;
}

.article-blur {
  position: sticky;
  top: 0;
  height: 0;
  z-index: 9;
  pointer-events: none;
}

.article-blur::after {
  content: "";
  display: none;
  position: absolute;
  top: 0;
  left: -50vw;
  right: -50vw;
  height: 4.5rem;
  background: linear-gradient(to bottom, var(--color-bg) calc(100% - 1.5rem), transparent 100%);
  pointer-events: none;
}

main.content.article-shell article .article-section > :is(h2, h3, h4, h5, h6) {
  position: sticky;
  top: 0;
  z-index: 11;
  margin-top: 0;
  padding-top: 0.2em;
  padding-bottom: 0.1em;
  transform: translateZ(0);
}

main.content.article-shell article .article-section > :is(h2, h3, h4, h5, h6)::before {
  content: "";
  position: absolute;
  top: 0;
  left: -50vw;
  right: -50vw;
  bottom: 0;
  background: var(--color-bg);
  z-index: -1;
  pointer-events: none;
}

main.content.article-shell article .article-section > :is(h2, h3, h4, h5, h6)::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -50vw;
  right: -50vw;
  height: 1px;
  background: var(--color-gray-50);
  pointer-events: none;
}



.article-body blockquote {
  border-left: 1px solid var(--color-gray-400);
  padding-left: 1em;
  margin-left: 0;
}

.article-body ul,
.article-body ol {
  margin: 0.5em 0;
  padding-left: 1.4em;
}

.article-body li {
  margin: 0.15em 0;
}

/* Keep long raw URLs inside article body text from causing horizontal overflow. */
.article-body :is(p, ul, ol, blockquote, figure, details, section, div.footnotes) a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

main.content { max-width: 752px; padding: 1em 1rem; margin: 0 auto; }
main.content.article-shell {
  --article-shell-pad-top: 3em;
  padding-top: var(--article-shell-pad-top);
}

.article-body {
  position: relative;
}


/* -- Sidenotes -- */
.sidenote {
  display: none;
}

.sidenote-number {
  font-weight: 600;
  color: var(--color-accent);
}

main.listing-page {
  font-family: var(--font-mono);
  margin-left: 0;
  padding: 1em;
}

.listing-wrap {
  max-width: 980px;
  margin: 0 auto;
}

.listing-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px dashed var(--color-gray-300);
}

.listing-header h1 {
  margin: 0;
  font-size: 1.34em;
  line-height: 1.15;
}

.listing-count {
  margin: 0;
  font-size: 0.88em;
  color: var(--color-gray-500);
}

.tag-term-page-main .listing-header h1 {
  color: var(--color-accent);
}

.listing-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  flex-basis: 100%;
}

.listing-control-label {
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--color-gray-500);
}

#listing-search {
  appearance: none;
  border: 1px solid var(--color-gray-200);
  border-radius: 0;
  background: var(--color-bg);
  color: var(--color-text-strong);
  font: inherit;
  font-size: 0.88em;
  line-height: 1.2;
  padding: 0.28rem 0.5rem;
  flex: 1;
  min-width: 120px;
}

#listing-search::placeholder {
  color: var(--color-gray-500);
}

.listing-controls select,
.listing-sort-dir {
  appearance: none;
  border: 1px solid var(--color-gray-200);
  border-radius: 0;
  background: var(--color-bg);
  color: var(--color-text-strong);
  font: inherit;
  font-size: 0.88em;
  line-height: 1.2;
  padding: 0.28rem 0.5rem;
}

.listing-controls select {
  min-width: 140px;
}

.listing-sort-dir {
  min-width: 56px;
  cursor: pointer;
}

.listing-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.listing-row {
  margin: 0;
  padding: var(--space-4) 0;
  border-bottom: 0;
}

.listing-row.is-disclaimed {
  padding-left: 0;
  padding-right: 0;
}

.listing-archived-badge {
  position: relative;
  display: inline;
  margin-left: 0.3em;
  cursor: default;
}

.listing-archived-icon {
  display: inline;
  width: auto;
  height: 1em;
  vertical-align: -0.18em;
  fill: #d4a017;
  stroke: var(--color-text);
  stroke-width: 68;
  paint-order: stroke fill;
}

.listing-row.is-disclaimed {
  color: var(--color-gray-400);
}

.listing-row.is-disclaimed :is(.listing-entry-title a, .listing-entry-meta, .listing-entry-meta a, .listing-tag) {
  color: var(--color-gray-400);
  background-image: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  text-decoration-color: transparent;
}

.listing-row.is-disclaimed .listing-entry-title,
.listing-row.is-disclaimed .listing-entry-title a {
  font-weight: 400;
}

.listing-row.is-disclaimed .listing-meta-pill {
  color: var(--color-gray-400);
  border-color: var(--color-gray-100);
  background: transparent;
}

.listing-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-5);
  align-items: start;
}

.listing-entry-main {
  min-width: 0;
}

.listing-entry-title {
  margin: 0 0 3px;
  font-size: 1.09em;
  line-height: 1.24;
}

.listing-entry-title a {
  text-decoration-thickness: 1px;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--color-text-strong);
  background-image: none;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  -webkit-text-fill-color: currentColor;
  text-decoration-color: transparent;
}

.listing-entry-title a:hover {
  color: var(--color-text-strong);
  text-decoration-color: var(--color-text-strong);
}

.listing-row.is-disclaimed .listing-entry-title a:hover {
  color: var(--color-gray-400);
  text-decoration-color: var(--color-gray-400);
}

.listing-entry-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
  font-size: 0.86em;
  color: var(--color-gray-600);
  min-width: 0;
  overflow-wrap: anywhere;
}

.listing-entry-date {
  white-space: nowrap;
}

.listing-tag-cluster {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
}

.listing-tag {
  text-decoration-thickness: 1px;
}

.article-archived-badge {
  display: inline;
  margin-left: 0.3em;
  cursor: default;
}

.article-archived-badge .listing-archived-icon {
  display: inline;
  height: 1em;
  width: auto;
  vertical-align: -0.18em;
  stroke: #000000;
  fill: #e9bc5f;
}

.listing-entry-side {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  min-width: 160px;
}

.listing-meta-pill {
  display: inline-block;
  border: 1px solid var(--color-gray-100);
  background: #fff;
  padding: 0.12rem 0.42rem;
  font-size: 0.78em;
  line-height: 1.2;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--color-gray-600);
}

.listing-meta-importance {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  white-space: nowrap;
  max-width: 100%;
}

hr {
    border: none;
    height: 1px;
    background-color: var(--color-gray-200);
}

table { margin: var(--space-4) 0; width: 100%;}

th,td { text-align: left; padding: 0.3em 0; }

th { cursor: pointer; font-size: 1em; user-select: none; }

.abstract {
  max-width: 560px;
  margin: 0 auto var(--space-4);
  padding: 0 1.5em;
  text-align: center;
  font-style: italic;
}

.highlight pre {
  border: 1px dashed var(--color-gray-200);
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--color-code-bg) !important;
  color: var(--color-text-strong) !important;
}

pre,
.highlight pre,
pre code,
.highlight pre code {
  font-family: var(--font-mono);
}

main.content img:not(.link-favicon):not(.author-icon) {
  max-width: 120%;
  height: auto;
  display: block;
  margin: 0 auto;
}

img.media-image.is-pending {
  background: var(--color-gray-50);
}

img.media-image.is-error {
  outline: 1px solid var(--color-error);
  outline-offset: 1px;
}

.media-frame {
  position: relative;
  width: 100%;
  max-width: min(100%, 550px);
  margin: 0 auto;
  overflow: hidden;
}

.media-frame--embed {
  min-height: var(--media-embed-height, 360px);
  border: 1px solid var(--color-gray-200);
  background: var(--color-embed-bg);
}

.media-frame--embed + .media-frame--embed {
  margin-top: var(--space-2);
}

.media-iframe {
  display: block;
  width: 100%;
  height: var(--media-embed-height, 360px);
  border: 0;
  background: #fff;
}

.media-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
  background: var(--color-gray-50);
}

.media-placeholder-label {
  position: relative;
  z-index: 2;
  color: var(--color-gray-500);
  font-size: 0.68rem;
  font-style: italic;
}

.media-frame.is-loaded .media-placeholder {
  opacity: 0;
  visibility: hidden;
  transition: opacity 150ms ease, visibility 0s linear 150ms;
}

.media-frame.is-error .media-placeholder {
  background: rgba(183, 20, 13, 0.08);
}

.media-frame.is-error .media-placeholder-label {
  color: var(--color-error-text);
}

@media (min-width: 768px) {
  .article-header::after,
  main.content.article-shell article .article-section > :is(h2, h3, h4, h5, h6)::after {
    display: none;
  }
}

@media (min-width: 1024px) {
  main.content.article-shell {
    --sidenote-width: 220px;
    --sidenote-gap: 2rem;
    max-width: min(66vw, 900px);
    padding-right: calc(var(--sidenote-width) + var(--sidenote-gap));
  }

  .article-header-main {
    padding-right: 0;
  }

  .article-meta {
    padding-right: 0;
  }

  .article-body {
    padding-right: 0;
  }

  .sidenote {
    display: block;
    position: absolute;
    right: calc(-1 * (var(--sidenote-width) + var(--sidenote-gap)));
    width: var(--sidenote-width);
    font-size: 0.9rem;
    line-height: 1.55;
    color: var(--color-gray-600);
    margin: 0;
  }

  .footnotes.has-sidenotes {
    display: none;
  }

  .article-blur::after {
    display: block;
  }

  main.content.article-shell article .article-section > :is(h2, h3, h4, h5, h6)::before {
    right: 0;
    transition: right 0.3s ease;
  }

  .article-blur::after {
    right: 0;
  }

  .article-blur.is-active::after {
    right: -50vw;
  }

  .article-body img:not(.link-favicon):not(.author-icon) {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  main.content.article-shell { --article-shell-pad-top: 1em; }

  main:not(.content) {
    padding: 1em 1rem;
  }

  main.listing-page {
    margin-left: 0;
    padding: 1em 1rem;
  }

  main.tag-term-page-main {
    padding-top: 0;
  }

  main.content img:not(.link-favicon):not(.author-icon) {
    max-width: 100%;
  }

  .listing-wrap {
    max-width: 100%;
  }

  .listing-header {
    align-items: flex-start;
    gap: var(--space-1) var(--space-3);
  }

  #listing-search {
    max-width: 100%;
    order: -1;
    flex-basis: 100%;
  }

  .listing-controls select {
    min-width: 0;
    max-width: 100%;
  }

  .listing-entry {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }

  .listing-entry-side {
    justify-content: flex-start;
    min-width: 0;
  }

  .media-frame {
    max-width: 100%;
  }

  table {
    display: block;
    width: 100%;
    margin: 0;
    overflow-x: auto;
  }

  th,
  td {
    white-space: nowrap;
  }

  pre,
  .highlight pre {
    overflow-x: auto;
  }


}

@media (prefers-reduced-motion: reduce) {
  a,
  .listing-entry-title a {
    transition: none;
  }

  .media-frame.is-loaded .media-placeholder {
    transition: none;
  }
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4em 0;
  font-size: 0.92em;
  color: var(--color-gray-600);
}

.site-footer-left a {
  color: var(--color-header);
  font-weight: bold;
}

.site-footer-right a {
  color: var(--color-gray-600);
}

.site-footer-center {
  flex: 1;
}

.site-footer-left,
.site-footer-right {
  white-space: nowrap;
}
