/* Brand overrides. Keep mdBook's built-in styles and variables as the base. */

/* Globals */

:root {
    --sidebar-header-border-color: var(--sidebar-active);
    /* Colours from 21 Analytics Website globals.css */
    --off-white: #fafafc;
    --primary-grey: #3e4b52;
    --secondary-green: #23c7ac;
    --neutrals-10-dark: #060708;
    --off-white-blue: #f5f5fb;
    --primary-green-75-dark: #05b776;
    --primary-blue-70-dark: #060666;
    --primary-blue-60-dark: #050658;
    --primary-blue-50-dark: #040549;
    --secondary-green-90-dark: #1fb39b;
    --secondary-green-70-dark: #188b78;
}

/* Preserve the documentation's spacing and table contrast. */
.content {
    padding: 40px 15px 50px;
}

code {
    padding: 16px;
    border-radius: 4px;
}

pre > code.hljs {
    padding: 16px;
}

pre > .buttons {
    right: 16px;
    top: 16px;
}

table thead {
    color: var(--table-header-text);
}

figcaption {
    text-align: center;
    font-size: 0.75em;
}

p:has(img) {
    text-align: center;
}

.chapter {
    margin: 0;
}

.sidebar .sidebar-scrollbox {
    padding: 12px 32px;
}

.chapter li.part-title {
    border-top: 1px var(--sidebar-fg) solid;
    padding-top: 12px;
    margin-top: 8px;
    opacity: 0.8;
    text-transform: uppercase;
}

.chapter li.chapter-item {
    margin-block-start: 0.4em;
}

.chapter strong {
    display: none;
}

.nav-chapters:hover {
    color: var(--arrow-hover);
}

.theme-popup .theme:hover,
.version-popup .version:hover {
    background-color: var(--theme-popup-hover);
}

.version-button {
    display: inline-block;
    min-width: 60px;
}

.version-popup {
    position: absolute;
    left: 148px;
    top: var(--menu-bar-height);
    z-index: 1000;
    border-radius: 4px;
    font-size: 0.7em;
    color: var(--fg);
    background: var(--theme-popup-bg);
    border: 1px solid var(--theme-popup-border);
    margin: 0;
    padding: 0;
    list-style: none;
    display: none;
    overflow: hidden;
}

.version-popup .version {
    display: block;
    padding: 2px 10px;
    line-height: 25px;
    white-space: nowrap;
    text-align: left;
    color: inherit;
    text-decoration: none;
}

/* Themes */

.light,
html:not(.js) {
    --bg: var(--off-white);
    --fg: var(--neutrals-10-dark);

    --sidebar-bg: var(--off-white-blue);
    --sidebar-fg: var(--neutrals-10-dark);
    --sidebar-active: var(--secondary-green-70-dark);
    --sidebar-spacer: #f4f4f4;

    --scrollbar: var(--primary-blue-70-dark);

    --icons: var(--primary-grey);
    --icons-hover: var(--neutrals-10-dark);

    --links: var(--secondary-green-90-dark);

    --inline-code-color: var(--primary-green-75-dark);

    --theme-popup-bg: var(--off-white);
    --theme-popup-border: var(--primary-blue-70-dark);
    --theme-popup-hover: var(--off-white-blue);
    --arrow-hover: var(--off-white);
    --theme-hover: var(--primary-blue-70-dark);

    --quote-bg: hsl(197, 37%, 96%);
    --quote-border: hsl(197, 37%, 91%);

    --table-border-color: var(--primary-blue-70-dark);
    --table-header-bg: var(--primary-blue-70-dark);
    --table-header-text: var(--off-white-blue);
    --table-alternate-bg: var(--off-white-blue);

    --searchbar-border-color: var(--primary-blue-70-dark);
    --searchbar-bg: var(--off-white-blue);
    --searchbar-fg: var(--neutrals-10-dark);
    --searchbar-shadow-color: var(--primary-blue-70-dark);
    --searchresults-header-fg: var(--primary-grey);
    --searchresults-border-color: var(--primary-blue-70-dark);
    --searchresults-li-bg: #e4f2fe;
    --search-mark-bg: #a2cff5;
}

.navy {
    --bg: var(--primary-blue-50-dark);
    --fg: var(--off-white);

    --sidebar-bg: var(--primary-blue-70-dark);
    --sidebar-fg: var(--off-white);
    --sidebar-active: var(--secondary-green);
    --sidebar-spacer: #2d334f;

    --scrollbar: var(--sidebar-fg);

    --icons: var(--off-white);
    --icons-hover: var(--off-white-blue);

    --links: var(--secondary-green-90-dark);

    --inline-code-color: var(--primary-green-75-dark);

    --theme-popup-bg: var(--primary-blue-50-dark);
    --theme-popup-border: var(--off-white-blue);
    --theme-popup-hover: var(--primary-blue-70-dark);
    --arrow-hover: var(--primary-blue-50-dark);
    --theme-hover: var(--off-white-blue);

    --quote-bg: hsl(226, 15%, 17%);
    --quote-border: hsl(226, 15%, 22%);

    --table-border-color: var(--off-white-blue);
    --table-header-bg: var(--off-white-blue);
    --table-header-text: var(--primary-blue-50-dark);
    --table-alternate-bg: var(--primary-blue-60-dark);

    --searchbar-border-color: var(--off-white);
    --searchbar-bg: var(--off-white-blue);
    --searchbar-fg: var(--primary-grey);
    --searchbar-shadow-color: #aaa;
    --searchresults-header-fg: var(--off-white);
    --searchresults-border-color: var(--off-white);
    --searchresults-li-bg: #242430;
    --search-mark-bg: #a2cff5;
}

@media (prefers-color-scheme: dark) {
    html:not(.js) {
        --bg: hsl(200, 7%, 8%);
        --fg: #98a3ad;

        --sidebar-bg: #292c2f;
        --sidebar-fg: #a1adb8;
        --sidebar-non-existent: #505254;
        --sidebar-active: #3473ad;
        --sidebar-spacer: #393939;

        --scrollbar: var(--sidebar-fg);

        --icons: #43484d;
        --icons-hover: #b3c0cc;

        --links: #2b79a2;

        --inline-code-color: #c5c8c6;

        --theme-popup-bg: #141617;
        --theme-popup-border: #43484d;
        --theme-hover: #1f2124;

        --quote-bg: hsl(234, 21%, 18%);
        --quote-border: hsl(234, 21%, 23%);

        --table-border-color: hsl(200, 7%, 13%);
        --table-header-bg: hsl(200, 7%, 28%);
        --table-alternate-bg: hsl(200, 7%, 11%);

        --searchbar-border-color: #aaa;
        --searchbar-bg: #b7b7b7;
        --searchbar-fg: #000;
        --searchbar-shadow-color: #aaa;
        --searchresults-header-fg: #666;
        --searchresults-border-color: #98a3ad;
        --searchresults-li-bg: #2b2b2f;
        --search-mark-bg: #355c7d;
    }
}
