/* ==========================================================================
   Mejoras UX para Entradas / Clusters en Móvil
   ========================================================================== */

#reading-progress-bar,
#toc-fab,
#toc-modal-overlay {
    display: none;
}

/* =========================================================
   MÓVIL / TABLET
   ========================================================= */
@media (max-width: 991px) {
    #reading-progress-bar {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        height: 6px;
        background: var(--ast-global-color-0);
        width: 0%;
        z-index: 9999;
        transition: width 0.1s linear;
    }

    #toc-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 20px;
        left: 20px;
        width: 56px;
        height: 56px;
        background-color: var(--ast-global-color-2);
        color: #ffffff;
        border-radius: 50%;
        border: none;
        box-shadow: 0 8px 22px rgba(15, 23, 42, 0.22);
        cursor: pointer;
        z-index: 9997;
        transition: transform 0.2s ease-out;
    }

    #toc-fab:active {
        transform: scale(0.95);
    }

    #toc-modal-overlay {
        display: flex;
        position: fixed;
        inset: 0;
        background-color: rgba(15, 23, 42, 0.48);
        z-index: 9998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

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

    #toc-modal-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 72vh;
        background-color: #ffffff;
        border-top-left-radius: 18px;
        border-top-right-radius: 18px;
        box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.12);
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    #toc-modal-overlay.is-active #toc-modal-panel {
        transform: translateY(0);
    }

    #toc-modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 1.25rem;
        border-bottom: 1px solid #e5e7eb;
        flex-shrink: 0;
    }

    #toc-modal-header h3 {
        margin: 0;
        font-size: 1.1rem;
        line-height: 1.2;
        color: #1f2937;
    }

    #toc-modal-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 46px;
        height: 46px;
        border: 1px solid #e5e7eb;
        border-radius: 999px;
        font-size: 2rem;
        line-height: 1;
        background: #ffffff;
        cursor: pointer;
        color: #888;
    }

    #toc-modal-content {
        padding: 1rem 1.25rem;
        overflow-y: auto;
    }

    #toc-modal-content .toc-link {
        display: block;
        padding: 0.9rem 0;
        text-decoration: none;
        color: var(--ast-global-color-3);
        border-bottom: 1px solid #f1f5f9;
        font-size: 1rem;
        line-height: 1.45;
    }

    #toc-modal-content .toc-link.toc-h3 {
        padding-left: 1.25rem;
        font-size: 0.94rem;
        color: #475569;
    }

    #toc-modal-content .toc-link:hover {
        color: var(--ast-global-color-0);
    }
}

/* =========================================================
   DESKTOP
   ========================================================= */
@media (min-width: 992px) {
    #reading-progress-bar,
    #toc-fab,
    #toc-modal-overlay {
        display: none !important;
    }
}
