/* =============================================================================
   code.css — Pygments / Nikola syntax highlighting
   Palette: Vim "retrobox" (dark), ported from gruvbox8
   AI-GENERATED STYLESHEET — modify freely, but it came from a machine.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Tokens
   -------------------------------------------------------------------------- */
:root {
  --code-bg: #1c1c1c;
  --code-fg: #ebdbb2;
  --code-highlight-bg: #303030;      /* CursorLine */
  --code-lineno-special-bg: #5f431f; /* IncSearch */
  --code-lineno-bg: #202020;
  --code-lineno-fg: #7c6f64;         /* LineNr */

  --code-comment: #928374;
  --code-plain: #ebdbb2;
  --code-operator: #8ec07c;          /* Operator / Structure */
  --code-keyword: #fb5944;           /* Keyword / Statement / Label */
  --code-error-bg: #fb5944;
  --code-deleted: #fb5944;
  --code-inserted: #b8bb26;
  --code-doc: #83a598;               /* Identifier, for #! shebangs etc. */
  --code-preproc: #8ec07c;           /* PreProc / Include / Define */
  --code-string: #b8bb26;
  --code-constant: #d3869b;
  --code-entity: #fe8019;            /* Special */
  --code-exception: #fb5944;
  --code-function: #b8bb26;
  --code-variable: #83a598;          /* Identifier */
  --code-type: #fabd2f;              /* Type / Typedef */
  --code-special: #fe8019;           /* Special / Delimiter / StorageClass */
  --code-whitespace: #504945;        /* NonText / Conceal */
}

/* -----------------------------------------------------------------------------
   2. Containers
   :is() keeps the scope list in one place instead of repeating it ~70 times.
   Caveat: :is() adopts the specificity of its most specific argument, so
   descendant rules normalize to 0,3,0. Harmless here, but worth knowing.
   -------------------------------------------------------------------------- */
pre {
  line-height: 125%;
}

pre.code,
.code .codetable,
.highlight pre {
  background: var(--code-bg);
  color: var(--code-fg);
}

:is(pre.code, .code .codetable, .highlight pre) .hll {
  background-color: var(--code-highlight-bg);
}

/* -----------------------------------------------------------------------------
   3. Comments — Retrobox sets gui=NONE, hence no italics
   -------------------------------------------------------------------------- */
:is(pre.code, .code .codetable, .highlight pre) :is(.c, .cm, .cpf, .c1, .cs) {
  color: var(--code-comment);
}

:is(pre.code, .code .codetable, .highlight pre) .ch {
  color: var(--code-doc);
}

:is(pre.code, .code .codetable, .highlight pre) .cp {
  color: var(--code-preproc);
}

/* -----------------------------------------------------------------------------
   4. Errors — emulates gui=bold,reverse
   -------------------------------------------------------------------------- */
:is(pre.code, .code .codetable, .highlight pre) .err {
  color: var(--code-bg);
  background-color: var(--code-error-bg);
  font-weight: bold;
}

/* -----------------------------------------------------------------------------
   5. Keywords
   -------------------------------------------------------------------------- */
:is(pre.code, .code .codetable, .highlight pre) :is(.k, .kp, .kr) {
  color: var(--code-keyword);
}

:is(pre.code, .code .codetable, .highlight pre) .kn,
:is(pre.code, .code .codetable, .highlight pre) .nn {
  color: var(--code-preproc);        /* import / namespace → Include */
}

:is(pre.code, .code .codetable, .highlight pre) .kd {
  color: var(--code-special);        /* declaration → StorageClass */
}

:is(pre.code, .code .codetable, .highlight pre) .kt {
  color: var(--code-type);           /* builtin types → Type */
}

:is(pre.code, .code .codetable, .highlight pre) .kc {
  color: var(--code-constant);       /* True / False / None → Constant */
}

:is(pre.code, .code .codetable, .highlight pre) .nl {
  color: var(--code-keyword);        /* Label */
}

/* -----------------------------------------------------------------------------
   6. Operators & punctuation
   -------------------------------------------------------------------------- */
:is(pre.code, .code .codetable, .highlight pre) .o {
  color: var(--code-operator);
}

:is(pre.code, .code .codetable, .highlight pre) .ow {
  color: var(--code-keyword);        /* and / or / not → Conditional */
}

:is(pre.code, .code .codetable, .highlight pre) .p {
  color: var(--code-fg);
}

:is(pre.code, .code .codetable, .highlight pre) .pm {
  color: var(--code-special);
}

:is(pre.code, .code .codetable, .highlight pre) .w {
  color: var(--code-whitespace);
}

/* -----------------------------------------------------------------------------
   7. Names
   -------------------------------------------------------------------------- */
:is(pre.code, .code .codetable, .highlight pre) .na {
  color: var(--code-variable);       /* HTML attribute names → Identifier */
}

:is(pre.code, .code .codetable, .highlight pre) .nb {
  color: var(--code-type);
}

:is(pre.code, .code .codetable, .highlight pre) .bp {
  color: var(--code-constant);
}

:is(pre.code, .code .codetable, .highlight pre) .nc {
  color: var(--code-type);
}

:is(pre.code, .code .codetable, .highlight pre) .nd {
  color: var(--code-special);        /* decorators */
}

:is(pre.code, .code .codetable, .highlight pre) .ni {
  color: var(--code-entity);         /* &amp; etc. → Special */
}

:is(pre.code, .code .codetable, .highlight pre) .ne {
  color: var(--code-exception);
}

:is(pre.code, .code .codetable, .highlight pre) .nf {
  color: var(--code-function);
  font-weight: bold;                 /* hi Function gui=bold */
}

:is(pre.code, .code .codetable, .highlight pre) .nt {
  color: var(--code-keyword);        /* HTML tags → Statement-ish */
}

:is(pre.code, .code .codetable, .highlight pre) :is(.nv, .vc, .vi, .vg, .py) {
  color: var(--code-variable);
}

:is(pre.code, .code .codetable, .highlight pre) .no {
  color: var(--code-constant);
}

:is(pre.code, .code .codetable, .highlight pre) :is(.fm, .vm) {
  color: var(--code-function);
}

/* -----------------------------------------------------------------------------
   8. Literals — numbers
   -------------------------------------------------------------------------- */
:is(pre.code, .code .codetable, .highlight pre) :is(.m, .mb, .mf, .mh, .mi, .mo, .il) {
  color: var(--code-constant);
}

/* -----------------------------------------------------------------------------
   9. Literals — strings
   -------------------------------------------------------------------------- */
:is(pre.code, .code .codetable, .highlight pre) :is(.s, .sb, .sh, .s2, .s1, .ss, .si) {
  color: var(--code-string);
}

:is(pre.code, .code .codetable, .highlight pre) .sa {
  color: var(--code-special);        /* f-string / affix prefix */
}

:is(pre.code, .code .codetable, .highlight pre) :is(.sc, .sx, .sr) {
  color: var(--code-error-bg);       /* escapes, regex → SpecialChar */
}

:is(pre.code, .code .codetable, .highlight pre) :is(.dl, .sd) {
  color: var(--code-string);
}

:is(pre.code, .code .codetable, .highlight pre) .se {
  color: var(--code-entity);
}

:is(pre.code, .code .codetable, .highlight pre) .si {
  text-decoration: underline;
  text-decoration-color: var(--code-variable);
}

/* -----------------------------------------------------------------------------
   10. Generic (diffs, emphasis, tracebacks)
   -------------------------------------------------------------------------- */
:is(pre.code, .code .codetable, .highlight pre) .ge {
  font-style: italic;
}

:is(pre.code, .code .codetable, .highlight pre) .ges {
  font-weight: bold;
  font-style: italic;
}

:is(pre.code, .code .codetable, .highlight pre) .gs {
  font-weight: bold;
}

:is(pre.code, .code .codetable, .highlight pre) :is(.gd, .gr) {
  color: var(--code-deleted);
}

:is(pre.code, .code .codetable, .highlight pre) .gi {
  color: var(--code-inserted);
}

:is(pre.code, .code .codetable, .highlight pre) .gt {
  color: var(--code-keyword);
}

:is(pre.code, .code .codetable, .highlight pre) :is(.gh, .gu) {
  color: var(--code-function);
}

:is(pre.code, .code .codetable, .highlight pre) :is(.go, .gp) {
  color: var(--code-comment);
}

/* -----------------------------------------------------------------------------
   11. Line numbers in <pre> blocks
   -------------------------------------------------------------------------- */
td.linenos .normal,
span.linenos {
  color: var(--code-lineno-fg);
  background-color: transparent;
  padding-left: 5px;
  padding-right: 5px;
}

td.linenos .special,
span.linenos.special {
  color: var(--code-fg);
  background-color: var(--code-lineno-special-bg);
  padding-left: 5px;
  padding-right: 5px;
}

/* -----------------------------------------------------------------------------
   12. Code tables & gutters
   -------------------------------------------------------------------------- */
.highlight table,
.highlight tr,
.highlight td,
.code table,
.code tr,
.code td {
  border-spacing: 0;
  border-collapse: separate;
  padding: 0;
}

table.codetable,
table.highlighttable {
  width: 100%;
}

.highlight pre,
.code pre {
  white-space: pre-wrap;
  line-height: normal;
}

:is(.highlighttable, .codetable) td.linenos {
  vertical-align: top;
  padding-inline: 10px;
  user-select: none;
  -webkit-user-select: none;
}

:is(.highlighttable, .codetable) td.linenos code::before {
  content: attr(data-line-number);
}

:is(.highlighttable, .codetable) td.code {
  overflow-wrap: normal;
  border-collapse: collapse;
}

:is(.highlighttable, .codetable) td.code code {
  overflow: unset;
  border: none;
  padding: 0;
  margin: 0;
  white-space: pre-wrap;
  line-height: unset;
  background: none;
}

.highlight .lineno.nonumber,
.code .lineno.nonumber {
  list-style: none;
}

td.linenos {
  text-align: right;
  width: 3.5em;
  padding-right: 0.5em;
  background: var(--code-lineno-bg);
  border-right: 1px solid #303030;
}

td.code {
  padding-left: 0.5em;
}
