:root {
    color-scheme: light;

    --font-body: "Source Sans 3", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;

    --bg: #f3f2f2;
    --bg-soft: #eceef1;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --text: #201f1d;
    --text-muted: #4a5563;
    --line: #d5dae2;
    --line-strong: #b7c1cf;

    --brand: #002e5d;
    --brand-2: #003da5;
    --brand-ink: #e6eef7;
    --accent: #a8c4e5;
    --accent-soft: #bdd6e6;
    --link: #003da5;
    --link-hover: #002e5d;
    --ack-bg: #e6eef7;

    --shadow-soft: 0 8px 28px rgba(0, 30, 60, 0.08);
    --shadow-card: 0 12px 38px rgba(0, 30, 60, 0.12);
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #10141b;
    --bg-soft: #131a24;
    --surface: #171e29;
    --surface-2: #1d2635;
    --text: #edf2f8;
    --text-muted: #a9b7c9;
    --line: #2c3748;
    --line-strong: #3b4a60;

    --brand: #12457e;
    --brand-2: #2e6cb5;
    --brand-ink: #d9e7f6;
    --accent: #7ba7d9;
    --accent-soft: #5d86b8;
    --link: #8db8e8;
    --link-hover: #b4d3f2;
    --ack-bg: #1a2636;

    --shadow-soft: 0 12px 32px rgba(0, 0, 0, 0.35);
    --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    background:
        radial-gradient(circle at 2% -8%, rgba(0, 46, 93, 0.12), transparent 32%),
        radial-gradient(circle at 102% 3%, rgba(0, 61, 165, 0.10), transparent 30%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-soft) 100%);
    color: var(--text);
    font-family: var(--font-body);
    letter-spacing: 0.01em;
    line-height: 1.65;
}

.page-header {
    position: relative;
    overflow: hidden;
    padding: 3rem 1.5rem 4rem;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    background:
        linear-gradient(120deg, rgba(0, 26, 54, 0.97), rgba(0, 46, 93, 0.95) 52%, rgba(0, 38, 80, 0.96)),
        linear-gradient(200deg, rgba(168, 196, 229, 0.14), transparent 48%);
    box-shadow: var(--shadow-soft);
}

.page-header::before,
.page-header::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.page-header::before {
    width: 340px;
    height: 340px;
    right: -120px;
    top: -140px;
    background: radial-gradient(circle, rgba(189, 214, 230, 0.2), transparent 70%);
}

.page-header::after {
    width: 260px;
    height: 260px;
    left: -120px;
    bottom: -130px;
    background: radial-gradient(circle, rgba(189, 214, 230, 0.12), transparent 68%);
}

.page-header > * {
    position: relative;
}

.page-header__eyebrow {
    margin: 0 0 0.8rem;
    color: var(--accent-soft);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
}

.project-name {
    margin: 0 auto;
    max-width: 46ch;
    color: #f2f7fc;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.6rem, 3.4vw, 2.5rem);
    line-height: 1.25;
}

.project-tagline {
    margin: 1rem auto 0.3rem;
    color: #dce8f4;
    font-weight: 600;
    font-size: 1.05rem;
}

.page-header__affiliation {
    margin: 0 auto;
    color: var(--accent-soft);
    font-style: italic;
    font-size: 0.92rem;
}

.page-header__links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.55rem;
    margin-top: 1.6rem;
}

.btn-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.05rem;
    border: 1px solid rgba(189, 214, 230, 0.55);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #f2f7fc;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.btn-pill:hover,
.btn-pill:focus-visible {
    transform: translateY(-1px);
    background: rgba(189, 214, 230, 0.2);
    border-color: var(--accent-soft);
}

.main-content {
    position: relative;
    max-width: 900px;
    margin: -1.8rem auto 2.5rem;
    padding: 2.2rem 2.3rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}

.main-content h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.45rem;
    line-height: 1.25;
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.4rem;
    margin: 2rem 0 0.9rem;
}

.main-content h2:first-child {
    margin-top: 0;
}

.section-number {
    color: var(--brand-2);
    font-weight: 600;
    margin-right: 0.35rem;
}

.main-content a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--link) 45%, transparent);
    text-underline-offset: 0.14em;
    transition: color 180ms ease, text-decoration-color 180ms ease;
}

.main-content a:hover,
.main-content a:focus-visible {
    color: var(--link-hover);
    text-decoration-color: var(--link-hover);
}

.placeholder {
    margin: 1rem 0;
    padding: 1rem 1.2rem;
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--text-muted);
    font-style: italic;
}

.acknowledgments {
    margin: 1rem 0;
    padding: 1rem 1.2rem;
    border-left: 4px solid var(--brand);
    border-top: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: 0 10px 10px 0;
    background: var(--ack-bg);
    font-size: 0.95rem;
}

.acknowledgments p {
    margin: 0;
}

.acknowledgments p + p {
    margin-top: 0.7rem;
}

.acknowledgments ul {
    margin: 0.5rem 0 0.7rem;
    padding-left: 1.3rem;
}

.acknowledgments li + li {
    margin-top: 0.35rem;
}

.logo-strip {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin: 0.2rem 0 0;
    padding: 1.4rem 1rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
}

.logo-strip img {
    height: 64px;
    width: auto;
}

.logo-rise--dark {
    display: none;
}

:root[data-theme="dark"] .logo-rise--light {
    display: none;
}

:root[data-theme="dark"] .logo-rise--dark {
    display: block;
}

.site-footer {
    max-width: 900px;
    margin: 0 auto 2.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.site-footer a {
    color: var(--link);
}

.site-footer__ai {
    margin-top: 0.3rem;
    font-size: 0.78rem;
    opacity: 0.8;
}

@media (max-width: 700px) {
    .main-content {
        margin: -1.2rem 0.8rem 2rem;
        padding: 1.5rem 1.1rem;
        border-radius: 12px;
    }

    .logo-strip {
        gap: 0.6rem;
    }

    .logo-strip img {
        height: 28px;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .page-header,
    .main-content {
        animation: riseIn 540ms ease-out both;
    }

    .main-content {
        animation-delay: 100ms;
    }
}

html.reduce-motion *,
html.reduce-motion *::before,
html.reduce-motion *::after {
    animation: none !important;
    transition: none !important;
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   Supporting-page components: figure cards, metric strips, case studies,
   data tables, lightbox.  Added for the BCDI results gallery and its three
   subpages.  Everything above this line is untouched.
   ========================================================================== */

:root {
    --good: #0f7b52;
    --good-soft: #e3f4ec;
    --bad: #a8322c;
    --bad-soft: #fbeceb;
    --warn: #8a5a10;
    --warn-soft: #fbf1de;
    /* Every scientific figure on this site is rendered on a white canvas, so
       figure cards keep a light backing even in dark mode -- otherwise the
       plots read as glaring rectangles floating on a dark page. */
    --fig-mat: #ffffff;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
    --good: #4cc38a;
    --good-soft: #16302a;
    --bad: #f0736b;
    --bad-soft: #33201f;
    --warn: #e0b055;
    --warn-soft: #302716;
    --fig-mat: #f7f8fa;
}

/* ------------------------------------------------------------ in-page nav */
.subpage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.9rem;
    margin: 1.2rem 0 0.5rem;
}

.subpage-card {
    display: block;
    padding: 1rem 1.1rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand-2);
    border-radius: 10px;
    background: var(--surface-2);
    text-decoration: none !important;
    color: inherit !important;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.subpage-card:hover,
.subpage-card:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--shadow-soft);
}

.subpage-card__title {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.02rem;
    color: var(--link);
    margin-bottom: 0.25rem;
}

.subpage-card__desc {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.breadcrumb {
    margin: 0 0 1.2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ------------------------------------------------------------ figure cards */
.fig {
    margin: 1.2rem 0 1.6rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    overflow: hidden;
}

.fig > a,
.fig > .fig__mat {
    display: block;
    background: var(--fig-mat);
    padding: 0.55rem;
    line-height: 0;
    cursor: zoom-in;
}

.fig img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 4px;
}

.fig video {
    display: block;
    width: 100%;
    height: auto;
    background: #0d1117;
}

.fig figcaption {
    padding: 0.75rem 0.95rem 0.85rem;
    font-size: 0.855rem;
    line-height: 1.55;
    color: var(--text-muted);
    border-top: 1px solid var(--line);
}

.fig figcaption b,
.fig figcaption strong {
    color: var(--text);
}

.fig__label {
    display: inline-block;
    margin-right: 0.4rem;
    font-family: var(--mono);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--brand-2);
}

.fig--wide {
    margin-left: -0.9rem;
    margin-right: -0.9rem;
}

.fig-pair {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
    gap: 1rem;
}

.fig-pair .fig {
    margin: 0;
}

/* ---------------------------------------------------------- metric strips */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(7.4rem, 1fr));
    gap: 1px;
    margin: 0.9rem 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--line);
    overflow: hidden;
}

.metrics div {
    padding: 0.55rem 0.7rem;
    background: var(--surface-2);
}

.metrics dt,
.metrics .m-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.metrics dd,
.metrics .m-value {
    display: block;
    margin: 0;
    font-family: var(--mono);
    font-size: 1.0rem;
    font-weight: 600;
    color: var(--text);
}

.m-value--good { color: var(--good); }
.m-value--bad  { color: var(--bad); }

/* ---------------------------------------------------------- case studies */
.case {
    margin: 1.8rem 0;
    padding: 1.15rem 1.25rem 1.3rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.case--good { border-top: 4px solid var(--good); }
.case--bad  { border-top: 4px solid var(--bad); }

.case__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.6rem;
    margin-bottom: 0.15rem;
}

.case__id {
    font-family: var(--mono);
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--text);
    word-break: break-all;
}

.badge {
    display: inline-block;
    padding: 0.14rem 0.6rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge--good { background: var(--good-soft); color: var(--good); border: 1px solid var(--good); }
.badge--bad  { background: var(--bad-soft);  color: var(--bad);  border: 1px solid var(--bad); }
.badge--warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }

.case__sub {
    margin: 0 0 0.5rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.case__lede {
    margin: 0.7rem 0 0;
}

/* collapsible "more figures" block */
details.more {
    margin: 1rem 0 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
}

details.more > summary {
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--link);
    list-style: none;
}

details.more > summary::-webkit-details-marker { display: none; }

details.more > summary::before {
    content: "▸ ";
    color: var(--brand-2);
}

details.more[open] > summary::before { content: "▾ "; }

details.more > summary:hover { color: var(--link-hover); }

.more__body {
    padding: 0 0.9rem 0.4rem;
    border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------ data tables */
.table-wrap {
    margin: 1.1rem 0;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.87rem;
}

table.data caption {
    padding: 0.65rem 0.85rem;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
}

table.data th,
table.data td {
    padding: 0.45rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

table.data thead th {
    background: var(--surface-2);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

table.data tbody tr:last-child td { border-bottom: none; }

table.data tbody tr:hover { background: var(--surface-2); }

table.data td.num,
table.data th.num {
    text-align: right;
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
}

table.data .row-good td { background: color-mix(in srgb, var(--good-soft) 60%, transparent); }
table.data .row-bad  td { background: color-mix(in srgb, var(--bad-soft) 60%, transparent); }

table.data code { font-size: 0.92em; }

/* ---------------------------------------------------------------- callouts */
.callout {
    margin: 1.2rem 0;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand-2);
    border-radius: 0 10px 10px 0;
    background: var(--surface-2);
    font-size: 0.93rem;
}

.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

.callout__title {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.35rem;
    color: var(--text);
}

.callout--warn { border-left-color: var(--warn); background: var(--warn-soft); }
.callout--good { border-left-color: var(--good); background: var(--good-soft); }
.callout--bad  { border-left-color: var(--bad);  background: var(--bad-soft); }

/* ------------------------------------------------------- inline utilities */
code, kbd, samp, pre {
    font-family: var(--mono);
}

.main-content code {
    padding: 0.08em 0.32em;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: 0.88em;
}

.main-content pre {
    padding: 0.8rem 0.95rem;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
    font-size: 0.82rem;
    line-height: 1.5;
}

.main-content pre code {
    padding: 0;
    border: none;
    background: none;
}

.lede {
    font-size: 1.05rem;
    color: var(--text-muted);
}

.step-list {
    margin: 1rem 0;
    padding-left: 0;
    list-style: none;
    counter-reset: step;
}

.step-list li {
    position: relative;
    counter-increment: step;
    padding: 0.15rem 0 0.6rem 2.4rem;
}

.step-list li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: 0.15rem;
    width: 1.7rem;
    height: 1.7rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--brand-2);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
}

.footnote {
    font-size: 0.83rem;
    color: var(--text-muted);
}

/* ---------------------------------------------------------------- lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    place-items: center;
    padding: 1.2rem;
    background: rgba(6, 10, 18, 0.9);
    cursor: zoom-out;
}

.lightbox[data-open="1"] { display: grid; }

.lightbox img {
    max-width: 100%;
    max-height: 92vh;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.lightbox__hint {
    position: absolute;
    bottom: 0.7rem;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.78rem;
}

@media (max-width: 700px) {
    .fig--wide { margin-left: 0; margin-right: 0; }
    .metrics { grid-template-columns: repeat(auto-fit, minmax(6rem, 1fr)); }
    .metrics dd, .metrics .m-value { font-size: 0.9rem; }
    .case { padding: 0.95rem 0.85rem 1rem; }
}

/* Two small utilities that replace the last inline style attributes, so the
   pages stay clean under html-validate's default preset (which forbids
   `style=`) if CI is ever widened past the root index.html. */
.nw { white-space: nowrap; }

.main-content h3.sub {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.12rem;
    line-height: 1.3;
    margin: 1.5rem 0 0.5rem;
}

/* a-CNA legend swatches. Colours are the actual render constants from
   viz/scripts/stage_video.jl -- lattice #5aa9e6, defect amber #faad1c -- shown as
   swatches rather than coloured text, because amber on white fails contrast as
   type but reads correctly as a filled dot next to its label. */
.swatch {
    display: inline-block;
    width: 0.72em;
    height: 0.72em;
    margin-right: 0.3em;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.28);
}

.swatch--lattice { background: #5aa9e6; }
.swatch--defect  { background: #faad1c; }
.swatch--true    { background: transparent; border: 1.5px solid var(--text-muted); }
