/* SiteForge overlay — the minimum of chrome latex.css doesn't opinionate on.
   latex.css owns the reading column, body serif, headings, tables and base dark
   mode. We only add: the header/nav, the theme toggle, breadcrumbs, listing
   cards, the writeup infobox (the one deliberately "security-flavoured" element),
   tag chips, the collapsible TOC, code blocks (toolbar + highlighting), KaTeX
   math, and the search UI. Custom colours are driven by --sf-* variables.

   Theme: latex.css's own `.latex-dark` class (toggled on <html> by site.js) flips
   its variables; we mirror the --sf-* set under the same selector so everything
   tracks the manual toggle. No prefers-color-scheme media query here — the inline
   script in base.html resolves the OS preference to that class before first paint. */

:root {
  --sf-muted:    #6b6b6b;
  --sf-border:   #d9d7cc;
  --sf-surface:  #f6f5ef;
  --sf-accent:   #7a1f2b;
  --sf-pill-bg:  #ecebe1;
  --sf-pill-fg:  #3a3a3a;
  --sf-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
html.latex-dark {
  --sf-muted:    #9aa0a6;
  --sf-border:   #3b4048;
  --sf-surface:  #24272c;
  --sf-accent:   #e58a95;
  --sf-pill-bg:  #2b3037;
  --sf-pill-fg:  #d3d8de;
}

/* ---- header / nav -------------------------------------------------------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  padding-bottom: 0.8rem;
  margin-bottom: 1.6rem;
  border-bottom: 1px solid var(--sf-border);
}
.site-title {
  font-weight: 700;
  font-size: 1.15rem;
  text-decoration: none;
  font-family: var(--sf-mono);
  letter-spacing: -0.01em;
}
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.15rem 1rem; }
.site-nav a { font-size: 0.95rem; text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }

/* ---- theme toggle (after the About link) --------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 1px solid var(--sf-border);
  border-radius: 6px;
  cursor: pointer;
  line-height: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--sf-accent); border-color: var(--sf-accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--sf-accent); outline-offset: 2px; }
.theme-toggle svg { display: block; }
.theme-toggle .icon-sun { display: none; }
html.latex-dark .theme-toggle .icon-moon { display: none; }
html.latex-dark .theme-toggle .icon-sun { display: block; }

/* ---- breadcrumbs --------------------------------------------------------- */
.breadcrumbs {
  font-family: var(--sf-mono);
  font-size: 0.8rem;
  color: var(--sf-muted);
  margin-bottom: 1rem;
}
.breadcrumbs .sep { opacity: 0.5; }
.breadcrumbs span[aria-current] { color: inherit; }

/* ---- meta line + tags ---------------------------------------------------- */
.meta { color: var(--sf-muted); font-size: 0.85rem; margin: 0.2rem 0 0.9rem; }
.byline time { margin-right: 0.6rem; }
.taglist { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.tag {
  font-family: var(--sf-mono);
  font-size: 0.78rem;
  text-decoration: none;
  color: var(--sf-pill-fg);
  background: var(--sf-pill-bg);
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
}
.tag:hover { color: var(--sf-accent); }
.tag-lg { font-size: 0.95rem; padding: 0.2rem 0.55rem; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.count { color: var(--sf-muted); font-size: 0.75em; }

/* ---- pills (writeup metadata) ------------------------------------------- */
.pill {
  display: inline-block;
  font-family: var(--sf-mono);
  font-size: 0.72rem;
  padding: 0.05rem 0.4rem;
  margin-left: 0.35rem;
  margin-right: 0.35rem;
  border: 1px solid var(--sf-border);
  border-radius: 3px;
  color: var(--sf-muted);
}
.pill-cat { color: var(--sf-accent); border-color: var(--sf-accent); }

/* ---- listing cards ------------------------------------------------------- */
.card-list { display: flex; flex-direction: column; gap: 1.2rem; margin: 1rem 0; }
.card { border-left: 2px solid var(--sf-border); padding-left: 1rem; }
.card-title { margin: 0 0 0.15rem; font-size: 1.1rem; }
.card-title a { text-decoration: none; }
.card-title a:hover { text-decoration: underline; }
.card-summary { margin: 0.3rem 0; color: var(--sf-muted); font-size: 0.92rem; }

/* ---- writeup infobox (the signature element) ----------------------------- */
.infobox {
  border: 1px solid var(--sf-border);
  border-left: 3px solid var(--sf-accent);
  background: var(--sf-surface);
  padding: 0.6rem 1rem;
  margin: 1.2rem 0;
  border-radius: 4px;
  font-size: 0.9rem;
}
.infobox dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0;
}
.infobox dt {
  font-family: var(--sf-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sf-muted);
  align-self: center;
}
.infobox dd { margin: 0; }
.infobox code { background: none; padding: 0; }

/* ---- collapsible TOC ----------------------------------------------------- */
.toc-box {
  border: 1px solid var(--sf-border);
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  margin: 1.2rem 0;
  background: var(--sf-surface);
}
.toc-box summary {
  cursor: pointer;
  font-family: var(--sf-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sf-muted);
}
.toc-box .toc { margin-top: 0.4rem; }
.toc-box ul { margin: 0.2rem 0; }
.toc-box a { text-decoration: none; }
.toc-box a:hover { text-decoration: underline; }

/* ---- CTF grouping -------------------------------------------------------- */
.ctf-group { margin-bottom: 1.6rem; }
.ctf-group h2 a { text-decoration: none; }
.ctf-group h2 a:hover { text-decoration: underline; }

.challenge-list {
  list-style: none;
  padding-left: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  column-gap: 2rem;
}
.challenge-list li { padding: 0.15rem 0; border-bottom: 1px dotted var(--sf-border); }
.challenge-list a  { text-decoration: none; }
.challenge-list a:hover  { text-decoration: underline; }

@media (max-width: 640px) {
  .challenge-list { grid-template-columns: 1fr; }
}

/* ---- code blocks --------------------------------------------------------- */
/* JS-off: the bare .highlight gets its own frame. JS-on: site.js wraps it in a
   .code-block with a toolbar (language label + copy button) and the .highlight
   sits flush inside. The Pygments background (from pygments.css) supplies the
   token surface; the border delineates it from the page in both themes. */
.highlight {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--sf-border);
  border-radius: 6px;
}
.highlight pre { margin: 0; padding: 0.8rem 1rem; background: none; border: none; }

.code-block {
  margin: 1rem 0;
  border: 1px solid var(--sf-border);
  border-radius: 6px;
  overflow: hidden;
}
.code-block .highlight { margin: 0; border: 0; border-radius: 0; }

.code-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.6rem;
  background: var(--sf-surface);
  border-bottom: 1px solid var(--sf-border);
}
.code-lang {
  margin-right: auto;
  font-family: var(--sf-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--sf-muted);
}
.copy-btn {
  margin-left: auto;
  font-family: var(--sf-mono);
  font-size: 0.72rem;
  color: var(--sf-muted);
  background: transparent;
  border: 1px solid var(--sf-border);
  border-radius: 4px;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
  line-height: 1.4;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.copy-btn:hover { color: var(--sf-accent); border-color: var(--sf-accent); }
.copy-btn:focus-visible { outline: 2px solid var(--sf-accent); outline-offset: 1px; }

/* ---- LaTeX math (KaTeX) -------------------------------------------------- */
.katex { font-size: 1.05em; }
.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.3rem 0;
  margin: 1rem 0;
}

/* ---- misc ---------------------------------------------------------------- */
.muted { color: var(--sf-muted); }
.site-footer { margin-top: 3rem; color: var(--sf-muted); font-size: 0.85rem; }
.home-section { margin-top: 2rem; }

.search-input {
  width: 100%;
  font-family: var(--sf-mono);
  font-size: 1rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--sf-border);
  border-radius: 4px;
  background: var(--sf-surface);
  color: inherit;
  box-sizing: border-box;
}
mark { background: color-mix(in srgb, var(--sf-accent) 25%, transparent); color: inherit; }
