.drop-shadow img,
.drop-shadow video,
video.drop-shadow {
    filter: drop-shadow(0 4px 8px rgb(0 0 0 / 25%));
}

/* Cap only tagged course diagrams so their labels do not grow on wide screens.
   Existing percentage widths still determine their size on smaller screens. */
.bd-article img.diagram-width-small {
    max-width: min(100%, 440px);
    height: auto;
}

.bd-article img.diagram-width-medium {
    max-width: min(100%, 470px);
    height: auto;
}

.bd-article img.diagram-width-large {
    max-width: min(100%, 550px);
    height: auto;
}

.bd-article img.diagram-width-overview {
    max-width: min(100%, 550px);
    height: auto;
}

/* Code block labels describe how learners should use each snippet. */
.bd-article {
    --course-code-background: #fff;
    --course-reference-background: #f1f3f5;
    --course-code-border: #d1d5db;
}

html[data-theme="dark"] .bd-article {
    --course-code-background: #181b20;
    --course-reference-background: #252a31;
    --course-code-border: #49515c;
}

.bd-article div.copy-code,
.bd-article div.view-code,
.bd-article div.terminal-output {
    position: relative;
}

.bd-article div.copy-code > .highlight > pre,
.bd-article div.view-code > .highlight > pre,
.bd-article div.terminal-output > .highlight > pre {
    padding-top: 1.25rem;
    background: var(--course-code-background);
    border: 1px solid var(--course-code-border);
    border-radius: 0.375rem;
}

.bd-article div.view-code > .highlight > pre,
.bd-article div.terminal-output > .highlight > pre {
    background: var(--course-reference-background);
}

.bd-article div.optional-dashed > .highlight > pre {
    border-style: dashed;
}

.bd-article div.copy-code::before,
.bd-article div.view-code::before,
.bd-article div.terminal-output::before {
    content: "Paste";
    position: absolute;
    top: 0;
    left: 1rem;
    transform: translateY(-50%);
    z-index: 1;
    padding: 0 0.4rem;
    background: var(--course-code-background);
    color: var(--pst-color-text-base);
    font-family: var(--pst-font-family-base);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.2;
}

.bd-article div.run-code::before { content: "Run"; }
.bd-article div.view-code::before { content: "Reference"; }
.bd-article div.terminal-output::before { content: "Output"; }
.bd-article div.copy-code.optional-dashed::before { content: "Optional: Paste"; }
.bd-article div.run-code.optional-dashed::before { content: "Optional: Run"; }

.bd-article .copy-code .copybtn {
    opacity: 1;
    background-color: var(--course-reference-background);
    border-color: var(--course-code-border);
    color: var(--pst-color-text-base);
}

.bd-article .copy-code .copybtn:hover {
    background-color: var(--course-code-background);
}

.bd-article .copy-code .copybtn svg {
    stroke: currentColor;
}

/* Also suppress controls if another script adds them to reference blocks. */
.bd-article .view-code .copybtn,
.bd-article .terminal-output .copybtn {
    display: none !important;
}

html[data-theme="dark"] .drop-shadow img,
html[data-theme="dark"] .drop-shadow video,
html[data-theme="dark"] video.drop-shadow {
    filter: drop-shadow(0 4px 8px rgb(255 255 255 / 25%));
}

/* Keep long inline package and file paths readable on narrow screens.
   Code blocks retain their own horizontal scrolling and original line breaks. */
.bd-article :not(pre) > code.literal,
.bd-article :not(pre) > code.literal .pre {
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Keep reward identifiers intact and give the Term column room to read. */
.bd-article .balance-reward-table :is(th, td):first-child {
    min-width: 9rem;
    width: 9rem;
    white-space: nowrap;
}

.bd-article .balance-reward-table td:first-child code.literal,
.bd-article .balance-reward-table td:first-child code.literal .pre {
    white-space: nowrap;
    overflow-wrap: normal;
}

/* Let the course title share a phone-sized header with both navigation buttons. */
@media (max-width: 575.98px) {
    .bd-header .navbar-header-items__start {
        flex: 1 1 auto;
        min-width: 0;
    }

    .bd-header .navbar-brand {
        max-width: 100%;
    }

    .bd-header .logo__title {
        white-space: normal;
        font-size: 1rem;
        line-height: 1.2;
    }
}

/* Clickable branches show independent entry points into the learning path. */
.learning-path-diagram {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
    --path-line: #76b900;
    --path-title: #426800;
    --path-card-background: transparent;
}

.learning-path-root {
    flex: 0 0 9rem;
    padding: 1rem;
    border: 2px solid var(--path-line);
    border-radius: 0.75rem;
    text-align: center;
    font-weight: 700;
    color: #111;
    background: #76b900;
}

.learning-path-branches {
    flex: 1;
    list-style: none;
    margin: 0 !important;
    padding: 0 0 0 2rem !important;
}

.learning-path-branches li {
    position: relative;
    padding: 0.5rem 0 0.5rem 2rem;
    margin: 0;
}

.learning-path-branches li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    border-left: 2px solid var(--path-line);
}

.learning-path-branches li:first-child::before { top: 50%; }
.learning-path-branches li:last-child::before { bottom: 50%; }

.learning-path-branches li::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 2rem;
    border-top: 2px solid var(--path-line);
}

.learning-path-branches a {
    display: block;
    position: relative;
    padding: 1rem;
    border: 2px solid var(--path-line);
    border-radius: 0.75rem;
    color: var(--pst-color-text-base);
    text-decoration: none;
    background: var(--path-card-background);
    border-left-width: 6px;
}

.learning-path-branches a strong {
    color: var(--path-title);
}

.learning-path-branches a.learning-path-recommended {
    color: #111;
    background: #76b900;
}

.learning-path-branches a.learning-path-recommended strong {
    color: inherit;
}

.learning-path-branches a:hover,
.learning-path-branches a:focus-visible {
    border-color: var(--path-title);
    outline: 2px solid var(--path-title);
    outline-offset: 3px;
}

.learning-path-branches::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 9rem;
    width: 2rem;
    border-top: 2px solid var(--path-line);
}

.learning-path-diagram { position: relative; }

@media (max-width: 575.98px) {
    .learning-path-diagram { flex-direction: column; align-items: stretch; }
    .learning-path-root { flex-basis: auto; }
    .learning-path-branches { padding-left: 0 !important; padding-top: 1rem !important; }
    .learning-path-branches::before { display: none; }
}

html[data-theme="dark"] .learning-path-diagram {
    --path-title: #a3e635;
}

/* Keep reward names readable while the descriptions use the remaining width. */
.reward-term-table table th:first-child,
.reward-term-table table td:first-child {
  white-space: nowrap;
  width: 1%;
}

.bd-article .reward-term-table td:first-child code.literal,
.bd-article .reward-term-table td:first-child code.literal .pre {
  white-space: nowrap;
  overflow-wrap: normal;
}

/* Compact group dividers retain the reward categories inside one table. */
.reward-term-table tbody tr:has(td:first-child strong) > td {
  background: var(--pst-color-surface);
  border-top: 1px solid var(--pst-color-border);
  padding-top: .3rem;
  padding-bottom: .3rem;
  font-size: .8rem;
}

/* Keep the reward switches aligned across the four training recipes. */
.ablation-recipes table {
  --active-ink: #196447;
  --active-fill: #e2f2e9;
  --off-ink: #8b421e;
  --off-fill: #fff2e6;
  --baseline-fill: #eff6f2;
  border-collapse: separate;
  border-spacing: 0 .35rem;
}
html[data-theme="dark"] .ablation-recipes table {
  --active-ink: #a5e4c4;
  --active-fill: #203e34;
  --off-ink: #ffca9e;
  --off-fill: #423024;
  --baseline-fill: #23342f;
}
.ablation-recipes table tbody td {
  background: var(--pst-color-surface);
  vertical-align: middle;
}
.ablation-recipes table tbody tr:first-child td { background: var(--baseline-fill); }
.ablation-recipes tbody td:first-child {
  border-radius: .5rem 0 0 .5rem;
  font-weight: 650;
}
.ablation-recipes tbody td:last-child { border-radius: 0 .5rem .5rem 0; }
.ablation-recipes :is(th, td):nth-child(n+2):nth-child(-n+4) { text-align: center; }
.ablation-recipes td:nth-child(n+2):nth-child(-n+4) p {
  display: inline-block;
  margin: 0;
  padding: .12rem .55rem;
  border: 1px solid transparent;
  border-radius: 1rem;
  color: var(--active-ink);
  background: var(--active-fill);
  font-size: .85rem;
  white-space: nowrap;
}
.ablation-recipes td:nth-child(n+2):nth-child(-n+4) p:has(strong) {
  color: var(--off-ink);
  background: var(--off-fill);
  border: 1px dashed currentColor;
}

/* A shared frame and caption treatment for Microduck recordings and diagrams. */
.bd-article [data-microduck-figure],
.bd-article .microduck-figure img {
  max-width: 100%;
  border-radius: .5rem;
  outline: 1px solid var(--pst-color-border);
  outline-offset: -1px;
}
.bd-article .microduck-figure figcaption {
  padding: .5rem 0;
  color: var(--pst-color-text-muted);
  font-size: .9rem;
  line-height: 1.5;
  text-align: start;
}
