@font-face {
    font-family: "Lexend";
    src:
      /* The path strategy for Binder is flatten. */
      url("Lexend.woff2") format("woff2"),
      /* Fallback to local font path. */
      url("fonts/Lexend.woff2") format("woff2");
}

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

:root {
    color-scheme: dark;
    --background: #222233;
    --background-header: #1E1E2D;
    --background-source: #2D2D3A;

    --panel: #1a1d26;
    --panel-alt: #232734;
    --panel-soft: #171722;

    --border: #56526e;
    --text: #e0def4;
    --muted: #6e6a86;
    --link: #8fb4ff;
    --accent: #f7a41d;
    --accent-strong: #ffb347;
}

body {
    margin: 0;
    font-family: Lexend;
    background: var(--background);
    color: var(--text);
    line-height: 1.55;
    overflow-x: hidden;
}

.hidden {
    display: none;
}

a {
    color: var(--link);
}

table {
    width: 100%;
    border-collapse: collapse;
}

pre {
    font-family: monospace;
    font-size: 0.95rem;
    background: var(--background-source);
    color: var(--text);
    padding: 1rem 1.25rem;
    margin: 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
}

:not(pre) > code {
    white-space: break-spaces;
}

code {
    font-family: monospace;
    font-size: 0.9em;
}

code a {
    color: var(--text);
}

.site-header {
    position: sticky;
    top: 0;
    /* Make sure nothing goes over the header. */
    z-index: 1;
    background: var(--background-header);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
}

.utility-bar,
.search-panel-inner,
.masthead,
.page-content section {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
}

.utility-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.35rem 0;
    position: relative;
}

.utility-brand {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
}

.utility-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.utility-button {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--panel-soft);
    color: var(--text);
    border-radius: 999px;
    padding: 0.45rem 0.9rem;
    font: inherit;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.utility-button:hover,
.utility-button:focus-visible,
.utility-button.active {
    background: var(--panel-alt);
    border-color: #49516a;
    color: #fff;
}

.search-panel {
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: rgba(22, 25, 34, 0.96);
    padding: 0.65rem 0;
}

.search-panel-inner {
    display: grid;
    grid-template-columns: 5.75rem minmax(0, 1fr);
    align-items: center;
    gap: 1.25rem;
}

.search-panel-spacer {
    min-height: 1px;
}

.search-panel-field {
    min-width: 0;
    display: flex;
    justify-content: flex-end;
}

#search {
    width: min(100%, 34rem);
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #0c0f16;
    color: var(--text);
    padding: 0.8rem 1rem;
    font: inherit;
}

#search::placeholder {
    color: var(--muted);
}

#search:focus-visible {
    outline: 2px solid rgba(143, 180, 255, 0.35);
    outline-offset: 2px;
}

.masthead {
    display: grid;
    grid-template-columns: 5.75rem minmax(0, 1fr);
    align-items: center;
    gap: 1.25rem;
    padding: 1.1rem 0 1rem;
}

.logo {
    align-items: center;
    justify-content: center;
    width: 5.75rem;
    height: 5.75rem;
    border-radius: 1.1rem;
    background: transparent;
    overflow: hidden;
    grid-row: 1 / span 2;
}

#logo {
    width: 100%;
    height: 100%;
    display: block;
}

.nav-row {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    grid-column: 2;
}

.path-bar {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 2.9rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.35rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}

#listNav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    flex: 1 1 auto;
    min-width: 0;
}

#listNav li a {
    display: block;
    color: var(--muted);
    padding: 0.45rem 0.8rem;
    border-radius: 10px;
    text-decoration: none;
    transition: background-color 120ms ease, color 120ms ease;
}

#listNav li a:hover {
    background: #2b3040;
    color: #fff;
}

#listNav li a.active {
    background: var(--accent);
    color: #111;
    font-weight: 700;
}

#moduleSummary {
    margin: 0;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    min-width: 0;
    grid-column: 2;
}

.source-link {
    display: inline-flex;
    align-items: center;
    gap: 0.85rem;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    flex: 0 0 auto;
    transition: color 120ms ease;
}

.source-link::before {
    content: "";
    width: 1px;
    height: 1.5rem;
    background: var(--border);
}

.source-link:hover,
.source-link:focus-visible {
    color: #fff;
}

.page-content {
    padding: 1.5rem 0 2.5rem;
}

section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

#status,
#tldDocs,
#fnProto,
#sectParams,
#sectFnErrors,
#sectSearchResults,
#sectSearchNoResults,
#sectFields,
#sectTypes,
#sectNamespaces,
#sectGlobalVars,
#sectValues,
#sectFns,
#sectErrSets,
#sectDocTests,
#sectSource {
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.1rem 1.25rem;
}

#tldDocs,
#sectParams,
#sectFnErrors,
#sectSearchResults,
#sectSearchNoResults,
#sectFields,
#sectTypes,
#sectNamespaces,
#sectGlobalVars,
#sectValues,
#sectFns,
#sectErrSets,
#sectDocTests,
#sectSource {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

#hdrName {
    display: none !important;
}

section h2 {
    font-size: 1.1rem;
    margin: 0 0 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
}

#listFields > div,
#listParams > div {
    margin-bottom: 1rem;
}

#listSearchResults {
    list-style: none;
    margin: 0;
    padding: 0;
}

#listSearchResults li + li {
    margin-top: 0.35rem;
}

#listSearchResults li a {
    display: block;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, 0.02);
}

#listSearchResults li a:hover,
#listSearchResults li.selected a {
    background: #2b3040;
    color: #fff;
}

.source-code {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0;
    overflow: auto;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--background-source);
}

.source-code pre {
    border: 0;
    border-radius: 0;
    background: transparent;
}

.source-line-numbers {
    position: sticky;
    left: 0;
    border-right: 2px solid var(--border);
    background: var(--background-source);
}

.source-line-numbers pre {
    text-align: right;
    color: #697085;
    min-width: 4.5rem;
}

.source-text {
    min-width: 0;
}

.source-text pre {
    min-width: max-content;
}

#tableFnErrors dt {
    font-weight: bold;
}

dl > div {
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-top: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
}

td,
th {
    vertical-align: top;
    padding: 0rem 0.5rem;
    max-width: 20em;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

ul.columns {
    column-width: 18rem;
    margin: 0;
    padding-left: 1.2rem;
}

#errors {
    background: #7f1d1d;
    color: #fff;
    position: fixed;
    bottom: 0;
    width: 100%;
    max-height: min(20rem, 50vh);
    padding: 0.75rem 1rem;
    border-top: 1px solid #ef4444;
}

#errors h1 {
    font-size: 1.5rem;
}

#errors pre {
    background: #991b1b;
    color: #fff;
}

.tok-kw {
    color: #f2f4f8;
    font-weight: bold;
}

.tok-str {
    color: #65e8a1;
}

.tok-builtin {
    color: #ffb06d;
}

.tok-comment {
    color: #b0aa7a;
    font-style: italic;
}

.tok-fn {
    color: #b1a0f8;
    font-weight: bold;
}

.tok-null,
.tok-number {
    color: #ff8a8a;
}

.tok-type {
    color: #78a4ff;
    font-weight: bold;
}

.version-container {
    position: relative;
}

.version-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 10;
    min-width: 180px;
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.version-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.version-item {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 120ms ease;
}

.version-item:hover,
.version-item:focus-visible {
    background: var(--panel-alt);
    color: #fff;
    text-decoration: none;
}

.version-item.current {
    /*color: #f9b64a;*/
    font-weight: 600;
}

@media (max-width: 720px) {
    .utility-bar,
    .search-panel-inner,
    .masthead,
    .page-content section {
        width: min(100%, calc(100% - 24px));
    }

    .search-panel-inner {
        display: block;
    }

    .search-panel-spacer {
        display: none;
    }

    #search {
        width: 100%;
    }

    .masthead {
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-areas:
            "logo summary"
            "nav nav";
        gap: 0.9rem 1rem;
    }

    .logo {
        grid-area: logo;
    }

    .nav-row {
        grid-area: nav;
        flex-wrap: wrap;
        gap: 0.7rem;
    }

    .path-bar {
        width: 100%;
        flex-basis: 100%;
        flex-wrap: wrap;
    }

    #moduleSummary {
        grid-area: summary;
        align-self: center;
        font-size: 0.95rem;
    }
}
