/* rmxbook - uses shared rustmax-themes.css variables */
:root {
    --rmx-sidebar-width: 280px;
    --rmx-toggle-size: 36px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font: var(--rmx-font-text);
    font-feature-settings: "onum" 1, "kern" 1;
    line-height: 1.6;
    background: var(--rmx-color-bg);
    color: var(--rmx-color-fg);
}

body {
    display: flex;
    min-height: 100vh;
}

a { color: var(--rmx-color-links); text-decoration: none; }
a:hover { color: var(--rmx-color-accents); }

/* Toggle - sticky, stays visible when scrolling */
.nav-toggle {
    position: sticky;
    top: 0.5rem;
    align-self: flex-start;
    flex-shrink: 0;
    width: var(--rmx-toggle-size);
    height: var(--rmx-toggle-size);
    margin: 0.5rem;
    padding: 0;
    border: 1px dashed var(--rmx-color-border);
    background: var(--rmx-color-bg-alt);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.nav-toggle::before {
    content: '';
    width: 18px;
    height: 2px;
    background: var(--rmx-color-fg);
    box-shadow: 0 6px 0 var(--rmx-color-fg), 0 -6px 0 var(--rmx-color-fg);
}

.nav-toggle:hover { background: var(--rmx-color-bg); }

/* Sidebar - in flow, animates width to collapse */
.sidebar {
    flex-shrink: 0;
    width: var(--rmx-sidebar-width);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--rmx-color-bg-alt);
    border-right: 1px dashed var(--rmx-color-border);
    padding: 1rem;
    transition: width 0.2s ease, padding 0.2s ease, border 0.2s ease;
}

.nav-collapsed .sidebar {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    border-right-color: transparent;
}

.sidebar-title {
    font: var(--rmx-font-em);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--rmx-color-border);
    white-space: nowrap;
}

.sidebar-title a { color: var(--rmx-color-fg); }
.sidebar-title a:hover { color: var(--rmx-color-accents); }
.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin: 0.3rem 0; white-space: nowrap; }
.sidebar li ul { padding-left: 1rem; }
.sidebar .current > a { font-weight: bold; }

/* Main - always centered with max-width */
main {
    flex: 1;
    min-width: 0;
    max-width: 50rem;
    margin: 0 auto;
    padding: 2rem 3rem;
}

article { line-height: 1.7; }

h1, h2, h3, h4, h5, h6 {
    font: var(--rmx-font-em);
    color: var(--rmx-color-accents);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    line-height: 1.3;
}

h1 { font-size: 2rem; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; letter-spacing: -0.01em; }
h3 { font-size: 1.25rem; }

code {
    font: var(--rmx-font-code);
    font-feature-settings: "lnum" 1;
    font-size: 0.9em;
    background: var(--rmx-color-bg-alt);
    padding: 0.15em 0.3em;
    border-radius: 3px;
}

pre {
    background: var(--rmx-color-bg-alt);
    border-left: 3px solid var(--rmx-color-accents);
    border-radius: 0 3px 3px 0;
    padding: 1rem;
    overflow-x: auto;
}

pre code { background: none; padding: 0; }

blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 3px solid var(--rmx-color-accents);
    border-radius: 0 3px 3px 0;
    background: var(--rmx-color-bg-alt);
}

table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
th, td { border: none; border-bottom: 1px solid var(--rmx-color-border); padding: 0.5rem; text-align: left; }
th { background: var(--rmx-color-bg-alt); border-bottom-width: 2px; }

.nav-links {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--rmx-color-border);
}

.nav-links a {
    padding: 0.5rem 1rem;
    border: 1px dashed var(--rmx-color-border);
}

.nav-links a:hover { background: var(--rmx-color-bg-alt); }

/* Mobile: vertical stacking */
@media (max-width: 768px) {
    body { flex-direction: column; }

    .nav-toggle {
        position: relative;
        top: 0;
        align-self: stretch;
        width: 100%;
        height: var(--rmx-toggle-size);
        margin: 0;
        border-left: none;
        border-right: none;
        border-top: none;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        max-height: 60vh;
        border-right: none;
        border-bottom: 1px dashed var(--rmx-color-border);
        transition: max-height 0.2s ease, padding 0.2s ease, border 0.2s ease;
    }

    .nav-collapsed .sidebar {
        width: 100%;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        border-bottom-color: transparent;
        overflow: hidden;
    }

    .sidebar li { white-space: normal; }

    main { padding: 1rem; }
}
