/* ========================================================
   GLOBAL SCALE KNOB (Controls entire navigation layout)
   ======================================================== */
:root {
    /* Change this single value to perfectly scale all layout elements */
    --ui-scale: 1rem; 
    
    /* Layout Constants derived from the scale factor */
    --nav-slice-portrait: calc(var(--ui-scale) * 3.5);  /* Top bar height */
    --nav-slice-landscape: calc(var(--ui-scale) * 20); /* Left sidebar width */
    --burger-hitbox-w: calc(var(--ui-scale) * 3.5);
    --burger-hitbox-h: calc(var(--ui-scale) * 3.5);
}

/* Basic Reset */
body { 
    margin: 0; 
    font-family: sans-serif; 
}

/* Root Grid System wrapping the application layout */
.page-container { 
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr;
    height: 100vh;
    width: 100vw;
}

/* ========================================================
   NARROW SCREENS (Default Top-Bar Horizontal Slice)
   ======================================================== */
.sidebar {
    width: 100%;
    height: var(--nav-slice-portrait);
    background-color: #f4f4f4;
    padding: calc(var(--ui-scale) * 0.5);
    box-shadow: 0 calc(var(--ui-scale) * 0.125) calc(var(--ui-scale) * 0.3) rgb(0 0 0 / 10%);
    transition: height 0.4s ease;
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    z-index: 1000;
}

/* Collapsed State for Top-Bar */
.sidebar.collapsed {
    height: var(--nav-slice-portrait); /* Kept high enough to display button */
}

/* Top-bar Navigation Layout */
.nav-content ul {
    list-style-type: none;
    padding: 0;
    margin: calc(var(--ui-scale) * 3) 0 0;
    display: flex; 
    flex-wrap: wrap;
    gap: calc(var(--ui-scale) * 1.25);
}

/* Dynamic handling for expanded menu height on mobile */
.sidebar:not(.collapsed) {
    height: auto;
    min-height: var(--nav-slice-portrait);
}

/* ========================================================
   WIDE SCREENS (Sidebar Behavior / Largest Dimension Slice)
   ======================================================== */
@media (width >= 768px) {
    .page-container {
        grid-template-rows: 1fr;
        grid-template-columns: auto 1fr; /* Shifts sidebar left, content right */
    }

    .sidebar {
        width: var(--nav-slice-landscape); 
        height: 100vh;
        box-shadow: calc(var(--ui-scale) * 0.125) 0 calc(var(--ui-scale) * 0.3) rgb(0 0 0 / 10%);
        transition: width 0.4s ease;
    }

    /* Collapsed State for Vertical Sidebar Slice */
    .sidebar.collapsed {
        width: calc(var(--ui-scale) * 4); /* Keeps a minimal strip for button icon */
        height: 100vh;
    }

    /* Sidebar Navigation Layout */
    .nav-content ul {
        flex-direction: column; 
        margin-top: calc(var(--ui-scale) * 5);
        gap: 0;
    }
}

/* ========================================================
   OPTION 1: NARROW ELEMENT WITH A LARGE HITBOX
   ======================================================== */
.toggle-btn {
    position: absolute;
    top: calc(var(--ui-scale) * 0.25);
    left: calc(var(--ui-scale) * 0.5);
    z-index: 1100;
    background: none;
    border: none;
    cursor: pointer;
    
    /* Massive clickable invisible wrapper square */
    width: var(--burger-hitbox-w);
    height: var(--burger-hitbox-h);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* The actual menu character stays tiny, crisp, and beautifully narrow */
.toggle-btn .dots {
    font-size: calc(var(--ui-scale) * 2);
    line-height: 1;
    display: block;
    width: auto;
    text-align: center;
}

/* ========================================================
   UNIVERSAL CONTENT LAYOUT ELEMENTS (SCALED)
   ======================================================== */
.main-content { 
    padding: calc(var(--ui-scale) * 1.25); 
    overflow: auto;
    box-sizing: border-box;
}

.nav-content a {
    display: block;
    padding: calc(var(--ui-scale) * 0.5) calc(var(--ui-scale) * 0.6);
    text-decoration: none;
    color: #333;
    white-space: nowrap;
    font-size: calc(var(--ui-scale) * 1.15);
    transition: opacity 0.3s, background-color 0.2s;
    border-radius: calc(var(--ui-scale) * 0.25);
}

.nav-content a:hover {
    background-color: rgb(0 0 0 / 5%);
}

/* Gracefully hide text links cleanly while sliding or when collapsed on desktop */
@media (width >= 768px) {
    .sidebar.collapsed .nav-content {
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }

    .sidebar:not(.collapsed) .nav-content {
        opacity: 1;
        transition: opacity 0.3s ease 0.1s;
    }
}

@media (width <= 767px) {
    .sidebar.collapsed .nav-content {
        display: none;
    }
}
