/* Dark theme. The base callout rules force a white surface, which leaves the
   dark theme's light body text on white and renders callout content invisible
   (measured 1.0:1). Restate the surface, border, and text colors for dark so
   the callout keeps its restrained look without dropping below WCAG AA. */

[data-bs-theme="dark"] .callout.callout-tip,
[data-bs-theme="dark"] .callout.callout-note,
.quarto-dark .callout.callout-tip,
.quarto-dark .callout.callout-note {
  border-color: #454c54;
  background-color: #2b3035 !important;
  color: #e9ecef;
}

[data-bs-theme="dark"] .callout.callout-tip .callout-body,
[data-bs-theme="dark"] .callout.callout-tip .callout-body-container,
[data-bs-theme="dark"] .callout.callout-note .callout-body,
[data-bs-theme="dark"] .callout.callout-note .callout-body-container,
.quarto-dark .callout.callout-tip .callout-body,
.quarto-dark .callout.callout-tip .callout-body-container,
.quarto-dark .callout.callout-note .callout-body,
.quarto-dark .callout.callout-note .callout-body-container {
  color: #e9ecef;
}

[data-bs-theme="dark"] .callout.callout-tip,
.quarto-dark .callout.callout-tip {
  border-left-color: #4ade80;
}

[data-bs-theme="dark"] .callout.callout-tip .callout-title,
[data-bs-theme="dark"] .callout.callout-tip .callout-title-container,
.quarto-dark .callout.callout-tip .callout-title,
.quarto-dark .callout.callout-tip .callout-title-container {
  color: #86efac;
}

[data-bs-theme="dark"] .callout.callout-note,
.quarto-dark .callout.callout-note {
  border-left-color: #38bdf8;
}

[data-bs-theme="dark"] .callout.callout-note .callout-title,
[data-bs-theme="dark"] .callout.callout-note .callout-title-container,
.quarto-dark .callout.callout-note .callout-title,
.quarto-dark .callout.callout-note .callout-title-container {
  color: #7dd3fc;
}

/* The collapse toggle inherits the light-theme link color and disappears
   against the dark surface. */
[data-bs-theme="dark"] .callout.callout-tip .callout-toggle,
[data-bs-theme="dark"] .callout.callout-note .callout-toggle,
.quarto-dark .callout.callout-tip .callout-toggle,
.quarto-dark .callout.callout-note .callout-toggle {
  color: #adb5bd;
}

/*
 * Dark-theme corrections for content that carries its own light styling.
 *
 * Several boxes in index.qmd, preface.qmd and references.qmd set a light
 * background with an inline style. Those boxes are light by design, and the
 * text inside them is given a dark colour inline. What was missing is the
 * inherited colour: any text in the box WITHOUT an inline colour fell back to
 * the dark theme's white body text, putting white on #f8f9fa (measured
 * 1.05:1). Restoring a dark inherited colour fixes the legibility without
 * changing the intended design or losing the accent colours.
 *
 * The durable fix is to replace these inline styles with a theme-aware class.
 * Until then this list has to track the background colours used in the source;
 * a new inline background will need a new entry here.
 */

[data-bs-theme="dark"] main [style*="background-color: #fafafa"],
[data-bs-theme="dark"] main [style*="background-color: #f8f9fa"],
[data-bs-theme="dark"] main [style*="background-color: #fef9f3"],
[data-bs-theme="dark"] main [style*="background-color: #fffbeb"],
[data-bs-theme="dark"] main [style*="background-color: #f0fdfa"],
[data-bs-theme="dark"] main [style*="background-color: #f0fdf4"],
[data-bs-theme="dark"] main [style*="background-color: #eff6ff"],
.quarto-dark main [style*="background-color: #fafafa"],
.quarto-dark main [style*="background-color: #f8f9fa"],
.quarto-dark main [style*="background-color: #fef9f3"],
.quarto-dark main [style*="background-color: #fffbeb"],
.quarto-dark main [style*="background-color: #f0fdfa"],
.quarto-dark main [style*="background-color: #f0fdf4"],
.quarto-dark main [style*="background-color: #eff6ff"] {
  color: #1f2937;
}

/* Links inside those boxes also inherit the dark theme's link colour, which is
   tuned for a dark surface and is too pale on these light cards. */
[data-bs-theme="dark"] main [style*="background-color: #fafafa"] a,
[data-bs-theme="dark"] main [style*="background-color: #f8f9fa"] a,
[data-bs-theme="dark"] main [style*="background-color: #fef9f3"] a,
[data-bs-theme="dark"] main [style*="background-color: #fffbeb"] a,
[data-bs-theme="dark"] main [style*="background-color: #f0fdfa"] a,
[data-bs-theme="dark"] main [style*="background-color: #f0fdf4"] a,
[data-bs-theme="dark"] main [style*="background-color: #eff6ff"] a,
.quarto-dark main [style*="background-color: #fafafa"] a,
.quarto-dark main [style*="background-color: #f8f9fa"] a,
.quarto-dark main [style*="background-color: #fef9f3"] a,
.quarto-dark main [style*="background-color: #fffbeb"] a,
.quarto-dark main [style*="background-color: #f0fdfa"] a,
.quarto-dark main [style*="background-color: #f0fdf4"] a,
.quarto-dark main [style*="background-color: #eff6ff"] a {
  color: #0b5f63;
}

/*
 * Sibling-handbook links on the Advisory page.
 *
 * These carried hardcoded slate colours inline (#64748b on the paragraph,
 * #475569 on the links) with no background behind them, so on the dark theme
 * they sat on the near-black page at 3.34:1 and 2.10:1. Defining them here
 * instead lets each theme pick a colour that actually passes.
 */
.handbook-family p {
  font-size: 0.88rem;
  color: #64748b;
  margin: 0;
}

.handbook-family a {
  color: #475569;
  text-decoration: none;
  border-bottom: 1px solid #cbd5e1;
}

[data-bs-theme="dark"] .handbook-family p,
.quarto-dark .handbook-family p {
  color: #adb5bd;
}

[data-bs-theme="dark"] .handbook-family a,
.quarto-dark .handbook-family a {
  color: #cbd5e1;
  border-bottom-color: #4b5563;
}
