/* ── tokens ── */
:root {
  --bg:         #0f0f0f;
  --bg-subtle:  #1a1a1a;
  --border:     #2a2a2a;
  --text:       #d4d4d4;
  --text-muted: #6b6b6b;
  --accent:     #5b8dd9;
  --accent-dim: #3a5f9e;
  --cve:        #c97b3e;
  --tag-bg:     #1e1e1e;
  --tag-text:   #8fb0d8;
  --code-bg:    #161616;
  --radius:     3px;
  --font-mono:  "JetBrains Mono", "Fira Code", "Cascadia Code", ui-monospace, monospace;
  --font-body:  "Inter", system-ui, -apple-system, sans-serif;
  --font-serif: Georgia, "Times New Roman", serif;
}

[data-theme="light"] {
  --bg:         #f8f8f6;
  --bg-subtle:  #efefed;
  --border:     #dcdcda;
  --text:       #1a1a1a;
  --text-muted: #8a8a8a;
  --accent:     #2755a8;
  --accent-dim: #1a3d7a;
  --cve:        #a0520f;
  --tag-bg:     #e8edf5;
  --tag-text:   #2755a8;
  --code-bg:    #f0f0ee;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.15s, color 0.15s;
}

/* ── layout ── */
.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

main.container { flex: 1; padding-top: 3rem; padding-bottom: 4rem; }

/* ── header ── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-title {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-title::before { content: "~/"; color: var(--text-muted); }

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-nav a {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.1s;
}

.site-nav a:hover,
.site-nav a.active { color: var(--text); }

/* ── theme toggle ── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0.2rem 0.5rem;
  line-height: 1;
  transition: color 0.1s, border-color 0.1s;
}

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

[data-theme="dark"] .icon-sun  { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: inline; }

/* ── footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── home intro ── */
.home-intro {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.tagline {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ── section headings ── */
.section-heading {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.page-header { margin-bottom: 2rem; }
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ── post list ── */
.post-list { display: flex; flex-direction: column; gap: 2rem; }

.post-item { display: flex; flex-direction: column; gap: 0.35rem; }

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.775rem;
  color: var(--text-muted);
}

.post-item h2, .post-item h3 {
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.post-item h2 a, .post-item h3 a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.1s;
}

.post-item h2 a:hover, .post-item h3 a:hover { color: var(--accent); }

.post-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.all-posts-link {
  display: inline-block;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  font-family: var(--font-mono);
  color: var(--accent);
  text-decoration: none;
}

.all-posts-link:hover { color: var(--accent-dim); }

/* ── tags ── */
.tag-list { display: inline-flex; gap: 0.35rem; flex-wrap: wrap; }

.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius);
  text-decoration: none;
  border: 1px solid transparent;
  transition: border-color 0.1s;
}

.tag:hover { border-color: var(--tag-text); }

.tag--large { font-size: 0.8rem; padding: 0.25rem 0.6rem; }

.tag-count { color: var(--text-muted); margin-left: 0.25rem; }

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

/* ── CVE badge ── */
.cve-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--cve);
  border: 1px solid var(--cve);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius);
  letter-spacing: 0.03em;
}

/* ── single post ── */
.post-single { max-width: 100%; }

.post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.3;
  margin-top: 0.6rem;
}

.post-summary.lead {
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.post-content { font-family: var(--font-serif); font-size: 1.05rem; line-height: 1.8; }

.post-content h2,
.post-content h3,
.post-content h4 {
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.post-content h2 { font-size: 1.3rem; }
.post-content h3 { font-size: 1.1rem; }
.post-content h4 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

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

.post-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post-content a:hover { color: var(--accent-dim); }

.post-content ul, .post-content ol {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
}

.post-content li { margin-bottom: 0.3rem; }

.post-content blockquote {
  border-left: 3px solid var(--border);
  padding: 0.5rem 0 0.5rem 1.25rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 1.5rem 0;
}

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

/* ── code ── */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.85rem;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Chroma: line numbers column */
.post-content .lntd:first-child {
  user-select: none;
  padding-right: 1rem;
}

.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.back-link {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.1s;
}

.back-link:hover { color: var(--text); }

/* ── about page ── */
.about-content { font-family: var(--font-serif); font-size: 1.05rem; line-height: 1.8; }
.about-content h2 {
  font-family: var(--font-body);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}
.about-content p { margin-bottom: 1.2rem; }
.about-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* ── table of contents ── */
.toc {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
  font-size: 0.875rem;
}

.toc-title {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.toc nav ul,
.toc ul { list-style: none; padding-left: 0; margin: 0; }

.toc nav ul ul,
.toc ul ul { padding-left: 1rem; margin-top: 0.2rem; }

.toc li { margin-bottom: 0.25rem; }

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

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

/* ── copy button ── */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  opacity: 0;
  transition: opacity 0.15s, color 0.1s;
}

.post-content pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); }

/* ── RSS link in footer ── */
.site-footer .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rss-link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius);
  transition: color 0.1s, border-color 0.1s;
}

.rss-link:hover { color: var(--text); border-color: var(--text-muted); }

/* ── read time ── */
.read-time {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.775rem;
}

/* ── PoC block ── */
.poc-block {
  border: 1px solid var(--cve);
  border-radius: var(--radius);
  margin-bottom: 2rem;
  overflow: hidden;
}

.poc-label {
  display: block;
  background: var(--cve);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
}

[data-theme="light"] .poc-label { color: #fff; }

.poc-body {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.poc-download {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.poc-download:hover { color: var(--accent-dim); }

.poc-hash {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  word-break: break-all;
}

.poc-notes {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

/* ── PGP block ── */
.pgp-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1rem;
  overflow: hidden;
}

.pgp-label {
  display: block;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.pgp-body {
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pgp-fingerprint {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
  background: none;
  border: none;
  padding: 0;
  letter-spacing: 0.04em;
  word-break: break-all;
}

.pgp-links { display: flex; gap: 1rem; }

.pgp-links a {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
}

.pgp-links a:hover { color: var(--accent-dim); }

.pgp-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
  font-style: italic;
}

/* ── colophon ── */
.colophon { color: var(--text-muted); }
.colophon a { color: var(--text-muted); text-decoration: none; }
.colophon a:hover { color: var(--text); }

/* ── misc ── */
.muted { color: var(--text-muted); font-size: 0.9rem; }

/* ── tables ── */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.post-content th,
.post-content td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
}

.post-content th {
  background: var(--bg-subtle);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.post-content tr:nth-child(even) td { background: var(--bg-subtle); }

.post-content .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
}

.post-content .table-wrap table { margin-bottom: 0; }

/* ── copy button: always visible on touch devices ── */
@media (hover: none) {
  .copy-btn { opacity: 1; }
}

/* ── responsive ── */
@media (max-width: 640px) {
  /* header: stack title + nav on two rows */
  .site-header { padding: 0.6rem 0; }
  .site-header .container {
    flex-wrap: wrap;
    gap: 0.4rem 0;
  }
  .site-title { flex: 1 0 100%; }
  .site-nav { gap: 1rem; width: 100%; }
  .site-nav a { font-size: 0.8rem; }

  /* bigger touch target for toggle */
  .theme-toggle { padding: 0.4rem 0.7rem; font-size: 1rem; }

  /* main spacing */
  main.container { padding-top: 1.75rem; padding-bottom: 2.5rem; }

  /* typography */
  .tagline { font-size: 0.9rem; }
  .post-header h1 { font-size: 1.3rem; }
  .post-content { font-size: 0.975rem; }
  .post-content h2 { font-size: 1.15rem; }
  .post-content h3 { font-size: 1rem; }

  /* toc */
  .toc { padding: 0.75rem 1rem; }

  /* tables: horizontally scrollable */
  .post-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* poc/pgp fingerprint wrap */
  .pgp-fingerprint { font-size: 0.75rem; }
  .poc-hash { font-size: 0.7rem; }

  /* footer */
  .site-footer .container { flex-direction: column; gap: 0.5rem; align-items: flex-start; }
}
