/* ============================================================
   thenets.org — Custom dark theme
   Inspired by Ghost Liebling theme
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #111111;
  --bg-card:     #1a1a1a;
  --bg-header:   #0a0a0a;
  --bg-code:     #0a0a0a;
  --bg-code-inline: #1e1e1e;
  --text:        #cccccc;
  --text-muted:  #8b949e;
  --text-faint:  #555555;
  --accent:      #00a1ff;
  --accent-dim:  rgba(0, 161, 255, 0.12);
  --accent-hover:#38b6ff;
  --border:      #2a2a2a;
  --border-card: #2e2e2e;
  --shadow:      0 2px 16px rgba(0, 0, 0, 0.5);

  --font-sans:   -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:   "Inconsolata", "Courier New", Courier, monospace;

  --max-width:   1200px;
  --post-width:  760px;
  --header-h:    60px;
  --radius:      6px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--header-h);
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.site-logo a {
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.01em;
  transition: color 0.15s, opacity 0.2s;
}
.site-logo a:hover { color: var(--accent); }

html.is-home .site-logo { transition: opacity 0.3s ease; }
html.is-home.at-top .site-logo { opacity: 0; pointer-events: none; }

.site-nav { display: flex; align-items: center; gap: 0.25rem; margin-left: auto; margin-right: 0.5rem; }

.site-nav a {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
}
.site-nav a:hover,
.site-nav a.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* Hamburger (mobile) */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}

/* ── Main layout ────────────────────────────────────────────── */
.site-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 2rem;
}

/* ── Home hero ──────────────────────────────────────────────── */
.home-hero {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.home-title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}
.home-description {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin: 0;
}

/* ── Page hero (about-me, etc.) ──────────────────────────────── */
.m-hero {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  position: relative;
  overflow: hidden;
  min-height: 365px;
  padding: 0;
}

.m-hero.with-picture {
  background: #000;
  color: #fff;
  min-height: 400px;
  box-shadow: inset 0 -1px 0 0 var(--bg);
}

.m-hero__picture {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0.7;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.m-hero__picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

.m-hero__content {
  position: relative;
  z-index: 2;
  text-align: center;
  width: 100%;
  padding: 5rem 2rem 1.5rem;
}
.m-hero__content::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.85));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-mask-image: linear-gradient(to bottom, transparent 50%, black);
  mask-image: linear-gradient(to bottom, transparent 50%, black);
}

.m-hero-title.bigger {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin: 0 0 0.5rem;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.m-hero-description {
  font-size: 0.938rem;
  letter-spacing: 0.3px;
  line-height: 1.5;
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

@media (min-width: 769px) {
  .m-hero.with-picture {
    min-height: 450px;
  }
  .m-hero__content {
    padding: 2rem 2rem;
  }
  .m-hero-title.bigger {
    font-size: 3.25rem;
    letter-spacing: 0.8px;
    margin-bottom: 10px;
  }
  .m-hero-description {
    font-size: 1.125rem;
  }
}

@media (min-width: 1100px) {
  .m-hero.with-picture {
    min-height: 565px;
  }
}

/* ── Wide figure card (profile photo with caption) ────────────── */
.kg-width-wide {
  max-width: calc(var(--post-width) + 200px);
  margin-left: auto;
  margin-right: auto;
}

.kg-width-wide img {
  width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kg-card-hascaption figcaption {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
  font-style: italic;
  text-align: center;
}

/* ── Featured posts ─────────────────────────────────────────── */
.featured-section {
  margin-bottom: 2.5rem;
}

.featured-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 1.25rem;
}

.featured-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.featured-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--accent-dim);
  transform: translateY(-2px);
}

.featured-card-image {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 1;
  transition: transform 0.3s ease;
}

.featured-card:hover .featured-card-image {
  transform: scale(1.03);
}

.featured-card-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 30%,
    rgba(0, 0, 0, 0.85) 100%
  );
}

.featured-card-ribbon {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 3;
  background: var(--accent);
  color: #000;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

.featured-card-content {
  position: relative;
  z-index: 3;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  color: #fff;
  text-decoration: none;
  border-bottom: none;
}

.featured-card-content:hover {
  color: #fff;
  border-bottom: none;
}

.featured-card-tag {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: lowercase;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.featured-card-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
  color: #fff;
}

.featured-card-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.65);
}

@media (max-width: 768px) {
  .featured-grid {
    grid-template-columns: 1fr;
  }
  .featured-card {
    min-height: 260px;
  }
}

/* ── Post grid ──────────────────────────────────────────────── */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.post-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), var(--shadow);
}

/* Cards without images get padding directly */
.post-card:not(.has-image) {
  padding: 1.5rem;
  gap: 0.5rem;
}

/* Post card image */
.post-card-image-link {
  display: block;
  border-bottom: none;
}
.post-card-image-link:hover {
  border-bottom: none;
}

.post-card-image {
  width: 100%;
  height: 160px;
  background-size: cover;
  background-position: center;
  transition: transform 0.25s ease;
}

.post-card:hover .post-card-image {
  transform: scale(1.03);
}

/* Clip the zoom so it doesn't overflow the card */
.post-card.has-image .post-card-image-link {
  overflow: hidden;
}

.post-card-body {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.post-card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
}
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--accent); }

.post-excerpt {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Post meta ──────────────────────────────────────────────── */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}
.post-meta time { color: var(--text-faint); }
.meta-sep { color: var(--text-faint); }

.post-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.tag {
  display: inline-block;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0,161,255,0.3);
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: lowercase;
  transition: background 0.15s, color 0.15s;
}
.tag:hover {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 3rem;
  list-style: none;
  padding: 0;
}
.pagination li {
  list-style: none;
}
.pagination a,
.pagination span,
.pagination .page-link {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
}
.pagination a:hover,
.pagination .page-link:hover { border-color: var(--accent); color: var(--accent); }
.pagination .active .page-link,
.pagination .active { border-color: var(--accent); color: var(--accent); }
.pagination .disabled .page-link { opacity: 0.4; cursor: default; }
.pagination .disabled .page-link:hover { border-color: var(--border-card); color: var(--text-muted); }
.pagination .page-link span {
  border: none;
  padding: 0;
  display: inline;
}

/* ── Single post ────────────────────────────────────────────── */
/* Break hero out of .site-main container to full viewport width */
.site-main > .m-hero {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  margin-top: -3rem; /* offset .site-main padding-top */
  margin-bottom: 0;
}
/* Remove extra gap between hero and post content */
.site-main > .m-hero + .page-single {
  padding-top: 0;
}

.page-single { max-width: 100%; }

.post-header {
  max-width: var(--post-width);
  margin: 0 auto 2.5rem;
}
.m-hero + .page-single .post-header {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}
.post-title {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 1rem;
}

.post-body-wrap {
  display: flex;
  align-items: flex-start;
  gap: 3rem;
  justify-content: center;
}

.post-content {
  max-width: var(--post-width);
  width: 100%;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Table of Contents sidebar ──────────────────────────────── */
.toc-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: calc(var(--header-h) + 2rem);
  max-height: calc(100vh - var(--header-h) - 4rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.toc-sidebar h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin: 0 0 0.75rem;
  padding-left: 0.5rem;
}

/* Hugo renders ToC as nav#TableOfContents > ul */
.toc-sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc-sidebar nav ul ul {
  padding-left: 0.75rem;
}
.toc-sidebar nav li { margin-bottom: 0.1rem; }
.toc-sidebar nav a {
  display: block;
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-left: 2px solid transparent;
  border-radius: 0 3px 3px 0;
  line-height: 1.4;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.toc-sidebar nav a:hover {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--accent-dim);
}
.toc-sidebar nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* ── Post content typography ────────────────────────────────── */
.post-content > * + * { margin-top: 1.25rem; }

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  margin-top: 2.25rem;
  margin-bottom: 0.5rem;
  line-height: 1.3;
  font-weight: 600;
  scroll-margin-top: calc(var(--header-h) + 1.5rem);
}
.post-content h1 { font-size: 1.9rem; }
.post-content h2 { font-size: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 0.4rem; }
.post-content h3 { font-size: 1.2rem; }
.post-content h4 { font-size: 1rem; color: var(--text-muted); }

.post-content p { margin: 0 0 1.2rem; }

.post-content a {
  color: var(--accent);
  border-bottom: 1px solid rgba(0,161,255,0.3);
  transition: border-color 0.15s;
}
.post-content a:hover {
  color: var(--accent-hover);
  border-bottom-color: var(--accent-hover);
}

/* Inline code */
.post-content :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-code-inline);
  border: 1px solid rgba(0,161,255,0.25);
  color: #e0b0ff;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* Code blocks */
.post-content pre {
  background: var(--bg-code);
  border: 1px solid rgba(0,161,255,0.3);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  box-shadow: 0 0 12px rgba(0,161,255,0.05);
}

.post-content pre code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.65;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}


/* ── CRT terminal glow for bash/sh code blocks ───────────── */
.post-content pre:has(> code[class*="language-bash"]),
.post-content pre:has(> code[class*="language-sh"]) {
  background: linear-gradient(#0a0a0a 30%, #000 80%, #111) !important;
  background-size: 400% 4px !important;
  background-repeat: repeat !important;
  text-shadow: 0 0 var(--bash-shadow-size, 2px) currentColor;
  animation: background-blink 0.3s ease infinite;
}
.post-content pre > code[class*="language-bash"],
.post-content pre > code[class*="language-sh"] {
  font-weight: 600;
  font-size: 1.05rem;
  text-shadow: 0 0 var(--bash-shadow-size, 2px) currentColor;
  animation: text-blink 0.2s steps(2) infinite;
}
/* Make each Prism token glow in its own color */
.post-content pre > code[class*="language-bash"] .token,
.post-content pre > code[class*="language-sh"] .token {
  text-shadow: 0 0 var(--bash-shadow-size, 2px) currentColor;
}

@keyframes text-blink {
  0%, 100% { opacity: 0.85; }
  10%      { opacity: 0.93; }
  40%      { opacity: 0.97; }
}
@keyframes background-blink {
  0%, 100% { opacity: 0.97; --bash-shadow-size: 1px; }
  30%      { opacity: 0.96; --bash-shadow-size: 3px; }
  60%      { opacity: 0.95; --bash-shadow-size: 2px; }
}

/* Blockquote */
.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--accent-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  font-style: italic;
}
.post-content blockquote p { margin: 0; }

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}
.post-content th,
.post-content td {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border-card);
  text-align: left;
}
.post-content th {
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
}
.post-content tr:nth-child(even) td { background: rgba(255,255,255,0.02); }

/* Lists */
.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
  margin: 0 0 1.2rem;
}
.post-content li { margin-bottom: 0.3rem; }
.post-content li > ul,
.post-content li > ol { margin-top: 0.3rem; margin-bottom: 0; }

/* Images */
.post-content img {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Video card ─────────────────────────────────────────────── */
.kg-video-card {
  margin: 1.5rem 0;
  text-align: center;
}

.kg-video-card video {
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #000;
}

/* ── PDF viewer ────────────────────────────────────────────── */
.pdf-viewer {
  margin: 1.5rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow);
}

.pdf-viewer object {
  display: block;
  border: none;
  background: #fff;
}

/* ── Mermaid diagrams ──────────────────────────────────────── */
.mermaid {
  margin: 1.5rem 0;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow-x: auto;
}

/* ── Bookmark card (Ghost kg-bookmark) ─────────────────────── */
.kg-bookmark-card {
  margin: 1.5rem 0;
}

.kg-bookmark-container {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.post-content a.kg-bookmark-container {
  border-bottom: 1px solid var(--border-card);
}

.kg-bookmark-container:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), var(--shadow);
  color: var(--text);
}
.post-content a.kg-bookmark-container:hover {
  border-bottom-color: var(--accent);
}

.kg-bookmark-content {
  flex: 1;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.kg-bookmark-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15rem 0.35rem;
}

.kg-bookmark-icon {
  width: 16px;
  height: 16px;
  border-radius: 2px;
  margin: 0;
  box-shadow: none;
  flex-shrink: 0;
}

.kg-bookmark-title {
  flex-basis: 100%;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.kg-bookmark-description {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kg-bookmark-metadata {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.25rem;
}

.kg-bookmark-author,
.kg-bookmark-publisher {
  font-size: 0.75rem;
}

.kg-bookmark-publisher::before {
  content: "\2022";
  margin: 0 0.3rem;
}

.kg-bookmark-thumbnail {
  flex-shrink: 0;
  width: 180px;
  position: relative;
  overflow: hidden;
}

.kg-bookmark-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

/* Hide broken images in bookmark cards */
.kg-bookmark-thumbnail img[data-failed],
.kg-bookmark-icon[data-failed] {
  display: none;
}
/* Collapse empty thumbnail container when image fails */
.kg-bookmark-thumbnail:has(img[data-failed]) {
  display: none;
}

@media (max-width: 600px) {
  .kg-bookmark-container {
    flex-direction: column;
  }
  .kg-bookmark-thumbnail {
    width: 100%;
    height: 160px;
    order: -1;
  }
}

/* ── Code caption ──────────────────────────────────────────── */
.code-caption {
  display: block;
  font-size: 0.8rem;
  color: var(--text-faint);
  font-style: italic;
  text-align: center;
  margin-top: -0.75rem;
  margin-bottom: 1.5rem;
}

/* ── File download card (Ghost kg-file-card) ──────────────────── */
.kg-file-card {
  margin: 1.5rem 0;
}

.kg-file-card-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.post-content a.kg-file-card-container {
  border-bottom: 1px solid var(--border-card);
}

.kg-file-card-container:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-dim), var(--shadow);
  color: var(--text);
}
.post-content a.kg-file-card-container:hover {
  border-bottom-color: var(--accent);
}

.kg-file-card-contents {
  flex: 1;
  min-width: 0;
}

.kg-file-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.kg-file-card-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.kg-file-card-metadata {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.kg-file-card-filename {
  font-weight: 500;
}

.kg-file-card-filesize {
  opacity: 0.8;
}

.kg-file-card-filesize::before {
  content: "\2022";
  margin-right: 0.5rem;
}

.kg-file-card-icon {
  flex-shrink: 0;
  margin-left: 1.5rem;
}

.kg-file-card-icon svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

/* ── Masonry gallery (CSS Grid, auto-built by JS) ──────────── */
/*
 * 3-column CSS Grid with dense packing. JS classifies each image
 * by aspect ratio and assigns grid spans via CSS custom properties:
 *   portrait  (ratio < 0.85) → 1 col, 2 rows (tall — double height)
 *   landscape (ratio ≥ 0.85) → 1 col, 1 row
 *   very-wide (ratio ≥ 2.0)  → 2 cols, 1 row
 * grid-auto-flow: dense fills gaps left by tall portraits.
 */
.masonry-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 180px;
  grid-auto-flow: dense;
  gap: 0.5rem;
  margin: 1.5rem 0;
  max-width: calc(var(--post-width) + 200px);
  margin-left: auto;
  margin-right: auto;
}

.masonry-gallery-item {
  grid-column: span var(--col-span, 1);
  grid-row: span var(--row-span, 1);
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: relative;
}

.masonry-gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: zoom-in;
  transition: transform 0.25s ease, filter 0.25s ease;
}

.masonry-gallery-item:hover img {
  transform: scale(1.04);
  filter: brightness(1.08);
}

@media (max-width: 768px) {
  .masonry-gallery {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 150px;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .masonry-gallery {
    grid-auto-rows: 120px;
  }
}

/* ── GLightbox dark theme overrides ────────────────────────────── */
.glightbox-clean .gslide-description {
  background: var(--bg-card);
  color: var(--text);
}
.glightbox-clean .gclose,
.glightbox-clean .gnext,
.glightbox-clean .gprev {
  filter: invert(1);
}

/* Make glightbox links not look like text links */
.post-content a.glightbox {
  border-bottom: none;
}
.post-content a.glightbox:hover {
  border-bottom: none;
}

.post-content figure {
  margin: 1.5rem 0;
  text-align: center;
}
.post-content figcaption {
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
  font-style: italic;
}

/* Horizontal rule */
.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* ── YouTube embed ───────────────────────────────────────────── */
.youtube-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 1.5rem 0;
  border-radius: var(--radius);
  border: 1px solid rgba(0,161,255,0.2);
  box-shadow: var(--shadow);
}
.youtube-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}

/* ── Post author box ────────────────────────────────────────── */
.post-author {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  max-width: var(--post-width);
  margin: 3rem auto 2rem;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
}
.post-author__avatar {
  flex-shrink: 0;
}
.post-author__avatar img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
}
.post-author__name {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  color: var(--accent);
}
.post-author__bio {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ── Post navigation ────────────────────────────────────────── */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--post-width);
  margin: 4rem auto 0;
  padding-top: 2rem;
}
.post-nav-prev,
.post-nav-next { max-width: 48%; }
.post-nav-next { text-align: right; margin-left: auto; }
.post-nav-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 0.25rem;
}
.post-nav a { font-size: 0.9rem; font-weight: 500; color: var(--text-muted); }
.post-nav a:hover { color: var(--accent); }

/* ── Tag page ───────────────────────────────────────────────── */
.list-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.list-title {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
}
.tag-label { color: var(--text-faint); font-weight: 400; }
.list-description { color: var(--text-muted); margin: 0; font-size: 0.9rem; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  margin-top: 5rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.825rem;
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }
.footer-links { margin-top: 0.5rem; display: flex; justify-content: center; gap: 1.25rem; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-card); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .toc-sidebar { display: none; }
  .post-body-wrap { justify-content: flex-start; }
}

@media (max-width: 768px) {
  .site-main { padding: 2rem 1.25rem; }
  .post-grid { grid-template-columns: 1fr; }
  .post-title { font-size: 1.5rem; }
  .post-header { margin-bottom: 1.5rem; }

  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0; right: 0;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 2rem;
    gap: 0.25rem;
  }
  .site-nav.open { display: flex; }
  .nav-toggle { display: flex; order: 3; }

  .post-nav { flex-direction: column; gap: 0; }
  .post-nav-prev,
  .post-nav-next { max-width: 100%; padding: 1rem 0; }
  .post-nav-prev { border-bottom: 1px solid var(--border-card); }
  .post-nav-next { text-align: left; margin-left: 0; }
}

@media (max-width: 480px) {
  .site-header-inner { padding: 0 1.25rem; }
  .site-main { padding: 1.5rem 1rem; }
  .home-title { font-size: 1.4rem; }
}

/* ── Search ──────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.search-trigger {
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0.25rem;
  border-radius: 6px; transition: color 0.2s;
}
@media (max-width: 768px) {
  .search-trigger { order: 2; margin-left: auto; margin-right: 1rem; }
}
.search-trigger svg { width: 18px; height: 18px; display: block; }
.search-trigger:hover { color: var(--accent); }

#search-modal {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 8vh;
}
#search-modal[hidden] { display: none; }

.search-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.search-box {
  position: relative; z-index: 1;
  width: min(640px, calc(100vw - 2rem));
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
  overflow: hidden;
}

.search-input-row {
  display: flex; align-items: center;
  padding: 0.75rem 1rem; gap: 0.5rem;
  border-bottom: 1px solid var(--border-card);
}
.search-input-row .search-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  color: var(--text-muted);
}

#search-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 1rem;
  font-family: var(--font-sans);
}
#search-input::placeholder { color: var(--text-muted); }
#search-input::-webkit-search-cancel-button { display: none; }

.search-esc-hint {
  font-size: 0.7rem; color: var(--text-muted);
  background: var(--bg); border: 1px solid var(--border-card);
  border-radius: 4px; padding: 0.15em 0.45em;
  font-family: var(--font-mono); flex-shrink: 0;
}

#search-results {
  max-height: 60vh; overflow-y: auto;
  padding: 0.5rem 0;
}
#search-results:empty { display: none; }

.search-result-card {
  display: block; padding: 0.75rem 1rem;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border-card);
  transition: background 0.15s;
}
.search-result-card:last-child { border-bottom: none; }
.search-result-card:hover,
.search-result-card:focus { background: var(--bg); outline: none; }
.search-result-card:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.search-result-title {
  font-size: 0.95rem; font-weight: 600;
  color: var(--text); margin-bottom: 0.2rem;
}
.search-result-meta {
  font-size: 0.78rem; color: var(--text-muted);
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 0.3rem;
}
.search-result-desc {
  font-size: 0.82rem; color: var(--text-muted);
  line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.search-result-tag {
  background: rgba(0,161,255,0.12); color: var(--accent);
  border-radius: 4px; padding: 0.1em 0.45em; font-size: 0.72rem;
}

.search-status {
  padding: 1.5rem 1rem; text-align: center;
  color: var(--text-muted); font-size: 0.875rem;
}
