:root {
    --colour-background: var(--appearance-colour-background, #0b0c0d);
    --colour-foreground: var(--appearance-colour-foreground, #e6e6e6);
    --colour-muted: var(--appearance-colour-muted, #a8a8a8);
    --colour-brand: var(--appearance-colour-brand, #5bbaff);
    --colour-card: var(--appearance-colour-card, #131416);
    --colour-accent: var(--appearance-colour-accent, #7ee787);
    --content-max-width: var(--appearance-content-max-width, 900px);
    --content-gutter: 24px;
    --base-font-size: var(--appearance-base-font-size, 16px);
    --base-line-height: var(--appearance-base-line-height, 1.5);
    --bg: var(--colour-background);
    --fg: var(--colour-foreground);
    --muted: var(--colour-muted);
    --brand: var(--colour-brand);
    --card: var(--colour-card);
    --accent: var(--colour-accent);
    --anchor-offset: 196px;
}

/* Utility colour helpers */
.bg-foreground {
    background-color: var(--fg);
}

.bg-background {
    background-color: var(--bg);
}

.bg-card {
    background-color: var(--card);
}

.bg-brand {
    background-color: var(--brand);
}

.bg-accent {
    background-color: var(--accent);
}

.text-foreground {
    color: var(--fg);
}

.text-background {
    color: var(--bg);
}

.text-brand {
    color: var(--brand);
}

.text-accent {
    color: var(--accent);
}

.text-muted {
    color: var(--muted);
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, 'Helvetica Neue', Arial, 'Apple Color Emoji', 'Segoe UI Emoji';
    color: var(--fg);
    background: var(--bg);
    font-size: var(--base-font-size);
    line-height: var(--base-line-height);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 100ms ease, transform 120ms ease;
    animation: page-enter 100ms ease;

    &#tinymce {
        max-width: max(1000px, 80vw);
        margin-inline: auto;
        padding: 0;

        section:not(.full-bleed) {
            padding-inline: var(--content-gutter);
        }
    }
}

@keyframes page-enter {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.is-page-leaving {
    animation: none;
    opacity: 0;
    transform: translateY(6px);
}

@media (prefers-reduced-motion: reduce) {
    body {
        transition: none;
        animation: none;
    }

    body.is-page-leaving {
        opacity: 1;
        transform: none;
    }
}

a {
    color: var(--brand);
    text-decoration: none
}

.btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--brand);
    color: #00172a;
    font-weight: 600
}

div:not(.nav-menu) {
    ul:not(.toc-list) {
        list-style: none;
        padding-left: 0;
    }

    ul:not(.toc-list) li {
        position: relative;
        padding-left: 1.7em;
    }

    ul:not(.toc-list) li::before {
        content: "\f120";
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        position: absolute;
        left: 0.5em;
        top: 0.35em;
        color: var(--brand);
        font-size: 0.9em;
        line-height: 1.1;
        opacity: 0;
        transition: opacity 0.2s ease;
    }
}

.fa-ready div:not(.nav-menu) ul:not(.toc-list) li::before {
    opacity: 1;
}

/* Screen reader */
.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.container section.hero {
    position: relative;
    padding: 56px 0;
    min-height: 360px;
    overflow: hidden;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;

    .hero-media {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        z-index: 0;
        grid-column: 1 / -1;
    }

    .hero-content {
        position: relative;
        z-index: 1;
        background: var(--card);
        border: 1px solid #222;
        border-radius: 16px;
        padding: 24px;
        box-shadow: 0 12px 30px rgba(0, 0, 0, .35)
    }

    &.home {
        padding: 156px 0;
    }
}

.hero-subtitle {
    margin: 8px 0 0;
    color: var(--muted);
}

section .inner.flex-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2em;

    & .left, & .right {
        width: 50%;
    }
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px
}

.cta-block {
    padding: 48px 0;
    background: var(--card);
    border-top: 1px solid #222;
    border-bottom: 1px solid #222;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.cta-card {
    background: color-mix(in hsl, var(--card), transparent 15%);
    border: 1px solid #222;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}

.cta-card h2 {
    margin: 0 0 12px;
}

.cta-card p {
    margin: 0 0 16px;
    color: var(--muted);
}

.archive {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;

    >.card {
        height: 100%;
    }
}

.footer-global {
    padding-top: 32px;
    border-top: 1px solid #222;
    background: var(--card);

    .container {
        padding-top: 0;
        padding-bottom: 32px;
    }
}

.footer-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    align-items: start;
}

.footer-brand img {
    max-width: 180px;
    height: auto;
    display: block;
    margin-bottom: 12px;
}

.footer-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.footer-nav-link {
    color: var(--fg);
    opacity: 0.85;

    &:hover {
        opacity: 1;
    }
}

.container {
    width: 100%;
    max-width: none;
    margin: 0 auto;
    display: grid;
    grid-template-columns: minmax(var(--content-gutter), 1fr) minmax(0, var(--content-max-width)) minmax(var(--content-gutter), 1fr);
    column-gap: 0;

    >* {
        grid-column: 2
    }

    >section {
        padding: 48px 0;
    }

    >.full-bleed {
        grid-column: 1 / -1
    }
}

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 38%);
    gap: 32px;
    align-items: start;
}

.article-main {
    max-width: 75ch;
    width: 100%;
}

.article-sidebar {
    position: sticky;
    top: calc(var(--anchor-offset) - 30px);
    display: grid;
    gap: 16px;
}

.toc-drawer {
    position: fixed;
    top: calc(var(--anchor-offset) + 24px);
    right: -1px;
    z-index: 45;
    display: none;
    align-items: center;
    pointer-events: none;
    gap: 0;
}

.toc-toggle {
    pointer-events: auto;
    width: auto;
    padding: 10px;
    border-radius: 999px 0 0 999px;
    background: var(--card);
    color: var(--fg);
    border: 1px solid #222;
    border-right: 0;
    /* box-shadow: 0 8px 18px rgba(0, 0, 0, .35); */
    position: absolute;
    top: 12px;
    left: -39px;
    z-index: 50;
    transition: ease .2s;
}

.is-open .toc-toggle {
    left: -30px;
    padding: 10px 0 10px 10px;
}

.toc-drawer {
    pointer-events: auto;
    width: min(320px, 80vw);
    transform: translateX(100%);
    transition: transform 0.25s ease;
}

.toc-drawer.is-open {
    transform: translateX(0);
}

.toc-panel .card {
    max-height: 70vh;
    overflow: auto;
    border-radius: 0 0 0 14px;
}

.toc-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 40;
    display: none;
}

.toc-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.toc-list,
.sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 6px;
}

.toc-list {
    padding-left: 0.4em;
}

.toc-list a,
.sidebar-list a {
    color: var(--fg);
    opacity: 0.85;
}

.toc-list a {
    position: relative;
    padding-left: 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.toc-list a::before {
    content: "\f02e";
    font-family: "Font Awesome 6 Free";
    color: var(--accent);
    position: absolute;
    left: 0;
    top: 1px;
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toc-list a.is-active::before {
    font-weight: 400;
    opacity: 0;
    transform: translateX(0);
}

.fa-ready .toc-list a.is-active::before {
    opacity: 1;
}

.toc-list a:hover,
.sidebar-list a:hover {
    opacity: 1;
}

.toc-list .toc-sub {
    margin-left: 12px;
    opacity: 0.9;
    font-size: 0.95em;
}

.nav-sub-toggle {
    display: none;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: transparent;
    color: var(--fg);
    border: 1px solid #222;
    padding: 0;
}

.nav-sub-toggle::before {
    content: "\f078";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 0.7em;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fa-ready .nav-sub-toggle::before {
    opacity: 1;
}

i[class^="fa-"],
i[class*=" fa-"] {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fa-ready i[class^="fa-"],
.fa-ready i[class*=" fa-"] {
    opacity: 1;
}

.full-bleed {
    display: grid;
    grid-template-columns: minmax(var(--content-gutter), 1fr) minmax(0, var(--content-max-width)) minmax(var(--content-gutter), 1fr);
    column-gap: 0;

    >* {
        grid-column: 2
    }

    >.bleed {
        grid-column: 1 / -1
    }
}

nav,
.site-nav {
    display: flex;
    gap: 6px;
    align-items: center;
    background: var(--card);
    padding: 12px 16px;
    border-bottom: 1px solid #222;
    flex-direction: column;

    .spacer {
        flex: 1
    }

    .nav-link {
        display: inline-block;
        padding: 8px 10px;
        border-radius: 10px;
    }

    .nav-li:hover>.nav-link {
        background: #1a1c20;
    }
}

.site-nav {
    position: sticky;
    top: 0;
    z-index: 99;
    background: color-mix(in hsl, var(--card), transparent 25%);
    backdrop-filter: blur(4px);

    strong,
    .nav-link {
        display: flex;
        align-items: center;
        line-height: 1;
    }
}

.site-logo {
    height: 40px;
    display: block
}

.nav-toggle {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: transparent;
    color: var(--fg);
    width: auto;
}

.nav-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
}

.nav-menu {
    display: block;

    .nav-ul {
        display: flex;
        gap: 12px;
        flex-wrap: wrap;
    }
}

.nav-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 30;

    &.is-open {
        opacity: 1;
        pointer-events: auto;
        height: 100vh;
    }
}

.nav-close {
    display: none;
    width: 36px;
    height: 36px;
    background: transparent;
    color: var(--fg);
    margin-bottom: 12px;
    margin-left: auto;
}

.nav-ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;

    .sub-menu {
        position: absolute;
        top: 100%;
        list-style: none;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
        min-width: 200px;
        padding: 6px 0 6px 10px;
        border-radius: 10px;
        background: #0e1012;
        border: 1px solid #222;
        box-shadow: 0 8px 18px rgba(0, 0, 0, .3);
        opacity: 0;
        transform: translateY(8px);
        pointer-events: none;
        transition: opacity .2s ease, transform .2s ease;
        z-index: 1;

        .nav-link {
            font-size: 0.95em;
            opacity: 0.85;
            display: inline-flex !important;
            justify-content: space-between;
        }


        .nav-li {
            display: block;
            /* cursor: pointer; */

            &:hover>.nav-link {
                opacity: 1;
                background: #1a1c20;
            }
        }
    }

    .sub-menu[data-depth="2"] .nav-li {
        display: block;
    }

    .sub-menu[data-depth="3"] {
        top: 0;
        left: calc(100%);
        transform: translateX(8px);
        z-index: 2;
        min-width: 350px;
        padding-right: 10px;
    }


    .nav-li {
        position: relative;
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;

        .nav-link {
            display: inline-block;

            &.active {
                background: #1a1c20;
                opacity: 1;
            }
        }

        >.nav-link::after {
            content: "";
        }

        &:has(> .sub-menu)>.nav-link::after {
            content: "\f078";
            font-family: "Font Awesome 6 Free";
            font-weight: 900;
            font-size: 0.7em;
            margin-left: 0.4em;
            opacity: 0;
            transition: opacity 0.2s ease;
        }

        &:has(> .sub-menu[data-depth="3"])>.nav-link::after {
            content: "\f054";
            position: absolute;
            right: 10px;
            cursor: default;
        }

        >.sub-menu {
            flex-basis: 100%;
        }

        &:hover>.sub-menu,
        &:focus-within>.sub-menu {
            opacity: 1;
            transform: translateY(0);
            pointer-events: auto;
        }
    }
}

.fa-ready .nav-li:has(> .sub-menu)>.nav-link::after {
    opacity: 0.75;
}

/* base nav list already styled */

.card {
    background: var(--card);
    border: 1px solid #222;
    border-radius: 14px;
    padding: 16px;
    margin: 12px 0;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .25)
}

input:not([type="checkbox"], [type="radio"]),
textarea,
button {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #333;
    background: #0e1012;
    color: var(--fg)
}

textarea {
    min-height: 220px;
    resize: vertical
}

button {
    cursor: pointer;
    background: var(--brand);
    color: #00172a;
    border: 0;
    font-weight: 600
}


h1,
h2,
h3 {
    margin: 0 0 12px
}

html {
    scroll-behavior: smooth;
}

h2,
h3 {
    scroll-margin-top: var(--anchor-offset);
}

.small {
    font-size: 12px;
    color: var(--muted)
}

img {
    max-width: 100%;
}

@media (max-width: 900px) {
    :root {
        --anchor-offset: 96px;
    }

    .article-layout {
        grid-template-columns: 1fr;
    }

    .article-sidebar {
        position: static;
    }

    .toc-card {
        display: none;
    }

    .toc-drawer {
        display: flex;
        top: calc(var(--anchor-offset) + 12px);
    }

    .toc-panel {
        z-index: 49;
    }

    .toc-backdrop {
        display: block;
    }

    .archive {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .article-layout .full-bleed {
        width: calc(100% + (var(--content-gutter) * 2));
        margin-inline: calc(var(--content-gutter) * -1);
    }

    .article-layout .full-bleed>* {
        max-width: 75ch;
        margin-inline: auto;
        width: 100%;
        padding-inline: var(--content-gutter);
    }

    .article-layout .full-bleed {
        grid-template-columns: minmax(0, 1fr);
    }

    body {
        padding-top: 71px;
    }

    .site-nav {
        flex-direction: row;
        position: fixed;
        width: 100%;
    }

    .nav-toggle {
        display: inline-flex;
        flex-direction: column;
    }

    .nav-menu {
        display: block;
        position: fixed;
        right: 0;
        top: 0;
        height: 100vh;
        width: min(270px, 80vw);
        background: var(--card);
        border: 1px solid #222;
        border-radius: 0;
        padding: 24px 16px;
        z-index: 40;
        border-width: 0 0 0 1px;
        transform: translateX(110%);
        transition: transform 0.25s ease;

        &.is-open {
            transform: translateX(0);
        }
    }

    .nav-close {
        display: block;
    }

    .nav-menu .nav-ul {
        flex-direction: column;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .nav-li {
        display: flex !important;
    }

    .nav-li:has(.sub-menu) {
        margin-bottom: -6px;

        &.is-open {
            margin-bottom: 0;
        }
    }

    .nav-li>.nav-link {
        flex: 1;
        /* padding-block: 12px; */
        line-height: var(--base-line-height);
    }

    .nav-li>.nav-link::after {
        display: none;
    }

    .nav-sub-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-menu .sub-menu {
        position: static;
        opacity: 1;
        transform: none;
        pointer-events: auto;
        max-height: 0;
        overflow: hidden;
        padding: 0 0 0 10px;
        border: 0;
        box-shadow: none;
        background: transparent;
        transition: max-height .25s ease;
        transform: unset !important;

        &[data-depth="3"] {
            min-width: unset;
        }
    }

    .nav-li.is-open>.sub-menu {
        max-height: 100vh;
    }
}

@media (max-width: 548px) {
    .archive {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
}
