/* ── Design Tokens ─────────────────────────────────── */

/* Fallback = dark (also used when JS is disabled) */
:root,
html[data-theme="dark"] {
  --bg:         #080b0f;
  --surface-1:  #0d1117;
  --surface-2:  #131920;
  --surface-3:  #1a2232;
  --accent:     #4f8ef7;
  --accent-dim: rgba(79,142,247,.12);
  --green:      #22c55e;
  --red:        #ef4444;
  --text-1:     #e2e8f0;
  --text-2:     #94a3b8;
  --text-3:     #4a5568;
  --border:     rgba(255,255,255,.07);
  --border-r:   4px;
  --font-mono:  'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --font-sans:  system-ui, -apple-system, sans-serif;
}


html[data-theme="light"] {
  --bg:         #f0f2f5;
  --surface-1:  #ffffff;
  --surface-2:  #f8f9fa;
  --surface-3:  #e9ecef;
  --accent:     #2563eb;
  --accent-dim: rgba(37,99,235,.10);
  --green:      #16a34a;
  --red:        #dc2626;
  --text-1:     #111827;
  --text-2:     #374151;
  --text-3:     #9ca3af;
  --border:     rgba(0,0,0,.10);
  --border-r:   4px;
  --font-mono:  'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  --font-sans:  system-ui, -apple-system, sans-serif;
}

/* ── Header Actions ─────────────────────────────────── */
.header-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.rss-btn {
  display: inline-flex;
  align-items: center;
  color: #f26522;
  flex-shrink: 0;
  transition: transform .15s, opacity .15s;
  line-height: 1;
}

.rss-btn:hover { transform: scale(1.25); opacity: .8; text-decoration: none; }
.rss-btn svg  { display: block; }

/* ── Theme Switcher ─────────────────────────────────── */
.theme-switcher {
  display: flex;
  gap: .45rem;
  align-items: center;
}

.theme-dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}

.theme-dot:hover              { transform: scale(1.25); }
.theme-dot.active             { border-color: var(--text-1); }
.theme-dot[data-t="dark"]     { background: #4f8ef7; }
.theme-dot[data-t="light"]    { background: #e2e8f0; border: 2px solid #9ca3af; }

/* ── Font Loading ───────────────────────────────────── */
/* font-display:swap prevents invisible text during font load */
@font-face {
  font-family: 'JetBrains Mono';
  font-display: swap;
}

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

/* ── Base ──────────────────────────────────────────── */
html { font-size: 15px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

/* ── Layout ────────────────────────────────────────── */
.container {
  width: min(860px, 100% - 2rem);
  margin-inline: auto;
  padding-block: 2rem;
  flex: 1;
}

/* ── Header ────────────────────────────────────────── */
.site-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header .logo {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-1);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: .6rem;
}

.site-header .logo:hover { color: var(--accent); }

.site-header .tagline {
  font-size: .75rem;
  font-weight: 400;
  color: var(--text-3);
}

/* ── Post Card ─────────────────────────────────────── */
article.post {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  transition: border-color .15s;
  /* Skip rendering off-screen cards — measurably improves LCP on long listing pages */
  content-visibility: auto;
  contain-intrinsic-size: 0 160px;
}

article.post:hover { border-color: var(--text-3); }

article.post h1,
article.post h2 {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: .25rem;
}

article.post h1 a,
article.post h2 a {
  color: var(--text-1);
}

article.post h1 a:hover,
article.post h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

article.post time {
  display: block;
  font-size: .75rem;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-bottom: .75rem;
}

.preview { color: var(--text-2); font-size: .9rem; margin-bottom: .75rem; }

.read-more {
  font-size: .8rem;
  font-family: var(--font-mono);
  color: var(--accent);
}

/* ── Full Article ──────────────────────────────────── */
article.post--full { max-width: 100%; }

article.post--full h1 {
  font-size: 1.3rem;
  margin-bottom: .25rem;
}

.content-body {
  color: var(--text-1);
  font-size: .95rem;
  margin-top: 1.25rem;
}

.content-body p   { margin-bottom: 1rem; }
.content-body ul  { margin: .75rem 0 .75rem 1.5rem; }
.content-body li  { margin-bottom: .3rem; }
.content-body strong { color: var(--text-1); }

/* ── Code Block ────────────────────────────────────── */
pre.codeblock {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: var(--border-r);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--green);
  line-height: 1.55;
  margin-block: 1rem;
  white-space: pre;
  position: relative;
}

.copy-btn {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: .7rem;
  padding: .2em .55em;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s;
}

pre.codeblock:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--accent); }

/* ── Pagination ────────────────────────────────────── */
.pagination {
  display: flex;
  gap: .4rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.pagination a, .pager-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding-inline: .5rem;
  border-radius: var(--border-r);
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-2);
  background: var(--surface-1);
  border: 1px solid var(--border);
  text-decoration: none;
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination a.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.pager-dots { border-color: transparent; background: transparent; color: var(--text-3); }

/* ── Footer ────────────────────────────────────────── */
.site-footer {
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: .85rem;
  font-size: .78rem;
  color: var(--text-3);
}

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

/* ── 404 ───────────────────────────────────────────── */
.not-found {
  text-align: center;
  padding: 4rem 1rem;
}

.not-found h1 {
  font-family: var(--font-mono);
  font-size: 5rem;
  color: var(--text-3);
  line-height: 1;
}

.not-found p { color: var(--text-2); margin-top: .75rem; }

/* ── Error ─────────────────────────────────────────── */
.error { color: var(--red); font-family: var(--font-mono); font-size: .85rem; }

/* ── About / Impressum ──────────────────────────────── */
.about-page {
  max-width: 720px;
}

.about-section {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.about-section h1 {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-1);
}

.about-section h2 {
  font-family: var(--font-mono);
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: .75rem;
}

.about-section h3 {
  font-family: var(--font-mono);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
  margin: 1.25rem 0 .6rem;
}

.about-section p {
  color: var(--text-2);
  font-size: .9rem;
  margin-bottom: .75rem;
  line-height: 1.75;
}

.about-section p:last-child { margin-bottom: 0; }

.about-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.about-list li {
  font-size: .9rem;
  color: var(--text-2);
  padding-left: 1rem;
  border-left: 2px solid var(--accent-dim);
  line-height: 1.65;
}

.about-list li strong { color: var(--text-1); }

.about-list code {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--green);
  background: var(--surface-2);
  padding: .1em .35em;
  border-radius: 3px;
}

.about-repo {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.about-repo-link {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: var(--font-mono);
  font-size: .82rem;
  color: var(--text-2);
  transition: color .15s;
}

.about-repo-link:hover { color: var(--accent); text-decoration: none; }

/* ── Stats Page ─────────────────────────────────────── */
.stats-kpi {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.kpi-box {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  padding: 1rem 1.5rem;
  min-width: 120px;
}

.kpi-num {
  font-family: var(--font-mono);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.kpi-lbl {
  font-size: .78rem;
  color: var(--text-3);
  margin-top: .35rem;
}

.stats-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.stats-tbl th,
.stats-tbl td {
  padding: .55rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.stats-tbl th {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-3);
  font-weight: 600;
}

.stats-tbl tr:hover td { background: var(--surface-2); }

/* ── Article Meta (date + reading time) ─────────────── */
.article-meta {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .75rem;
}

article.post time   { display: inline; margin-bottom: 0; }
.reading-time {
  font-size: .75rem;
  color: var(--text-3);
  font-family: var(--font-mono);
}

/* ── Article Navigation (prev/next) ─────────────────── */
.article-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.article-nav__item {
  display: block;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  padding: .75rem 1rem;
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--text-2);
  transition: border-color .15s, color .15s;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.article-nav__item:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.article-nav__next { text-align: right; }

/* ── Table of Contents ──────────────────────────────── */
.toc {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-dim);
  border-radius: var(--border-r);
  padding: .85rem 1rem;
  margin-bottom: 1.5rem;
  font-size: .85rem;
}

.toc-title {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .5rem;
}

.toc-list {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.toc-list li { color: var(--text-2); }
.toc-list li.toc-sub { margin-left: 1rem; }
.toc-list a { color: var(--text-2); font-size: .85rem; }
.toc-list a:hover { color: var(--accent); text-decoration: none; }

/* ── Search ─────────────────────────────────────────── */
.search-btn {
  display: inline-flex;
  align-items: center;
  color: var(--text-2);
  flex-shrink: 0;
  transition: transform .15s, color .15s;
  line-height: 1;
}

.search-btn:hover { transform: scale(1.25); color: var(--accent); text-decoration: none; }
.search-btn svg   { display: block; }

.search-page { max-width: 720px; }

.search-form {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

.search-input {
  flex: 1;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  padding: .55rem .85rem;
  font-family: var(--font-sans);
  font-size: .9rem;
  color: var(--text-1);
  outline: none;
  transition: border-color .15s;
}

.search-input:focus { border-color: var(--accent); }

.search-submit {
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--border-r);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: .82rem;
  padding: .55rem 1rem;
  cursor: pointer;
  transition: background .15s;
}

.search-submit:hover { background: var(--accent); color: var(--bg); }

.search-count { color: var(--text-3); font-size: .82rem; margin-bottom: 1rem; font-family: var(--font-mono); }
.search-none  { color: var(--text-2); }
.search-result time { margin-bottom: 0; }

.search-tags { margin-top: .25rem; }
.search-tags--below { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.search-tags__label { font-size: .8rem; color: var(--text-3); font-family: var(--font-mono); margin-bottom: .65rem; }

/* ── Tags ───────────────────────────────────────────── */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .6rem;
}

.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .15em .5em;
  text-decoration: none;
  transition: color .12s, border-color .12s;
}

.tag:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
.tag--untagged { color: var(--text-3); border-style: dashed; }
.tag--untagged:hover { color: var(--red); border-color: var(--red); }

.tag--lg {
  font-size: .82rem;
  padding: .25em .65em;
}

.tag-count {
  color: var(--text-3);
  font-size: .75em;
}

/* Tag index page */
.tag-index__title,
.tag-page__title {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 1.25rem;
}

.tag-page__count { color: var(--text-3); font-weight: 400; }

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

/* ── Highlight (search match) ───────────────────────── */
mark {
  background: rgba(79,142,247,.25);
  color: inherit;
  border-radius: 2px;
  padding: 0 .1em;
}

html[data-theme="light"] mark { background: rgba(37,99,235,.18); }

/* ── Breadcrumb ─────────────────────────────────────── */
.breadcrumb {
  margin-bottom: 1.25rem;
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem;
  padding: 0;
  margin: 0;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-3);
}

.breadcrumb__item + .breadcrumb__item::before {
  content: '/';
  color: var(--text-3);
  margin-right: .3rem;
}

.breadcrumb__item a { color: var(--text-3); }
.breadcrumb__item a:hover { color: var(--accent); text-decoration: none; }
.breadcrumb__item--active { color: var(--text-2); }

/* ── Related Articles ───────────────────────────────── */
.related-articles {
  margin-top: 1.25rem;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  padding: 1.25rem 1.5rem;
}

.related-articles__title {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .75rem;
}

.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.related-list a {
  font-size: .88rem;
  color: var(--text-2);
}

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

/* ── Archive ────────────────────────────────────────── */
.archive-page__title {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 1.5rem;
}

.archive-page__total {
  font-weight: 400;
  color: var(--text-3);
  font-size: .85rem;
}

.archive-year {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--border-r);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.archive-year summary {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1.5rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  font-family: var(--font-mono);
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .04em;
  transition: color .15s;
}

.archive-year summary::-webkit-details-marker { display: none; }
.archive-year summary::before {
  content: '▶';
  font-size: .65rem;
  color: var(--text-3);
  transition: transform .2s;
  display: inline-block;
}

.archive-year[open] summary::before { transform: rotate(90deg); }
.archive-year summary:hover { color: var(--accent); }

.archive-year__count {
  font-weight: 400;
  color: var(--text-3);
  font-size: .8em;
}

.archive-list {
  list-style: none;
  padding: 0 1.5rem;
  margin: 0 0 .5rem;
  display: flex;
  flex-direction: column;
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding: .4rem 0;
  border-bottom: 1px solid var(--border);
}

.archive-item:last-child { border-bottom: none; }

.archive-item__date {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--text-3);
  flex-shrink: 0;
  width: 11ch;
}

.archive-item__title {
  font-size: .88rem;
  color: var(--text-1);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.archive-item .post-tags {
  flex-shrink: 0;
  margin-bottom: 0;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 600px) {
  article.post { padding: 1rem; }
  .site-header .tagline { display: none; }
}
