/* ============================================================
   DAFTAR-ISI.CSS  —  complete updated file
   Scenarios:
     1. Desktop  (> 1080px)           : sidebar always visible
     2. Tablet   (601px – 1080px)     : strip tab + slide-in panel on hover
     3. Mobile   (≤ 600px)            : hamburger + slide-up panel
   ============================================================ */


/* ============================================================
   EXISTING DESKTOP SIDEBAR STYLES — unchanged
   ============================================================ */
.daftar-isi {
    padding: 15px 10px;
    position: sticky;
    top: 50px;
    height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}

#toc-container {
    padding: 10px 0px;
    overflow-y: auto;
    flex-grow: 1;
}

.toc-root {
    padding: 0;
    margin: 0;
    list-style: none;
}

.toc-root, .toc-root ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#toc-controls {
    padding: 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 12px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-evenly;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    gap: 8px;
}

#toc-controls button {
    background-color: #ffffff;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    flex: 1;
    align-items: center;
}

#toc-controls button:hover {
    background-color: #537d90;
    color: white;
    border-color: #537d90;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

#toc-controls button:active {
    transform: translateY(0);
    background-color: #436575;
}

.toc-item {
    display: flex;
    align-items: flex-start;
    gap: 0px;
}

.toc-item a {
    text-decoration: none;
    color: #334155;
    font-size: 0.85rem;
    padding: 4px 0;
    display: block;
    flex: 1;
    line-height: 1.5;
}

.toc-item a:hover { color: #2563eb; }

.toc-rank-1 { margin-left: 0;   font-weight: bold; }
.toc-rank-2 { margin-left: 20px; }
.toc-rank-3 { margin-left: 40px; }
.toc-rank-4 { margin-left: 60px; }
.toc-rank-5 { margin-left: 80px; }

.toc-item:not(:has(.toc-chevron)) {
    padding-left: 25px;
}

.toc-item.is-open::before {
    transform: rotate(90deg);
}

.toc-item:hover {
    background-color: rgba(37, 99, 235, 0.05);
}

.toc-chevron {
    font-size: 10px;
    color: #374151;
    margin-right: 5px;
    vertical-align: middle;
    flex-shrink: 0;
    width: 15px;
    text-align: center;
    align-self: flex-start;
    margin-top: 7px;
    cursor: pointer;
    user-select: none;
    display: inline-block;
    transition: transform 0.2s ease, color 0.2s ease;
    transform-origin: center;
}

.toc-chevron:hover {
    color: #3b82f6;
    filter: brightness(1.2);
    transition: all 0.2s ease;
}

.toc-item.is-expanded > .toc-chevron {
    transform: rotate(90deg);
}


/* ============================================================
   SHARED: NEW ELEMENTS — hidden by default on desktop
   ============================================================ */

/* Hover zone — invisible wrapper, hidden on desktop */
#toc-hover-zone {
    display: none;
}

/* The hamburger button — hidden on desktop */
#toc-hamburger {
    display: none;
}

/* Mobile panel — hidden on desktop */
#toc-mobile-panel {
    display: none;
}

/* Shared panel header style (used by both tablet and mobile panels) */
#toc-panel-header,
#toc-mobile-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background-color: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    font-weight: 700;
    font-size: 14px;
    color: #334155;
    position: sticky;
    top: 0;
    z-index: 1;
}

#toc-panel-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.2s ease, color 0.2s ease;
}

#toc-panel-close:hover {
    background-color: #e2e8f0;
    color: #1e293b;
}

#toc-panel-content,
#toc-mobile-panel-content {
    padding: 12px 16px;
}

/* The overlay (mobile only) */
#toc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#toc-overlay.is-active {
    opacity: 1;
}


/* ============================================================
   SCENARIO 2: TABLET  (601px – 1080px)
   e.g. portrait monitor, tablet, stylus device
   Panel opens and closes purely via CSS hover — no JS needed
   ============================================================ */
@media screen and (min-width: 601px) and (max-width: 1080px) {

    /* Hide the desktop sidebar */
    .daftar-isi {
        display: none;
    }

    /* Collapse the grid to a single content column */
    .konten-utama {
        grid-template-columns: 1fr;
        padding-left: 30px;
    }

    /* Show the hover zone — it sits fixed on the left edge */
    #toc-hover-zone {
        display: block;
        position: fixed;
        left: 0;
        top: 120px;
        z-index: 10000;
    }

    /* The vertical strip tab */
    #toc-tab {
        display: flex;
        align-items: center;
        justify-content: center;

        width: 25px;
        height: 160px;
        background-color: #357d90;
        border-radius: 0 8px 8px 0;
        cursor: pointer;

        transition: background-color 0.2s ease, width 0.2s ease;
    }

    #toc-hover-zone:hover #toc-tab {
        background-color: #2a6474;
        width: 26px;
    }

    /* Rotated label inside the tab */
    #toc-tab-label {
        writing-mode: vertical-rl;
        transform: rotate(180deg);
        font-size: 12px;
        font-weight: 900;
        letter-spacing: 2px;
        color: white;
        white-space: nowrap;
        user-select: none;
        pointer-events: none;
    }

    /* Panel: hidden by default, positioned just to the right of the tab */
    #toc-panel {
        display: block;          /* always in flow so hover works */
        position: absolute;
        top: 0;
        left: 22px;              /* flush with the right edge of the tab */
        width: 300px;
        height: 90vh;
        max-height: 90vh;
        overflow-y: auto;
        background-color: #ffffff;
        border-radius: 0 12px 12px 0;
        box-shadow: 4px 0 30px rgba(0, 0, 0, 0.15);

        /* Hidden state: slid behind the tab, invisible */
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.35s ease;
    }

    /* Revealed state: hover anywhere in the zone shows the panel */
    #toc-hover-zone:hover #toc-panel {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }
}


/* ============================================================
   SCENARIO 3: MOBILE  (≤ 600px)
   e.g. smartphones
   ============================================================ */
@media screen and (max-width: 600px) {

    /* Hide the desktop sidebar */
    .daftar-isi {
        display: none;
    }

    /* Single column layout */
    .konten-utama {
        grid-template-columns: 1fr;
    }

    /* Show the hamburger button, fixed bottom-right */
    #toc-hamburger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;

        position: fixed;
        bottom: 25px;
        right: 20px;

        width: 56px;
        height: 56px;
        border-radius: 50%;
        border: 3px solid #f8fafc;

        background-color: #357d90;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        cursor: pointer;
        z-index: 8000;

        transition: background-color 0.2s ease, transform 0.2s ease;
    }

    #toc-hamburger:active {
        background-color: #2a6474;
        transform: scale(0.95);
    }

    /* The three lines */
    #toc-hamburger span {
        display: block;
        width: 24px;
        height: 2px;
        background-color: white;
        border-radius: 2px;
        pointer-events: none;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    /* Animate hamburger → X when panel is open */
    #toc-hamburger.is-active span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }
    #toc-hamburger.is-active span:nth-child(2) {
        opacity: 0;
    }
    #toc-hamburger.is-active span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    /* Mobile panel slides up from the bottom */
    #toc-mobile-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 75vh;
        border-radius: 20px 20px 0 0;
        background-color: #ffffff;
        box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.2);
        overflow-y: auto;
        z-index: 10000;

        /* Start off-screen below */
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.1, 0.7, 1.0, 0.1);
    }

    #toc-mobile-panel.is-active {
        display: block;
        transform: translateY(0);
    }
}
