/* ==========================================================================
   Article side rails (partials/article-rails.hbs)

   The rails container covers the whole <article> and each rail sits in one
   side gutter, so the rails are always exactly as tall as the article. The
   TOC and the card stack are position: sticky inside their rail: they pin
   under the site header while the article scrolls and stop at the end of
   the article. Nothing here depends on JavaScript measuring the page.
   ========================================================================== */

:root {
    --mx-rail-width: 280px;
    --mx-rail-gap: 30px;                 /* space between the text column and a rail */
    --mx-rail-sticky-top: 96px;          /* 65px sticky site header + breathing room */
    --mx-main-half: calc(var(--content-width, 720px) / 2);
    --mx-ink: #0a3d4a;
    --mx-rail-font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Old injected sidebars (toc-modals-articles.js / bifrost-gateway-cta-new.js).
   Kept hidden in case those scripts are still in Code injection. */
#maxim-left-sidebar,
#maxim-right-sidebar,
#maxim-right-divider {
    display: none !important;
}

.mx-rails {
    display: none;
}

/* In-page anchors (TOC clicks, shared #links) land below the sticky header. */
.gh-content > h2,
.gh-content > h3 {
    scroll-margin-top: var(--mx-rail-sticky-top);
}

@media (min-width: 1440px) {
    .has-article-rails .gh-article {
        position: relative;
    }

    .mx-rails {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 5;
        pointer-events: none;
        /* This is a layout wrapper, not a page footer */
        margin: 0;
        padding: 0;
        border: 0;
    }

    .mx-rail {
        position: absolute;
        top: 0;
        bottom: 0;
        width: var(--mx-rail-width);
        font-family: var(--mx-rail-font);
        pointer-events: none;
    }

    .mx-rail > * {
        pointer-events: auto;
    }

    .mx-rail--left {
        right: calc(50% + var(--mx-main-half) + var(--mx-rail-gap));
    }

    .mx-rail--right {
        left: calc(50% + var(--mx-main-half) + 20px);
        width: calc(var(--mx-rail-width) + 11px); /* + divider and its gap */
        padding-left: 10px;
        border-left: 1px solid rgba(0, 0, 0, 0.08);
    }

    /* The author block moves from the article header into the left rail,
       so the TOC can sit directly under it. */
    .has-article-rails .gh-article-header > .gh-article-sidebar {
        display: none;
    }

    .mx-rail .gh-article-sidebar {
        position: static;
        padding: 0 16px;
    }

    /* Wide and full-width cards would run under the rails */
    .has-article-rails .gh-content > .kg-width-wide,
    .has-article-rails .gh-content > .kg-width-full {
        grid-column: main;
    }
}

/* ---------------------------------------------------------------- TOC */

.mx-toc {
    position: sticky;
    top: var(--mx-rail-sticky-top);
    margin-top: 24px;
    max-height: calc(100vh - var(--mx-rail-sticky-top) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    padding: 20px 16px;
    box-sizing: border-box;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.mx-toc::-webkit-scrollbar {
    display: none;
}

.mx-toc[hidden] {
    display: none;
}

.mx-toc-title {
    margin: 0 0 16px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: rgba(10, 61, 74, 0.6);
}

.mx-toc-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 0 8px 0 0;
    list-style: none;
}

.mx-toc-item {
    margin: 0;
    padding: 0;
}

.mx-toc-item--h3 {
    padding-left: 16px;
}

.mx-toc-link {
    display: block;
    font-size: 14px;
    line-height: 1.4;
    color: rgba(10, 61, 74, 0.75);
    text-decoration: none;
    transition: color 150ms ease;
}

.mx-toc-item--h3 .mx-toc-link {
    font-size: 13px;
    color: rgba(10, 61, 74, 0.65);
}

.mx-toc-link:hover,
.mx-toc-link:focus-visible,
.mx-toc-item.is-active .mx-toc-link {
    color: var(--mx-ink);
}

.mx-toc-item.is-active .mx-toc-link {
    font-weight: 500;
}

/* ------------------------------------------------------- Right rail cards */

.mx-rail-sticky {
    position: sticky;
    top: var(--mx-rail-sticky-top);
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-height: calc(100vh - var(--mx-rail-sticky-top) - 16px);
    overflow-y: auto;
    scrollbar-width: none;
}

.mx-rail-sticky::-webkit-scrollbar {
    display: none;
}

/* Zero specificity, so the per-element margins below still apply */
:where(.mx-rail) p {
    margin: 0;
}

/* Bifrost Edge + Gateway card */

.mx-cta {
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e5e5e5;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.mx-cta::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, #e5e5e5 1px, transparent 1px);
    background-size: 16px 16px;
    opacity: 0.5;
    pointer-events: none;
}

.mx-cta-corner,
.mx-cta-btn-corner {
    position: absolute;
    width: 6px;
    height: 6px;
}

.mx-cta-corner--tl { top: -1px; left: -1px; border-top: 1px solid #d1d5db; border-left: 1px solid #d1d5db; }
.mx-cta-corner--tr { top: -1px; right: -1px; border-top: 1px solid #d1d5db; border-right: 1px solid #d1d5db; }
.mx-cta-corner--bl { bottom: -1px; left: -1px; border-bottom: 1px solid #d1d5db; border-left: 1px solid #d1d5db; }
.mx-cta-corner--br { bottom: -1px; right: -1px; border-bottom: 1px solid #d1d5db; border-right: 1px solid #d1d5db; }

.mx-cta-body {
    position: relative;
    padding: 24px 20px;
    text-align: center;
}

.mx-cta-logo {
    display: block;
    width: auto;
    height: 32px;
    margin: 0 auto 16px;
}

.mx-cta-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--mx-ink);
}

.mx-cta-text {
    margin: 0 0 20px;
    font-size: 13px;
    line-height: 1.5;
    color: #64748b;
}

.mx-cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mx-cta-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-decoration: none;
    transition: all 0.15s ease;
}

.mx-cta-btn--primary {
    background: #33c09e;
    color: #fff;
    border: 2px solid #82ceb6;
    box-shadow: 0 0 8px rgba(51, 192, 158, 0.3);
}

.mx-cta-btn--primary:hover {
    background: #2aa382;
    color: #fff;
    box-shadow: 0 0 12px rgba(51, 192, 158, 0.5);
    transform: translateY(-1px);
}

.mx-cta-btn-corner {
    width: 4px;
    height: 4px;
}

.mx-cta-btn-corner--tl { top: -1px; left: -1px; border-top: 1px solid #177b62; border-left: 1px solid #177b62; }
.mx-cta-btn-corner--tr { top: -1px; right: -1px; border-top: 1px solid #177b62; border-right: 1px solid #177b62; }
.mx-cta-btn-corner--bl { bottom: -1px; left: -1px; border-bottom: 1px solid #177b62; border-left: 1px solid #177b62; }
.mx-cta-btn-corner--br { bottom: -1px; right: -1px; border-bottom: 1px solid #177b62; border-right: 1px solid #177b62; }

.mx-cta-btn--secondary {
    background: transparent;
    color: var(--mx-ink);
    border: 1px solid #e5e5e5;
}

.mx-cta-btn--secondary:hover {
    background: #f8fafc;
    color: var(--mx-ink);
    border-color: #d1d5db;
}

/* Bifrost product card */

.mx-product {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    gap: 14px;
    padding: 20px 16px;
    box-sizing: border-box;
    border: 1px solid rgba(0, 0, 0, 0.12);
}

.mx-product-icon {
    display: block;
    width: 18px;
    height: 18px;
    color: var(--mx-ink);
}

.mx-product-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.mx-product-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--mx-ink);
}

.mx-product-text {
    font-size: 13px;
    line-height: 1.5;
    color: rgba(10, 61, 74, 0.85);
}

.mx-product-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--mx-ink);
    text-decoration: none;
    transition: gap 150ms ease;
}

.mx-product-link:hover {
    gap: 8px;
    color: var(--mx-ink);
}

.mx-product-link svg {
    width: 16px;
    height: 16px;
    transition: transform 150ms ease;
}

.mx-product-link:hover svg {
    transform: translateX(2px);
}

@media (prefers-reduced-motion: reduce) {
    .mx-toc-link,
    .mx-cta-btn,
    .mx-product-link,
    .mx-product-link svg {
        transition: none;
    }

    .mx-cta-btn--primary:hover {
        transform: none;
    }
}
