/* Custom Properties */
:root {
    --docs-color-primary:       light-dark(#2563eb, #60a5fa);
    --docs-color-primary-hover: light-dark(#1d4ed8, #3b82f6);
    --docs-color-primary-light: light-dark(#eff6ff, rgba(96, 165, 250, 0.1));
    --docs-color-text:          light-dark(#374151, #cbd5e1);
    --docs-color-text-muted:    light-dark(#4b5563, #a3aebf);
    --docs-color-text-faint:    light-dark(#6b7280, #8b95a7);
    --docs-color-heading:       light-dark(#111827, #f1f5f9);
    --docs-color-link:          var(--docs-color-primary);
    --docs-color-border:        light-dark(#e5e7eb, #334155);
    --docs-color-border-light:  light-dark(#f3f4f6, #1e293b);
    --docs-color-bg:            light-dark(#ffffff, transparent);
    --docs-color-bg-muted:      light-dark(#f9fafb, rgba(255, 255, 255, 0.03));
    --docs-color-code-bg:       light-dark(#f3f4f6, #1e293b);
    --docs-color-code-text:     light-dark(#1f2937, #e2e8f0);
    --docs-font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif,
        "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --docs-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
        "Liberation Mono", "Courier New", monospace;
    --docs-sidebar-width: 14rem;
    --docs-toc-width: 13rem;
    --docs-content-max-width: 48rem;
    --docs-nav-top: 0;
}

html {
    scroll-padding-top: 5rem;
}

/* Layout */
.docs-layout {
    display: grid;
    grid-template-columns: 1fr;
    font-family: var(--docs-font-sans);
    color: var(--docs-color-text);
    line-height: 1.65;

    @media (min-width: 1024px) {
        grid-template-columns: var(--docs-sidebar-width) 1fr;
    }

    @media (min-width: 1280px) {
        grid-template-columns: var(--docs-sidebar-width) 1fr var(--docs-toc-width);
    }
}

.docs-layout--no-nav {
    @media (min-width: 1024px) {
        grid-template-columns: 1fr;
    }

    @media (min-width: 1280px) {
        grid-template-columns: 1fr var(--docs-toc-width);
    }
}

.docs-layout--no-toc {
    @media (min-width: 1280px) {
        grid-template-columns: var(--docs-sidebar-width) 1fr;
    }
}

.docs-layout--no-nav.docs-layout--no-toc {
    @media (min-width: 1024px) {
        grid-template-columns: 1fr;
    }

    @media (min-width: 1280px) {
        grid-template-columns: 1fr;
    }
}

/* Mobile Navigation */
.docs-mobile-nav {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--docs-color-border);
    background: var(--docs-color-bg);

    @media (min-width: 1024px) {
        display: none;
    }

    & select {
        width: 100%;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
        font-family: var(--docs-font-sans);
        border: 1px solid var(--docs-color-border);
        border-radius: 0.375rem;
        background-color: var(--docs-color-bg);
        color: var(--docs-color-text);
    }
}

/* Sidebar */
.docs-sidebar {
    display: none;
    position: sticky;
    top: var(--docs-nav-top);
    align-self: start;
    max-height: calc(100dvh - var(--docs-nav-top));
    overflow-y: auto;
    padding: 2rem 1.5rem;
    border-right: 1px solid var(--docs-color-border);
    font-size: 0.875rem;

    @media (min-width: 1024px) {
        display: block;
    }
}

/* Align the navigation text with the Filament page heading; link highlights stick out by their padding. */
.fi-body .docs-sidebar {
    margin-left: -0.75rem;
    padding-left: 0;
}

.docs-sidebar-group {
    margin-bottom: 1.5rem;
}

.docs-sidebar-group-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--docs-color-text-faint);
    margin: 0 0 0.5rem 0.75rem;
}

.docs-sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;

    & li {
        margin: 0;
    }
}

.docs-sidebar-link {
    display: block;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    color: var(--docs-color-text-muted);
    text-decoration: none;
    transition: color 0.15s, background-color 0.15s;

    &:hover {
        color: var(--docs-color-heading);
        background-color: var(--docs-color-border-light);
    }

    &.docs-sidebar-link--active {
        color: var(--docs-color-primary);
        font-weight: 500;
        background-color: var(--docs-color-primary-light);
        /*border-left: 2px solid var(--docs-color-primary);*/
    }
}

/* Mermaid diagrams: the source stays visible as code until docs.js has rendered it */
.docs-prose .docs-mermaid[data-rendered]:not([data-error]) {
    font-family: var(--docs-font-sans);
    background: none;
    padding: 0;
    text-align: center;
    line-height: normal;

    & .node rect { rx: 8px; ry: 8px; }
    & .edgeLabel { font-size: 0.8125rem; }

    & svg {
        display: block;
        margin-inline: auto;
        max-width: 100%;
        height: auto;
    }
}

/* Content */
.docs-content {
    padding: 1.5rem;
    min-width: 0;
    max-width: var(--docs-content-max-width);

    @media (min-width: 1024px) {
        padding: 2rem 2.5rem;
    }
}

/* Prose / Typography */
.docs-prose {
    & h1, & h2, & h3, & h4, & h5, & h6 {
        color: var(--docs-color-heading);
        font-weight: 600;
        line-height: 1.3;
        margin-top: 2em;
        margin-bottom: 0.75em;
        position: relative;

        &:hover .docs-heading-permalink {
            opacity: 1;
        }
    }

    & h1 { font-size: 2rem; margin-top: 0; }
    & h2 { font-size: 1.5rem; border-bottom: 1px solid var(--docs-color-border); padding-bottom: 0.4em; }
    & h3 { font-size: 1.25rem; }
    & h4 { font-size: 1.125rem; }

    & p {
        margin: 0 0 1.25em;
    }

    & a {
        color: var(--docs-color-link);
        text-decoration: none;

        &:hover {
            text-decoration: underline;
        }
    }

    & strong {
        font-weight: 600;
        color: var(--docs-color-heading);
    }

    & code {
        font-family: var(--docs-font-mono);
        font-size: 0.875em;
        background: var(--docs-color-code-bg);
        color: var(--docs-color-code-text);
        padding: 0.15em 0.35em;
        border-radius: 0.25rem;
    }

    & pre {
        background: var(--docs-color-code-bg);
        border-radius: 0.5rem;
        padding: 1rem 1.25rem;
        overflow-x: auto;
        margin: 0 0 1.5em;
        font-size: 0.875rem;
        line-height: 1.7;

        & code {
            background: none;
            padding: 0;
            border-radius: 0;
            font-size: inherit;
        }
    }

    & blockquote {
        border-left: 3px solid var(--docs-color-primary);
        margin: 0 0 1.5em;
        padding: 0.5em 1em;
        color: var(--docs-color-text-muted);
        background: var(--docs-color-bg-muted);
        border-radius: 0 0.375rem 0.375rem 0;

        & p:last-child {
            margin-bottom: 0;
        }
    }

    & ul {
        list-style-type: disc;
        margin: 0 0 1.25em;
        padding-left: 1.75em;
    }

    & ol {
        list-style-type: decimal;
        margin: 0 0 1.25em;
        padding-left: 1.75em;
    }

    & li {
        margin-bottom: 0.35em;

        & > ul, & > ol {
            margin-top: 0.35em;
            margin-bottom: 0;
        }
    }

    & table {
        width: 100%;
        border-collapse: collapse;
        margin: 0 0 1.5em;
        font-size: 0.875rem;

        & th, & td {
            border: 1px solid var(--docs-color-border);
            padding: 0.5rem 0.75rem;
            text-align: left;
        }

        & th {
            background: var(--docs-color-bg-muted);
            font-weight: 600;
            color: var(--docs-color-heading);
        }
    }

    & hr {
        border: none;
        border-top: 1px solid var(--docs-color-border);
        margin: 2em 0;
    }

    & img,
    & video {
        max-width: 100%;
        height: auto;
        border-radius: 0.5rem;
        cursor: zoom-in;
    }

    & a img, & a video {
        cursor: pointer;
    }

    & figure {
        margin: 0 0 1.5em;

        & img, & video {
            display: block;
        }
    }

    & figcaption {
        margin-top: 0.5rem;
        font-size: 0.875rem;
        color: var(--docs-color-text-muted);
        text-align: center;
    }

    & details {
        margin: 0 0 1em;
        border: 1px solid var(--docs-color-border);
        border-radius: 0.5rem;

        & > summary {
            display: flex;
            align-items: center;
            gap: 1rem;
            padding: 0.625rem 1rem;
            font-weight: 600;
            color: var(--docs-color-heading);
            cursor: pointer;
            list-style: none;

            &::-webkit-details-marker {
                display: none;
            }

            /* Chevron at the end, drawn as an SVG mask so it takes the text colour. */
            &::after {
                content: '';
                flex-shrink: 0;
                width: 1.125rem;
                height: 1.125rem;
                margin-left: auto;
                background-color: var(--docs-color-text-faint);
                mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") center / contain no-repeat;
                transition: transform 0.2s;
            }

            &:hover::after {
                background-color: var(--docs-color-heading);
            }
        }

        &[open] > summary {
            border-bottom: 1px solid var(--docs-color-border);

            &::after {
                transform: rotate(180deg);
            }
        }

        & > :not(summary) {
            margin-inline: 1rem;
        }

        & > :nth-child(2) {
            margin-top: 1rem;
        }

        & > :last-child {
            margin-bottom: 1rem;
        }
    }
}

/* Lightbox */
.docs-lightbox {
    /* 100% instead of 100vw, so the right edge doesn't sit under the page scrollbar. */
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    outline: none;
    font-family: var(--docs-font-sans);
    color: var(--docs-color-heading);
    --docs-lightbox-glass:        light-dark(rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.16));
    --docs-lightbox-glass-hover:  light-dark(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.26));
    --docs-lightbox-glass-border: light-dark(rgba(15, 23, 42, 0.14), rgba(255, 255, 255, 0.24));

    &::backdrop {
        background: light-dark(rgba(241, 245, 249, 0.88), rgba(2, 6, 23, 0.88));
        backdrop-filter: blur(6px);
    }

    & .docs-lightbox-stage {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.75rem;
        height: 100%;
        padding: 4.5rem 5.5rem 1.5rem;
        box-sizing: border-box;
    }

    & .docs-lightbox-media {
        display: flex;
        justify-content: center;
        min-height: 0;
        max-width: 100%;

        & img, & video {
            max-width: 100%;
            max-height: calc(100dvh - 10rem);
            object-fit: contain;
            border-radius: 0.5rem;
            outline: none;
            box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.35);
        }
    }

    & .docs-lightbox-info,
    & button {
        background: var(--docs-lightbox-glass);
        border: 1px solid var(--docs-lightbox-glass-border);
        backdrop-filter: blur(12px) saturate(1.5);
        border-radius: 999px;
        box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.2);
        color: inherit;
    }

    /* Caption and counter share one glass pill, separated by a divider. */
    & .docs-lightbox-info {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        max-width: min(48rem, 100%);
        padding: 0.3rem 0.9rem;
        font-size: 0.875rem;
    }

    & .docs-lightbox-caption {
        margin: 0;

        &:empty {
            display: none;
        }
    }

    & .docs-lightbox-counter {
        flex-shrink: 0;
        font-weight: 500;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    & .docs-lightbox-caption:not(:empty) + .docs-lightbox-counter {
        padding-left: 0.75rem;
        border-left: 1px solid var(--docs-lightbox-glass-border);
        opacity: 0.75;
    }

    &[data-single] .docs-lightbox-info:has(.docs-lightbox-caption:empty) {
        display: none;
    }

    & button {
        position: absolute;
        display: grid;
        place-items: center;
        width: 2.75rem;
        height: 2.75rem;
        padding: 0;
        cursor: pointer;
        transition: background-color 0.15s;

        &:hover {
            background: var(--docs-lightbox-glass-hover);
        }

        & svg {
            width: 1.375rem;
            height: 1.375rem;
            stroke-width: 2.25;
        }
    }

    & .docs-lightbox-close {
        top: 1.5rem;
        right: 1.5rem;
    }

    & .docs-lightbox-prev,
    & .docs-lightbox-next {
        top: 50%;
        transform: translateY(-50%);
    }

    & .docs-lightbox-prev {
        left: 1.5rem;
    }

    & .docs-lightbox-next {
        right: 1.5rem;
    }

    &[data-single] :is(.docs-lightbox-prev, .docs-lightbox-next, .docs-lightbox-counter) {
        display: none;
    }
}

/* Heading Permalink */
.docs-heading-permalink {
    position: absolute;
    left: -1.5em;
    color: var(--docs-color-text-faint);
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.15s;
    font-weight: 400;

    &:hover {
        color: var(--docs-color-primary);
        text-decoration: none;
    }
}

/* Table of Contents (right sidebar) */
.docs-toc-aside {
    display: none;
    position: sticky;
    top: var(--docs-nav-top);
    align-self: start;
    max-height: calc(100dvh - var(--docs-nav-top));
    overflow-y: auto;
    padding: 2rem 1.5rem 2rem 0;
    font-size: 0.8125rem;

    @media (min-width: 1280px) {
        display: block;
    }
}

.docs-toc-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--docs-color-text-faint);
    margin: 0 0 0.75rem;
}

.docs-toc-nav .docs-toc {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--docs-color-border);

    & ul {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    & li {
        margin: 0;
    }

    & > li > a {
        display: block;
        padding: 0.25rem 0 0.25rem 0.75rem;
        margin-left: -1px;
        border-left: 1px solid transparent;
        color: var(--docs-color-text-muted);
        text-decoration: none;
        transition: color 0.15s, border-color 0.15s;

        &:hover {
            color: var(--docs-color-heading);
            border-left-color: var(--docs-color-text-faint);
        }
    }

    & > li > ul > li > a {
        display: block;
        padding: 0.2rem 0 0.2rem 1.5rem;
        margin-left: -1px;
        border-left: 1px solid transparent;
        color: var(--docs-color-text-faint);
        font-size: 0.75rem;
        text-decoration: none;
        transition: color 0.15s, border-color 0.15s;

        &:hover {
            color: var(--docs-color-text-muted);
            border-left-color: var(--docs-color-border);
        }
    }
}

/* Pagination */
.docs-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--docs-color-border);
    font-size: 0.875rem;

    & a {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        color: var(--docs-color-primary);
        text-decoration: none;
        font-weight: 500;
        transition: color 0.15s;

        &:hover {
            color: var(--docs-color-primary-hover);
        }
    }
}

.docs-pagination-spacer {
    flex: 1;
}

.docs-wrapper {
    max-width: 80rem;
    margin-block: 2rem;
    margin-inline: auto;
}

/* Standalone mode */
.docs-standalone {
    padding: 0;
    max-width: 80rem;
    margin-block: 2rem;
    margin-inline: auto;
    background: var(--docs-color-bg);
    font-family: var(--docs-font-sans);
    color: var(--docs-color-text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

    & *, & *::before, & *::after {
        box-sizing: border-box;
    }

    & .docs-layout {
        min-height: 100dvh;
    }
}
