/* ==========================================================================
   Artem Cherezov — security research blog
   Direction: "Synthesis" — Grid palette + indexed feed, serif masthead,
   Ledger post structure. Dark default, light optional.
   ========================================================================== */

/* ------------------------------ Tokens ---------------------------------- */

:root,
:root[data-theme="dark"] {
  --bg: #1a1c1f;
  --bg-raised: #212429;
  --bg-inline: #25282d;
  --border: #32353a;
  --border-strong: #464a50;

  --text: #ebedee;
  --text-body: #c0c4c8;
  --text-soft: #c6c9cc;
  --text-muted: #94989d;
  --text-faint: #63676c;

  --accent: oklch(0.66 0.17 40);
  --accent-soft: oklch(0.7 0.15 40);

  --tok-kw: oklch(0.68 0.15 40);
  --tok-str: #9db8a4;
  --tok-comment: #5c6165;
  --tok-punc: #94989d;
  --tok-fn: #ebedee;
  --tok-num: #94989d;
  --tok-ok: #9db8a4;

  --sev-critical: #e0674a;
  --sev-high: #e0954e;
  --sev-medium: #cbb15e;
}

:root[data-theme="light"] {
  --bg: #f0ede7;
  --bg-raised: #e7e3db;
  --bg-inline: #e4e0d8;
  --border: #d8d3ca;
  --border-strong: #c3bdb2;

  --text: #1c1d1f;
  --text-body: #3a3d40;
  --text-soft: #33363a;
  --text-muted: #6b6f74;
  --text-faint: #9a9ea3;

  --accent: oklch(0.55 0.17 40);
  --accent-soft: oklch(0.5 0.15 40);

  --tok-kw: oklch(0.5 0.15 40);
  --tok-str: #4a6b3a;
  --tok-comment: #9a9ea3;
  --tok-punc: #6b6f74;
  --tok-fn: #1c1d1f;
  --tok-num: #6b6f74;
  --tok-ok: #4a6b3a;

  --sev-critical: #c0392b;
  --sev-high: #b5701f;
  --sev-medium: #8a7320;
}

/* ------------------------------- Base ----------------------------------- */

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

/* Explicit inline link — visibly blue and underlined. */
.link { color: #3b82f6; text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: #60a5fa; }

/* Inline links inside prose (post body, about) read as links: accent + underline. */
.article p a,
.article li a,
.about p a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.article p a:hover,
.article li a:hover,
.about p a:hover { color: var(--accent-soft); }

code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--bg-inline);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

.container { max-width: 1160px; margin: 0 auto; }

/* ------------------------------ Header ---------------------------------- */

.site-header {
  text-align: center;
  padding: 34px 0 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: "Newsreader", Georgia, serif;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.brand:hover { color: var(--text); }

.nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  margin-top: 14px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--accent); }

.theme-toggle {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  line-height: 1;
  color: var(--text-muted);
}
.theme-toggle svg { display: block; }
.theme-toggle:hover { color: var(--text); }

/* Show the moon in dark mode, the sun in light mode. */
.theme-toggle .sun { display: none; }
:root[data-theme="light"] .theme-toggle .moon { display: none; }
:root[data-theme="light"] .theme-toggle .sun { display: block; }

/* ------------------------------ Footer ---------------------------------- */

.site-footer {
  position: relative;
  margin-top: auto;
  margin-bottom: 40px;
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-faint);
}
.site-footer a:hover { color: var(--text); }
.site-footer .sep { margin: 0 6px; }

/* Social group stays centered; RSS floats to the right, just shy of the edge. */
.site-footer__rss {
  position: absolute;
  right: 40px;
  top: 24px;
}

@media (max-width: 640px) {
  /* Stack on narrow screens so RSS doesn't overlap the social group. */
  .site-footer__rss {
    position: static;
    display: block;
    margin-top: 10px;
  }
}

/* ----------------------------- Page intro ------------------------------- */

.page-intro { padding: 48px 40px 0; }

.page-intro__title {
  margin: 10px 0 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--accent);
}

.page-intro__lead {
  margin: 14px 0 0;
  font-size: 17px;
  color: var(--text-muted);
  max-width: 460px;
  line-height: 1.5;
}

/* ----------------------------- Post index ------------------------------- */

.post-index { margin-top: 36px; }

.post-row {
  display: grid;
  grid-template-columns: 72px 1fr 170px 110px;
  align-items: baseline;
  padding: 22px 40px;
  border-top: 1px solid var(--border);
  transition: background 120ms ease;
}
.post-row:last-child { border-bottom: 1px solid var(--border); }

.post-row__num {
  font: 15px "JetBrains Mono", monospace;
  color: var(--accent);
}

.post-row__main { padding-right: 32px; }

.post-row__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.post-row__title a { color: var(--accent); }
.post-row__title a:hover { color: var(--accent-soft); }

.post-row__desc {
  font-size: 16.5px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
  max-width: 560px;
}

.post-row__cat {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.post-row__cve {
  font: 13px "JetBrains Mono", monospace;
  color: var(--accent);
  letter-spacing: 0;
  text-transform: none;
  margin-top: 6px;
}

.post-row__date {
  font: 14px "JetBrains Mono", monospace;
  color: var(--text-faint);
  text-align: right;
}

/* Severity labels (advisories + post header) */
.sev {
  font: 13px "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}
.sev--critical { color: var(--sev-critical); }
.sev--high { color: var(--sev-high); }
.sev--medium { color: var(--sev-medium); }

/* Inline emphasis inside article prose */
.article .em { color: var(--text); }

/* ------------------------------- Article -------------------------------- */

.article-shell {
  display: grid;
  grid-template-columns: 190px 792px;
  gap: 56px;
  justify-content: center;
  padding: 52px 32px 72px;
}

/* TOC rail */
.toc { position: sticky; top: 32px; }

.toc__label {
  font: 13px "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-left: 1px solid var(--border);
  font: 14.5px "JetBrains Mono", monospace;
}

.toc__link {
  display: block;
  padding-left: 13px;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.toc__link:hover { color: var(--text); }
.toc__link.active {
  padding-left: 12px;
  border-left-color: var(--accent);
  color: var(--accent-soft);
}

/* Post header */
.article__back {
  display: inline-block;
  font: 14.5px "JetBrains Mono", monospace;
  color: var(--text-muted);
  margin-bottom: 26px;
}

.post-header__tags {
  display: flex;
  gap: 14px;
  font: 14px "JetBrains Mono", monospace;
  color: var(--accent);
  margin-bottom: 14px;
}
.post-header__tags .tag-dim { color: var(--text-faint); }

.post-header__title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.post-header__sub {
  font-size: 19px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 12px 0 0;
}

.post-header__byline {
  font: 14.5px "JetBrains Mono", monospace;
  color: var(--text-faint);
  margin-top: 16px;
}

/* TL;DR — hairline rules, no box */
.tldr {
  margin: 30px 0;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.tldr__label {
  font: 600 13px "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-bottom: 8px;
}

.tldr p {
  margin: 0;
  font-size: 18px;
  line-height: 1.6;
  color: var(--text-soft);
}

/* Sections */
.sec-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 40px 0 14px;
}
.sec-head:first-of-type { margin-top: 0; }

.sec-head__num {
  font: 15px "JetBrains Mono", monospace;
  color: var(--accent);
}

.sec-head__title {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.article p {
  font-size: 18.5px;
  line-height: 1.7;
  color: var(--text-body);
  margin: 0 0 18px;
}

/* Screenshots / figures in post body. */
.post-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Code blocks */
.code-block {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 34px 18px 16px;
  margin: 0 0 18px;
}

.code-block pre {
  margin: 0;
  font: 15px/1.65 "JetBrains Mono", monospace;
  overflow-x: auto;
}

/* Thin, themed scrollbars on horizontally-scrolling code (Chromium's default
   is thick and light). Firefox uses the standard scrollbar-* properties. */
.code-block pre,
.details pre {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.code-block pre::-webkit-scrollbar,
.details pre::-webkit-scrollbar {
  height: 8px;
}
.code-block pre::-webkit-scrollbar-track,
.details pre::-webkit-scrollbar-track {
  background: transparent;
}
.code-block pre::-webkit-scrollbar-thumb,
.details pre::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}
.code-block pre::-webkit-scrollbar-thumb:hover,
.details pre::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

.code-block code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: var(--text-body);
}

.code-block__copy {
  position: absolute;
  top: 10px;
  right: 12px;
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: 13px "JetBrains Mono", monospace;
  color: var(--text-faint);
}
.code-block__copy:hover { color: var(--text); }

.tok-comment { color: var(--tok-comment); }
.tok-kw { color: var(--tok-kw); }
.tok-str { color: var(--tok-str); }
.tok-punc { color: var(--tok-punc); }
.tok-fn { color: var(--tok-fn); }
.tok-num { color: var(--tok-num); }
.tok-ok { color: var(--tok-ok); }

/* Collapsible terminal output */
.details {
  margin: 0 0 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.details summary {
  cursor: pointer;
  padding: 10px 14px;
  font: 14px "JetBrains Mono", monospace;
  color: var(--text-muted);
  list-style: none;
}
.details summary::-webkit-details-marker { display: none; }
.details summary:hover { color: var(--text); }
.details pre {
  margin: 0;
  padding: 4px 14px 14px;
  font: 14.5px/1.65 "JetBrains Mono", monospace;
  color: var(--text-muted);
  overflow-x: auto;
}
.details pre code { background: none; border: none; padding: 0; font-size: inherit; color: inherit; }

/* Collapsible whose body is rendered markdown (prose + highlighted code). */
.details__body { padding: 4px 14px 14px; }
.details__body > :first-child { margin-top: 0; }
.details__body > :last-child { margin-bottom: 0; }
.details__body p { font-size: 18.5px; line-height: 1.7; color: var(--text-body); margin: 0 0 14px; }

/* Related */
.related {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.related__label {
  font: 13px "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 12px;
}
.related ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 16.5px;
  color: var(--text-soft);
}
.related__arrow { color: var(--accent); margin-right: 6px; }
.related__note { color: var(--text-faint); font-size: 15px; }

/* ------------------------------ Advisories ------------------------------ */

.adv-index { margin-top: 36px; }

.adv-row {
  display: grid;
  grid-template-columns: 170px 190px minmax(0, 1fr) 120px 90px;
  column-gap: 24px;
  align-items: baseline;
  padding: 20px 40px;
  border-top: 1px solid var(--border);
  transition: background 120ms ease;
}
.adv-row--head {
  padding: 12px 40px;
  border-top: 2px solid var(--text);
}
.adv-row--head > div {
  font: 12px "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}
.adv-row:not(.adv-row--head):hover { background: var(--bg-raised); }
.adv-row:last-child { border-bottom: 1px solid var(--border); }

/* Only Description wraps; the rest stay on one line. */
.adv-row__id,
.adv-row__soft,
.adv-row__sev,
.adv-row__credit { white-space: nowrap; }

.adv-row__id { font: 600 15px "JetBrains Mono", monospace; }
.adv-row__id a { color: var(--accent); }
.adv-row__id a:hover { color: var(--accent-soft); }
.adv-row__soft {
  font: 14px "JetBrains Mono", monospace;
  color: var(--text-soft);
}
.adv-row__soft a { color: var(--text-soft); }
.adv-row__soft a:hover { color: var(--accent); }
.adv-row__desc { font-size: 15.5px; color: var(--text-muted); line-height: 1.5; }
.adv-row__credit {
  font: 14px "JetBrains Mono", monospace;
  color: var(--text-muted);
}
.adv-row__credit a { color: var(--text-muted); }
.adv-row__credit a:hover { color: var(--accent); }

/* -------------------------------- About --------------------------------- */

.about { max-width: 680px; margin: 0 auto; padding: 52px 24px 72px; }

.about h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}
.about__handle {
  font: 400 17px "JetBrains Mono", monospace;
  color: var(--accent);
  letter-spacing: 0;
}

.about__lead {
  font-size: 21px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 12px 0 0;
}
.about__tag {
  font: 14px "JetBrains Mono", monospace;
  color: var(--accent);
  letter-spacing: 0.02em;
  vertical-align: middle;
  margin-left: 8px;
}

.about__rule { height: 1px; background: var(--border); margin: 30px 0; border: none; }

.about p {
  font-size: 18.5px;
  line-height: 1.7;
  color: var(--text-body);
  margin: 0 0 18px;
}

.about__label {
  font: 13px "JetBrains Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin: 34px 0 12px;
}

.about__areas {
  font-size: 17px;
  color: var(--text-soft);
  line-height: 1.8;
}
.about__areas .sep { color: var(--text-faint); margin: 0 8px; }

.about__contact {
  font: 15px "JetBrains Mono", monospace;
  color: var(--text-muted);
}
.about__contact a { color: var(--text-soft); }
.about__contact a:hover { color: var(--accent); }
.about__contact .sep { color: var(--text-faint); margin: 0 8px; }

/* ------------------------------ Responsive ------------------------------ */

@media (max-width: 1000px) {
  .article-shell {
    grid-template-columns: minmax(0, 792px);
    padding: 40px 24px 64px;
  }
  .toc-rail { display: none; }
}

@media (max-width: 760px) {
  .page-intro { padding: 36px 20px 0; }
  .page-intro__title { font-size: 30px; }
  .post-row {
    grid-template-columns: 48px 1fr;
    row-gap: 8px;
    padding: 18px 20px;
  }
  .post-row__cat { grid-column: 2; }
  .post-row__date { grid-column: 2; text-align: left; }
  .adv-row,
  .adv-row--head {
    grid-template-columns: 1fr;
    row-gap: 6px;
    padding: 16px 20px;
  }
  .adv-row__desc { padding-right: 0; }
  /* The header row's column labels don't map onto a stacked layout. */
  .adv-row--head { display: none; }
}

/* ---------------- Path A: Chroma syntax highlighting -> palette ---------- */
/* Maps Hugo/Chroma token classes onto the same colors the hand-written
   tok-* spans used, so Markdown code blocks match the site's look. */
.code-block .chroma { background: none; }
.code-block .chroma code { background: none; border: none; padding: 0; color: var(--text-body); }
.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1, .chroma .cs { color: var(--tok-comment); font-style: normal; }
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr, .chroma .kt { color: var(--tok-kw); }
.chroma .s, .chroma .sb, .chroma .sc, .chroma .s1, .chroma .s2, .chroma .se, .chroma .sh { color: var(--tok-str); }
.chroma .nt { color: var(--tok-kw); }                 /* YAML keys / tags */
.chroma .p, .chroma .pi { color: var(--tok-punc); }
.chroma .nf, .chroma .nb, .chroma .fm { color: var(--tok-fn); }
.chroma .m, .chroma .mi, .chroma .mf, .chroma .mh { color: var(--tok-num); }
.chroma .l, .chroma .no { color: var(--tok-str); }    /* literals / constants */
