/*
 * Base Styling for Custom Jekyll Layout
 * Uses Flexbox for two-column layout and sticky TOC scrolling
 */

/* ROOT HEIGHT FIX: CRITICAL for position: sticky and scrolling to work reliably */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

/* 1. FLEXBOX PARENT: Sets up the two-column structure */
.page-wrapper {
    display: flex; /* Activate flexbox */
    max-width: 1400px; /* Max width for the entire page content */
    margin: 0 auto; /* Center the whole page on large screens */
    padding: 20px; /* General padding around the edges */
    padding-top: 50px; /* Push content down from the browser top */
}

/* 2. TOC SIDEBAR: Fixed width, sticky position, and internal scrolling */
.toc-sidebar {
    /* Fixed width for the sidebar */
    flex: 0 0 280px; 
    padding-right: 20px;
    
    /* Make the TOC stick to the top of the browser window */
    position: sticky; 
    top: 50px; /* Distance from the top of the viewport */
    
    /* CRITICAL FIXES FOR SCROLLING */
    /* Allows the content to scroll internally if it exceeds max-height */
    overflow-y: auto; 
    /* Ensures the TOC box doesn't take up the full screen height */
    max-height: 90vh; 

    /* FIX FOR LONG HEADER TEXT WRAPPING */
    word-wrap: break-word; 
    overflow-wrap: break-word;

    /* Optional: Styling for visual separation */
    /* border-right: 1px solid #ddd; */
}

/* 3. MAIN CONTENT: Takes up the remaining space */
.main-content {
    flex: 1; /* Tells the main content to take all available space */
    padding-left: 30px;
    min-width: 0; /* Prevents overflow issues with very long lines */

    /* Optional: Styling for visual separation */
    /* border-left: 1px solid #eee; */
}

/* 4. RESPONSIVE BREAKPOINT: Stacks the columns on smaller screens (tablets in portrait, phones) */
@media (max-width: 1000px) {
    .page-wrapper {
        display: block; /* Stacks the columns vertically */
        padding: 10px;
    }
    .toc-sidebar {
        width: 100%; /* Full width when stacked */
        position: static; /* Remove sticky position when stacked */
        max-height: none; /* No height restriction when stacked */
        margin-bottom: 20px;
        padding-right: 0;
    }
    .main-content {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
    }
}

/* 5. TOC Specific Styling (optional, to clean up the look) */
.toc-sidebar ul {
    list-style-type: none; /* Remove bullet points */
    padding-left: 0;
}
.toc-sidebar li {
    padding: 3px 0;
}

/* ----------------------------------------------------------- */
/* 6. TABLE STYLING: Restores Borders and Striped Rows         */
/* ----------------------------------------------------------- */

.main-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 20px 0;
    font-size: 0.95em;
    line-height: 1.5;
    display: table; /* Overrides potential block display issues */
}

/* Header Styling */
.main-content table th {
    background-color: #f6f8fa; /* Light grey header */
    color: #24292e;
    font-weight: 600;
    border: 1px solid #dfe2e5;
    padding: 10px 12px;
    text-align: left;
}

/* Data Cell Styling */
.main-content table td {
    border: 1px solid #dfe2e5;
    padding: 10px 12px;
    vertical-align: top;
}

/* Zebra Striping (Alternate Row Colors) */
.main-content table tr:nth-child(even) {
    background-color: #f6f8fa;
}

/* Hover effect for better readability */
.main-content table tr:hover {
    background-color: #f2f4f6;
}

/* Mobile Responsive Tables */
@media (max-width: 768px) {
    .main-content table {
        display: block;
        overflow-x: auto; /* Adds horizontal scroll on small phones */
        white-space: normal;
    }
}

/* Remove the "push down" effect from paragraphs in tables */
.main-content table td p {
    margin-top: 0;
    margin-bottom: 10px; /* Keep space BETWEEN paragraphs, but not at the top */
}

/* Ensure the very last paragraph in a cell doesn't add extra bottom padding */
.main-content table td p:last-child {
    margin-bottom: 0;
}
