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

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

:root {
  --bg: #fafaf8;
  --surface: #f0ede8;
  --border: #e0ddd8;
  --border-light: #eceae6;
  --text: #141414;
  --text-muted: #555;
  --text-faint: #999;
  --accent: #e87830;
  --text-body: #222;
  --code-bg: #1a1918;
  --font-body: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --surface: #1c1b19;
    --border: #2a2826;
    --border-light: #201f1d;
    --text: #dedad6;
    --text-muted: #888;
    --text-faint: #555;
    --text-body: #c0bcb8;
    --code-bg: #0a0908;
    --accent: #e87830;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111110;
  --surface: #1c1b19;
  --border: #2a2826;
  --border-light: #201f1d;
  --text: #dedad6;
  --text-muted: #888;
  --text-faint: #555;
  --text-body: #c0bcb8;
  --code-bg: #0a0908;
  --accent: #e87830;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fafaf8;
  --surface: #f0ede8;
  --border: #e0ddd8;
  --border-light: #eceae6;
  --text: #141414;
  --text-muted: #555;
  --text-faint: #999;
  --accent: #e87830;
  --text-body: #222;
  --code-bg: #1a1918;
  color-scheme: light;
}

::selection {
  background: #e0d8cc;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) ::selection {
    background: #3a3530;
    color: #e8e0d8;
  }
}

:root[data-theme="dark"] ::selection {
  background: #3a3530;
  color: #e8e0d8;
}

/* ── Base ── */

html {
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
}

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

/* ── Layout ── */

.site-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
}

/* ── Header ── */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}

.site-name {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: color 0.15s;
}

.site-name:hover {
  color: var(--text-muted);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-family: var(--font-mono);
  font-size: 12px;
}

.nav-link {
  color: var(--text-faint);
  transition: color 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text-muted);
}

.theme-toggle {
  font-size: 13px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  color: var(--text-faint);
  transition: color 0.15s;
}

.theme-toggle:hover {
  color: var(--text-muted);
}

/* ── Footer ── */

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.footer-links {
  display: flex;
  gap: 0.75rem;
}

.footer-links a {
  color: var(--text-faint);
  transition: color 0.2s;
  display: flex;
}

.footer-links a:hover {
  color: var(--text-muted);
}

/* ── Post list ── */

.post-list {
  list-style: none;
}

.post-item {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.75rem 0;
  color: var(--text);
  transition: opacity 0.15s;
}

.post-list li + li .post-item {
  border-top: 1px solid var(--border-light);
}

.post-item:hover {
  opacity: 0.7;
}

.post-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}

.post-title {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
}

.post-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  margin-left: auto;
  flex-shrink: 0;
  text-transform: lowercase;
}

/* ── Article header ── */

.article-header {
  margin-bottom: 1.75rem;
}

.article-title {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.article-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0;
}

.article-meta span + span::before {
  content: "\00b7";
  margin: 0 0.5rem;
  color: var(--border);
}

.meta-chip {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 2px;
  vertical-align: 1px;
}

.article-meta .meta-chip {
  margin-left: 0.5rem;
}

.article-meta .meta-chip::before {
  content: none;
  margin: 0;
}

/* ── Prose ── */

.article-body p {
  margin-bottom: 1.4rem;
  color: var(--text-body);
}

.article-body h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin: 3rem 0 0.75rem;
  letter-spacing: -0.01em;
}

.article-body h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 2rem 0 0.5rem;
}

.article-body p + ul,
.article-body p + ol {
  margin-top: -0.7rem;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.4rem 1.25rem;
  color: var(--text-body);
  font-size: 0.95rem;
  line-height: 1.75;
}

.article-body li {
  margin-bottom: 0.1rem;
  padding-left: 0.25rem;
}

.article-body li::marker {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
}

.article-body blockquote {
  border-left: 2px solid var(--accent);
  margin: 1.25rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
}

.article-body blockquote p {
  color: var(--text-muted);
  margin-bottom: 0;
}

.article-body a {
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  color: var(--text);
  transition: color 0.15s, text-decoration-color 0.15s;
}

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

/* ── Inline code ── */

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--text);
  background: var(--surface);
  padding: 2px 5px;
  border-radius: 3px;
}

/* ── Code blocks ── */

.article-body pre {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
  overflow-x: auto;
  white-space: pre;
  line-height: 1.7;
  color: #b8b0a8;
  border-radius: 4px;
}

.article-body pre code {
  background: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  border-radius: 0;
}

.article-body .highlight {
  margin: 0.75rem 0;
  position: relative;
  overflow-x: auto;
}

.article-body .highlight pre {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  white-space: pre;
  overflow-x: visible;
}

/* ── Tables ── */

.article-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin: 1rem 0;
}

.article-body th {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  text-align: left;
  padding: 0.5rem 1rem 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.article-body td {
  padding: 0.5rem 1rem 0.5rem 0;
  color: var(--text-body);
  font-size: 15px;
}

.article-body tr + tr td {
  border-top: 1px solid var(--border-light);
}

/* ── HR ── */

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── Images ── */

.article-body img {
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 3px;
  margin: 1.25rem 0 0.25rem;
  display: block;
  opacity: 0.92;
}

.article-body figure.img-caption {
  display: inline-block;
  margin: 1.25rem 0 1.5rem;
}

.article-body figure.img-caption img {
  display: block;
  margin: 0;
}

.article-body figure.img-caption figcaption {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #666;
  margin-top: 0.4rem;
}

/* ── Code scrollbars ── */

.article-body pre::-webkit-scrollbar {
  height: 4px;
}

.article-body pre::-webkit-scrollbar-track {
  background: transparent;
}

.article-body pre::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 2px;
}

/* ── Copy button ── */

.copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.03em;
  color: var(--text-faint);
  background: none;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 2px 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.highlight:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  color: var(--text-muted);
}

/* ── Code block selection ── */

.highlight ::selection,
.article-body pre ::selection {
  background: #3a3530;
  color: #e8e0d8;
}

/* ── Post navigation ── */

.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 4rem;
  padding-top: 1.5rem;
  gap: 2rem;
}

.post-nav a {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  transition: color 0.15s;
  max-width: 50%;
}

.post-nav a:hover { color: var(--text); }

.post-nav-label {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 0.3rem;
}

.post-nav-next { text-align: right; margin-left: auto; }

/* ── Page header ── */

.page-header {
  margin-bottom: 2.5rem;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ── Table of contents ── */

.toc {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  margin-bottom: 1.5rem;
}

.toc:empty { display: none; }

.toc-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}

.toc-toggle:hover { color: var(--text-muted); }
.toc-toggle::before { content: '+ '; }
.toc.open .toc-toggle::before { content: '- '; }

.toc-list {
  border-left: 1px solid var(--border);
  padding-left: 1rem;
  display: none;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.5rem;
}

.toc.open .toc-list { display: flex; }

.toc a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
  display: block;
}

.toc a:hover { color: var(--text); }

.toc a.toc-sub {
  padding-left: 1rem;
  color: var(--text-faint);
  font-size: 10px;
}

.toc a.toc-sub:hover { color: var(--text-muted); }

/* ── @mentions ── */

.article-body a.mention {
  font-family: var(--font-mono);
  font-size: 0.8em;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--surface);
  padding: 1px 4px;
  border-radius: 3px;
  transition: color 0.15s;
}

.article-body a.mention:hover {
  color: var(--text);
}

/* ── Heading anchors ── */

.article-body h2,
.article-body h3 {
  position: relative;
}

.heading-anchor {
  position: absolute;
  left: -1.1em;
  color: var(--border);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.85em;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.article-body h2:hover .heading-anchor,
.article-body h3:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
  color: var(--text-faint);
}

/* ── View counts ── */

.view-count:empty,
.post-views:empty { display: none; }

.view-count:not(:empty)::before {
  content: "\00b7";
  margin: 0 0.5rem;
  color: var(--border);
}

.post-views:not(:empty)::before {
  content: "\00b7";
  margin: 0 0.35rem;
}

/* ── Heading flash ── */

@keyframes headingFlash {
  0%   { color: var(--text); }
  30%  { color: var(--text-muted); }
  100% { color: var(--text); }
}

.heading-flash { animation: headingFlash 1s ease-out; }

/* ── Resume toast ── */

.resume-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  opacity: 0;
  transform: translateY(0.5rem);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 50;
}

.resume-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.resume-toast:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

/* ── About page ── */

.about-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.pfp {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.about-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}


.about-role {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* ── Search ── */

.header-search {
  display: none;
  align-items: center;
  position: relative;
}

.header-search.open { display: flex; }

.search-input {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  background: none;
  border: none;
  outline: none;
  width: 140px;
  padding: 0;
}

.search-input::placeholder { color: var(--text-faint); }

.search-dropdown {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow-y: auto;
  max-height: 260px;
  z-index: 100;
  min-width: 260px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.search-dropdown:empty { display: none; }

.search-result {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
}

.search-result + .search-result { border-top: 1px solid var(--border-light); }

.search-result:hover,
.search-result.sr-active { background: var(--surface); }

.search-result-title {
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.search-result-date {
  color: var(--text-faint);
  font-size: 10px;
  flex-shrink: 0;
}

.search-result-preview {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  margin-top: 0.15rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-preview mark {
  background: none;
  color: var(--text-muted);
}

/* ── Focus ── */

:focus-visible {
  outline: 1px solid var(--text-faint);
  outline-offset: 2px;
}

/* ── Responsive ── */

@media (max-width: 520px) {
  .site-wrap { padding: 2rem 1.25rem 4rem; }
  .site-header { margin-bottom: 3rem; }
  .article-title { font-size: 22px; }
  .post-item { flex-wrap: wrap; gap: 0.15rem; }
  .post-date { width: 100%; }
  .article-body pre { font-size: 12px; padding: 1rem 1.1rem; }
  .article-body table { font-size: 13px; }
  .post-nav { flex-direction: column; gap: 1rem; }
  .post-nav a { max-width: 100%; }
  .post-nav-next { text-align: left; margin-left: 0; }
  .heading-anchor { display: none; }
  .article-body img { max-width: 100% !important; width: 100% !important; height: auto !important; }
  .article-body figure.img-caption { display: block; }
  .copy-btn { display: none; }
}

/* ── Print ── */

@media print {
  body { background: #fff; font-size: 11pt; }
  .site-wrap { max-width: 100%; padding: 0; }
  .site-header, .site-footer, .post-nav { display: none; }
  .article-body pre {
    background: #f5f5f5 !important;
    color: #333 !important;
    border-color: #ddd !important;
  }
  .article-body a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #888;
  }
}
