/* ==========================================================
   Floating Table of Contents (TOC) - resultadosanimalitos.com
   ========================================================== */

/* --- FAB Button (Floating Action Button) --- */
.toc-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 900;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--gradient-gold);
    color: #0a0e17;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(245, 166, 35, 0.35), 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.toc-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(245, 166, 35, 0.5), 0 3px 12px rgba(0, 0, 0, 0.5);
}

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

.toc-fab svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
}

.toc-fab.is-open svg {
    transform: rotate(45deg);
}

/* --- TOC Panel --- */
.toc-panel {
    position: fixed;
    bottom: 88px;
    right: 24px;
    z-index: 899;
    width: min(340px, calc(100vw - 48px));
    max-height: min(65vh, 480px);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-hover);
    border-radius: var(--border-radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 30px rgba(245, 166, 35, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.96);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    display: flex;
    flex-direction: column;
}

.toc-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* --- Panel Header --- */
.toc-panel__header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toc-panel__header svg {
    width: 18px;
    height: 18px;
    color: var(--color-accent-gold);
    flex-shrink: 0;
}

.toc-panel__title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-text-primary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* --- TOC List (scrollable) --- */
.toc-panel__list {
    list-style: none;
    margin: 0;
    padding: 8px 0;
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: var(--color-accent-gold) transparent;
}

.toc-panel__list::-webkit-scrollbar {
    width: 4px;
}

.toc-panel__list::-webkit-scrollbar-thumb {
    background: rgba(245, 166, 35, 0.3);
    border-radius: 4px;
}

.toc-panel__list::-webkit-scrollbar-track {
    background: transparent;
}

/* --- TOC Items --- */
.toc-panel__item {
    margin: 0;
}

.toc-panel__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    line-height: 1.4;
    transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
    border-left: 3px solid transparent;
}

.toc-panel__link:hover {
    background: rgba(245, 166, 35, 0.06);
    color: var(--color-text-primary);
    padding-left: 22px;
    border-left-color: var(--color-accent-gold);
}

.toc-panel__link.is-active {
    color: var(--color-accent-gold);
    background: rgba(245, 166, 35, 0.08);
    border-left-color: var(--color-accent-gold);
    font-weight: 600;
}

.toc-panel__emoji {
    font-size: 1.1rem;
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.toc-panel__label {
    flex: 1;
    min-width: 0;
}

/* --- Progress Bar --- */
.toc-panel__progress {
    height: 3px;
    background: rgba(255, 255, 255, 0.04);
    flex-shrink: 0;
}

.toc-panel__progress-bar {
    height: 100%;
    width: 0%;
    background: var(--gradient-gold);
    transition: width 0.15s ease;
    border-radius: 0 3px 3px 0;
}

/* --- Overlay for mobile --- */
.toc-overlay {
    position: fixed;
    inset: 0;
    z-index: 898;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

.toc-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    .toc-fab {
        bottom: 18px;
        right: 18px;
        width: 48px;
        height: 48px;
    }

    .toc-fab svg {
        width: 22px;
        height: 22px;
    }

    .toc-panel {
        bottom: 76px;
        right: 18px;
        width: calc(100vw - 36px);
        max-height: 55vh;
    }
}

/* --- Hide when at very top of page (JS adds this) --- */
.toc-fab.is-hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8);
    pointer-events: none;
}

/* --- SEO: <nav> landmark styling --- */
nav.toc-nav {
    /* Ensures the nav landmark is properly recognized */
}

/* --- Print: hide TOC --- */
@media print {

    .toc-fab,
    .toc-panel,
    .toc-overlay {
        display: none !important;
    }
}