/* Code and command-line blocks (MD-82). Loaded on every page by
   SiteHeader; /code-blocks.js adds the frame and highlighting.
   Token colours all meet WCAG AA (4.5:1) on #07101f; the lowest is
   comments at about 6.7:1. */

.code-frame {
  min-width: 0;
  margin: 0 0 1.2em;
  border: 1px solid #2d3e56;
  border-radius: 10px;
  background: #07101f;
  overflow: hidden;
}
/* A hidden block (e.g. a quiz question without code) hides its frame too. */
.code-frame:has(> pre[hidden]) {
  display: none;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 8px 6px 14px;
  border-bottom: 1px solid #1d2a40;
  background: #0f1a2c;
}
.code-lang {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a7b5c9;
}
.code-copy {
  min-height: 30px;
  padding: 4px 12px;
  border: 1px solid #2d3e56;
  border-radius: 6px;
  background: transparent;
  color: #dfe7f2;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
}
.code-copy:hover,
.code-copy:focus-visible {
  border-color: var(--mint, #53e3bd);
  color: var(--mint, #53e3bd);
}

/* The block itself; beats each tool's own .code-block rules. */
.code-frame > pre[data-lang],
.code-frame > pre.code-block,
.code-frame > pre.guide-code {
  margin: 0;
  padding: 14px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #dfe7f2;
  font:
    0.84rem/1.6 "IBM Plex Mono",
    ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  white-space: pre;
  overflow-x: auto;
  tab-size: 2;
}
.code-frame > pre:focus-visible {
  outline: 2px solid var(--mint, #53e3bd);
  outline-offset: -2px;
}
.code-frame > pre code {
  padding: 0;
  background: none;
  font: inherit;
  color: inherit;
}

/* Command-line blocks: wrap long commands, prompt from CSS (never copied). */
.code-frame.is-terminal > pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.term-line {
  display: block;
  padding-left: 1.4em;
  text-indent: -1.4em;
}
.term-cmd::before {
  content: "$ ";
  color: var(--mint, #53e3bd);
  user-select: none;
}
.term-cont {
  padding-left: 2.8em;
}
.term-nl {
  display: none;
}
.term-blank {
  min-height: 1.6em;
}
.term-out {
  color: #a7b5c9;
}

/* Tokens. */
.hljs-comment,
.hljs-quote {
  color: #8a9ab2;
  font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-doctag {
  color: #c9a8ff;
}
.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-template-string {
  color: #8ee6b8;
}
.hljs-number,
.hljs-symbol,
.hljs-bullet {
  color: #ffc58a;
}
.hljs-attr,
.hljs-attribute,
.hljs-property,
.hljs-variable,
.hljs-template-variable,
.hljs-params {
  color: #7cc7ff;
}
.hljs-built_in,
.hljs-type,
.hljs-class .hljs-title,
.hljs-title.class_ {
  color: #ffd88a;
}
.hljs-title,
.hljs-title.function_,
.hljs-section,
.hljs-name {
  color: #9fdcff;
}
.hljs-meta,
.hljs-meta .hljs-keyword,
.hljs-deletion,
.hljs-tag {
  color: #f2a7c7;
}
.hljs-emphasis {
  font-style: italic;
}
.hljs-strong {
  font-weight: 700;
}

@media (max-width: 640px) {
  .code-frame > pre[data-lang],
  .code-frame > pre.code-block,
  .code-frame > pre.guide-code {
    padding: 12px 14px;
    font-size: 0.8rem;
  }
}
