/* CTF writeups — night lab theme (matches portfolio) */

@import url("https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800&family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&family=Literata:ital,opsz,wght@0,7..72,400;0,7..72,600;1,7..72,400&display=swap");

:root {
  --void: #0e1014;
  --surface: #161a22;
  --surface-2: #1c222d;
  --line: rgba(232, 230, 225, 0.08);
  --line-hot: rgba(232, 230, 225, 0.16);
  --bone: #e8e6e1;
  --bone-dim: #9a9aa3;
  --bone-mute: #6a6d78;
  --coral: #ff5c39;
  --coral-soft: #ff8a6e;
  --coral-glow: rgba(255, 92, 57, 0.14);
  --code: #12151c;
  --focus: #ff5c39;
  --measure: 68ch;

  /* legacy aliases used in older markup */
  --bg: var(--void);
  --panel: var(--surface);
  --panel2: var(--surface-2);
  --text: var(--bone-dim);
  --dim: var(--bone-mute);
  --head: var(--bone);
  --accent: var(--coral);
  --htb: var(--coral);
  --pg: var(--coral-soft);
}

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

html {
  scroll-behavior: smooth;
  color-scheme: dark;
  overflow-x: clip;
  max-width: 100%;
}

body {
  background: var(--void);
  color: var(--bone-dim);
  font: 16px/1.7 "Literata", Georgia, serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: clip;
  max-width: 100%;
}

::selection {
  background: rgba(255, 92, 57, 0.28);
  color: var(--bone);
}

a {
  color: var(--coral);
  text-decoration: none;
  text-underline-offset: 0.15em;
}

a:hover {
  color: var(--bone);
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .card {
    transition: none;
  }
  .card:hover {
    transform: none;
  }
}

code,
pre,
kbd {
  font-family: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px 16px;
  padding: 14px clamp(16px, 4vw, 28px);
  background: rgba(14, 16, 20, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  min-width: 0;
  max-width: 100%;
}

.topbar .home {
  color: var(--bone-mute);
  font: 600 12px/1 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar .home:hover {
  color: var(--coral);
  text-decoration: none;
}

.topbar .brand {
  color: var(--bone);
  font: 700 12px/1 "Archivo", system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.55em;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.topbar .brand a.home,
.topbar .brand-link {
  color: var(--coral);
  letter-spacing: 0.12em;
  text-decoration: none;
}

.topbar .brand a.home:hover,
.topbar .brand-link:hover {
  color: var(--bone);
  text-decoration: none;
}

.topbar .brand-sep {
  color: var(--bone-mute);
  font-weight: 500;
  letter-spacing: 0.08em;
}

/* ── Article ─────────────────────────────────────────── */
.article {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px clamp(16px, 4vw, 28px) 80px;
}

.boxhead {
  border-bottom: 1px solid var(--line-hot);
  padding-bottom: 24px;
  margin-bottom: 4px;
}

.boxhead h1 {
  font: 800 clamp(2rem, 5vw, 2.75rem)/1.05 "Archivo", system-ui, sans-serif;
  color: var(--bone);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 16px 0 10px;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.bh-left {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.meta {
  color: var(--bone-mute);
  font: 13px/1.4 "IBM Plex Mono", monospace;
  margin-top: 4px;
}

.meta code {
  color: var(--coral-soft);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 0;
  font: 700 10px/1 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid var(--line-hot);
  white-space: nowrap;
}

.badge.htb {
  background: var(--coral-glow);
  color: var(--coral);
  border-color: rgba(255, 92, 57, 0.4);
}

.badge.pg {
  background: rgba(255, 138, 110, 0.1);
  color: var(--coral-soft);
  border-color: rgba(255, 138, 110, 0.35);
}

.badge.os {
  background: var(--surface-2);
  color: var(--bone-mute);
  border-color: var(--line-hot);
}

.badge.deep {
  background: var(--coral-glow);
  color: var(--coral-soft);
  border-color: rgba(255, 92, 57, 0.35);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  font: 500 11px/1.2 "IBM Plex Sans", system-ui, sans-serif;
  color: var(--bone-dim);
  background: var(--surface-2);
  border: 1px solid var(--line-hot);
  border-radius: 0;
  padding: 6px 10px;
  letter-spacing: 0.04em;
  white-space: normal;
  max-width: 100%;
  overflow-wrap: anywhere;
}

/* ── TOC + body ──────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 44px;
  margin-top: 32px;
  align-items: start;
}

.toc {
  position: sticky;
  top: 72px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font: 500 12px/1.4 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.03em;
  border-left: 2px solid var(--line-hot);
  padding-left: 14px;
  max-height: calc(100vh - 96px);
  overflow: auto;
}

.toc::before {
  content: "On this page";
  display: block;
  color: var(--bone-mute);
  font: 700 10px/1 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.toc a {
  color: var(--bone-mute);
  padding: 5px 0;
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -16px;
  padding-left: 14px;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.toc a:hover {
  color: var(--coral);
  text-decoration: none;
  border-left-color: rgba(255, 92, 57, 0.45);
}

.toc a.lvl3 {
  padding-left: 26px;
  font-size: 11px;
  opacity: 0.92;
}

.toc-empty {
  color: var(--bone-mute);
  font: 600 11px/1 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.body {
  min-width: 0;
  max-width: min(var(--measure), 100%);
  overflow-wrap: break-word;
}

.body h1,
.body h2,
.body h3 {
  font-family: "Archivo", system-ui, sans-serif;
  color: var(--bone);
  line-height: 1.2;
  scroll-margin-top: 88px;
  letter-spacing: 0.02em;
}

.body h2 {
  font-size: 1.35rem;
  font-weight: 700;
  text-transform: uppercase;
  margin: 40px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-hot);
}

.body h2:first-child {
  margin-top: 0;
}

.body h3 {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 28px 0 12px;
  color: var(--coral-soft);
  text-transform: none;
  letter-spacing: 0;
}

.body h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 24px 0 10px;
  color: var(--coral);
}

.body p {
  margin: 0 0 1em;
  max-width: min(var(--measure), 100%);
  overflow-wrap: break-word;
}

.body ul,
.body ol {
  margin: 0 0 1em 1.35rem;
  max-width: var(--measure);
}

.body li {
  margin: 0.35em 0;
  padding-left: 0.15em;
}

.body li::marker {
  color: var(--coral-soft);
}

.body a {
  border-bottom: 1px solid rgba(255, 92, 57, 0.35);
  text-decoration: none;
}

.body a:hover {
  border-bottom-color: var(--coral);
  color: var(--bone);
}

.body img {
  max-width: 100%;
  height: auto;
  border-radius: 0;
  border: 1px solid var(--line-hot);
  margin: 12px 0 18px;
}

.body table {
  border-collapse: collapse;
  margin: 0 0 20px;
  font-size: 14px;
  width: 100%;
  max-width: 100%;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.body th,
.body td {
  border: 1px solid var(--line-hot);
  padding: 9px 12px;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.body th {
  background: var(--surface-2);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-weight: 600;
  color: var(--bone);
}

/* code */
.body :not(pre) > code {
  background: var(--code);
  color: var(--coral-soft);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.12em 0.4em;
  font-size: 0.88em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.body pre {
  background: var(--code);
  border: 1px solid var(--line-hot);
  border-radius: 0;
  border-left: 3px solid rgba(255, 92, 57, 0.5);
  padding: 16px 18px;
  overflow-x: auto;
  overflow-y: hidden;
  margin: 0 0 1.25em;
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 100%;
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

.body pre code {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: inherit;
  white-space: inherit;
  overflow-wrap: inherit;
  word-break: inherit;
  max-width: 100%;
  min-width: 0;
}

.body pre code.hljs {
  background: none;
  padding: 0;
}

/* callouts */
.body blockquote {
  margin: 0 0 1.25em;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--coral);
  border-radius: 0;
  color: var(--bone-dim);
  max-width: var(--measure);
}

.body blockquote p {
  margin: 0 0 0.65em;
}

.body blockquote p:last-child {
  margin: 0;
}

.body blockquote strong {
  color: var(--bone);
  font-weight: 600;
}

.body hr {
  border: 0;
  border-top: 1px solid var(--line-hot);
  margin: 2rem 0;
}

/* ── Index catalog ───────────────────────────────────── */
.index {
  max-width: 1120px;
  margin: 0 auto;
  padding: 44px clamp(16px, 4vw, 28px) 90px;
}

.index h1 {
  font: 800 clamp(2.25rem, 6vw, 3.25rem)/1 "Archivo", system-ui, sans-serif;
  color: var(--bone);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.index .lede {
  color: var(--bone-dim);
  max-width: 42rem;
  margin: 16px 0 40px;
  font-size: 1.05rem;
  line-height: 1.7;
  overflow-wrap: break-word;
}

.index-section {
  margin-bottom: 3rem;
}

.index-section h2 {
  font: 700 1.15rem/1.2 "Archivo", system-ui, sans-serif;
  color: var(--bone);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 1.1rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--line-hot);
}

.index-section h2 .count {
  color: var(--bone-mute);
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  margin-left: 0.4rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  min-width: 0;
  max-width: 100%;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  background: var(--surface);
  border: none;
  border-radius: 0;
  padding: 18px 16px 16px;
  min-height: 148px;
  min-width: 0;
  max-width: 100%;
  transition: background 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
  color: inherit;
  border-left: 2px solid transparent;
}

.card:hover {
  background: var(--surface-2);
  text-decoration: none;
  border-left-color: var(--coral);
  color: inherit;
  transform: none;
}

.card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
  z-index: 1;
}

.card-top {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}

/* Badges loose on the card (no card-top wrapper) still form a row */
.card > .badge {
  margin: 0 6px 10px 0;
}

.card > .badge + .badge {
  margin-left: 0;
}

.card > .card-title,
.card > h3 {
  margin-top: 0;
}

.card h3,
.card .card-title {
  display: block;
  font: 700 1.08rem/1.25 "Archivo", system-ui, sans-serif;
  color: var(--bone);
  margin: 0 0 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.card:hover h3,
.card:hover .card-title {
  color: var(--bone);
}

.card .tags {
  margin-top: auto;
  padding-top: 4px;
  gap: 6px;
}

/* Tags on surface cards need lift so they do not blend in */
.card .tag {
  background: var(--void);
  border-color: var(--line-hot);
  color: var(--bone-mute);
  padding: 5px 8px;
}

.card:hover .tag {
  border-color: rgba(232, 230, 225, 0.22);
  color: var(--bone-dim);
}

.card.is-deep {
  border-left-color: rgba(255, 92, 57, 0.35);
}

.card.is-deep:hover {
  border-left-color: var(--coral);
}

.foot {
  border-top: 1px solid var(--line);
  color: var(--bone-mute);
  text-align: center;
  padding: 28px 20px;
  font: 600 11px/1.5 "IBM Plex Sans", system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.foot a {
  color: var(--coral-soft);
  text-decoration: none;
}

.foot a:hover {
  color: var(--bone);
  text-decoration: underline;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .toc {
    position: static;
    border-left: 0;
    border: 1px solid var(--line);
    background: var(--surface);
    padding: 14px 14px 12px;
    max-height: none;
    overflow: visible;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
  }
  .toc::before {
    flex: 1 0 100%;
    margin-bottom: 4px;
  }
  .toc a {
    margin-left: 0;
    padding: 6px 10px;
    border: 1px solid var(--line-hot);
    border-left: 1px solid var(--line-hot);
    background: var(--void);
    font-size: 11px;
  }
  .toc a:hover {
    border-color: rgba(255, 92, 57, 0.4);
    background: var(--surface-2);
  }
  .toc a.lvl3 {
    padding-left: 10px;
    opacity: 0.85;
  }
  .boxhead h1 {
    font-size: 1.85rem;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .card {
    min-height: 0;
  }
  .body {
    max-width: none;
  }
}

@media (min-width: 761px) and (max-width: 980px) {
  .layout {
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 28px;
  }
}

/* Lab figures (screenshot callout replacements) */
figure.lab-figure {
  margin: 1.1rem 0 1.35rem;
  padding: 0;
  border: 1px solid var(--line-hot);
  border-radius: 0;
  background: var(--code);
  overflow: hidden;
}
figure.lab-figure img,
figure.lab-figure svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
}
figure.lab-figure figcaption {
  font: 500 12px/1.45 "IBM Plex Sans", system-ui, sans-serif;
  color: var(--bone-mute);
  padding: 10px 14px 12px;
  border-top: 1px solid var(--line);
  letter-spacing: 0.02em;
}
