@font-face {
    font-family: "Atkinson Hyperlegible";
    font-style: normal;
    font-display: swap;
    font-weight: 400;
    src: url(../fonts/atkinson-hyperlegible-latin-400-normal.woff2)
        format("woff2");
}

@font-face {
    font-family: "Atkinson Hyperlegible";
    font-style: normal;
    font-display: swap;
    font-weight: 700;
    src: url(../fonts/atkinson-hyperlegible-latin-700-normal.woff2)
        format("woff2");
}

:root {
  --accent: #1095c1;
  --sidebar-w: 256px;
  --header-h: 64px;
  --overlay: rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg: oklch(from var(--accent) 1 0 h);
  --bg-offset: oklch(from var(--accent) 0.97 0.005 h);
  --bg-offset-2: oklch(from var(--accent) 0.94 0.008 h);
  --text: oklch(from var(--accent) 0.2 0.02 h);
  --text-muted: oklch(from var(--accent) 0.6 0.02 h);
  --border: oklch(from var(--accent) 0.9 0.008 h);
  --primary: oklch(from var(--accent) 0.55 0.14 h);
  --primary-inverse: oklch(from var(--accent) 1 0 h);
  --code-bg: oklch(from var(--accent) 0.96 0.005 h);
}

[data-theme="dark"] {
  --bg: oklch(from var(--accent) 0.16 0.02 h);
  --bg-offset: oklch(from var(--accent) 0.2 0.02 h);
  --bg-offset-2: oklch(from var(--accent) 0.24 0.02 h);
  --text: oklch(from var(--accent) 0.84 0.02 h);
  --text-muted: oklch(from var(--accent) 0.52 0.02 h);
  --border: oklch(from var(--accent) 0.3 0.02 h);
  --primary: oklch(from var(--accent) 0.76 0.12 h);
  --primary-inverse: oklch(from var(--accent) 0.16 0.02 h);
  --code-bg: oklch(from var(--accent) 0.2 0.02 h);
}

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

html {
    font-family: "Atkinson Hyperlegible", sans-serif;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
}

body {
    margin: 0;
    min-height: 100vh;
}

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

button {
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-offset);
    color: var(--text);
    padding: 4px 8px;
    line-height: 1;
    margin: 0;

    &:hover {
        background: var(--bg-offset-2);
    }
}

body > header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    z-index: 200;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    padding: 0 20px;
    display: flex;
    align-items: center;

    nav {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
    }
}

mobile-drawer,
theme-toggle {
    display: contents;
}

.site-title {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-decoration: none;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menu-btn {
    display: none;
    justify-content: center;
    font-size: 16px;
    width: 36px;
    height: 28px;
    text-align: center;

    span {
        align-self: center;
    }
}

.theme-btn {
    font-size: 14px;
}

.shell {
    display: flex;
    padding-top: var(--header-h);
    min-height: 100vh;
}

docs-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-offset);
    border-right: 1px solid var(--border);
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);

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

        li {
            margin: 0;

            a {
                display: block;
                padding: 4px 20px;
                font-size: 14px;
                letter-spacing: 0.2px;
                color: var(--text);
                text-decoration: none;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;

                &:hover {
                    background: var(--bg-offset-2);
                    color: var(--primary);
                }

                &.active {
                    background: var(--primary);
                    color: var(--primary-inverse);
                    border-radius: 8px;
                }
            }
        }
    }
}

.sidebar-nav {
    padding: 12px;
    padding-top: 0px;
}

.sidebar-section {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    padding: 20px 20px 4px;
    margin: 0;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 99;

    &.open {
        display: block;
    }
}

docs-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    padding: 40px 48px 80px;
}

.content {
    max-width: 740px;
    margin: 0 auto;

    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        font-family: var(--mono);

        &:hover .heading-anchor {
            opacity: 1;
        }
    }

    h1 {
        font-size: 28px;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border);
        margin-bottom: 24px;
    }

    h2 {
        font-size: 20px;
        padding-bottom: 4px;
        border-bottom: 1px solid var(--border);
        margin-top: 36px;
        margin-bottom: 16px;
    }

    h3 {
        font-size: 17px;
        margin-top: 28px;
        margin-bottom: 8px;
    }

    p,
    li {
        font-size: 16px;
        line-height: 1.8;
    }

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

    code {
        font-family: var(--mono);
        font-size: 13px;
        padding: 4px 8px;
        background: var(--code-bg);
        border-radius: 4px;
    }

    pre {
        position: relative;
        border-radius: 8px;
        padding: 16px 20px;
        overflow-x: auto;
        margin-bottom: 24px;
        border: 1px solid var(--border);
        background: var(--code-bg);

        code {
            font-size: 13px;
            line-height: 1.65;
            padding: 0;
            background: none;
            border: none;
        }

        &[data-lang]::before {
            content: attr(data-lang);
            position: absolute;
            top: 8px;
            right: 12px;
            font-size: 10px;
            font-family: var(--mono);
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 1.5px;
        }
    }

    blockquote {
        border-left: 4px solid var(--primary);
        padding: 8px 16px;
        margin: 20px 0;
        color: var(--text-muted);
        font-size: 14px;
        background: var(--bg-offset-2);
        border-radius: 0 4px 4px 0;

        p {
            margin: 0;
        }
    }

    table {
        font-size: 13px;
        font-family: var(--mono);
        width: 100%;
        margin-bottom: 24px;
        border-collapse: collapse;
    }

    th,
    td {
        border: 1px solid var(--border);
        padding: 8px 12px;
    }

    th {
        background: var(--bg-offset-2);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 1px;
        font-weight: 700;
    }

    ul,
    ol {
        padding-left: 24px;
        margin-bottom: 16px;
    }
}

.heading-anchor {
    opacity: 0;
    text-decoration: none;
    font-size: 14px;
    margin-left: 8px;
    color: var(--text-muted);
}

docs-search {
    position: relative;
    flex: 1;
    max-width: 480px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    font-family: inherit;
    font-size: 15px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-offset);
    color: var(--text);
    outline: none;

    &::placeholder {
        color: var(--text-muted);
        font-size: 14px;
    }

    &:focus {
        border-color: var(--primary);
    }
}

.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    min-width: 320px;
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 300;

    &.open {
        display: block;
    }
}

.search-hit {
    display: block;
    padding: 12px 16px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border);

    &:last-child {
        border-bottom: none;
    }

    &:hover {
        background: var(--bg-offset);
    }
}

.search-hit-title {
    display: block;
    font-size: 14px;
    font-weight: 700;
    font-family: var(--mono);
    margin-bottom: 4px;
}

.search-hit-path {
    display: block;
    font-size: 11px;
    font-family: var(--mono);
    color: var(--text-muted);
    margin-bottom: 4px;
}

.search-hit-snippet {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.search-empty {
    padding: 16px;
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
}

@media (max-width: 768px) {
    docs-search {
        max-width: 140px;
    }

    .search-results {
        min-width: 280px;
        right: -40px;
        left: auto;
    }
}

@media (max-width: 480px) {
    docs-search {
        max-width: 112px;
    }
}

.loading {
    font-size: 12px;
    font-family: var(--mono);
    color: var(--text-muted);
    letter-spacing: 0.8px;
    padding: 8px 0;

    &::after {
        content: ".";
        animation: dots 1.2s steps(3, end) infinite;
    }
}

@keyframes dots {
    0% {
        content: ".";
    }
    33% {
        content: "..";
    }
    66% {
        content: "...";
    }
}

@media (max-width: 768px) {
    .menu-btn {
        display: inline-flex !important;
    }

    docs-sidebar {
        transform: translateX(-100%);
        z-index: 150;

        &.open {
            transform: translateX(0);
            box-shadow: 6px 0 30px rgba(0, 0, 0, 0.12);
        }
    }

    docs-content {
        margin-left: 0;
        padding: 24px 20px 48px;
    }
}

@media (max-width: 480px) {
    docs-content {
        padding: 20px 16px 48px;
    }
}
