/* Self-hosted fonts (latin subset, SIL OFL) */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(/static/fonts/inter-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400 500;
  font-display: swap;
  src: url(/static/fonts/jetbrains-mono-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Newsreader';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url(/static/fonts/newsreader-italic.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Newsreader';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url(/static/fonts/newsreader-normal.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* =========================================================
   main.css — Minimal sans-serif blog
   Fonts: Inter (UI + body) · JetBrains Mono (code)
   Theme: warm editorial paper (light) / warm charcoal (dark)
   ========================================================= */

/* --- Custom properties: Catppuccin Mocha (dark) --- */
:root,
[data-theme="dark"] {
  --bg: #18171a;
  --bg-alt: #131214;
  --surface: #232127;
  --surface-hi: #2f2c34;
  --overlay: #4a4650;
  --text: #e8e4dc;
  --subtext: #b4aea3;
  --muted: #8f897f;
  --accent: #e0a46a;
  --accent-alt: #c9a7e8;
  --green: #a6e3a1;
  --red: #f38ba8;
  --yellow: #f9e2af;
  --border: #2c2a30;
  --shadow: rgba(0, 0, 0, 0.35);

  /* Code block header — slightly lighter than bg */
  --code-header-bg: #232127;
  --code-body-bg: #131214;

  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace;
}

/* --- Custom properties: Catppuccin Latte (light) --- */
[data-theme="light"] {
  --bg: #faf7f2;
  --bg-alt: #f2eee6;
  --surface: #ece6da;
  --surface-hi: #e0d8c8;
  --overlay: #c9bfac;
  --text: #25221d;
  --subtext: #555047;
  --muted: #6b655b;
  --accent: #a8531a;
  --accent-alt: #7a3fb0;
  --green: #40a02b;
  --red: #d20f39;
  --yellow: #df8e1d;
  --border: #e3dccd;
  --shadow: rgba(37, 34, 29, 0.1);

  --code-header-bg: #ece6da;
  --code-body-bg: #f2eee6;
}

/* --- Reset & base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Masthead --- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

/* backdrop-filter is on a pseudo-element so it doesn't create a containing
   block for position:fixed children (the fullscreen mobile nav). */
.masthead::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: -1;
}

.masthead__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.masthead__logo {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.masthead__logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.masthead__tagline {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.masthead__nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.875rem;
}

.nav-link {
  color: var(--subtext);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
  font-weight: 450;
}

.nav-link:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-link--feed svg {
  opacity: 0.7;
}

.nav-link--dropdown::after {
  content: "▾" / ""; /* empty alt text: decorative, not announced */
  margin-left: 0.2em;
  font-size: 0.75em;
  opacity: 0.6;
}

.nav-dropdown {
  position: relative;
  cursor: pointer; /* required for :hover to fire in WebKit/Safari */
}

.nav-dropdown__menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  padding: 0.5rem 0.25rem 0.25rem;
  min-width: 160px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}

.nav-dropdown:hover .nav-dropdown__menu,
.nav-dropdown:focus-within .nav-dropdown__menu {
  display: block;
}

.nav-dropdown__item {
  display: block;
  padding: 0.4rem 0.75rem;
  color: var(--subtext);
  text-decoration: none;
  border-radius: 0.35rem;
  font-size: 0.875rem;
  font-weight: 450;
  transition:
    color 0.15s,
    background 0.15s;
}

.nav-dropdown__item:hover {
  color: var(--text);
  background: var(
    --surface2,
    color-mix(in srgb, var(--border) 50%, transparent)
  );
  text-decoration: none;
}

/* pagelist template */
.pagelist__group-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 2rem 0 0.75rem;
}

.pagelist {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.pagelist__item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.pagelist__item:first-child {
  border-top: 1px solid var(--border);
}

.pagelist__link {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.pagelist__link:hover {
  color: var(--accent);
}

.pagelist__desc {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* --- Layout container --- */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  flex: 1;
}

.container--narrow {
  max-width: 720px;
}

/* --- Newspaper layout (main + sidebar) --- */
.newspaper-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 3rem;
  margin-top: 2.5rem;
}

@media (max-width: 920px) {
  .newspaper-layout {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .sidebar {
    border-top: 1px solid var(--border);
    padding-top: 2rem;
  }
}

/* --- Hero section --- */
.hero {
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.hero__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.hero__title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.875rem;
  color: var(--text);
}

.hero__title a {
  color: inherit;
  text-decoration: none;
}

.hero__title a:hover {
  color: var(--accent);
}

.hero__desc {
  font-size: 1.0625rem;
  color: var(--subtext);
  margin-bottom: 1.5rem;
  max-width: 560px;
  line-height: 1.65;
}

/* --- Article grid --- */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

/* --- Post card --- */
.post-card {
  background-color: var(--bg);
  padding: 1.375rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: background-color 0.15s;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.post-card:hover {
  background-color: var(--surface);
}

.post-card__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.post-card__title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.post-card__title a {
  color: var(--text);
  text-decoration: none;
}

.post-card__title a:hover {
  color: var(--accent);
}

.post-card__desc {
  font-size: 0.85rem;
  color: var(--subtext);
  line-height: 1.55;
  flex: 1;
}

.post-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.25rem;
}

.post-card--small .post-card__title {
  font-size: 0.9375rem;
}

/* --- Sidebar --- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.sidebar-widget__title {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.sidebar-list__item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.sidebar-list__item a {
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  line-height: 1.3;
}

.sidebar-list__item a:hover {
  color: var(--accent);
}

.sidebar-list__item time {
  font-size: 0.7rem;
  color: var(--muted);
}

/* --- Tags --- */
.tag {
  display: inline-block;
  padding: 0.15em 0.6em;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  background-color: var(--surface);
  color: var(--subtext);
  text-decoration: none;
  transition:
    background-color 0.15s,
    color 0.15s;
}

.tag:hover {
  background-color: var(--accent);
  color: var(--bg);
  text-decoration: none;
}

.tag--hero {
  background-color: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.tag--large {
  font-size: 0.875rem;
  padding: 0.3em 0.8em;
}

.tag--active {
  background-color: var(--accent);
  color: var(--bg);
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.55em 1.1em;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.15s;
}

.btn--primary {
  background-color: var(--accent);
  color: var(--bg);
}

.btn--primary:hover {
  opacity: 0.88;
  text-decoration: none;
}

/* --- Reading time --- */
.reading-time {
  font-size: 0.75rem;
  color: var(--muted);
}

/* --- Article page --- */
.article {
  padding: 2.5rem 0;
}

.article__header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.article__meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--subtext);
  margin-bottom: 1rem;
}

.article__title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: var(--text);
  margin-bottom: 0.875rem;
}

.article__lead {
  font-size: 1.1rem;
  color: var(--subtext);
  line-height: 1.65;
  margin-bottom: 1rem;
}

.article__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.article__footer {
  margin-top: 1.5rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

/* --- Prose body --- */
.prose {
  line-height: 1.75;
  font-size: 1.0625rem;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-top: 2.25em;
  margin-bottom: 0.6em;
}

.prose h1 {
  font-size: 1.875rem;
}

.prose h2 {
  font-size: 1.375rem;
}

.prose h3 {
  font-size: 1.125rem;
}

.prose h4 {
  font-size: 1rem;
}

.prose h2 + p,
.prose h3 + p {
  margin-top: 0;
}

.prose p {
  margin-bottom: 1.35em;
}

.prose a {
  color: var(--accent);
}

.prose a:hover {
  text-decoration: underline;
}

.prose ul,
.prose ol {
  margin: 0.5em 0 1.35em 1.4em;
}

.prose li {
  margin-bottom: 0.3em;
}

.prose li > ul,
.prose li > ol {
  margin-bottom: 0;
}

.prose blockquote {
  border-left: 2px solid var(--accent);
  margin: 1.5em 0;
  padding: 0.75em 1.25em;
  color: var(--subtext);
  font-style: italic;
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5em 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 0.9rem;
}

.prose th,
.prose td {
  padding: 0.6em 0.875em;
  border: 1px solid var(--border);
  text-align: left;
}

.prose th {
  background-color: var(--surface);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--subtext);
}

.prose tr:nth-child(even) td {
  background-color: var(--bg-alt);
}

/* Inline code */
.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.15em 0.4em;
  border-radius: 4px;
  background-color: var(--surface);
  color: var(--accent-alt);
}

/* ── Code blocks ─────────────────────────────────────────────────────────── */

.code-block {
  border-radius: 10px;
  overflow: hidden;
  margin: 1.75em 0;
  border: 1px solid var(--border);
  font-size: 0.875rem;
}

/* Header bar: dots + optional filename + language badge */
.code-block__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  background-color: var(--code-header-bg);
  border-bottom: 1px solid var(--border);
  gap: 0.75rem;
}

.code-block__dots {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.code-block__dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.code-block__dot--red {
  background: #ff5f57;
}

.code-block__dot--yellow {
  background: #febc2e;
}

.code-block__dot--green {
  background: #28c840;
}

.code-block__filename {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--subtext);
  flex: 1;
  /* truncate long names */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-block__lang {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--muted);
  text-transform: lowercase;
  flex-shrink: 0;
  border: 1px solid var(--border);
  padding: 0.1em 0.45em;
  border-radius: 3px;
}

/* Copy button */
.code-block__copy {
  margin-left: auto;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0.2em 0.3em;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition:
    color 0.15s,
    border-color 0.15s;
  line-height: 1;
}

.code-block__copy:hover {
  color: var(--subtext);
  border-color: var(--border);
}

.code-block__copy--copied {
  color: var(--green) !important;
}

/* Shell / terminal blocks */
/* Shell blocks follow the theme like every other code block; only the prompt icon differs. */
.code-block__terminal-icon {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.05em;
  flex-shrink: 0;
}

/* The chroma <pre> sits directly in the code-block, no extra border/radius */
.code-block .chroma,
.prose .code-block .chroma {
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  padding: 1.125em 1.25em;
  background-color: var(--code-body-bg);
  overflow-x: auto;
  line-height: 1.6;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.prose .code-block .chroma code {
  background-color: var(--code-body-bg);
  padding: 0em;
}

/* ── Figure / Image (Medium-style) ──────────────────────────────────────── */

.figure {
  margin: 2.5em 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.625rem;
}

/* Shimmer wrapper — isolates the loading animation from the figcaption */
.figure__media {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 6px;
  background-color: var(--surface);
  /* line-height: 0 removes the inline gap below the img element */
  line-height: 0;
}

/* Animated shimmer sweep shown while the image is loading */
.figure__media::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--surface-hi) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: img-shimmer 1.8s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.35s ease;
}

/* Hide shimmer once the image has loaded */
.figure__media.media--loaded::before {
  opacity: 0;
  animation: none;
}

@keyframes img-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.figure__media img {
  display: block;
  width: 100%;
  height: auto; /* combined with width+height attrs → browser reserves space */
  max-width: 100%;
  border-radius: inherit;
  position: relative;
  z-index: 2;
  /* Start invisible; fade in on load */
  opacity: 0;
  transition: opacity 0.5s ease;
}

.figure__media img.img--loaded {
  opacity: 1;
}

.figure figcaption {
  font-size: 0.8125rem;
  color: var(--muted);
  text-align: center;
  max-width: 480px;
  line-height: 1.5;
}

/* Wide: breaks slightly out of column */
.figure--wide {
  margin-left: -2.5rem;
  margin-right: -2.5rem;
}

.figure--wide .figure__media {
  border-radius: 4px;
}

/* Full-bleed: viewport width */
.figure--full {
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  width: 100vw;
  max-width: 100vw;
}

.figure--full .figure__media {
  border-radius: 0;
}

.figure--full .figure__media img {
  width: 100%;
  max-width: 100%;
}

/* --- Giscus comments --- */
.giscus-wrap {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.giscus-wrap .giscus {
  margin: 0;
}

/* --- Suggested posts --- */
.suggested {
  margin-top: 3.5rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.suggested__title {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.suggested__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

@media (max-width: 640px) {
  .suggested__grid {
    grid-template-columns: 1fr;
  }
}

/* --- Breadcrumb --- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--subtext);
}

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

/* --- Page header --- */
.page-header {
  margin-bottom: 0.5rem;
}

.page-header__count {
  font-size: 0.875rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* --- Theme toggle (icon-only) --- */
theme-toggle button,
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3em 0.4em;
  cursor: pointer;
  color: var(--subtext);
  display: flex;
  align-items: center;
  transition:
    border-color 0.15s,
    color 0.15s;
  line-height: 1;
}

theme-toggle button:hover,
.theme-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

theme-toggle button svg,
.theme-toggle-btn svg {
  display: block;
}

/* --- Feed widget --- */
feed-widget .feed-widget {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.125rem;
}

feed-widget .feed-widget__title {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

feed-widget .feed-widget__links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

feed-widget .feed-widget__link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8125rem;
  color: var(--subtext);
  text-decoration: none;
}

feed-widget .feed-widget__link:hover {
  color: var(--accent);
}

/* --- Footer --- */
.site-footer {
  background-color: var(--bg-alt);
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.site-footer__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.site-footer__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-footer__right a {
  color: var(--subtext);
}

.site-footer__right a:hover {
  color: var(--accent);
}

/* --- Hamburger toggle (hidden on desktop) --- */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  cursor: pointer;
  color: var(--subtext);
  align-items: center;
  transition:
    border-color 0.15s,
    color 0.15s;
  flex-shrink: 0;
}

.nav-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.nav-toggle__icon--close {
  display: none;
}
.nav-toggle[aria-expanded="true"] .nav-toggle__icon--open {
  display: none;
}
.nav-toggle[aria-expanded="true"] .nav-toggle__icon--close {
  display: block;
}

/* --- Mobile nav overlay (direct child of body — no containing-block issues) --- */
.mobile-nav {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: var(--bg);
  padding: 0 1.75rem calc(1.75rem + env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0s linear 0.22s;
}

.mobile-nav.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  transition:
    opacity 0.22s ease,
    transform 0.22s ease,
    visibility 0s linear 0s;
}

/* Header row inside the overlay */
.mobile-nav__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mobile-nav__brand {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.mobile-nav__close {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.4rem;
  color: var(--subtext);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.mobile-nav__close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .masthead__tagline {
    display: none;
  }
  .masthead__nav {
    display: none;
  }
  .nav-toggle {
    display: flex;
  }

  /* Nav list */
  .mobile-nav__list {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-top: 0.25rem;
  }

  .mobile-nav__link {
    display: flex;
    align-items: center;
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    padding: 0.95rem 0;
    border-bottom: 1px solid var(--border);
    transition: color 0.15s;
  }

  .mobile-nav__link:hover {
    color: var(--accent);
  }

  /* Group row: link + expand chevron */
  .mobile-nav__group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    border-bottom: 1px solid var(--border);
  }

  .mobile-nav__group > .mobile-nav__link {
    flex: 1;
    border-bottom: none;
  }

  .mobile-nav__expand {
    background: none;
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 0.35rem 0.45rem;
    color: var(--subtext);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition:
      transform 0.2s ease,
      border-color 0.15s;
    flex-shrink: 0;
  }

  .mobile-nav__expand:hover {
    border-color: var(--accent);
    color: var(--accent);
  }
  .mobile-nav__group.is-open .mobile-nav__expand {
    transform: rotate(180deg);
  }

  .mobile-nav__children {
    display: none;
    width: 100%;
    padding: 0.25rem 0 0.5rem 1rem;
  }

  .mobile-nav__group.is-open .mobile-nav__children {
    display: block;
  }

  .mobile-nav__child {
    display: block;
    font-size: 1rem;
    color: var(--subtext);
    text-decoration: none;
    padding: 0.6rem 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
    transition: color 0.15s;
  }

  .mobile-nav__child:last-child {
    border-bottom: none;
  }
  .mobile-nav__child:hover {
    color: var(--accent);
  }

  .mobile-nav__footer {
    padding-top: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 2rem 1rem 3rem;
  }

  .hero__title {
    font-size: 1.625rem;
  }

  .article__title {
    font-size: 1.625rem;
  }

  .article-grid {
    grid-template-columns: 1fr;
  }

  .figure--wide {
    margin-left: -1rem;
    margin-right: -1rem;
  }

  .figure--wide .figure__media {
    border-radius: 4px;
  }

  .site-footer__inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --- Accessibility: skip link, focus ring, reduced motion --- */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 1000;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: var(--bg);
  border-radius: 4px;
}
.skip-link:focus { top: 0.5rem; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =========================================================
   Editorial layer: serif reading type, flat lists, quiet chrome
   ========================================================= */
:root { --font-ui: var(--font-sans); }

/* Serif only for titles and article prose; UI headings stay sans */
.masthead__logo,
.hero__title,
.article__title,
.article__lead,
.post-card__title,
.page-header__title,
.prose h1, .prose h2, .prose h3, .prose h4,
.prose { font-family: var(--font-serif); }

.masthead__logo { font-size: 1.3rem; font-weight: 600; letter-spacing: -0.01em; }
.masthead__tagline { display: none; }
.masthead__rule { display: none; }
.masthead__inner { padding: 1rem 1.5rem; }
.nav-link { font-size: 0.875rem; }

.container--narrow { max-width: 680px; }
.container { padding-top: 3.5rem; }

.hero__title { font-size: clamp(2.25rem, 5vw, 3.25rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.hero__desc { font-family: var(--font-serif); font-size: 1.25rem; max-width: 60ch; }
.btn { border-radius: 2px; }

.article { padding-top: 1rem; }
.article__title { font-size: clamp(2rem, 5vw, 2.875rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.12; }
.article__lead { font-size: 1.3rem; line-height: 1.5; }
.article__header { border-bottom: 0; padding-bottom: 0.5rem; margin-bottom: 1.5rem; }
.article__footer { border-top: 1px solid var(--border); }

.prose { font-size: 1.1875rem; line-height: 1.75; }
.prose h2 { font-size: 1.6rem; font-weight: 600; }
.prose h3 { font-size: 1.3rem; font-weight: 600; }
.prose a { text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: var(--accent); }
.prose blockquote { font-size: 1.1em; border-left-width: 3px; }
.prose code, .prose pre, .code-block { font-family: var(--font-mono); }
.prose code { color: var(--text); }
.prose img { border-radius: 2px; }
.prose table { font-family: var(--font-sans); }

/* Code blocks: drop macOS traffic-light dots */
.code-block { border-radius: 4px; }
.code-block__dots { display: none; }

/* Index lists: flat, no card chrome */
.article-grid { display: block; border: 0; border-radius: 0; overflow: visible; }
.post-card { padding: 1.5rem 0; border: 0; border-bottom: 1px solid var(--border); background: none; }
.post-card:hover { background: none; }
.post-card__title { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.01em; }
.post-card__desc { font-size: 1rem; max-width: 60ch; }
.post-card--small { padding: 0; border: 0; }
.post-card--small .post-card__title { font-size: 1.1rem; }

/* Suggested: three open columns instead of a bordered grid */
.suggested__grid { gap: 2rem; border: 0; border-radius: 0; overflow: visible; }

/* Tags: quiet text chips */
.tag { border-radius: 2px; background: none; border: 1px solid var(--border); color: var(--subtext); }
.tag--hero { background: none; border-color: var(--accent); }
.tag--large { font-size: 0.9rem; }
.page-header { margin-bottom: 1.5rem; }
.page-header__title { font-family: var(--font-serif); }

/* Sidebar & widgets */
.feed-widget { border-radius: 2px; }
feed-widget .feed-widget { background: none; border-radius: 2px; }
.sidebar-widget__title, .suggested__title { font-family: var(--font-sans); }

/* Footer */
.site-footer { background: none; }
.site-footer__inner { padding: 2rem 1.5rem; }

@media (max-width: 640px) {
  .prose { font-size: 1.0625rem; }
  .container { padding-top: 2rem; }
  .article__lead { font-size: 1.15rem; }
  .site-footer__inner { flex-direction: column; align-items: flex-start; }
}

/* =========================================================
   Interaction polish
   ========================================================= */
html { scroll-padding-top: 5rem; }

/* Whole card clickable (stretched link), single tab stop */
.post-card { position: relative; }
.post-card__title a::after { content: ""; position: absolute; inset: 0; }
.post-card__tags { position: relative; z-index: 1; }
.post-card:hover .post-card__title a { color: var(--accent); }
.post-card--small:hover { opacity: 0.85; }

/* Nav: current page + animated underline */
.nav-link[aria-current="page"], .nav-dropdown__item[aria-current="page"] { color: var(--text); }
.nav-link { position: relative; }
.nav-link::before { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px; background: var(--accent); transform: scaleX(0); transition: transform 0.2s ease; }
.nav-link:hover::before, .nav-link[aria-current="page"]::before { transform: scaleX(1); }
.nav-link--feed::before { display: none; }
.mobile-nav__link[aria-current="page"], .mobile-nav__child[aria-current="page"] { color: var(--accent); }

/* Dropdown: fade in, no hover gap */
.nav-dropdown__menu { display: block; opacity: 0; visibility: hidden; transform: translateY(-4px); transition: opacity 0.15s, transform 0.15s, visibility 0.15s; }
.nav-dropdown:hover .nav-dropdown__menu, .nav-dropdown:focus-within .nav-dropdown__menu { opacity: 1; visibility: visible; transform: none; }

/* Heading anchors */
.heading-anchor { margin-left: 0.4em; color: var(--muted); text-decoration: none !important; opacity: 0; transition: opacity 0.15s; font-family: var(--font-sans); }
.prose :is(h2, h3):hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }
@media (hover: none) { .heading-anchor { display: none; } }

/* Reading progress */
.read-progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: 0 50%; z-index: 150; pointer-events: none; }

/* Touch targets */
@media (pointer: coarse) {
  .tag { padding: 0.35em 0.8em; }
  .nav-toggle, .mobile-nav__close, theme-toggle button { min-width: 44px; min-height: 44px; justify-content: center; }
}

/* Table of contents */
.toc { font-family: var(--font-sans); font-size: 0.9rem; margin: 0 0 2rem; padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: 2px; }
.toc summary { cursor: pointer; font-weight: 600; color: var(--subtext); }
.toc ol { list-style: none; margin: 0.75rem 0 0; }
.toc li { margin: 0.35rem 0; }
.toc__sub { padding-left: 1rem; }
.toc a { color: var(--subtext); text-decoration: none; }
.toc a:hover { color: var(--accent); }

/* Back to top */
.to-top { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 120; width: 40px; height: 40px; display: grid; place-items: center; background: var(--surface); color: var(--subtext); border: 1px solid var(--border); border-radius: 2px; cursor: pointer; opacity: 0; visibility: hidden; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s, visibility 0.2s, color 0.15s; }
.to-top.is-visible { opacity: 1; visibility: visible; transform: none; }
.to-top:hover { color: var(--accent); }
@media print { .to-top, .read-progress, .toc { display: none; } }

/* =========================================================
   Accessibility & robustness
   ========================================================= */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#main-content:focus { outline: none; }
.sidebar-widget__title a { color: inherit; text-decoration: none; }
.sidebar-widget__title a:hover { color: var(--accent); }
.pagelist__item--row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }

/* Wide content scrolls instead of breaking the layout on phones */
.prose table { display: block; overflow-x: auto; }
.prose pre { overflow-x: auto; }
.prose img, .prose video, .prose iframe { max-width: 100%; }
.prose { overflow-wrap: break-word; }

@media (forced-colors: active) {
  .tag, .btn, .to-top, .toc { border: 1px solid ButtonText; }
  .read-progress { background: Highlight; }
}

@media print {
  .masthead, .mobile-nav, .site-footer, .sidebar, .giscus-wrap, .suggested, .nav-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .prose a { color: inherit; text-decoration: underline; }
  .prose a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; }
}

/* =========================================================
   Click-to-zoom images (Medium-style lightbox)
   ========================================================= */
.prose img:not(a img) { cursor: zoom-in; }
dialog.zoom { border: 0; padding: 0; margin: 0; max-width: none; max-height: none; width: 100vw; height: 100vh; background: transparent; color: var(--text); display: none; place-items: center; cursor: zoom-out; overflow: hidden; }
dialog.zoom[open] { display: grid; }
dialog.zoom::backdrop { background: color-mix(in srgb, var(--bg) 96%, transparent); }
dialog.zoom figure { margin: 0; display: grid; justify-items: center; gap: 0.75rem; max-width: 96vw; }
dialog.zoom img { max-width: 96vw; max-height: 86vh; width: auto; height: auto; object-fit: contain; border-radius: 2px; transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1); transform-origin: 0 0; box-shadow: 0 10px 40px var(--shadow); }
dialog.zoom figcaption { font-family: var(--font-sans); font-size: 0.875rem; color: var(--subtext); max-width: 70ch; text-align: center; }
dialog.zoom .zoom__close { position: fixed; top: 1rem; right: 1rem; width: 44px; height: 44px; display: grid; place-items: center; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 2px; cursor: pointer; font-size: 1.25rem; line-height: 1; }
