/* blog-19182 — minimal theme. Black/white light, dark-green/black dark. */

/* self-hosted fonts (Geist + Geist Mono) */
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/geist-400.woff2") format("woff2");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/geist-500.woff2") format("woff2");
}
@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/geist-700.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/geist-mono-400.woff2") format("woff2");
}

:root {
  --light: #e9e7e1;
  --lightgray: #d8d5cd;
  --gray: #999489;
  --darkgray: #6a655c;
  --dark: #2b2926;
  --secondary: #505050;
  --tertiary: #707070;
  --highlight: rgba(64, 64, 64, 0.08);
  --textHighlight: #fff23688;

  --font-header: "Geist", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: "Geist", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --maxw: 960px;
}

:root[data-theme="dark"] {
  --light: #0c0c0c;
  --lightgray: #1e1e1e;
  --gray: #b0b0b0;
  --darkgray: #e0e0e0;
  --dark: #f5f5f5;
  --secondary: #1a8c4a;
  --tertiary: #606060;
  --highlight: rgba(255, 255, 255, 0.08);
  --textHighlight: #b3aa0288;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--light);
  color: var(--dark);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* WebGL flow-noise background (scripts/background.js) — fixed full-viewport,
   painted above the (opaque) body background but below all content so it
   covers the whole page while scrolling. Body color is the WebGL fallback. */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 0;
  display: block;
  pointer-events: none;
}
.content,
.site-footer { position: relative; z-index: 1; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }

/* ---- header ---- */
.site-header {
  border-bottom: 1px solid var(--lightgray);
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--light) 88%, transparent);
  backdrop-filter: blur(8px);
  z-index: 20;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  flex-wrap: wrap;
}
.site-title {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  color: var(--secondary);
}
.site-title svg {
  display: block;
  transition: transform 0.2s, color 0.2s;
}
.site-title:hover { color: var(--dark); }
.site-title:hover svg { transform: scale(1.08); }
.site-nav { display: flex; gap: 0.9rem; flex: 1; flex-wrap: wrap; }
.site-nav a {
  color: var(--secondary);
  text-decoration: none;
  font-size: 0.92rem;
}
.site-nav a:hover { color: var(--dark); }
.site-nav a[aria-current="page"] { color: var(--dark); border-bottom: 2px solid var(--secondary); }

.theme-toggle {
  background: none;
  border: 1px solid var(--lightgray);
  color: var(--dark);
  border-radius: 6px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  cursor: pointer;
}
.theme-toggle:hover { background: var(--highlight); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* ---- main ---- */
.content { flex: 1; padding: 1.25rem 0 1.5rem; }

.article-title {
  font-family: var(--font-header);
  font-size: 2.1rem;
  line-height: 1.2;
  margin: 0 0 0.6rem;
}
.content-meta { color: var(--gray); font-size: 0.88rem; margin-bottom: 0.4rem; }
.content-meta .dot { margin: 0 0.45rem; }
.tag-list { margin-bottom: 1.5rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.tag {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--secondary);
  background: var(--highlight);
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  text-decoration: none;
}
.tag:hover { background: var(--lightgray); }

/* ---- prose ---- */
.prose { font-size: 1.02rem; }
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-family: var(--font-header);
  line-height: 1.25;
  margin: 2rem 0 0.8rem;
}
.prose h2 { font-size: 1.5rem; border-bottom: 1px solid var(--lightgray); padding-bottom: 0.3rem; }
.prose h3 { font-size: 1.22rem; }
.prose p { margin: 0.9rem 0; }
.prose a { color: var(--secondary); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
.prose a:hover { color: var(--dark); }
.prose a.external::after { content: " ↗"; font-size: 0.8em; color: var(--gray); }
.prose img { max-width: 100%; height: auto; border-radius: 6px; display: block; margin: 1.2rem auto; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: 0.3rem 0; }
.prose blockquote {
  margin: 1.2rem 0;
  padding: 0.4rem 1rem;
  border-left: 3px solid var(--secondary);
  color: var(--darkgray);
  background: var(--highlight);
  border-radius: 0 6px 6px 0;
}
.prose hr { border: none; border-top: 1px solid var(--lightgray); margin: 2rem 0; }
.prose mark { background: var(--textHighlight); color: inherit; }

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--highlight);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  /* no ligatures — keeps tokens like <|name|> from rendering as arrow glyphs */
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
}
.prose pre {
  font-family: var(--font-mono);
  font-size: 0.84rem;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0;
  padding: 1rem;
  border: 1px solid var(--lightgray);
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.5;
}
.prose pre code { background: none; padding: 0; font-size: inherit; }

/* shiki light/dark via CSS vars */
.prose pre.shiki, .prose pre.shiki span { background: transparent !important; }
.prose pre code span { color: var(--shiki-light); }
:root[data-theme="dark"] .prose pre code span { color: var(--shiki-dark); }

.prose table { border-collapse: collapse; width: 100%; margin: 1.2rem 0; font-size: 0.92rem; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--lightgray); padding: 0.4rem 0.6rem; text-align: left; vertical-align: top; }
.prose th { background: var(--highlight); font-family: var(--font-body); }

.prose iframe { width: 100%; border: 1px solid var(--lightgray); border-radius: 8px; margin: 1rem 0; }

/* heading anchor links */
.prose .header-anchor { color: inherit; text-decoration: none; }
.prose .header-anchor:hover { color: var(--secondary); }

/* footnotes — markdown-it-footnote output. The plugin emits its own
   <hr class="footnotes-sep">, so that is the single divider (no border on
   .footnotes, or they'd double up). */
.footnotes-sep { border: none; border-top: 1px solid var(--lightgray); margin: 2.5rem 0 1.2rem; }
.footnotes { font-size: 0.88rem; color: var(--darkgray); }
.footnotes-list { padding-left: 1.2rem; }
.footnote-item { margin: 0.5rem 0; padding: 0.1rem 0.4rem; border-radius: 6px; transition: background 0.4s ease; }
.footnote-item p { margin: 0.25rem 0; }
.footnote-ref a { text-decoration: none; font-weight: 500; padding: 0 0.1em; }
.footnote-ref a:hover { text-decoration: underline; }
.footnote-backref { text-decoration: none; margin-left: 0.35rem; color: var(--gray); }
.footnote-backref:hover { color: var(--secondary); }
/* highlight the note you jumped to (and the ref you return to) so you don't
   lose your place */
.footnote-item:target { background: var(--highlight); }
.footnote-ref a:target { background: var(--highlight); border-radius: 4px; }

/* ---- entry lists ---- */
.entry-list { list-style: none; padding: 0; }
.entry-list li {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--lightgray);
  flex-wrap: nowrap;
}
/* title takes the left, shrinking with an ellipsis instead of wrapping to a 2nd line */
.entry-list li a:first-child {
  font-weight: 500; color: var(--dark); text-decoration: none;
  min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.entry-list li a:first-child:hover { color: var(--secondary); }
.entry-list li .tag { flex-shrink: 0; }
/* date is always the last item, pinned to the far right, never wraps/shrinks */
.entry-date {
  color: var(--gray); font-size: 0.82rem; font-family: var(--font-mono);
  order: 99; margin-left: auto; flex-shrink: 0; white-space: nowrap;
}

.tag-index { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.6rem; }
.tag-index li { display: flex; align-items: center; gap: 0.3rem; }

/* ---- table of contents ---- */
.toc {
  border: 1px solid var(--lightgray);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
}
.toc summary { cursor: pointer; color: var(--secondary); font-family: var(--font-mono); font-size: 0.82rem; }
.toc ul { list-style: none; padding-left: 0; margin: 0.6rem 0 0.2rem; }
.toc li { margin: 0.25rem 0; }
.toc .toc-h3 { padding-left: 1rem; }
.toc a { color: var(--darkgray); text-decoration: none; }
.toc a:hover { color: var(--secondary); }

/* ---- link archive filter ---- */
.archive-filter {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 1.2rem 0 1.8rem;
  position: sticky;
  top: 56px;
  background: var(--light);
  padding: 0.6rem 0;
  z-index: 5;
}
.archive-filter input, .archive-filter select {
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--lightgray);
  border-radius: 6px;
  background: var(--light);
  color: var(--dark);
}
.archive-filter input { flex: 1; min-width: 180px; }
.archive-count { color: var(--gray); font-size: 0.82rem; font-family: var(--font-mono); }
li.archive-hidden { display: none; }
/* every archive link is external — drop the ↗ noise here */
.archive-page a.external::after { content: none; }

/* ---- internal link previews (popover) ---- */
.popover {
  position: fixed;
  z-index: 50;
  width: 290px;
  max-height: 220px;
  overflow: hidden;
  background: var(--light);
  border: 1px solid var(--lightgray);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  padding: 0.75rem 0.9rem;
  font-size: 0.78rem;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  pointer-events: none;
}
.popover.visible { opacity: 1; transform: translateY(0); }
.popover .popover-title { font-family: var(--font-header); font-weight: 700; font-size: 0.98rem; margin-bottom: 0.35rem; }
.popover .popover-body { color: var(--darkgray); }
.popover .popover-body :is(h1, h2, h3) { font-size: 0.92rem; margin: 0.5rem 0 0.3rem; }
.popover .popover-body img { max-width: 100%; border-radius: 6px; }
.popover .popover-body a { color: var(--secondary); text-decoration: none; }
/* fade the bottom so truncated content doesn't look cut */
.popover::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2.4rem;
  background: linear-gradient(transparent, var(--light));
  pointer-events: none;
}
@media (hover: none) { .popover { display: none; } }
/* footnote hover previews are short — let them size to content, no fade */
.footnote-popover { width: auto; max-width: 320px; max-height: none; }
.footnote-popover::after { content: none; }
.footnote-popover .popover-body p { margin: 0; }

/* ---- projects (cards live in markdown but themed here) ---- */
.project-list { display: flex; flex-direction: column; gap: 1rem; margin: 1.5rem 0; }
.project-card {
  border: 1px solid var(--lightgray);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  background: var(--light);
  transition: border-color 0.2s, transform 0.1s;
}
.project-card:hover { border-color: var(--secondary); transform: translateY(-1px); }
.project-title { font-weight: 600; margin-bottom: 0.3rem; font-family: var(--font-header); }
.project-title a { color: var(--dark); text-decoration: none; }
.project-title a:hover { color: var(--secondary); }
.project-desc { font-size: 0.94rem; color: var(--darkgray); }
.project-desc a { color: var(--secondary); }
.project-date { font-size: 0.78rem; color: var(--gray); font-family: var(--font-mono); margin-left: 0.5rem; font-weight: normal; }

/* ---- footer ---- */
.site-footer {
  border-top: 1px solid var(--lightgray);
  padding: 1.5rem 0 2.5rem;
  font-size: 0.85rem;
  color: var(--gray);
  margin-top: 0;
}
.site-footer .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.footer-meta { margin: 0; }
.footer-meta a { color: var(--gray); text-decoration: none; }
.footer-meta a:hover { color: var(--secondary); }
.footer-meta .dot { margin: 0 0.45rem; }

.footer-right { display: flex; align-items: center; gap: 0.8rem; margin-left: auto; }
.footer-right .theme-toggle { width: 30px; height: 30px; }

.sand-details { display: flex; flex-direction: column; align-items: flex-end; }
.sand-details summary {
  list-style: none;
  cursor: pointer;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lightgray);
  opacity: 0.5;
  transition: opacity 0.2s, background 0.2s;
}
.sand-details summary::-webkit-details-marker { display: none; }
.sand-details summary::marker { content: ""; }
.sand-details summary:hover { opacity: 1; background: var(--secondary); }
.sand-details[open] summary { background: var(--secondary); opacity: 1; }
.sand-wrap { margin-top: 0.8rem; display: flex; flex-direction: column; align-items: flex-end; }
#sand-canvas {
  border: 1px solid var(--lightgray);
  border-radius: 4px;
  image-rendering: pixelated;
  cursor: crosshair;
  background: var(--light);
  touch-action: none;
}
.sand-clear {
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--lightgray);
  border-radius: 5px;
  background: var(--light);
  color: var(--dark);
  cursor: pointer;
}
.sand-clear:hover { background: var(--highlight); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .article-title { font-size: 1.7rem; }
  .site-nav { order: 3; width: 100%; }
  #sand-canvas { display: none; }
  .sand-details { display: none; }
  /* show full titles instead of truncating them on narrow screens */
  .entry-list li a:first-child {
    flex: 1; white-space: normal; overflow: visible; text-overflow: clip;
  }
  /* hide tags on mobile so titles can wrap without overlap */
  .entry-list li .tag { display: none; }
}

/* hide sand garden on coarse pointers / small screens (desktop-only easter egg) */
@media (hover: none) { .sand-details { display: none; } }
