/* ============================================================
   article.css — «хром» сторінки статті (лейаут, мета, зміст,
   сайдбар, шеринг, схожі, прогрес, кнопка «вгору»).
   Типографіка тіла статті — окремо в article-content.css.
   ============================================================ */

/* ---------- Прогрес читання ---------- */
.read-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px; width: 0;
    background: var(--accent, #00c3ff);
    z-index: 1200;
    transition: width .08s linear;
}

/* ---------- Лейаут: контент + сайдбар ---------- */
.article-layout {
    width: min(1280px, 92%);
    margin: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 48px;
    padding: 40px 0 60px;
    align-items: start;
}
.article { min-width: 0; }   /* дозволяє довгому контенту стискатись */

/* ---------- Шапка статті ---------- */
.article-head { margin-bottom: 8px; }
.article-head h1 {
    margin: 12px 0 14px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.15;
    color: var(--dark, #0b0c10);
}
.article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    color: var(--muted, #5b6b7d);
    font-size: 14px;
}
.article-meta .article-author {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--dark, #0b0c10);
}
.article-meta .article-author img { border-radius: 50%; }
.article-meta .cat-badge {
    padding: 3px 11px;
    border-radius: 20px;
    background: rgba(0, 195, 255, .12);
    color: var(--accent-dark, #0092c4);
    font-weight: 700;
    font-size: 13px;
}
.article-meta .upd { color: var(--accent-dark, #0092c4); font-weight: 600; }

.article-lead {
    margin: 20px 0 0;
    font-size: 1.15em;
    line-height: 1.65;
    color: #33414f;
}

/* ============================================================
   Зміст (TOC) — sticky у правому сайдбарі.
   Стани пунктів керуються з article.js:
     .is-passed  — розділ уже прочитано
     .is-active  — поточний розділ
     (без класу)  — наступні розділи
   Вертикальна доріжка (--toc-progress, px) тягнеться до точки читання.
   ============================================================ */
.toc[hidden] { display: none; }

.toc__title {
    margin: 0 0 14px;
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted, #5b6b7d);
}

.toc__list {
    list-style: none;
    margin: 0;
    padding: 2px 0;
    position: relative;
    max-height: min(64vh, 540px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scroll-behavior: smooth;
}
.toc__list::-webkit-scrollbar { width: 6px; }
.toc__list::-webkit-scrollbar-thumb { background: #d6dee8; border-radius: 3px; }

/* Доріжка (сірий трек) — уся висота контенту списку */
.toc__list::before {
    content: "";
    position: absolute;
    left: 4px; top: 0; bottom: 0;
    width: 2px;
    background: #e6ecf3;
    border-radius: 2px;
}
/* Заповнення = дочитано до цієї точки */
.toc__list::after {
    content: "";
    position: absolute;
    left: 4px; top: 0;
    width: 2px;
    height: var(--toc-progress, 0px);
    background: linear-gradient(180deg, var(--accent-dark, #0092c4), var(--accent, #00c3ff));
    border-radius: 2px;
    transition: height .18s ease;
}

.toc__list li { margin: 0; }
.toc__list a {
    position: relative;
    display: block;
    padding: 7px 6px 7px 20px;
    color: #5b6b7d;
    text-decoration: none;
    line-height: 1.4;
    font-size: 14px;
    border-radius: 6px;
    transition: color .15s, background .15s;
}
/* Вузол на доріжці */
.toc__list a::before {
    content: "";
    position: absolute;
    left: 0; top: 50%;
    width: 9px; height: 9px;
    margin-top: -4.5px;
    box-sizing: border-box;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #cfd8e3;
    transition: background .15s, border-color .15s, box-shadow .15s;
    z-index: 1;
}

/* H3 — текст глибше, вузол трохи менший, але лишається на спільній осі */
.toc__list li.toc__h3 a { padding-left: 34px; font-size: 13px; color: #7a8593; }
.toc__list li.toc__h3 a::before { left: 1px; width: 7px; height: 7px; margin-top: -3.5px; }

.toc__list a:hover { color: var(--accent-dark, #0092c4); background: rgba(0, 195, 255, .06); }

/* Пройдені розділи */
.toc__list li.is-passed a { color: #8b96a2; }
.toc__list li.is-passed a::before { background: var(--accent, #00c3ff); border-color: var(--accent, #00c3ff); }

/* Поточний розділ */
.toc__list li.is-active a {
    color: var(--accent-dark, #0092c4);
    font-weight: 700;
    background: rgba(0, 195, 255, .08);
}
.toc__list li.is-active a::before {
    background: var(--accent, #00c3ff);
    border-color: var(--accent-dark, #0092c4);
    box-shadow: 0 0 0 4px rgba(0, 195, 255, .18);
}

/* ---------- Шеринг ---------- */
.article-share {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 34px 0;
    padding-top: 22px;
    border-top: 1px solid #e6ebf2;
}
.article-share span { font-weight: 700; color: var(--dark, #0b0c10); margin-right: 4px; }
.article-share a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px; height: 42px;
    border-radius: 50%;
    background: #f0f4f8;
    color: var(--dark, #0b0c10);
    text-decoration: none;
    transition: transform .2s, background .2s, color .2s;
}
.article-share a:hover {
    transform: translateY(-3px);
    background: var(--accent, #00c3ff);
    color: #fff;
}
.article-share svg { width: 18px; height: 18px; fill: currentColor; }

/* ---------- CTA-форма після статті ---------- */
.article-cta {
    margin: 40px 0;
    padding: 34px 30px;
    background: #f5f8fb;
    border: 1px solid #e6ebf2;
    border-radius: var(--radius, 14px);
}
.article-cta .section-heading { margin-bottom: 22px; text-align: center; }
.article-cta .section-heading span {
    font-weight: 700; color: var(--accent-dark, #0092c4);
    letter-spacing: .12em; font-size: 14px;
}
.article-cta .section-heading h2 { margin: 12px 0 0; font-size: clamp(24px, 3vw, 32px); }

/* ---------- Prev / Next ---------- */
.article-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 40px 0 0;
}
.article-nav a {
    display: block;
    padding: 18px 20px;
    background: #fff;
    border: 1px solid #eef1f6;
    border-radius: var(--radius, 14px);
    text-decoration: none;
    box-shadow: var(--shadow, 0 5px 20px rgba(0, 0, 0, .06));
    transition: transform .25s, box-shadow .25s;
}
.article-nav a:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover, 0 12px 34px rgba(0, 0, 0, .12)); }
.article-nav small { color: var(--muted, #5b6b7d); font-weight: 700; }
.article-nav strong { display: block; margin-top: 6px; color: var(--dark, #0b0c10); line-height: 1.35; }
.article-nav .next { text-align: right; }

/* ---------- Сайдбар ---------- */
/* Sticky вішаємо на САМ grid-елемент — тоді він липне в межах усієї
   висоти рядка гріда (а не куцого батька). align-self:start обов'язково. */
.article-aside {
    min-width: 0;
    position: sticky;
    top: calc(var(--header-height, 72px) + 20px);
    align-self: start;
    max-height: calc(100vh - var(--header-height, 72px) - 40px);
    overflow: hidden auto;      /* якщо сайдбар вищий за екран — скролиться сам */
}
/* Обгортка тепер просто вертикальний стек, без sticky */
.aside-sticky {
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.aside-card {
    background: #fff;
    border: 1px solid #eef1f6;
    border-radius: var(--radius, 14px);
    box-shadow: var(--shadow, 0 5px 20px rgba(0, 0, 0, .06));
    padding: 20px;
}
.aside-card h3 {
    margin: 0 0 14px;
    font-size: 16px;
    color: var(--dark, #0b0c10);
}
.aside-services { list-style: none; margin: 0; padding: 0; }
.aside-services li { margin: 0 0 10px; }
.aside-services a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--dark, #0b0c10);
    font-weight: 600;
    font-size: 14px;
    transition: background .15s, color .15s;
}
.aside-services a:hover { background: rgba(0, 195, 255, .08); color: var(--accent-dark, #0092c4); }
.aside-cta {
    background: var(--dark, #0b0c10);
    color: #fff;
    text-align: center;
}
.aside-cta h3 { color: #fff; }
.aside-cta p { margin: 0 0 16px; color: #cbd5e1; font-size: 14px; }
.aside-cta .btn {
    display: inline-flex;
    padding: 13px 24px;
    background: var(--accent, #00c3ff);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    border-radius: 12px;
    transition: transform .25s;
}
.aside-cta .btn:hover { transform: translateY(-3px); }

/* ---------- Схожі статті (карусель) ---------- */
.related { width: min(1280px, 92%); margin: 0 auto 60px; }
.related h2 { font-size: clamp(22px, 3vw, 30px); margin: 0 0 20px; color: var(--dark, #0b0c10); }
.carousel-wrapper { position: relative; }
.carousel {
    display: flex;
    gap: 18px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 6px 2px 14px;
    scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel-item {
    flex: 0 0 260px;
    background: #fff;
    border: 1px solid #eef1f6;
    border-radius: var(--radius, 14px);
    overflow: hidden;
    text-decoration: none;
    color: var(--dark, #0b0c10);
    box-shadow: var(--shadow, 0 5px 20px rgba(0, 0, 0, .06));
    transition: transform .25s, box-shadow .25s;
}
.carousel-item:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover, 0 12px 34px rgba(0, 0, 0, .12)); }
.carousel-item img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.carousel-item .tile-title { padding: 12px 14px; font-size: 14px; font-weight: 700; line-height: 1.35; }
.carousel-btn {
    position: absolute;
    top: 40%;
    transform: translateY(-50%);
    width: 44px; height: 44px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .15);
    cursor: pointer;
    font-size: 16px;
    color: var(--dark, #0b0c10);
    z-index: 2;
    transition: transform .2s, background .2s, color .2s;
}
.carousel-btn:hover { background: var(--accent, #00c3ff); color: #fff; }
.carousel-btn.left { left: -8px; }
.carousel-btn.right { right: -8px; }

/* ---------- Кнопка «вгору» ---------- */
.to-top {
    position: fixed;
    right: 20px; bottom: 20px;
    width: 48px; height: 48px;
    border: 0;
    border-radius: 50%;
    background: var(--dark, #0b0c10);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s, background .2s;
    z-index: 1100;
}
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { background: var(--accent, #00c3ff); transform: translateY(-3px); }

/* ---------- Адаптив ---------- */
@media (max-width: 980px) {
    .article-layout { grid-template-columns: 1fr; gap: 0; padding-top: 28px; }
    .article-aside { display: none; }
}
@media (max-width: 560px) {
    .article-nav { grid-template-columns: 1fr; }
    .carousel-btn { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    .read-progress, .to-top, .carousel, .toc__list, .toc__list::after { transition: none; scroll-behavior: auto; }
}