/*
  Code Block — syntax-highlighted samples with a header bar and copy button.

  Structure:
    <div class="code-sample" data-lang="html">
      <button class="code-copy-btn" type="button">Copy</button>
      <pre class="code-block"><code class="language-html">…</code></pre>
    </div>

  The header bar (language label) is rendered via ::before on .code-sample using
  the data-lang attribute. The copy button is absolutely positioned in that bar.
*/

.code-sample {
  position: relative;
  border: 1px solid var(--wm-color-border);
  border-radius: var(--wm-radius-xs);
  overflow: hidden;
}

/* Header bar — shows the language label */
.code-sample::before {
  content: attr(data-lang);
  display: block;
  padding: 0 0.85rem;
  line-height: 2rem;
  min-height: 2rem;
  background: var(--wm-color-surface-strong);
  border-bottom: 1px solid var(--wm-color-border);
  font-size: 0.68rem;
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, monospace;
  letter-spacing: 0.06em;
  color: var(--wm-color-text-muted);
  text-transform: lowercase;
}

/* Copy button — top-right of the header bar */
.code-copy-btn {
  all: unset;
  position: absolute;
  top: 0;
  right: 0;
  height: 2rem;
  z-index: 1;
  padding: 0 0.75rem;
  font-size: 0.65rem;
  font-weight: 500;
  font-family: var(--wm-font-sans, 'Inter', sans-serif);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--wm-color-text-muted);
  border: none;
  border-left: 1px solid var(--wm-color-border);
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  line-height: 2rem;
  transition: color 0.15s ease, background 0.15s ease;
}

.code-copy-btn:hover,
.code-copy-btn:focus {
  background: var(--wm-color-surface-muted);
  color: var(--wm-color-text);
}

/* Code block — the <pre> inside .code-sample */
pre.code-block {
  background: var(--wm-color-bg);
  border: none;
  border-radius: 0;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-size: 0.75rem;
  line-height: 1.7;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Menlo, monospace;
  color: var(--wm-color-text-secondary);
  margin: 0;
  tab-size: 2;
}

.code-block code {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  padding: 0;
}
