/* resux.xyz */

/* ---------- fonts (self-hosted, no third-party requests) ---------- */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("/fonts/Inter-Regular.woff") format("woff"); }
@font-face { font-family: "Inter"; font-style: italic; font-weight: 400; font-display: swap; src: url("/fonts/Inter-Italic.woff") format("woff"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("/fonts/Inter-SemiBold.woff") format("woff"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 400; font-display: swap; src: local("JetBrains Mono"), url("/fonts/JetBrainsMono-Regular.woff2") format("woff2"); }

/* ---------- tokens: light by default, dark follows the system ---------- */
:root {
  --bg: #FFFFFF;
  --text: #1A1A1A;
  --muted: #5F6368;
  --border: #E5E5E5;
  --code-bg: #F5F5F5;
  --inline-code-bg: #F0F0F0;
  --quote-border: #D4D4D4;

  /* the colour of the avatar's eyes: running-text links and the highlighted-line tint only */
  --accent: #4651F0;
  --accent-hover: #2F38C4;
  --hl-line: rgba(70, 81, 240, .10);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "DejaVu Sans Mono", Menlo, Consolas, monospace;

  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616;
    --text: #E8E8E8;
    --muted: #A0A0A0;
    --border: #2A2A2A;
    --code-bg: #1F1F1F;
    --inline-code-bg: #262626;
    --quote-border: #3A3A3A;
    --accent: #8E97FF;
    --accent-hover: #B3BAFF;
    --hl-line: rgba(142, 151, 255, .16);
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.65;
}
h1, h2, h3, h4, p, ol, ul, dl, dd, blockquote, figure, pre { margin: 0; }
h1, h2, h3, h4, strong, b, th { font-weight: 600; }
img { max-width: 100%; height: auto; }

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 2px; }

/* links in running text */
main a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
main a:hover { color: var(--accent-hover); }

.skip {
  position: absolute; left: -9999px; top: 8px; z-index: 10;
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
}
.skip:focus { left: 8px; }

/* ---------- page frame: one column everywhere ---------- */
.page { max-width: 700px; margin: 0 auto; padding: 32px 24px 48px; }
main { margin-top: 56px; }

.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 4px 24px;
}
.brand {
  display: inline-flex; align-items: center; gap: 12px; min-height: 44px;
  font-size: 17px; font-weight: 600; color: var(--text);
}
/* search field between the brand and the nav; js/search.js fills the list below the header */
.site-header { position: relative; }
.search { flex: 1 1 110px; min-width: 0; }
.search[hidden], .search [hidden] { display: none; }
.search input {
  display: block; width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text);
  font-family: var(--font-sans); font-size: 14px;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search-results, .search-status {
  position: absolute; z-index: 6; left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px; list-style: none;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.search-status { padding: 12px 16px; font-size: 14px; color: var(--muted); }
.search-results a { display: block; padding: 8px 10px; border-radius: 4px; }
.search-results a:hover, .search-results a:focus-visible { background: var(--code-bg); outline: none; }
.search-results .hit-title { display: block; font-size: 15px; font-weight: 600; color: var(--text); }
.search-results .hit-text { display: block; font-size: 13px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.search-results mark { background: var(--hl-line); color: var(--text); border-radius: 2px; }
.avatar { display: block; width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.nav { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0 20px; font-size: 15px; }
@media (max-width: 420px) { .nav { gap: 0 12px; } }  /* six links fit one row from 390px up */
.nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); }
.nav a:hover, .nav a[aria-current] { color: var(--text); }

/* js/code.js adds this button and shows it after one screen of scrolling */
.to-top {
  position: fixed; z-index: 5;
  right: calc(16px + env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  height: 44px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--muted);
  font-family: var(--font-sans); font-size: 13px; font-weight: 400; line-height: 1;
  cursor: pointer;
}
.to-top:hover { color: var(--text); }
.to-top[hidden] { display: none; }
.site-header:focus { outline: none; }  /* only ever focused by the Top button */

.site-footer { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 64px; font-size: 14px; color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ---------- home, writeup index, About, 404 ---------- */
.page-title, .intro > h1 { font-size: 28px; line-height: 1.25; letter-spacing: -0.015em; margin-bottom: 14px; }
.intro p + p { margin-top: 12px; }
.section { margin-top: 48px; }
.section-title { font-size: 20px; line-height: 1.3; margin-bottom: 8px; }
.empty { color: var(--muted); }

.meta { font-size: 14px; line-height: 1.5; color: var(--muted); }

/* attack chain: an ordered list set as one line, arrows drawn between the steps */
.chain { list-style: none; padding: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.chain li { display: inline; }
.chain li:not(:last-child)::after { content: "\00a0\2192  "; }

/* writeup list: rules between entries, not around them */
.entries { list-style: none; padding: 0; }
.entry { padding: 18px 0; }
.entry:first-child { padding-top: 6px; }
.entry + .entry { border-top: 1px solid var(--border); }
.entry-title { font-size: 18px; line-height: 1.35; }
/* the negative margin grows the tap target to 44px without moving the text */
.entry-title a { display: block; margin: -10px 0; padding: 10px 0; color: var(--text); text-decoration: none; }
.entry-title a:hover { color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }
.entry.has-badge { display: flex; align-items: flex-start; gap: 14px; }
.entry-body { flex: 1; min-width: 0; }
.badge { flex: none; width: 48px; height: 48px; margin-top: 2px; border-radius: 50%; }
.entry .meta { margin-top: 2px; }
.entry .chain { margin-top: 4px; }

/* label / value rows on the About page */
.rows > div { display: flex; flex-wrap: wrap; gap: 0 16px; padding: 10px 0; }
.rows > div + div { border-top: 1px solid var(--border); }
.rows dt { flex: 0 0 160px; }
@media (max-width: 480px) { .rows dt { flex-basis: 120px; } }  /* room for an address or URL on one line */
.rows dd { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.rows a { display: inline-block; margin: -9px 0; padding: 9px 0; }
.after-rows { margin-top: 12px; }

/* technique tags: under the chain on a writeup, and the index at /tags/ */
.tags { list-style: none; padding: 0; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 14px; line-height: 1.5; }
main .tags a, main .browse a { color: var(--muted); text-decoration: none; }
main .tags a::before { content: "#"; }
main .tags a:hover, main .browse a:hover { color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.browse { margin: -6px 0 14px; font-size: 14px; }
.section-title + .browse { margin: -4px 0 6px; }
.tag-index { list-style: none; padding: 0; columns: 2 220px; column-gap: 32px; }
.tag-index li { padding: 4px 0; break-inside: avoid; }
main .tag-index a { color: var(--text); text-decoration: none; }
main .tag-index a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.tag-index .count { margin-left: 4px; font-size: 13px; color: var(--muted); }

/* ---------- writeup page ---------- */
.banner {
  display: block; width: 100%; margin-bottom: 28px;
  aspect-ratio: 9 / 2; object-fit: cover; object-position: 50% 12%;  /* 12% frames the badge on an HTB pwn card */
  border: 1px solid var(--border); border-radius: 6px;
}
.post-head { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.post-title { font-size: 34px; line-height: 1.2; letter-spacing: -0.02em; overflow-wrap: break-word; }
.post-head .meta { margin-top: 10px; }
.post-head .chain { margin-top: 14px; font-size: 15px; color: var(--text); }

.post-nav {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 24px;
  margin-top: 48px; padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 15px;
}
.post-nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--text); text-decoration: none; }
.post-nav a:hover { color: var(--text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; }

/* ---------- jump register on writeups ---------- */
/* The list is in the page twice and only one copy is ever displayed: a fold-out under
   the title on narrow screens, a rail in the margin beside the column on wide ones. */
.toc-list, .toc-list ol { list-style: none; padding: 0; }
.toc-list ol { padding-left: 14px; }
.toc-list a { display: block; color: var(--muted); text-decoration: none; }
.toc-list a:hover { color: var(--text); }

.toc-fold { margin: 8px 0 -14px; font-size: 15px; }
.toc-fold summary { padding: 11px 0; line-height: 22px; cursor: pointer; }
.toc-fold nav { padding-bottom: 10px; }
.toc-fold a { padding: 11px 0; line-height: 22px; }

.toc-rail { display: none; }
@media (min-width: 1200px) {
  .toc-fold { display: none; }
  .post { position: relative; }
  /* as tall as the article, so the list inside can stay in view down to its end */
  .toc-rail {
    display: block;
    position: absolute; top: 0; bottom: 0; left: calc(100% + 40px);
    width: calc(50vw - 390px); max-width: 260px;
  }
  .toc-side {
    position: sticky; top: 24px;
    max-height: calc(100vh - 100px); overflow-y: auto;  /* ends above the Top button */
    margin: -4px; padding: 12px 4px 4px;
    font-size: 14px; line-height: 1.4;
    scrollbar-width: thin; scrollbar-color: var(--quote-border) transparent;
  }
  .toc-label { margin-bottom: 4px; font-weight: 600; }
  .toc-side a { padding: 5px 0; }
}
@media (min-width: 1200px) and (pointer: coarse) {
  .toc-side a { display: flex; align-items: center; min-height: 44px; padding: 0; }
}

/* ---------- prose (rendered markdown) ---------- */
.prose { font-size: 17px; line-height: 1.7; overflow-wrap: break-word; }
.prose > * + *, .prose blockquote > * + *, .prose li > * + * { margin-top: 1.15em; }
.prose h2, .prose h3, .prose h4 { scroll-margin-top: 16px; }
.prose h2 { font-size: 23px; line-height: 1.3; letter-spacing: -0.01em; }
.prose h3 { font-size: 18px; line-height: 1.4; }
.prose h4 { font-size: 17px; line-height: 1.4; }
.prose > h2 { margin-top: 2.1em; }
.prose > h3, .prose > h4 { margin-top: 1.9em; }
.prose > h2 + *, .prose > h3 + *, .prose > h4 + * { margin-top: 0.65em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li + li, .prose li > ul, .prose li > ol { margin-top: 0.35em; }
.prose li::marker { color: var(--muted); }
.prose blockquote { padding-left: 18px; border-left: 2px solid var(--quote-border); color: var(--muted); }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 2.5em 0; }
.prose img { display: block; border: 1px solid var(--border); border-radius: 6px; }
.prose table { display: block; overflow-x: auto; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.prose th, .prose td { padding: 8px 20px 8px 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.prose :not(pre) > code {
  font-family: var(--font-mono); font-size: 0.86em; font-weight: 400;
  padding: 2px 5px;
  background: var(--inline-code-bg);
  border-radius: 4px;
  color: var(--text);
}
.prose .footnote-definition { font-size: 15px; color: var(--muted); }

/* Goodies: one ## entry per script, a rule between entries */
.goodies > h2 ~ h2 { padding-top: 1.7em; border-top: 1px solid var(--border); }

/* ---------- code blocks ---------- */
.prose pre {
  --pad-x: 16px;  /* side padding */
  --end: 0px;     /* extra room at the line end, set where a Copy button sits */
  overflow-x: hidden;  /* long lines wrap (below) so a whole command reads at once */
  padding: 14px var(--pad-x);
  background: var(--code-bg);
  border-radius: 6px;
  font-family: var(--font-mono); font-size: 13.5px; font-weight: 400; line-height: 1.65;
  tab-size: 4;
  /* keep the scrollbar track the colour of the block in both schemes */
  scrollbar-width: thin;
  scrollbar-color: var(--quote-border) transparent;
}
.prose pre code { display: block; padding-right: var(--end); font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.prose pre span { font-weight: 400; }
.giallo-l { display: inline-block; width: 100%; min-height: 1lh; }
.giallo-ln { display: inline-block; margin-right: 1em; user-select: none; color: var(--muted); }

/* hl_lines: a tint across the full width of the block, padding included */
.prose pre .z-l-hl, .prose pre .z-d-hl {
  width: calc(100% + 2 * var(--pad-x) + var(--end));
  margin: 0 calc(-1 * (var(--pad-x) + var(--end))) 0 calc(-1 * var(--pad-x));
  padding: 0 calc(var(--pad-x) + var(--end)) 0 var(--pad-x);
  background: var(--hl-line);
}

/* js/code.js wraps command blocks in .codeblock and adds the Copy button */
.codeblock { position: relative; }
.codeblock pre { --end: 64px; }
/* 44px tall to tap, but only the top 36px (the first code line) is painted, so the
   button never covers part of a second line. The label sits on the first line. */
.copy {
  position: absolute; top: 0; right: 0;
  min-width: 64px; height: 44px; padding: 14px 14px 0;
  border: 0 solid transparent; border-bottom-width: 8px; border-radius: 0 6px 0 6px;
  background: var(--code-bg); background-clip: padding-box;
  color: var(--muted);
  font-family: var(--font-sans); font-size: 12px; font-weight: 400; line-height: 22px;
  cursor: pointer;
}
.copy:hover { color: var(--text); }

/* Syntax colours come from giallo-light.css / giallo-dark.css (GitHub Light / Dark).
   These few fall below 4.5:1 on --code-bg, so they are darkened or lightened here.
   The class numbers belong to those two themes as generated by Zola 0.23.4. */
@media (prefers-color-scheme: light) {
  .prose pre .z-l-3 { color: #1D7432; }  /* green,  was #22863A */
  .prose pre .z-l-5 { color: #5E666F; }  /* grey,   was #6A737D */
  .prose pre .z-l-8 { color: #C12736; }  /* red,    was #D73A49 */
  .prose pre .z-l-9 { color: #A84907; }  /* orange, was #E36209 */
}
@media (prefers-color-scheme: dark) {
  .prose pre .z-d-3 { color: #979EA7; }  /* grey,   was #6A737D */
}
