/*
* Prefixed by https://autoprefixer.github.io
* PostCSS: v8.4.14,
* Autoprefixer: v10.4.7
* Browsers: last 4 version
*/

:root {
    --sidebar-width: 270px;
    --sidebar-resize-indicator-width: 0px;
    --toc-width: 270px;
    --center-content-toc-shift: calc(-1 * var(--toc-width) / 2);
    --toc-bg-h1: rgba(114, 137, 218, 0.05);
    --toc-bg-h2: rgba(114, 137, 218, 0.03);
    --toc-bg-active: rgba(86, 114, 210, 0.15);
    --toc-border-active: rgb(86, 114, 210);
}

.nav-chapters {
    /* adjust width of buttons that bring to the previous or the next page */
    min-width: 50px;
}

.previous {
    /*
    adjust the space between the left sidebar or the left side of the screen
    and the button that leads to the previous page
    */
    margin-left: var(--page-padding);
}

 @media only screen {
    main {
        display: -webkit-box;
        display: -ms-flexbox;
        display: flex;
    }

    @media (max-width: 1079px) {
        .sidebar-hidden #sidetoc {
            display: none;
        }
    }

    @media (max-width: 1439px) {
        .sidebar-visible #sidetoc {
            display: none;
        }
    }

    @media (1079px <= width <= 1339px) {
        .sidebar-hidden main {
            position: relative;
            left: var(--center-content-toc-shift);
        }
    }

    @media (1439px <= width <= 1700px) {
        .sidebar-visible main {
            position: relative;
            left: var(--center-content-toc-shift);
        }
    }

    .content-wrap {
        width: 100%;
    }

    #sidetoc {
        margin-top: 20px;
        margin-left: 10px;
        margin-right: auto;
    }
    #pagetoc {
        position: fixed;
        /* adjust TOC width */
        width: var(--toc-width);
        max-height: 60vh; /* Limit the height to 60% of the viewport height */
        overflow-y: auto; /* Add vertical scrolling when content exceeds max-height */
        height: auto; /* Allow the height to be dynamic based on content up to max-height */
        margin-bottom: 20px; /* Add some margin at the bottom */
        scrollbar-width: thin; /* Make scrollbar thin for Firefox */
        scrollbar-color: var(--sidebar-fg) var(--sidebar-bg); /* Standard scrollbar color */
    }
    #pagetoc a {
        border-left: 2px solid var(--sidebar-bg);
        color: var(--fg) !important;
        display: block;
        padding-bottom: 5px;
        padding-top: 5px;
        padding-left: 10px;
        text-align: left;
        text-decoration: none;
        transition: all 0.2s ease;
        margin-bottom: 1px;
        border-radius: 0 4px 4px 0;
    }
    #pagetoc a:hover {
        background: var(--sidebar-bg);
        color: var(--sidebar-fg) !important;
        border-left-color: var(--links);
        padding-left: 15px;
    }
    #pagetoc a.active {
        background: var(--toc-bg-active);
        color: var(--links) !important;
        border-left-color: var(--toc-border-active);
        font-weight: bold;
        padding-left: 15px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    }
    /* Enhanced heading styles for better hierarchy visualization */
    #pagetoc .pagetoc-title {
        font-weight: bold;
        font-size: 1.2em;
        border-left-color: var(--links);
        border-left-width: 3px;
        margin-bottom: 10px;
        padding-top: 8px;
        padding-bottom: 8px;
        background: var(--toc-bg-active);
        color: var(--links) !important;
        border-bottom: 1px solid rgba(0,0,0,0.07);
    }
    #pagetoc .pagetoc-H1 {
        font-weight: bold;
        font-size: 1.05em;
        border-left-color: var(--icons);
        background: var(--toc-bg-h1);
    }
    #pagetoc .pagetoc-H2 {
        padding-left: 20px;
        font-weight: 600;
        font-size: 1em;
        border-left-color: var(--sidebar-active);
        opacity: 0.95;
        background: var(--toc-bg-h2);
    }
    #pagetoc .pagetoc-H3 {
        padding-left: 40px;
        font-weight: normal;
        font-size: 0.95em;
        border-left-color: var(--quote-border);
        opacity: 0.9;
    }
    #pagetoc .pagetoc-H4 {
        padding-left: 60px;
        font-weight: normal;
        font-size: 0.9em;
        color: var(--sidebar-fg) !important;
        opacity: 0.9;
    }
    #pagetoc .pagetoc-H5 {
        padding-left: 80px;
        font-weight: normal;
        font-size: 0.85em;
        opacity: 0.8;
    }
    #pagetoc .pagetoc-H6 {
        padding-left: 100px;
        font-weight: normal;
        font-size: 0.8em;
        opacity: 0.7;
    }
}

/* Style the scrollbar for webkit browsers (Chrome, Safari, etc.) */
#pagetoc::-webkit-scrollbar {
    width: 6px;
}

#pagetoc::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}

#pagetoc::-webkit-scrollbar-thumb {
    background-color: var(--sidebar-fg);
    border-radius: 6px;
}

 @media print {
    #sidetoc {
        display: none;
    }
}

/* Table formatting for horizontal scrolling with column width control */
.table-wrapper {
    overflow: auto;         /* Enable both X and Y scrolling */
    max-height: 85vh;       /* Limit height to viewport to create scrolling context */
    width: 100%;
    margin-bottom: 1.5em;
    border: 1px solid var(--table-border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.page-wrapper table {
    width: 100%;
    border-collapse: separate; /* Required for sticky borders in some browsers */
    border-spacing: 0;
}

/* Sticky Table Headers */
.page-wrapper table thead tr th {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: var(--bg); /* Ensure header isn't transparent */
    color: var(--fg);
    border-bottom: 2px solid var(--table-border-color);
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.4);
}

/* Sticky First Column (Optional: Improves readability for wide tables) */
.page-wrapper table tbody td:first-child,
.page-wrapper table thead th:first-child {
    position: sticky;
    left: 0;
    background-color: var(--bg);
    z-index: 15; /* Below header, above content */
    border-right: 1px solid var(--table-border-color);
}

/* Header of first column needs higher z-index to stay on top of both scrolls */
.page-wrapper table thead th:first-child {
    z-index: 30;
}

/* Back to Top Button */
#back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none; /* Hidden by default */
    background-color: var(--sidebar-bg);
    color: var(--fg);
    border: 1px solid var(--table-border-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    text-align: center;
    line-height: 50px; /* Center icon vertically */
    font-size: 20px;
    cursor: pointer;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: opacity 0.3s, background-color 0.3s;
}

#back-to-top:hover {
    background-color: var(--theme-hover);
}

@media (max-width: 768px) {
    #back-to-top {
        bottom: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        line-height: 40px;
        font-size: 16px;
    }
}

/* Widen the main content area to fill the screen */
.content, .content-wrap {
    max-width: 100% !important; /* Override mdbook's default ~750px limit */
    padding-left: 20px;
    padding-right: 20px;
}

/* Ensure the main container expands with the sidebar state */
main {
    width: 100%;
}

.page-wrapper table th, .page-wrapper table td {
    white-space: normal;
    word-wrap: break-word;
}

/* Define column widths */
/*.page-wrapper table th:nth-of-type(1), .page-wrapper table td:nth-of-type(1) { min-width: 150px; }*/
/*.page-wrapper table th:nth-of-type(2), .page-wrapper table td:nth-of-type(2) { min-width: 150px; }*/
/*.page-wrapper table th:nth-of-type(3), .page-wrapper table td:nth-of-type(3) { min-width: 200px; }*/
.page-wrapper table th:nth-of-type(4), .page-wrapper table td:nth-of-type(4) { min-width: 400px; } /* Description */
.page-wrapper table th:nth-of-type(5), .page-wrapper table td:nth-of-type(5) { min-width: 400px; } /* Exploit Methods */
.page-wrapper table th:nth-of-type(6), .page-wrapper table td:nth-of-type(6) { min-width: 400px; } /* TLDR Mitigation */