/* ═══════════════════════════════════════════════════════════════════════════
   SITE ENHANCEMENTS — Reading Progress, Back-to-Top, A-Z Ribbon
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Hide Quarto's built-in back-to-top (we provide our own) ──────────── */
#quarto-back-to-top {
    display: none !important;
}

/* ── Reading Progress Bar ────────────────────────────────────────────────── */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #0071e3, #34c759);
    z-index: 99999;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}

/* ── Back to Top Button ──────────────────────────────────────────────────── */
#back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 113, 227, 0.9);
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 113, 227, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease,
                background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

#back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#back-to-top:hover {
    background: rgba(0, 119, 237, 1);
    box-shadow: 0 6px 20px rgba(0, 113, 227, 0.45);
    transform: translateY(-2px);
}

#back-to-top:active {
    transform: translateY(0);
}

/* ── A-Z Jump Ribbon ─────────────────────────────────────────────────────── */
#az-ribbon {
    position: sticky;
    top: 56px;  /* below navbar */
    z-index: 1050;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding: 6px 12px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

#az-ribbon a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6e6e73;
    text-decoration: none;
    transition: all 0.2s ease;
}

#az-ribbon a:hover {
    background: rgba(0, 113, 227, 0.08);
    color: #0071e3;
    text-decoration: none;
}

#az-ribbon a.active {
    background: #0071e3;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}

#az-ribbon a.disabled {
    color: #d1d1d6;
    pointer-events: none;
    cursor: default;
}

/* Dark mode overrides */
[data-bs-theme="dark"] #az-ribbon {
    background: rgba(30, 30, 30, 0.88);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] #az-ribbon a {
    color: #98989d;
}

[data-bs-theme="dark"] #az-ribbon a:hover {
    background: rgba(0, 113, 227, 0.15);
    color: #64d2ff;
}

[data-bs-theme="dark"] #back-to-top {
    background: rgba(10, 132, 255, 0.9);
}

[data-bs-theme="dark"] #reading-progress {
    background: linear-gradient(90deg, #0a84ff, #30d158);
}

/* ── Mobile adjustments ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
    #az-ribbon {
        top: 50px;
        padding: 4px 6px;
        gap: 1px;
    }

    #az-ribbon a {
        width: 26px;
        height: 26px;
        font-size: 0.7rem;
    }

    #back-to-top {
        bottom: 80px;  /* above mobile TOC toggle */
        right: 16px;
        width: 42px;
        height: 42px;
    }
}
