/**
 * Table of contents + reading time (BudgetAtlas articles).
 * Desktop (>=1024px): TOC expanded by default. Mobile: collapsed until opened.
 */

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

.article-readtime-budgetatlas {
    margin: 0 0 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #64748b;
}

.article-toc-readtime-budgetatlas {
    margin: 1.5rem 0 2rem;
    padding: 1rem 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: #f8fafc;
    font-family: inherit;
}

.article-toc-readtime-budgetatlas__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.article-toc-readtime-budgetatlas__heading {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #334155;
}

.article-toc-readtime-budgetatlas__toggle {
    flex-shrink: 0;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    border-radius: 0.375rem;
    background: #fff;
    padding: 0.35rem 0.65rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #2563eb;
    line-height: 1.2;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.article-toc-readtime-budgetatlas__toggle:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.article-toc-readtime-budgetatlas__toggle:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.article-toc-readtime-budgetatlas__panel {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.article-toc-readtime-budgetatlas__list {
    margin: 0;
    padding-left: 1.25rem;
    padding-bottom: 0.25rem;
    list-style: decimal;
}

.article-toc-readtime-budgetatlas__item {
    margin: 0.35rem 0;
    padding-left: 0.25rem;
    font-size: 1rem;
    line-height: 1.45;
    color: #334155;
}

.article-toc-readtime-budgetatlas__link {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.article-toc-readtime-budgetatlas__link:hover {
    color: #1d4ed8;
    border-bottom-color: #93c5fd;
}

.article-toc-readtime-budgetatlas__link:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Desktop: expanded by default */
.article-toc-readtime-budgetatlas__panel {
    max-height: none;
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 1023px) {
    /* Extra room so the last list line is not clipped (panel overflow + card padding). */
    .article-toc-readtime-budgetatlas--open {
        padding-bottom: 1.2rem;
    }

    .article-toc-readtime-budgetatlas:not(.article-toc-readtime-budgetatlas--open) .article-toc-readtime-budgetatlas__panel {
        max-height: 0;
        opacity: 0;
        pointer-events: none;
        overflow: hidden;
    }

    .article-toc-readtime-budgetatlas--open .article-toc-readtime-budgetatlas__panel {
        max-height: 60rem;
        opacity: 1;
        pointer-events: auto;
        overflow: visible;
        padding-bottom: 0.35rem;
    }

    .article-toc-readtime-budgetatlas:not(.article-toc-readtime-budgetatlas--open) .article-toc-readtime-budgetatlas__list {
        padding-bottom: 0;
    }

    .article-toc-readtime-budgetatlas--open .article-toc-readtime-budgetatlas__list {
        padding-bottom: 0.5rem;
    }
}

@media (min-width: 1024px) {
    .article-toc-readtime-budgetatlas__toolbar {
        margin-bottom: 0.5rem;
    }

    .article-toc-readtime-budgetatlas--closed .article-toc-readtime-budgetatlas__panel {
        max-height: 0;
        opacity: 0;
        pointer-events: none;
    }
}
