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

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

:root {
  --bg:         #FAFAF8;
  --bg2:        #F0F0EC;
  --code-bg:    #f2e8cf;  /* Gruvbox-inspired warm code surface */
  --faint:      #EDEDE8;
  --dim:        #6E6E65;  /* 4.92:1 on --bg — WCAG AA */
  --ink:        #111110;
  --accent:     #C47900;  /* decorative only */
  --accent-tx:  #9A5C00;  /* 5.15:1 on --bg — WCAG AA */
  --accent-bg:  rgba(196, 121, 0, 0.07);
  --badge-bd:   rgba(154, 92, 0, 0.4);
  --max:        720px;
  --sans:       'IBM Plex Sans', system-ui, sans-serif;
  --mono:       'IBM Plex Mono', ui-monospace, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #282828;  /* Gruvbox dark */
    --bg2:       #3c3836;  /* Gruvbox dark bg3 */
    --code-bg:   #32302f;  /* Gruvbox dark bg1 */
    --faint:     #504945;  /* Gruvbox dark bg4 */
    --dim:       #a89984;  /* Gruvbox fg4 — ~6.1:1 on --bg */
    --ink:       #ebdbb2;  /* Gruvbox fg1 */
    --accent:    #d79921;  /* Gruvbox yellow */
    --accent-tx: #fabd2f;  /* Gruvbox bright yellow */
    --accent-bg: rgba(215, 153, 33, 0.12);
    --badge-bd:  rgba(250, 189, 47, 0.4);
  }
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  line-height: 1.8;
  padding: 0 24px 80px;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent-tx); }

/* ── SKIP LINK (WCAG 2.4.1) ──────────── */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 16px;
  font-size: 13px;
  z-index: 9999;
  border-radius: 2px;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-to-content:focus { top: 8px; }

/* ── FOCUS (WCAG 2.4.7) ──────────────── */
:focus-visible {
  outline: 2px solid var(--accent-tx);
  outline-offset: 3px;
  border-radius: 2px;
}

/* ── NAV ──────────────────────────────── */
nav {
  max-width: var(--max);
  margin: 0 auto;
  padding: 40px 0 48px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.wordmark { font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }
.wordmark span { color: var(--accent); }

.nav-links { display: flex; gap: 28px; }
.nav-links a { font-size: 13px; color: var(--dim); }
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--ink); }

/* ── HERO ─────────────────────────────── */
.hero { max-width: var(--max); margin: 0 auto 40px; }
.hero-bio { font-size: 13px; line-height: 1.8; color: var(--dim); }
.hero-bio strong { font-weight: 500; color: var(--ink); }

/* ── DIVIDER ──────────────────────────── */
hr.divider {
  max-width: var(--max);
  margin: 0 auto 40px;
  border: none;
  border-top: 1px solid var(--faint);
}

/* ── SECTION LABEL ────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  max-width: var(--max);
  margin: 0 auto 16px;
}

/* ── POST LIST ────────────────────────── */
.posts { max-width: var(--max); margin: 0 auto; }

.posts-header {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 0 24px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--faint);
}

.post-row {
  display: grid;
  grid-template-columns: 104px 1fr;
  gap: 0 24px;
  align-items: start;
  padding: 16px 0;
  border-bottom: 1px solid var(--faint);
}

.post-date { font-size: 12px; color: var(--dim); white-space: nowrap; padding-top: 2px; }

.post-title a {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  display: block;
  text-wrap: pretty;
}
.post-title a:hover { color: var(--accent-tx); }

.post-desc {
  font-size: 12px;
  color: var(--dim);
  margin-top: 5px;
  line-height: 1.6;
  text-wrap: pretty;
}

.post-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 8px; }
.tag { font-size: 11px; color: var(--dim); background: var(--bg2); padding: 2px 6px; border-radius: 2px; }
.tag.cve { color: var(--accent-tx); background: var(--accent-bg); }

.cve-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-tx);
  border: 1px solid var(--badge-bd);
  padding: 1px 6px;
  border-radius: 2px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

.embargo-hash {
  display: block;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.03em;
  margin-top: 3px;
  opacity: 0.7;
}

/* ── EMBARGO ──────────────────────────── */
.embargo {
  max-width: var(--max);
  margin: 0 auto 48px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-size: 13px;
  color: var(--dim);
  border-left: 2px solid var(--accent);
  padding-left: 14px;
}
.embargo-can { color: var(--accent-tx); font-weight: 500; white-space: nowrap; }
.embargo-text { line-height: 1.6; }

/* ── PAGE HEADER ──────────────────────── */
.page-header { max-width: var(--max); margin: 0 auto 40px; }

/* ── SINGLE POST ──────────────────────── */
.post { max-width: var(--max); margin: 0 auto; }
.post-header { margin-bottom: 40px; }

.post-meta {
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.post-title-large {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  max-width: 640px;
  text-wrap: pretty;
  letter-spacing: -0.02em;
}

.post-header .post-tags { margin-top: 12px; }

.embargo-notice {
  background: var(--accent-bg);
  border-left: 2px solid var(--accent);
  padding: 12px 16px;
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 32px;
}

/* ── POST BODY ────────────────────────── */
.post-body {
  max-width: var(--max);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  overflow-wrap: break-word;
}

.post-body h2 {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 48px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--faint);
}

.post-body h3 {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  margin: 32px 0 10px;
}

.post-body p { margin-bottom: 20px; }

.post-body a {
  color: var(--accent-tx);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.post-body a:hover { opacity: 0.75; }
.post-body strong { font-weight: 600; }
.post-body em { font-style: italic; }

.post-body code {
  font-family: var(--mono);
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 2px;
  font-size: 0.875em;
}

.post-body pre {
  font-family: var(--mono);
  background: var(--code-bg);
  color: var(--ink);
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 24px 0;
  font-size: 13px;
  line-height: 1.65;
  tab-size: 4;
  word-break: normal;
  position: relative;
}
.post-body pre code { background: none; padding: 0; font-size: inherit; word-break: normal; }

.post-body blockquote {
  border-left: 2px solid var(--faint);
  padding-left: 16px;
  color: var(--dim);
  margin: 24px 0;
  font-style: italic;
}

.post-body ul, .post-body ol { margin: 0 0 20px 20px; }
.post-body li { margin-bottom: 6px; }
.post-body hr { border: none; border-top: 1px solid var(--faint); margin: 40px 0; }

.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
  margin: 24px 0;
}
.post-body th {
  text-align: left;
  font-weight: 600;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--faint);
  padding: 6px 16px 8px 0;
}
.post-body td {
  border-bottom: 1px solid var(--faint);
  padding: 8px 16px 8px 0;
  vertical-align: top;
}
.post-body tr:last-child td { border-bottom: none; }

/* ── FOOTER ───────────────────────────── */
footer {
  max-width: var(--max);
  margin: 64px auto 0;
  padding-top: 24px;
  border-top: 1px solid var(--faint);
  font-size: 12px;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
footer a:hover { color: var(--ink); }

/* ── RESPONSIVE ───────────────────────── */
@media (max-width: 560px) {
  body { padding: 0 16px 60px; }
  .posts-header, .post-row { grid-template-columns: 88px 1fr; }
  nav { flex-direction: column; gap: 16px; padding-bottom: 32px; }
  .embargo { flex-direction: column; gap: 6px; }
  .post-title-large { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── ENHANCEMENTS ─────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* Lede paragraph */
.post-body > p:first-child { font-size: 17px; line-height: 1.7; }

/* Post row hover */
.post-title a { transition: transform 0.15s ease, color 0.15s; }
.post-title a:hover { transform: translateX(3px); }

/* Table row hover */
.post-body td { transition: background 0.1s; }
.post-body tbody tr:hover td { background: var(--faint); }

/* Heading anchors */
.heading-anchor {
  display: inline-block;
  margin-left: 8px;
  opacity: 0;
  color: var(--dim);
  text-decoration: none;
  font-weight: 400;
  transition: opacity 0.15s;
  font-size: 0.9em;
}
.post-body h2:hover .heading-anchor,
.post-body h3:hover .heading-anchor,
.heading-anchor:focus { opacity: 1; }

/* Code language labels */
.post-body pre[data-lang]::after {
  content: attr(data-lang);
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 10px;
  font-family: var(--mono);
  color: var(--dim);
  letter-spacing: 0.05em;
  opacity: 0.6;
  pointer-events: none;
  user-select: none;
}

/* Wider code blocks on large viewports */
body { overflow-x: clip; }
@media (min-width: 820px) {
  .post-body pre {
    width: calc(100% + 40px);
    margin-left: -20px;
    padding-left: 40px;
    padding-right: 40px;
    border-radius: 0 3px 3px 0;
  }
}
