
/* ==========================================
   CODE BLOCKS
   Rendered by partials/code-block.php. Highlighting is applied
   server-side, so these classes only need to supply color.
   ========================================== */
.code-block {
  margin: 20px 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--gray-200);
}

.code-block-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-100);
}

.code-block-label {
  font-family: 'IBM Plex Mono', Consolas, monospace;
  font-size: var(--text-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-900);
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  font-size: var(--text-2xs);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.code-copy:hover {
  background: var(--gray-100);
  color: var(--gray-900);
  border-color: var(--gray-300);
}

.code-copy.is-copied {
  color: var(--emerald-700);
  border-color: var(--emerald-300);
  background: var(--emerald-50);
}

.code-block pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
  background: transparent;
}

.code-block pre code {
  font-family: 'IBM Plex Mono', Consolas, monospace;
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.7;
  color: var(--gray-900);
  background: none;
  padding: 0;
  white-space: pre;
}

/* Token colors, tuned for a light background. Kept few on purpose: more hues
   read as noise rather than meaning. They sit at 600 on the palette: the 700s
   were legible but muddy against white, and the greys below 600 disappeared. */
.code-block .tok-key     { color: var(--sky-600); }
.code-block .tok-str     { color: var(--emerald-600); }
.code-block .tok-num     { color: var(--amber-600); }
.code-block .tok-lit     { color: var(--amber-600); }
.code-block .tok-punc    { color: var(--gray-600); }
.code-block .tok-comment { color: var(--gray-600); font-style: italic; font-weight: 400; }
.code-block .tok-cmd     { color: var(--gray-900); font-weight: 600; }
.code-block .tok-flag    { color: var(--purple-600); }
.code-block .tok-url     { color: var(--blue-600); }
.code-block .tok-cont    { color: var(--gray-600); }
.code-block .tok-kw      { color: var(--purple-600); font-weight: 600; }
.code-block .tok-var     { color: var(--sky-600); }
.code-block .tok-fn      { color: var(--blue-600); }
.code-block .tok-tag     { color: var(--sky-600); }

/* Language tabs. Only one variant is in flow at a time, so the block's height
   follows whichever snippet is showing instead of the tallest one. */
.code-block-bar {
  flex-wrap: wrap;
}

.code-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}

.code-tab {
  padding: 4px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--gray-500);
  font-family: inherit;
  font-size: var(--text-2xs);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.code-tab:hover {
  color: var(--gray-900);
  background: var(--gray-100);
}

.code-tab.is-active {
  background: var(--white);
  color: var(--gray-900);
  box-shadow: inset 0 0 0 1px var(--gray-200);
}

.code-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.code-variant {
  display: none;
}

.code-variant.is-active {
  display: block;
}


@media (max-width: 640px) {
  .code-block pre code { font-size: var(--text-2xs); }
}


/* Migration articles show an old and a new version of the same thing. The rail
   color lets a reader tell them apart before reading the label. Opt-in, so
   documentation blocks are unaffected. */
.code-block-before {
  border-left: 3px solid var(--gold-f0c040);
}

.code-block-after {
  border-left: 3px solid var(--primary-blue);
}
