/* PracticalCoder site layer — loaded after /css/pico.classless.min.css */
/* These light-scheme vars lose to Pico's dark :root:not([data-theme]) and
   :root[data-theme="dark"] rules on specificity, so they only ever apply in
   light contexts; the [data-theme="light"] branch keeps the brand values
   under an authored light pin. */
:root,
:root[data-theme="light"] {
  --pico-font-family: 'Lora', Georgia, 'Times New Roman', serif;
  --pico-font-family-sans-serif: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --pico-primary: #6366f1;
  --pico-primary-hover: #4f46e5;
  --pico-primary-underline: rgba(99, 102, 241, 0.5);
  --pico-primary-focus: rgba(99, 102, 241, 0.25);
  --pico-color: #334155;
  --pico-background-color: #f8fafc;
  --pico-muted-color: #64748b;
  --pico-muted-border-color: #e2e8f0;
  --pico-border-radius: 0.5rem;
  --bleed: 0px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--pico-font-family-sans-serif);
}

/* Slate headings are light-scheme only. Under dark scheme — OS preference
   with no data-theme, or an authored data-theme="dark" pin — Pico's per-theme
   heading vars apply; a hardcoded color here renders dark-on-dark. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) h1,
  :root:not([data-theme]) h2,
  :root:not([data-theme]) h3,
  :root:not([data-theme]) h4,
  :root:not([data-theme]) h5,
  :root:not([data-theme]) h6 {
    color: #0f172a;
  }
}
:root[data-theme="light"] h1,
:root[data-theme="light"] h2,
:root[data-theme="light"] h3,
:root[data-theme="light"] h4,
:root[data-theme="light"] h5,
:root[data-theme="light"] h6 {
  color: #0f172a;
}

h1 {
  font-weight: 800;
}

/* Fixed header fragment (public/fragments/header.html is 3em tall) */
body.shared-header-enabled {
  padding-top: 3em;
}

/* Reading column */
main.container,
body > main {
  max-width: 48rem;
  margin-inline: auto;
}

/* Image slots (html-hydrator emits figure.article-image.slot-{hero|body-N} > picture > img) */
figure.article-image {
  margin: 2rem 0;
}

figure.article-image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--pico-border-radius);
}

figure.article-image.slot-hero {
  margin: 1.5rem calc(-1 * var(--bleed)) 2rem;
}

figure.article-image[class*="slot-body"] {
  max-width: 75%;
  margin-inline: auto;
}

figure.article-image figcaption {
  font-size: 0.875rem;
  color: var(--pico-muted-color);
  text-align: center;
  margin-top: 0.5rem;
}

/* Legacy articles / markers that emit a bare img */
article > img,
img.article-image-legacy {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 2rem auto;
  border-radius: var(--pico-border-radius);
}

/* Diagrams */
.hydrate-diagram svg {
  max-width: 100%;
  max-height: 28rem;
  height: auto;
  display: block;
  margin: 2rem auto;
}

/* Code blocks + copy button (moved out of press-agent tools/html_design.py) */
.code-block-wrapper {
  position: relative;
}

.copy-button {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--pico-primary);
  color: #fff;
  border: none;
  border-radius: calc(var(--pico-border-radius) - 0.25rem);
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
  width: auto;
  margin: 0;
}

.code-block-wrapper:hover .copy-button,
pre:not(.mermaid):hover .copy-button {
  opacity: 1;
}

.copy-button:hover {
  background: var(--pico-primary-hover);
}

/* Dark scheme: the bright brand primary washes out white label text; use
   Pico's darker primary-background (applies to OS dark with no data-theme
   and to an authored data-theme="dark" pin). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .copy-button {
    background: var(--pico-primary-background);
  }
  :root:not([data-theme]) .copy-button:hover {
    background: var(--pico-primary-hover-background);
  }
}
:root[data-theme="dark"] .copy-button {
  background: var(--pico-primary-background);
}
:root[data-theme="dark"] .copy-button:hover {
  background: var(--pico-primary-hover-background);
}
