/* =============================================
   Imports
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700;800&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

/* =============================================
   Design tokens — terminal palette
   ============================================= */

:root {
  --max-layout-width: 1400px;

  --mono-font: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --sans-serif-font: 'IBM Plex Sans', Helvetica, Arial, sans-serif;

  /* light: warm paper terminal */
  --background-color: #f5f3ec;
  --bg-0: #ece8dc;
  --bg-1: #e1dccb;
  --bg-2: #faf9f4;
  --bg-3: #cfc9b4;
  --hover-color: #14160f;
  --primary-color: #146b3a;
  --accent-amber: #8a5300;
  --divider-color: rgba(20, 22, 15, 0.2);
  --text-color: #191c14;
  --text-color-high-contrast: #0c0e08;
  --meta-color: #5c6151;
  --codeblock-bg: #14171a;
  --codeblock-highlight: #1e2226;
  color-scheme: light;
}

[data-theme='dark'] {
  --background-color: #0a0e0e;
  --bg-0: #111716;
  --bg-1: #182220;
  --bg-2: #0d1312;
  --bg-3: #2a3634;
  --hover-color: #eef5f1;
  --primary-color: #3ef08d;
  --accent-amber: #ffb454;
  --divider-color: rgba(212, 222, 217, 0.18);
  --text-color: #cfdad5;
  --text-color-high-contrast: #eef5f1;
  --meta-color: #86988f;
  --codeblock-bg: #0c1110;
  --codeblock-highlight: #16201d;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --background-color: #0a0e0e;
    --bg-0: #111716;
    --bg-1: #182220;
    --bg-2: #0d1312;
    --bg-3: #2a3634;
    --hover-color: #eef5f1;
    --primary-color: #3ef08d;
    --accent-amber: #ffb454;
    --divider-color: rgba(212, 222, 217, 0.18);
    --text-color: #cfdad5;
    --text-color-high-contrast: #eef5f1;
    --meta-color: #86988f;
    --codeblock-bg: #0c1110;
    --codeblock-highlight: #16201d;
    color-scheme: dark;
  }
}

/* =============================================
   Table of contents — sticky sidebar
   ============================================= */

@media (min-width: 1000px) {
  /* max-layout-width governs .content's width; widen article past its
     theme default (max-layout-width - 12rem) so there's room for the TOC
     gutter on the left without pushing the reading column off-center. */
  article {
    max-width: var(--max-layout-width) !important;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 60%) minmax(0, 1fr);
    column-gap: 2rem;
    align-items: start;
  }

  article > * {
    grid-column: 2;
  }

  /* TOC lives in the left gutter, right-aligned toward the (centered)
     reading column instead of sharing a track with it — the old layout
     put both in one grid track, which shifted the content off-center by
     roughly half the TOC's width. */
  article > .toc-container {
    grid-column: 1;
    grid-row: 1 / 999;
    justify-self: end;
    width: 14rem;
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    align-self: start;
    font-size: 0.78rem;
    line-height: 1.6;
    font-family: var(--mono-font);
    opacity: 0.5;
    transition: opacity 0.2s ease;
  }

  article > .toc-container:hover,
  article > .toc-container:focus-within {
    opacity: 1;
  }

  .toc-container h3 {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.55;
    margin-block: 0 0.6rem;
  }

  .toc-container ul {
    padding-inline-start: 0.75rem;
    border-left: 1px solid var(--divider-color);
  }
}

/* =============================================
   Code blocks
   ============================================= */

pre code::before {
  background-color: color-mix(in srgb, var(--codeblock-bg), white 12%);
  color: rgba(255, 255, 255, 0.4);
}

/* =============================================
   Base typography
   ============================================= */

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--sans-serif-font);
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--mono-font);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h2 {
  border-bottom: 1px solid var(--divider-color);
  padding-bottom: 0.4rem;
}

a {
  transition: color 0.15s ease;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* =============================================
   Link colours
   ============================================= */

main a { color: var(--primary-color); }

main a:hover,
main a:focus {
  color: var(--accent-amber) !important;
  background-color: transparent !important;
}

main a:hover::before,
main a:focus::before {
  display: none !important;
}

/* =============================================
   Page background — faint grid texture
   ============================================= */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--background-color);
  background-image:
    linear-gradient(var(--divider-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--divider-color) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: 0.35;
  pointer-events: none;
}

/* =============================================
   Navbar
   ============================================= */

/* Stylised wordmark instead of the site title text.
   Real DOM elements (see templates/partials/nav.html), not ::before/::after
   generated content — generated content only paints after the stylesheet is
   parsed, so on the dev server a live-reload mid-paint could blank the
   wordmark out entirely and shrink the link's clickable box to nothing. */
.home-title {
  display: inline-flex !important;
  align-items: center;
  gap: 0.28em;
}

.home-title-wordmark {
  font-family: var(--mono-font);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--primary-color);
}

.home-title-typed {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  vertical-align: bottom;
  width: 0;
  margin-inline-start: 0.35em;
  font-weight: 500;
  letter-spacing: normal;
  color: var(--meta-color);
  animation: type-welcome 1.6s steps(19, end) 1 both;
  animation-delay: 0.4s;
}

@keyframes type-welcome {
  from { width: 0; }
  to { width: 19ch; }
}

.home-title-cursor {
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  margin-inline-start: 0.15em;
  vertical-align: -0.15em;
  background: var(--text-color-high-contrast);
  animation: blink 1s steps(1) infinite;
}

body > header {
  position: sticky;
  top: 0;
  z-index: 100;
  margin-inline: -5vmin;
  padding-inline: 5vmin;
  background: var(--background-color) !important;
  border-bottom: 1px solid var(--divider-color);
}

body > header nav a {
  font-family: var(--mono-font);
  font-size: 0.9rem;
}

body > header nav a:hover,
body > header nav a:focus {
  background: transparent !important;
  border-radius: 0 !important;
  color: var(--primary-color) !important;
  text-decoration: underline;
  text-underline-offset: 4px;
}

body > header nav a:hover::before,
body > header nav a:focus::before {
  display: none !important;
}

/* =============================================
   Flat panel utility (formerly "glass")
   ============================================= */

.glass {
  background: var(--bg-2);
  border: 1px solid var(--divider-color);
  border-radius: 0;
}

/* =============================================
   Animations
   ============================================= */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes blink {
  0%, 49%  { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* =============================================
   Homepage intro card
   ============================================= */

.intro-grid {
  display: flex;
  gap: 2rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 2rem;
  animation: fadeInUp 0.5s ease both;
}

.intro-grid-text {
  flex: 1;
  min-width: 250px;
  font-size: 1.05rem;
  line-height: 1.75;
}

/* =============================================
   Eyebrow label
   ============================================= */

.eyebrow {
  font-family: var(--mono-font);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-amber);
  margin: 0 0 0.5rem;
}

/* =============================================
   Stat row
   ============================================= */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--divider-color);
  border: 1px solid var(--divider-color);
  margin: 1.5rem 0;
}

.stat {
  background: var(--bg-2);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stat-number {
  font-family: var(--mono-font);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-color);
}

.stat-label {
  font-family: var(--mono-font);
  font-size: 0.72rem;
  color: var(--meta-color);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

@media (max-width: 700px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

/* =============================================
   Grouped skill tags
   ============================================= */

.skill-groups {
  margin-top: 0.75rem;
}

.skill-groups p {
  font-family: var(--mono-font);
  font-size: 0.82rem;
  color: var(--text-color);
  margin: 0.35rem 0;
}

.skill-group-label {
  display: inline-block;
  min-width: 11rem;
  color: var(--meta-color);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  margin-right: 0.5rem;
}

/* =============================================
   Social links
   ============================================= */

.social-links {
  display: flex;
  gap: 0.4rem;
  margin-top: 1.25rem;
  align-items: center;
  flex-wrap: wrap;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0;
  font-size: 0.72rem;
  white-space: nowrap;
  font-family: var(--mono-font);
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  background: transparent;
  border: 1px solid var(--divider-color);
  color: var(--text-color) !important;
}

.social-link img {
  width: 14px;
  height: 14px;
}

[data-theme="dark"] .social-link img {
  filter: invert(1);
}

.social-links .social-link:hover::before,
.social-links .social-link:focus::before {
  display: none !important;
}

.social-links .social-link:hover,
.social-links .social-link:focus {
  text-decoration: none;
  background: var(--primary-color) !important;
  border-color: var(--primary-color);
  color: var(--background-color) !important;
  outline: none;
}

.social-link:hover img,
.social-link:focus img {
  filter: none;
}

/* =============================================
   Avatar
   ============================================= */

.intro-grid-avatar {
  flex-shrink: 0;
  width: 28%;
  min-width: 140px;
  text-align: center;
}

.intro-grid-avatar img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 0;
  object-fit: cover;
  border: 1px solid var(--divider-color);
}

/* =============================================
   Project cards
   ============================================= */

.projects-grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}

.project-card-wrapper {
  transition: transform 0.2s ease;
}

.project-card-wrapper:hover {
  transform: translateY(-3px);
}

.project-card {
  position: relative;
  border-radius: 0;
  padding: 0.85rem 1.1rem;
  background: var(--bg-2);
  border: 1px solid var(--divider-color);
  border-left: 3px solid var(--meta-color);
  box-shadow: none;
  transition: background-color 0.2s ease;
}

.project-card a:hover::before {
  display: none !important;
}

.project-card.lang-rust { border-left-color: #dea584; }
.project-card.lang-cpp { border-left-color: #f34b7d; }
.project-card.lang-python { border-left-color: #3572a5; }
.project-card.lang-lua { border-left-color: #000080; }
.project-card.lang-shell { border-left-color: #89e051; }
.project-card.lang-javascript { border-left-color: #f1e05a; }
.project-card.lang-typescript { border-left-color: #3178c6; }
.project-card.lang-c { border-left-color: #555555; }

.project-card-wrapper:hover .project-card {
  background: var(--bg-1);
}

.project-card code {
  font-size: 0.85em;
}

.project-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.project-card-title {
  display: block;
  margin-top: 0;
  font-family: var(--mono-font);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-color-high-contrast);
}

.project-card-stat {
  font-family: var(--mono-font);
  font-size: 0.8rem;
  color: var(--meta-color);
  white-space: nowrap;
}

.project-card-desc {
  margin: 0.4rem 0 0;
}

.project-card-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.4rem;
  font-family: var(--mono-font);
  font-size: 0.8rem;
  color: var(--meta-color);
}

.project-card-lang {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.lang-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  display: inline-block;
}

.lang-dot.lang-rust { background: #dea584; }
.lang-dot.lang-cpp { background: #f34b7d; }
.lang-dot.lang-python { background: #3572a5; }
.lang-dot.lang-lua { background: #000080; }
.lang-dot.lang-shell { background: #89e051; }
.lang-dot.lang-javascript { background: #f1e05a; }
.lang-dot.lang-typescript { background: #3178c6; }
.lang-dot.lang-c { background: #555555; }
.lang-dot.lang-other { background: var(--meta-color); }

.project-card-footer {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.35rem;
}

.project-card-tags {
  font-family: var(--mono-font);
  font-size: 0.8rem;
  color: var(--meta-color);
}

.project-card-link {
  display: inline-block;
  flex-shrink: 0;
  font-family: var(--mono-font);
  font-size: 0.85rem;
  color: var(--primary-color);
}

.project-card-link:hover,
.project-card-link:focus {
  color: var(--accent-amber);
}

.cv-tagline {
  font-size: 1.05rem;
  line-height: 1.75;
  margin: -0.25rem 0 1rem;
  max-width: 60ch;
}

.cv-pdf-link {
  margin-top: -0.5rem;
  font-family: var(--mono-font);
  font-size: 0.85rem;
}

/* =============================================
   CV / About entry panels
   ============================================= */

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 1.25rem 0;
}

.entry {
  border: 1px solid var(--divider-color);
  border-left: 3px solid transparent;
  background: var(--bg-2);
  padding: 1rem 1.25rem;
  opacity: 0;
  animation: fadeInUp 0.4s ease forwards;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.entry:hover {
  border-left-color: var(--primary-color);
  background: var(--bg-1);
}

.entry-list .entry:nth-child(1)  { animation-delay: 0.02s; }
.entry-list .entry:nth-child(2)  { animation-delay: 0.06s; }
.entry-list .entry:nth-child(3)  { animation-delay: 0.10s; }
.entry-list .entry:nth-child(4)  { animation-delay: 0.14s; }
.entry-list .entry:nth-child(5)  { animation-delay: 0.18s; }
.entry-list .entry:nth-child(6)  { animation-delay: 0.22s; }
.entry-list .entry:nth-child(7)  { animation-delay: 0.26s; }
.entry-list .entry:nth-child(8)  { animation-delay: 0.30s; }
.entry-list .entry:nth-child(9)  { animation-delay: 0.34s; }
.entry-list .entry:nth-child(10) { animation-delay: 0.38s; }

.entry-title {
  font-family: var(--mono-font);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text-color-high-contrast);
  margin: 0 0 0.15rem;
}

.entry-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--mono-font);
  font-size: 0.78rem;
  color: var(--meta-color);
  margin: 0 0 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.entry-meta .accent {
  color: var(--accent-amber);
}

.entry-meta .entry-date {
  color: var(--meta-color);
  white-space: nowrap;
}

.entry-body {
  margin: 0;
  line-height: 1.6;
}

.entry-tags {
  margin-top: 0.6rem;
  font-family: var(--mono-font);
  font-size: 0.78rem;
  color: var(--meta-color);
}

.entry-media {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.entry-photo {
  width: 220px;
  max-width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid var(--divider-color);
  flex-shrink: 0;
}

.entry-media > div {
  flex: 1;
  min-width: 220px;
}

/* =============================================
   Post list
   ============================================= */

#posts-list {
  margin-top: 3rem;
}

.bloglist-container {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: visible !important;
  display: flex !important;
  flex-direction: column;
  gap: 0.9rem;
}

.post-card {
  border-radius: 0;
  background: var(--bg-2);
  border: 1px solid var(--divider-color);
  border-left: 3px solid transparent;
  box-shadow: none;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  opacity: 0;
  animation: fadeInUp 0.4s ease forwards;
}

.post-card:nth-child(1) { animation-delay: 0.02s; }
.post-card:nth-child(2) { animation-delay: 0.06s; }
.post-card:nth-child(3) { animation-delay: 0.10s; }
.post-card:nth-child(4) { animation-delay: 0.14s; }
.post-card:nth-child(5) { animation-delay: 0.18s; }
.post-card:nth-child(6) { animation-delay: 0.22s; }

.post-card:hover {
  background: var(--bg-1);
  border-left-color: var(--primary-color);
}

.post-card .bloglist-meta {
  background: transparent !important;
  border-bottom: none !important;
  display: block !important;
  padding: 1rem 1.5rem 0 !important;
  font-family: var(--mono-font);
}

.post-card .bloglist-content {
  background: transparent !important;
  border-bottom: none !important;
  display: block !important;
  padding: 0.5rem 1.5rem 1.25rem !important;
}

.post-card a:hover::before {
  display: none !important;
}

/* =============================================
   Post pages
   ============================================= */

article.h-entry {
  max-width: var(--max-layout-width) !important;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.5rem;
}

/* =============================================
   Reduced motion
   ============================================= */

@media (prefers-reduced-motion: reduce) {
  .intro-grid,
  .post-card,
  .entry {
    animation: none !important;
    opacity: 1 !important;
  }

  .home-title-cursor {
    animation: none !important;
  }

  .home-title-typed {
    animation: none !important;
    width: 19ch !important;
  }
}

/* =============================================
   Post grid (tile index)
   ============================================= */

.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 2rem;
}

.post-tile:nth-child(6n+1) { background: linear-gradient(135deg, #146b3a, #0d4326); }
.post-tile:nth-child(6n+2) { background: linear-gradient(135deg, #8a5300, #5c3600); }
.post-tile:nth-child(6n+3) { background: linear-gradient(135deg, #2a3634, #14171a); }
.post-tile:nth-child(6n+4) { background: linear-gradient(135deg, #3ef08d, #146b3a); }
.post-tile:nth-child(6n+5) { background: linear-gradient(135deg, #ffb454, #8a5300); }
.post-tile:nth-child(6n+0) { background: linear-gradient(135deg, #5c6151, #2a3634); }

.post-tile {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0.75rem;
  border-radius: 0;
  text-decoration: none;
  transition: transform 0.25s ease;
  border: 1px solid var(--divider-color);
  box-shadow: none;
}

.post-tile:hover {
  transform: translateY(-3px);
  z-index: 1;
}

.post-tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.post-tile:hover img { transform: scale(1.05); }

.post-tile:has(img)::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, rgba(0,0,0,0.08) 55%);
  z-index: 1;
}

.post-tile-content {
  position: relative;
  z-index: 2;
  background: rgba(10, 14, 14, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0;
  padding: 0.6rem 0.75rem;
  font-family: var(--mono-font);
}

.post-tile-date {
  font-size: 0.65rem;
  opacity: 0.75;
  margin: 0 0 0.3rem;
  font-weight: 400;
  color: white !important;
}

.post-tile-title {
  font-size: clamp(0.8rem, 1.4vw, 1rem);
  font-weight: 700;
  margin: 0 0 0.4rem;
  line-height: 1.3;
  color: white !important;
}

.post-tile-desc {
  font-size: 0.72rem;
  line-height: 1.35;
  font-weight: 400;
  opacity: 0.85;
  margin: 0 0 0.4rem;
  color: white !important;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

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

.post-tile-tags span {
  font-size: 0.65rem;
  opacity: 0.82;
  color: white !important;
}

.post-tile:hover,
.post-tile:focus {
  color: white !important;
  background-color: unset !important;
}

.post-tile:hover::before,
.post-tile:focus::before { display: none !important; }

.post-tile:has(img):hover::before { display: block !important; }

@media (max-width: 768px) {
  .post-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
}

@media (max-width: 480px) {
  .post-grid { grid-template-columns: repeat(2, 1fr); gap: 4px; }
}

/* =============================================
   Accessibility
   ============================================= */

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

.e-content video {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

/* =============================================
   Mermaid diagrams — click to zoom
   ============================================= */

.diagram-zoomable {
  cursor: zoom-in;
  transition: outline-color 0.15s ease;
  outline: 1px solid transparent;
  outline-offset: 4px;
}

.diagram-zoomable:hover,
.diagram-zoomable:focus-visible {
  outline-color: var(--primary-color);
}

body.diagram-lightbox-open {
  overflow: hidden;
}

.diagram-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: color-mix(in srgb, var(--background-color) 88%, transparent);
  backdrop-filter: blur(2px);
  cursor: zoom-out;
}

.diagram-lightbox[hidden] {
  display: none;
}

.diagram-lightbox-content {
  max-width: 92vw;
  max-height: 88vh;
  overflow: auto;
  cursor: default;
  background: var(--bg-2);
  border: 1px solid var(--bg-1);
  padding: 1.5rem;
}

.diagram-lightbox-content svg,
.diagram-lightbox-content img {
  display: block;
  width: 100%;
  height: auto;
  min-width: 640px;
}

.diagram-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 2rem;
  line-height: 1;
  color: var(--text-color);
  background: transparent;
  border: 1px solid var(--bg-1);
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
}

.diagram-lightbox-close:hover,
.diagram-lightbox-close:focus-visible {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* =============================================
   Print — Cmd/Ctrl+P on /cv/ produces a clean PDF
   from the same markdown, no separate document.
   ============================================= */

@media print {
  :root {
    --background-color: #fff;
    --bg-0: #fff;
    --bg-1: #f4f4f4;
    --bg-2: #fff;
    --bg-3: #eee;
    --primary-color: #000;
    --accent-amber: #000;
    --divider-color: #ccc;
    --text-color: #000;
    --text-color-high-contrast: #000;
    --meta-color: #444;
  }

  body::before,
  body > header,
  footer,
  .toc-container,
  .theme-switcher-wrapper,
  .home-title-cursor,
  .cv-pdf-link,
  a[href="#main-content"] {
    display: none !important;
  }

  @media (min-width: 1000px) {
    article {
      display: block !important;
      max-width: 100% !important;
    }
  }

  body {
    font-size: 11pt;
    line-height: 1.35;
  }

  main a {
    color: #000;
    text-decoration: underline;
  }

  h1 { font-size: 20pt; }
  h2 {
    font-size: 13pt;
    margin-top: 1.1em;
    border-bottom-color: #000;
  }

  .entry,
  .project-card,
  .project-card-wrapper {
    break-inside: avoid;
    background: #fff !important;
    box-shadow: none !important;
    animation: none !important;
    opacity: 1 !important;
  }

  .entry-list,
  .projects-grid {
    gap: 0.5rem;
  }

  .project-card.lang-rust,
  .project-card.lang-cpp,
  .project-card.lang-python,
  .project-card.lang-lua,
  .project-card.lang-shell,
  .project-card.lang-javascript,
  .project-card.lang-typescript,
  .project-card.lang-c {
    border-left-color: #000;
  }

  .project-card-link::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #444;
  }

  code, pre {
    background: #f4f4f4 !important;
    color: #000 !important;
  }
}
