/* window.name - security-research blog by David Vieira-Kurz
   Minimal, content-first. No web fonts, no external requests. */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --ink: #0a0a0b;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --accent: #7c3aed;
  --accent-ink: #ffffff;
  --accent-soft: rgba(124, 58, 237, .10);
  /* Light-mode code boxes: white/violet */
  --code-bg: #faf7ff;
  --code-ink: #241f33;
  --code-line: rgba(124, 58, 237, .22);
  --code-inline-bg: rgba(124, 58, 237, .08);
  /* syntax highlighting on light background */
  --hl-comment: #8a8f98;
  --hl-keyword: #7c3aed;
  --hl-string: #0a7d4d;
  --hl-number: #b4530a;
  --hl-title: #1d4ed8;
  --hl-built: #9333ea;
  --hl-tag: #1d4ed8;
  --hl-deletion: #c0392b;
  --hl-meta: #8a8f98;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-serif: var(--font-sans);
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 72ch;
  --wrap: 980px;
}

:root[data-theme="dark"] {
  --bg: #0c0c0e; --surface: #111113; --surface-2: #17171a;
  --ink: #ededf0; --ink-2: #c7c7cc; --muted: #8a8a91;
  --line: #26262a; --line-strong: #3a3a40;
  --accent: #b69bff; --accent-ink: #141019; --accent-soft: rgba(182, 155, 255, .16);
  --code-bg: #0b0810; --code-ink: #e6e3dc; --code-line: rgba(182, 155, 255, .20);
  --code-inline-bg: var(--surface-2);
  --hl-comment: #7b8089; --hl-keyword: #c4a6ff; --hl-string: #9ed8b8; --hl-number: #e8c675;
  --hl-title: #8cc2ff; --hl-built: #cbb2ff; --hl-tag: #8cc2ff; --hl-deletion: #ff7b7b; --hl-meta: #8b8e96;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0e; --surface: #111113; --surface-2: #17171a;
    --ink: #ededf0; --ink-2: #c7c7cc; --muted: #8a8a91;
    --line: #26262a; --line-strong: #3a3a40;
    --accent: #b69bff; --accent-ink: #141019; --accent-soft: rgba(182, 155, 255, .16);
    --code-bg: #0b0810; --code-ink: #e6e3dc; --code-line: rgba(182, 155, 255, .20);
    --code-inline-bg: var(--surface-2);
    --hl-comment: #7b8089; --hl-keyword: #c4a6ff; --hl-string: #9ed8b8; --hl-number: #e8c675;
    --hl-title: #8cc2ff; --hl-built: #cbb2ff; --hl-tag: #8cc2ff; --hl-deletion: #ff7b7b; --hl-meta: #8b8e96;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 var(--font-sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  min-height: 100vh; display: flex; flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
::selection { background: var(--accent); color: var(--accent-ink); }
.wrap { width: min(var(--wrap), 100% - 40px); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 12px; }
.mono { font-family: var(--font-mono); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px); -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 20px; height: 56px; }
.brand { font: 600 16px/1 var(--font-mono); letter-spacing: -.01em; display: inline-flex; align-items: center; color: var(--ink); }
.brand b { font-weight: 700; }
.nav { display: flex; gap: 2px; margin-left: 6px; }
.nav a { white-space: nowrap; padding: 6px 10px; border-radius: 6px; font-size: 14.5px; color: var(--muted); }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { color: var(--ink); }
.spacer { flex: 1; }
.icon-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 11px;
  background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 7px;
  font: 500 14px var(--font-sans); cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.icon-btn kbd { font: 500 11px var(--font-mono); padding: 1px 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); }
.icon-btn svg { width: 16px; height: 16px; flex: none; }
.theme-btn { width: 34px; padding: 0; justify-content: center; }
.theme-btn .moon { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}
@media (max-width: 680px) {
  .site-header .wrap { gap: 8px; }
  .nav a { padding: 6px 7px; font-size: 14px; }
  .icon-btn .label, .icon-btn kbd { display: none; }
  .icon-btn { width: 34px; padding: 0; justify-content: center; }
}
@media (max-width: 440px) { .nav a.opt { display: none; } }

/* ---------- Sections ---------- */
.section { padding: clamp(36px, 6vw, 64px) 0; }
.section-top { padding-top: clamp(24px, 4vw, 40px); }
.lead { font-size: clamp(15px, 1.8vw, 18px); color: var(--ink-2); max-width: 64ch; margin: 10px 0 0; line-height: 1.55; }
.big-head { font: 800 clamp(28px, 5vw, 46px)/1.0 var(--font-sans); letter-spacing: -.03em; margin: 0 0 8px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-head h2 { font: 800 clamp(26px, 4vw, 40px)/1.0 var(--font-sans); letter-spacing: -.03em; margin: 0; }
.section-head .sub { color: var(--muted); font: 500 13px var(--font-mono); }

/* ---------- Search ---------- */
.searchbox { position: relative; margin: 22px 0 6px; }
.searchbox svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.searchbox input {
  width: 100%; height: 44px; padding: 0 42px; font: 15px var(--font-sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
}
.searchbox input::placeholder { color: var(--muted); }
.searchbox input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbox .clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; display: none; font-size: 19px; line-height: 1; }
.searchbox .clear:hover { background: var(--surface-2); color: var(--ink); }
.searchbox.has-value .clear { display: block; }
.resultbar { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 2px; color: var(--muted); font: 500 12.5px var(--font-mono); }
.resultbar button { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.resultbar button:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Archive list (Project-Zero style) ---------- */
.arch-list { display: flex; flex-direction: column; }
.arch-item { display: flex; align-items: baseline; gap: 22px; padding: 12px 0; border-top: 1px solid var(--line); }
.arch-item:first-child { border-top: 0; }
.arch-date {
  flex: none; font: 500 12.5px/1 var(--font-mono); color: var(--ink-2);
  border: 1px solid var(--line-strong); border-radius: 4px; padding: 7px 9px; letter-spacing: .03em;
}
.arch-title { font: 400 clamp(16px, 2.1vw, 20px)/1.35 var(--font-sans); color: var(--ink); }
.arch-item:hover .arch-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.arch-item:hover .arch-date { border-color: var(--accent); color: var(--accent); }
.arch-title mark { background: var(--accent-soft); color: inherit; padding: 0 1px; border-radius: 2px; }
.empty { padding: 56px 0; color: var(--muted); }
.empty b { display: block; font: 700 22px var(--font-sans); color: var(--ink); margin-bottom: 6px; }
@media (max-width: 560px) {
  .arch-item { flex-direction: column; gap: 7px; padding: 14px 0; }
  .arch-date { align-self: flex-start; }
}

/* ---------- CVE / GHSA table (clean, dense) ---------- */
.table-scroll { overflow-x: auto; border-top: 1px solid var(--line-strong); }
.cve-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.cve-table th { text-align: left; font: 600 11.5px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 18px 10px 0; border-bottom: 1px solid var(--line); }
.cve-table td { padding: 11px 18px 11px 0; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
.cve-table td.id { font-family: var(--font-mono); font-size: 13px; color: var(--ink); white-space: nowrap; }
.cve-table td.id .yr { color: var(--muted); }
.cve-table td .yr { color: var(--muted); font-weight: 400; }
.cve-table tr:last-child td { border-bottom: 0; }
.cve-table a { color: var(--accent); }
.cve-table a:hover { text-decoration: underline; text-underline-offset: 2px; }
.cve-table .wu { white-space: nowrap; }
.cve-note { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ---------- Tags (article byline) ---------- */
.tag { display: inline-block; font: 500 12px/1 var(--font-mono); padding: 4px 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); }
a.tag:hover { border-color: var(--line-strong); color: var(--ink); }

/* ---------- Article ---------- */
.progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--accent); z-index: 100; }
.article-head { padding: clamp(32px, 6vw, 60px) 0 22px; border-bottom: 1px solid var(--line); }
.crumbs { font: 500 13px var(--font-mono); color: var(--muted); margin-bottom: 20px; }
.crumbs a:hover { color: var(--ink); }
.article-head h1 { font: 800 clamp(28px, 4.6vw, 46px)/1.1 var(--font-sans); letter-spacing: -.03em; margin: 0 0 16px; max-width: 30ch; }
.article-head .byline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); font: 500 13px var(--font-mono); }
.article-head .byline .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.article-layout { display: grid; grid-template-columns: minmax(0, var(--measure)) 220px; gap: clamp(28px, 5vw, 72px); justify-content: start; padding: 30px 0 20px; }
.article-layout.no-toc { grid-template-columns: minmax(0, var(--measure)); }
.toc { position: sticky; top: 84px; align-self: start; font-size: 13.5px; max-height: calc(100vh - 110px); overflow: auto; }
.toc h2 { font: 600 11.5px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a { display: block; padding: 5px 0 5px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--muted); line-height: 1.35; }
.toc li a:hover { color: var(--ink); }
.toc li a.active { border-left-color: var(--accent); color: var(--ink); font-weight: 600; }
@media (max-width: 960px) { .article-layout { grid-template-columns: minmax(0, 1fr); } .toc { display: none; } }

.note { border: 1px solid var(--line); border-left: 2px solid var(--accent); background: var(--surface-2); border-radius: 6px; padding: 12px 16px; font-size: 14px; color: var(--ink-2); margin: 0 0 28px; }
.note b { color: var(--ink); }

.prose { font-size: 17px; line-height: 1.72; overflow-wrap: break-word; }
.prose > * + * { margin-top: 1.1em; }
.prose p { margin-block: 0; }
.prose p + p { margin-top: 1.1em; }
.prose h2 { font: 700 25px/1.25 var(--font-sans); letter-spacing: -.02em; margin: 2em 0 .5em; }
.prose h3 { font: 700 19px/1.3 var(--font-sans); letter-spacing: -.01em; margin: 1.7em 0 .4em; }
.prose h4 { font: 600 16px var(--font-sans); margin: 1.5em 0 .3em; }
.prose a { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); text-underline-offset: .2em; word-break: break-word; }
.prose a:hover { text-decoration-color: var(--accent); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .35em; }
.prose blockquote { margin-inline: 0; padding: 2px 0 2px 18px; border-left: 2px solid var(--line-strong); color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.2em 0; }
.prose strong, .prose b { font-weight: 650; }
.prose code { font: .86em var(--font-mono); background: var(--code-inline-bg); color: var(--ink); padding: .12em .4em; border-radius: 4px; overflow-wrap: anywhere; }
.prose img { border-radius: 6px; border: 1px solid var(--line); display: block; margin: 1.4em auto; }
.prose table { border-collapse: collapse; width: 100%; font-size: 15px; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; border: 1px solid var(--line); padding: 8px 12px; vertical-align: top; }
.prose th { background: var(--surface-2); }

.prose pre, .prose figure.codeblock, .prose figure.highlight { margin-inline: 0; }
.prose pre {
  position: relative; background: var(--code-bg); color: var(--code-ink); border-radius: 8px;
  border: 1px solid var(--code-line); border-left: 3px solid var(--accent);
  padding: 16px 18px; overflow-x: auto; font: 13.5px/1.6 var(--font-mono); tab-size: 4; -moz-tab-size: 4; margin-block: 0;
}
.prose pre code { background: none; padding: 0; font: inherit; color: inherit; border-radius: 0; overflow-wrap: normal; white-space: pre; }
.prose figure { margin: 1.4em 0; }
.prose figure.codeblock figcaption { font: 500 12px var(--font-mono); color: var(--accent); margin-bottom: 6px; letter-spacing: .02em; }
.codewrap { position: relative; }
.codewrap .copy {
  position: absolute; top: 8px; right: 8px; font: 500 11.5px var(--font-mono);
  color: color-mix(in srgb, var(--code-ink) 65%, transparent); background: color-mix(in srgb, var(--code-ink) 8%, transparent);
  border: 1px solid var(--code-line); border-radius: 5px; padding: 4px 9px; cursor: pointer; opacity: 0; transition: opacity .15s;
}
.codewrap:hover .copy, .codewrap .copy:focus-visible { opacity: 1; }
.codewrap .copy:hover { color: var(--accent); border-color: var(--accent); }
.codewrap .lang { position: absolute; bottom: 7px; right: 12px; font: 500 10.5px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: color-mix(in srgb, var(--code-ink) 50%, transparent); pointer-events: none; }
@media (hover: none) { .codewrap .copy { opacity: 1; } }

figure.missing-img { margin: 1.4em 0; padding: 24px 20px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--muted); font: 500 13px var(--font-mono); }

/* highlight.js (theme-aware via tokens) */
.hljs { color: var(--code-ink); }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag, .hljs-meta .hljs-keyword { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta .hljs-string { color: var(--hl-string); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-attr, .hljs-variable, .hljs-template-variable { color: var(--hl-number); }
.hljs-title, .hljs-section, .hljs-title.function_, .hljs-name { color: var(--hl-title); }
.hljs-built_in, .hljs-type, .hljs-class .hljs-title, .hljs-title.class_ { color: var(--hl-built); }
.hljs-tag, .hljs-attribute { color: var(--hl-tag); }
.hljs-deletion { color: var(--hl-deletion); }
.hljs-meta { color: var(--hl-meta); }

mark { background: var(--accent-soft); color: inherit; padding: 0 1px; border-radius: 2px; }

.comments { margin-top: 52px; border-top: 1px solid var(--line); padding-top: 22px; }
.comments summary { cursor: pointer; font: 700 18px var(--font-sans); list-style: none; display: flex; align-items: center; gap: 10px; }
.comments summary::-webkit-details-marker { display: none; }
.comments summary::before { content: "▸"; color: var(--muted); transition: transform .15s; display: inline-block; }
.comments[open] summary::before { transform: rotate(90deg); }
.comments .hint { color: var(--muted); font-size: 14px; margin: 8px 0 18px; }
.comment { padding: 14px 0; border-top: 1px solid var(--line); font-size: 15.5px; line-height: 1.6; }
.comment .who { font: 500 13px var(--font-mono); color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.comment .who b { color: var(--ink); font-weight: 600; }
.comment.own { background: var(--surface-2); padding-inline: 14px; border-radius: 6px; border-top-color: transparent; margin-top: 4px; }
.comment.own .who b::after { content: " · author"; color: var(--muted); font-weight: 500; }
.comment p { margin: 0; }

.versions { margin-top: 42px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.versions h2 { font: 600 11.5px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.versions ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.versions a { font-weight: 600; }
.versions a:hover { text-decoration: underline; text-underline-offset: 3px; }
.versions span { color: var(--muted); font: 500 12px var(--font-mono); margin-left: 8px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 52px 0 8px; }
.pager a { display: block; padding: 16px 18px; border: 1px solid var(--line); border-radius: 8px; }
.pager a:hover { border-color: var(--line-strong); }
.pager small { display: block; font: 500 12px var(--font-mono); color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-bottom: 6px; }
.pager b { font: 600 16px/1.3 var(--font-sans); display: block; }
.pager .next { text-align: right; }
@media (max-width: 600px) { .pager { grid-template-columns: 1fr; } .pager .next { text-align: left; } }

/* ---------- Static pages ---------- */
.page { padding: clamp(32px, 6vw, 64px) 0 40px; }
.page h1 { font: 800 clamp(32px, 5vw, 52px)/1.03 var(--font-sans); letter-spacing: -.03em; margin: 0 0 20px; }
.page .prose { max-width: var(--measure); }
.todo { border: 1px dashed var(--line-strong); background: var(--surface-2); border-radius: 8px; padding: 14px 18px; font-size: 14.5px; color: var(--ink-2); }
.todo b { color: var(--ink); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 32px 0 44px; color: var(--muted); font-size: 13.5px; }
.site-footer .wrap { display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px 48px; }
.site-footer a { color: var(--ink-2); }
.site-footer a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.site-footer .links { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: flex-end; align-content: start; }
.site-footer p { margin: 0 0 8px; max-width: 64ch; line-height: 1.6; }
@media (max-width: 680px) { .site-footer .wrap { grid-template-columns: 1fr; } .site-footer .links { justify-content: flex-start; } }

.to-top { position: fixed; right: 18px; bottom: 18px; width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .2s; font-size: 17px; z-index: 30; }
.to-top.show { opacity: 1; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
@media print {
  .site-header, .progress, .to-top, .toc, .pager, .site-footer .links, .codewrap .copy, .searchbox { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .prose pre { background: #f4f4f4; color: #000; border: 1px solid #ccc; white-space: pre-wrap; }
  .prose a::after { content: " (" attr(href) ")"; font-size: .8em; color: #555; }
}
