/* =========================================================
   Table of Contents — matrisa-sudbi.ru
   ========================================================= */

.ms-toc {
    --toc-accent: #2ec5b6;
    --toc-accent-soft: rgba(46, 197, 182, 0.12);
    --toc-bg: #fbf6ec;
    --toc-ink: #1c2333;
    --toc-muted: #6b7385;
    --toc-line: #ece3d0;

    max-width: 760px;
    margin: 32px auto 40px;
    padding: 8px 0 0;
    background: var(--toc-bg);
    border-radius: 22px;
    border: 1px solid var(--toc-line);
    font-family: 'Golos Text', 'PT Sans', system-ui, sans-serif;
    color: var(--toc-ink);
    overflow: hidden;
    position: relative;
}

/* декоративная вертикальная полоса слева */
.ms-toc::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--toc-accent), transparent);
}

/* шапка-кнопка */
.ms-toc__toggle {
    all: unset;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 18px 24px 16px;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
}

.ms-toc__toggle:focus-visible {
    outline: 2px solid var(--toc-accent);
    outline-offset: -2px;
    border-radius: 22px;
}

.ms-toc__toggle-icon {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--toc-accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 14px -6px rgba(46,197,182,0.55);
}

.ms-toc__title {
    flex: 1;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.ms-toc__chevron {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(46,197,182,0.1);
    color: var(--toc-accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.35s cubic-bezier(.4,.0,.2,1), background 0.3s ease;
}

.ms-toc.is-collapsed .ms-toc__chevron {
    transform: rotate(-90deg);
}

/* прогресс-бар чтения статьи */
.ms-toc__progress {
    height: 3px;
    background: rgba(46,197,182,0.15);
    position: relative;
    overflow: hidden;
}

.ms-toc__progress-bar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--toc-accent), var(--toc-accent) 70%, #7fe0d4);
    transition: width 0.1s linear;
}

/* список */
.ms-toc__list {
    list-style: none;
    margin: 0 !important;
    padding: 14px 20px 20px 24px;
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.45s cubic-bezier(.4,.0,.2,1),
                padding 0.35s cubic-bezier(.4,.0,.2,1),
                opacity 0.25s ease;
    opacity: 1;
}

.ms-toc.is-collapsed .ms-toc__list {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.ms-toc__item {
    position: relative;
    line-height: 1.5;
}

.ms-toc__item + .ms-toc__item {
    margin-top: 6px;
}

.ms-toc__item--h3 {
    padding-left: 36px;
}

.ms-toc__item--h3 .ms-toc__num {
    display: none;
}

.ms-toc__item--h3::before {
    content: "";
    position: absolute;
    left: 18px;
    top: 13px;
    width: 10px;
    height: 1px;
    background: var(--toc-line);
}

.ms-toc__link {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 6px 10px 6px 8px;
    text-decoration: none;
    color: var(--toc-muted);
    border-radius: 10px;
    transition: color 0.2s ease, background 0.2s ease;
}

.ms-toc__link:hover {
    color: var(--toc-ink);
    background: var(--toc-accent-soft);
}

.ms-toc__num {
    flex: 0 0 auto;
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--toc-accent);
    letter-spacing: 0.03em;
    min-width: 22px;
}

.ms-toc__text {
    font-size: 15.5px;
    font-weight: 500;
}

/* активный пункт — подсвечивается при скролле */
.ms-toc__item.is-active > .ms-toc__link {
    color: var(--toc-ink);
    background: var(--toc-accent-soft);
}

.ms-toc__item.is-active > .ms-toc__link .ms-toc__num {
    color: var(--toc-accent);
}

.ms-toc__item.is-active > .ms-toc__link .ms-toc__text {
    font-weight: 600;
}

/* плавный скролл + отступ под липкий хедер */
html {
    scroll-behavior: smooth;
}

:where(h2, h3)[id] {
    scroll-margin-top: 90px; /* подгоните под высоту хедера */
}

/* адаптив */
@media (max-width: 640px) {
    .ms-toc {
        margin: 24px 12px 28px;
        border-radius: 18px;
    }
    .ms-toc__toggle { padding: 14px 18px; }
    .ms-toc__title { font-size: 17px; }
    .ms-toc__list { padding: 10px 16px 16px 18px; }
    .ms-toc__text { font-size: 14.5px; }
    .ms-toc__item--h3 { padding-left: 30px; }
    .ms-toc__item--h3::before { left: 14px; }
}

/* уважение к prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .ms-toc__chevron,
    .ms-toc__list,
    .ms-toc__link,
    .ms-toc__progress-bar { transition: none; }
}
/* убираем дефолтные маркеры ol */
.ms-toc__list {
    list-style: none !important;
}
.ms-toc__list li::marker {
    content: none !important;
}
.ms-toc__item {
    list-style: none !important;
}

/* Стили таблицы */
.blog-article table {
    width: 100%;
    border-collapse: collapse;
    margin: 25px 0;
    font-size: 15px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.blog-article table thead {
    background: linear-gradient(135deg, #2dd4bf 0%, #14b8a6 100%);
    color: #fff;
}

.blog-article table thead th {
    padding: 14px 18px;
    text-align: left;
    font-weight: 600;
    font-size: 15px;
    border: none;
}

.blog-article table tbody tr {
    border-bottom: 1px solid #e8f4f2;
    transition: background 0.2s ease;
}

.blog-article table tbody tr:last-child {
    border-bottom: none;
}

.blog-article table tbody tr:nth-child(even) {
    background: #f7fbfa;
}

.blog-article table tbody tr:hover {
    background: #ecf8f6;
}

.blog-article table tbody td {
    padding: 14px 18px;
    vertical-align: top;
    color: #333;
    line-height: 1.5;
    border: none;
}

.blog-article table tbody td:first-child {
    font-weight: 600;
    color: #0d9488;
    white-space: nowrap;
}

/* Прокрутка по горизонтали на мобильных */
@media (max-width: 768px) {
    .blog-article table {
        font-size: 14px;
    }
    .blog-article table thead th,
    .blog-article table tbody td {
        padding: 10px 12px;
    }
}

.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 25px 0;
}

.table-scroll table {
    margin: 0;
    min-width: 600px; /* минимальная ширина, ниже которой включится скролл */
}

/* красивый скроллбар */
.table-scroll::-webkit-scrollbar {
    height: 6px;
}
.table-scroll::-webkit-scrollbar-thumb {
    background: #2dd4bf;
    border-radius: 3px;
}
.table-scroll::-webkit-scrollbar-track {
    background: #f0f0f0;
}
