/* BlueSCSI documentation styles.
   Same tokens as the hand-written pages in public/, so the docs read as part of
   the same site. No framework: the layout here is a header, a sidebar and a
   column of prose, which is not worth a CDN round trip before first paint. */

:root {
    --primary-color: #005bb5;
    --light-gray: #f4f4f4;
    --dark-gray: #333;

    --background-color: var(--light-gray);
    --surface: #fff;
    --text-color: var(--dark-gray);
    --link-color: var(--primary-color);
    --muted-text: #6a707c;
    --card-border: #e2e5ea;
    --code-bg: #eceff3;
    --code-text: #0a3d75;
    --sidebar-bg: #fff;
    --header-bg: #fff;
    --mark-bg: #fff3b0;
    --shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --focus-ring: rgba(0, 91, 181, 0.35);
}

:root.dark-mode {
    --background-color: #282c34;
    --surface: #3a3f4b;
    --text-color: #d7dae0;
    --link-color: #61afef;
    --muted-text: #9aa2b1;
    --card-border: #4a505e;
    --code-bg: #2f333d;
    --code-text: #9ecbff;
    --sidebar-bg: #31353f;
    --header-bg: #31353f;
    --mark-bg: #6b5a1f;
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --focus-ring: rgba(97, 175, 239, 0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    background: var(--background-color);
    color: var(--text-color);
}

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

:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ---- Top bar ---- */

.docs-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.6rem 1.25rem;
}

.docs-header .brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.docs-header .brand img {
    height: 34px;
    width: auto;
    display: block;
}

.docs-header .spacer {
    flex: 1 1 auto;
}

.icon-button {
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0.4rem 0.55rem;
}

.icon-button:hover {
    border-color: var(--card-border);
    color: var(--link-color);
}

#sidebarToggle {
    display: none;
}

/* ---- Search ---- */

.docs-search {
    position: relative;
    flex: 1 1 auto;
    max-width: 420px;
}

.docs-search input {
    width: 100%;
    font: inherit;
    font-size: 0.95rem;
    color: var(--text-color);
    background: var(--background-color);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 0.45rem 0.75rem;
}

.docs-search input::placeholder {
    color: var(--muted-text);
}

.docs-search input:focus {
    border-color: var(--link-color);
    box-shadow: 0 0 0 3px var(--focus-ring);
    outline: none;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    max-height: 60vh;
    overflow-y: auto;
    display: none;
    z-index: 60;
}

.search-results a,
.search-results .empty {
    display: block;
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--card-border);
    color: inherit;
    text-decoration: none;
}

.search-results a:last-child,
.search-results .empty {
    border-bottom: none;
}

.search-results a:hover,
.search-results a.active {
    background: var(--code-bg);
}

.search-results .title {
    font-weight: 600;
    color: var(--link-color);
}

.search-results .snippet,
.search-results .empty {
    font-size: 0.85rem;
    color: var(--muted-text);
}

.search-results mark {
    background: var(--mark-bg);
    color: inherit;
    padding: 0 1px;
    border-radius: 2px;
}

/* ---- Layout ---- */

.docs-layout {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    max-width: 1320px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 0;
}

#sidebar {
    flex: 0 0 260px;
    position: sticky;
    top: 4.5rem;
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
    background: var(--sidebar-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem 1.1rem;
    font-size: 0.93rem;
}

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

#sidebar ul ul {
    margin: 0.15rem 0 0.5rem 0.75rem;
    padding-left: 0.6rem;
    border-left: 1px solid var(--card-border);
}

#sidebar li {
    margin: 0.15rem 0;
}

/* A bare <li> with no link is a section heading in _Sidebar.md. */
#sidebar > ul > li {
    font-weight: 600;
    margin-top: 0.9rem;
    color: var(--muted-text);
    text-transform: uppercase;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}

#sidebar > ul > li:first-child {
    margin-top: 0;
}

/* A top-level entry that is itself a link (Home) is a page, not a section. */
#sidebar > ul > li > a {
    font-weight: normal;
    font-size: 0.93rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-color);
}

#sidebar ul ul li {
    font-weight: normal;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.93rem;
    color: var(--text-color);
}

#sidebar a {
    color: var(--text-color);
    text-decoration: none;
    display: block;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
}

#sidebar a:hover {
    background: var(--code-bg);
    color: var(--link-color);
}

#sidebar a.current {
    background: var(--code-bg);
    color: var(--link-color);
    font-weight: 600;
}

#main-content {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 52rem;
    padding-bottom: 2rem;
}

/* ---- Prose ---- */

#main-content h1 {
    font-size: 2rem;
    margin: 0 0 0.5rem;
    line-height: 1.25;
}

#main-content h2 {
    font-size: 1.5rem;
    margin: 2rem 0 0.5rem;
}

#main-content h3 {
    font-size: 1.2rem;
    margin: 1.5rem 0 0.4rem;
}

#main-content h1,
#main-content h2,
#main-content h3,
#main-content h4,
#main-content h5,
#main-content h6 {
    scroll-margin-top: 4.5rem;
}

#main-content hr {
    border: none;
    border-top: 1px solid var(--card-border);
    margin: 1rem 0 1.5rem;
}

#main-content img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

#main-content code {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

#main-content pre {
    background: var(--code-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    overflow-x: auto;
}

#main-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.codehilite {
    background: var(--code-bg);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    overflow-x: auto;
    margin: 1rem 0;
}

.codehilite pre {
    background: none;
    border: none;
    border-radius: 0;
    margin: 0;
}

#main-content blockquote {
    margin: 1rem 0;
    padding: 0.25rem 1rem;
    border-left: 3px solid var(--card-border);
    color: var(--muted-text);
}

#main-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    display: block;
    overflow-x: auto;
}

#main-content th,
#main-content td {
    border: 1px solid var(--card-border);
    padding: 0.5rem 0.7rem;
    text-align: left;
    vertical-align: top;
}

#main-content thead th {
    background: var(--code-bg);
    font-weight: 600;
}

/* ---- Alerts (> [!NOTE] and friends) ---- */

.alert {
    border: 1px solid var(--alert-border, var(--card-border));
    border-left-width: 4px;
    border-radius: 10px;
    background: var(--alert-bg, var(--surface));
    padding: 0.9rem 1.1rem;
    margin: 1.25rem 0;
}

.alert p {
    margin: 0.35rem 0 0;
}

.alert p:only-of-type {
    margin-top: 0.35rem;
}

.alert-primary {
    --alert-border: #4a90d9;
    --alert-bg: rgba(74, 144, 217, 0.1);
}

.alert-info {
    --alert-border: #4bb3c4;
    --alert-bg: rgba(75, 179, 196, 0.1);
}

.alert-success {
    --alert-border: #4caf72;
    --alert-bg: rgba(76, 175, 114, 0.12);
}

.alert-warning {
    --alert-border: #d99a26;
    --alert-bg: rgba(217, 154, 38, 0.13);
}

.alert-danger {
    --alert-border: #d9534f;
    --alert-bg: rgba(217, 83, 79, 0.12);
}

/* ---- Page meta and site footer ---- */

.edit-note {
    margin-top: 3rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--card-border);
    font-size: 0.87rem;
    color: var(--muted-text);
}

.edit-note p {
    margin: 0.2rem 0;
}

.site-footer {
    border-top: 1px solid var(--card-border);
    margin-top: 2rem;
    padding: 2rem 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--muted-text);
}

.site-footer nav {
    margin-bottom: 0.75rem;
}

.site-footer nav a,
.site-footer .social a {
    color: var(--link-color);
    text-decoration: none;
    margin: 0 0.4rem;
}

.site-footer nav a:hover,
.site-footer .social a:hover {
    text-decoration: underline;
}

.site-footer p {
    margin: 0.5rem 0 0;
}

/* ---- Small screens ---- */

@media (max-width: 900px) {
    #sidebarToggle {
        display: inline-block;
    }

    .docs-layout {
        display: block;
        padding: 1rem 1.25rem 0;
    }

    #sidebar {
        display: none;
        position: static;
        max-height: none;
        width: 100%;
        margin-bottom: 1.5rem;
    }

    #sidebar.open {
        display: block;
    }

    #main-content {
        max-width: none;
    }

    .docs-header {
        flex-wrap: wrap;
    }

    .docs-search {
        order: 3;
        flex-basis: 100%;
        max-width: none;
    }
}
