/* ========================================= */
/*  Sidebar: left fixed, mobile hamburger    */
/* ========================================= */

.main-layout {
    display: flex;
    flex: 1;
    min-height: calc(100vh - var(--header-height, 60px) - var(--footer-height, 60px));
}

/* Re-wrap footer: PaperMod's footer is normally after main,
   but we want it full-width below the layout. Override via CSS. */
body { display: flex; flex-direction: column; min-height: 100vh; }
footer { margin-top: auto; }

.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--theme);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

#sidebar-toggle { display: none; }
.sidebar-overlay { display: none; }
.sidebar-toggle-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 200;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--theme);
    border: 1px solid var(--border);
    color: var(--primary);
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.sidebar-toggle-btn:hover { background: var(--entry); }

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-site {
    padding: 16px 20px;
    font-size: 1.1rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}
.sidebar-site a { color: var(--primary); box-shadow: none; }

.sidebar-tree { flex: 1; padding: 8px 0; overflow-y: auto; }

.sidebar-foot {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
}
.sidebar-foot a { color: var(--secondary); box-shadow: none; }

/* Tree list */
.tree-list { list-style: none; padding: 0; margin: 0; }

.tree-item {
    display: block;
    padding: 5px 16px 5px 24px;
    font-size: 0.88rem;
    color: var(--secondary);
    box-shadow: none;
    border-left: 2px solid transparent;
    transition: all 0.15s;
}
.tree-item:hover {
    color: var(--primary);
    background: var(--entry);
    border-left-color: var(--primary);
}
.tree-item.active {
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.tree-folder { padding: 0; }
.tree-label {
    padding: 6px 20px;
    font-size: 0.82rem;
    color: var(--secondary);
    cursor: pointer;
    list-style: none;
    user-select: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.tree-label::marker { display: none; }
.tree-label::-webkit-details-marker { display: none; }
.tree-label::before {
    content: "\25B6";
    display: inline-block;
    width: 14px;
    font-size: 0.65rem;
    margin-right: 4px;
    transition: transform 0.15s;
}
details[open] > .tree-label::before { transform: rotate(90deg); }

.tree-folder .tree-item { padding-left: 40px; }

/* Dynamic list on home / section pages */
.dynamic-list {
    list-style: none;
    padding: 0;
    margin: 16px 0;
}
.dynamic-list li { margin-bottom: 10px; }
.dynamic-list a { box-shadow: none; }
.list-title { font-weight: 600; }
.list-desc { display: block; font-size: 0.85rem; color: var(--secondary); }

/* Mobile */
@media (max-width: 768px) {
    .main-layout { flex-direction: column; }

    .sidebar-toggle-btn { display: flex; }
    .sidebar-overlay { display: none; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 300;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    #sidebar-toggle:checked ~ .sidebar { transform: translateX(0); }
    #sidebar-toggle:checked ~ .sidebar + .sidebar-overlay,
    #sidebar-toggle:checked ~ #sidebar-overlay,
    #sidebar-toggle:checked ~ .sidebar ~ .sidebar-overlay {
        display: block;
    }
    /* Overlay: we rely on sibling selectors, but need to reach it from checkbox */
    #sidebar-toggle:checked ~ .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.55);
        z-index: 250;
    }
    .main { padding-left: 16px; padding-right: 16px; }
}
