/* =============================================
   BLOG.CSS — стили статей блога
   ============================================= */

/* Глобальный фикс box-sizing для всех элементов страницы */
*, *::before, *::after {
    box-sizing: border-box;
}

/* Запрещаем горизонтальный скролл всей страницы */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* =============================================
   HEADER FIX — на страницах блога хедер всегда
   с фоном (нет hero-секции под ним)
   ============================================= */

/* Страницы блога: хедер сразу scrolled-состояние */
.article-page-wrapper .header::before,
body:not([class*="index"]) .header::before {
    background: rgba(240, 244, 248, 0.98) !important;
    border-bottom-color: rgba(59, 110, 165, 0.12) !important;
    backdrop-filter: blur(20px) !important;
}

.article-page-wrapper .header__logo,
.article-page-wrapper .header__nav-link,
.article-page-wrapper .header__phone {
    color: var(--clr-text, #1a1a2e) !important;
}

/* Принудительно светлый хедер на блог-страницах */
.blog-page .header {
    background: rgba(240, 244, 248, 0.98);
    border-bottom: 1px solid rgba(59, 110, 165, 0.12);
    backdrop-filter: blur(20px);
}

.blog-page .header:not(.scrolled) .header__logo,
.blog-page .header:not(.scrolled) .header__nav-link,
.blog-page .header:not(.scrolled) .header__phone {
    color: var(--clr-text, #1a1a2e) !important;
}

.blog-page .header:not(.scrolled) .burger span {
    background: var(--clr-text, #1a1a2e) !important;
}

.blog-page .header:not(.scrolled) .header__icon-call {
    color: #3b6ea5 !important;
}

.blog-page .header:not(.scrolled) .header__icon-whatsapp {
    color: #25D366 !important;
}

/* =============================================
   MOBILE HEADER — мобильное меню
   (копирует механику из основного styles.css,
   но с высоким специфичностью для blog-page)
   ============================================= */

@media (max-width: 900px) {
    .header__nav {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(15, 25, 45, 0.97);
        backdrop-filter: blur(16px);
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
        z-index: 900;
    }

    .header__nav.open {
        opacity: 1;
        pointer-events: all;
    }

    .header__nav-list {
        flex-direction: column;
        gap: 8px;
        text-align: center;
        padding: 0;
    }

    .header__nav-item--dropdown {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .header__nav-dropdown {
        position: static !important;
        display: flex !important;
        flex-direction: column;
        background: rgba(255,255,255,0.06);
        border-radius: 10px;
        padding: 4px 0;
        margin-top: 4px;
        min-width: 180px;
        box-shadow: none;
    }

    .header__nav-dropdown li a {
        color: rgba(255,255,255,0.75) !important;
        font-size: 15px;
        padding: 10px 24px;
        text-align: center;
    }

    .header__nav-dropdown li a:hover {
        color: #fff !important;
        background: rgba(255,255,255,0.08);
    }

    .header__nav-link {
        font-size: 20px !important;
        font-weight: 600 !important;
        color: rgba(255,255,255,0.9) !important;
        padding: 12px 24px;
        border-radius: 12px;
        display: block;
    }

    .header__nav-link:hover {
        color: #fff !important;
        background: rgba(255,255,255,0.08) !important;
    }

    .header__nav.open .header__nav-link,
    .header__nav.open .header__nav-link:hover {
        color: rgba(255,255,255,0.9) !important;
    }

    .burger {
        display: flex !important;
        z-index: 1001;
        position: relative;
    }

    .header__phone {
        display: none !important;
    }

    .header__icon-call,
    .header__icon-whatsapp {
        display: flex !important;
    }

    .header__actions .btn--primary {
        display: none !important;
    }

    /* Burger поверх оверлея */
    .burger {
        position: relative;
        z-index: 1001;
    }

    .burger.active span {
        background: #ffffff !important;
    }
}

/* =============================================
   Article page layout
   ============================================= */
.article-page {
    padding: 40px 0 80px;
    background: var(--clr-bg, #f8f9fb);
}

.article__breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #888;
    margin-bottom: 32px;
    flex-wrap: wrap;
}

.article__breadcrumb a {
    color: #3b6ea5;
    text-decoration: none;
}

.article__breadcrumb a:hover {
    text-decoration: underline;
}

/* Layout: article + sidebar */
.article__layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 32px;
    align-items: start;
    /* Запрещаем grid-детям вылезать за контейнер */
    min-width: 0;
}

.article__layout > * {
    min-width: 0;
}

@media (max-width: 1024px) {
    .article__layout {
        grid-template-columns: 1fr;
    }
    .article__sidebar {
        order: 2;
    }
}

/* Article content */
.article__content {
    background: #fff;
    border-radius: 16px;
    padding: 48px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
    /* Текст не вылезает за карточку */
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
}

@media (max-width: 900px) {
    .article__content {
        padding: 32px 24px;
    }
}

@media (max-width: 600px) {
    .article__content {
        padding: 20px 14px 28px;
        border-radius: 10px;
    }
}

.article__header {
    margin-bottom: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid #eee;
}

.article__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.article__category {
    background: rgba(59, 110, 165, 0.12);
    color: #3b6ea5;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.article__date, .article__read {
    font-size: 13px;
    color: #999;
}

.article__read::before {
    content: '· ';
}

.article__title {
    font-size: clamp(24px, 3.5vw, 36px);
    font-weight: 700;
    line-height: 1.3;
    color: #1a1a2e;
    margin-bottom: 16px;
}

.article__lead {
    font-size: 17px;
    line-height: 1.7;
    color: #555;
    border-left: 3px solid #3b6ea5;
    padding-left: 16px;
}

/* Article body */
.article__body {
    /* Все дочерние элементы не вылезают за ширину */
    overflow-wrap: break-word;
    word-break: break-word;
}

.article__body h2 {
    font-size: clamp(17px, 2.5vw, 22px);
    font-weight: 700;
    color: #1a1a2e;
    margin: 40px 0 16px;
    padding-top: 8px;
    line-height: 1.35;
}

.article__body h2:first-child {
    margin-top: 0;
}

.article__body p {
    font-size: 16px;
    line-height: 1.8;
    color: #444;
    margin-bottom: 16px;
    max-width: 100%;
}

.article__body ul, .article__body ol {
    padding-left: 20px;
    margin-bottom: 20px;
}

.article__body li {
    font-size: 16px;
    line-height: 1.8;
    color: #444;
    margin-bottom: 8px;
}

.article__body strong {
    color: #222;
}

/* Изображения в теле статьи */
.article__body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

/* Callouts */
.article__callout {
    border-radius: 10px;
    padding: 16px 20px;
    margin: 24px 0;
    font-size: 15px;
    line-height: 1.7;
}

.article__callout--info {
    background: rgba(59, 110, 165, 0.08);
    border-left: 4px solid #3b6ea5;
    color: #2a4a73;
}

.article__callout--warning {
    background: rgba(255, 160, 0, 0.1);
    border-left: 4px solid #f59e0b;
    color: #7a5200;
}

.article__callout--tip {
    background: rgba(16, 185, 129, 0.08);
    border-left: 4px solid #10b981;
    color: #065f46;
}

/* Article figures / photos */
.article__figure {
    margin: 24px auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,.08);
    max-width: 600px;
}

.article__figure img {
    width: 100%;
    height: 340px;
    object-fit: cover;
    object-position: center;
    display: block;
}

.article__figure figcaption {
    font-size: 13px;
    color: #888;
    padding: 10px 16px 12px;
    background: #f8f9fb;
    line-height: 1.55;
    border-top: 1px solid #eef0f4;
}

/* Tables */
.article__table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 24px 0;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    /* Таблица не вылезает за card */
    max-width: 100%;
}

.article__table {
    width: 100%;
    min-width: 400px; /* минимальная ширина, дальше скролл */
    border-collapse: collapse;
    font-size: 14px;
}

.article__table th {
    background: #f3f6fb;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: #3b4a6b;
    border-bottom: 2px solid #e5e7eb;
    /* white-space: nowrap убран — позволяем перенос */
    white-space: normal;
    word-break: normal;
}

.article__table td {
    padding: 10px 14px;
    color: #444;
    border-bottom: 1px solid #f0f2f5;
    vertical-align: top;
    font-size: 13px;
    line-height: 1.5;
}

.article__table tr:last-child td {
    border-bottom: none;
}

.article__table tr:hover td {
    background: #f8fafc;
}

@media (max-width: 600px) {
    .article__table-wrap {
        margin: 16px -14px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* Mistake headers */
.article__mistake {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-top: 40px;
}

.article__mistake-num {
    font-size: 42px;
    font-weight: 800;
    color: rgba(59, 110, 165, 0.15);
    line-height: 1;
    flex-shrink: 0;
}

.article__mistake h2 {
    margin: 0 !important;
    padding-top: 0 !important;
}

/* Footer */
.article__footer {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid #eee;
}

.article__author {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 32px;
}

.article__author-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b6ea5, #6c5ce7);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.article__author div:last-child {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.article__author strong {
    font-size: 15px;
    color: #1a1a2e;
}

.article__author span {
    font-size: 13px;
    color: #888;
}

.article__related {
    margin-bottom: 8px;
}

.article__related h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    margin-bottom: 12px;
}

.article__related a {
    display: block;
    font-size: 14px;
    color: #3b6ea5;
    text-decoration: none;
    margin-bottom: 8px;
    transition: color 0.2s;
}

.article__related a:hover {
    color: #2a5490;
    text-decoration: underline;
}

/* =============================================
   SIDEBAR
   ============================================= */
.article__sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 100px;
}

.article__toc,
.article__cta-box,
.article__links-box {
    background: #fff;
    border-radius: 14px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.article__toc h4,
.article__cta-box h4,
.article__links-box h4 {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a2e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
}

.article__toc ul,
.article__links-box ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.article__toc ul a,
.article__links-box ul a {
    font-size: 14px;
    color: #555;
    text-decoration: none;
    line-height: 1.5;
    transition: color 0.2s;
}

.article__toc ul a:hover,
.article__links-box ul a:hover {
    color: #3b6ea5;
}

.article__cta-box p {
    font-size: 14px;
    color: #666;
    margin-bottom: 16px;
    line-height: 1.6;
}

/* =============================================
   MOBILE ADAPTATION — статьи блога
   ============================================= */

/* Tablet */
@media (max-width: 1024px) {
    .article__sidebar {
        order: 2;
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        position: static;
    }

    .article__toc {
        grid-column: 1 / -1;
    }
}

/* Mobile ≤768px */
@media (max-width: 768px) {
    .article-page {
        padding: 20px 0 48px;
    }

    .article__breadcrumb {
        font-size: 12px;
        margin-bottom: 16px;
        gap: 6px;
    }

    .article__header {
        margin-bottom: 20px;
        padding-bottom: 16px;
    }

    .article__title {
        font-size: clamp(18px, 5vw, 24px);
        line-height: 1.35;
        margin-bottom: 10px;
    }

    .article__lead {
        font-size: 15px;
        line-height: 1.65;
    }

    .article__meta {
        gap: 6px;
        margin-bottom: 10px;
    }

    .article__body h2 {
        font-size: clamp(16px, 4.5vw, 20px);
        margin: 24px 0 10px;
    }

    .article__body p,
    .article__body li {
        font-size: 15px;
        line-height: 1.75;
    }

    .article__body ul,
    .article__body ol {
        padding-left: 16px;
    }

    .article__callout {
        padding: 12px 14px;
        font-size: 14px;
        margin: 14px 0;
        border-radius: 8px;
    }

    /* Таблица: НЕ white-space:nowrap, разрешаем перенос */
    .article__table th,
    .article__table td {
        padding: 8px 10px;
        font-size: 13px;
        white-space: normal;
        word-break: break-word;
    }

    .article__mistake {
        gap: 8px;
        margin-top: 24px;
        align-items: flex-start;
    }

    .article__mistake-num {
        font-size: 24px;
        line-height: 1.4;
    }

    .article__footer {
        margin-top: 28px;
        padding-top: 20px;
    }

    .article__author {
        gap: 10px;
        flex-wrap: wrap;
    }

    .article__sidebar {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .article__toc {
        grid-column: auto;
    }

    .article__toc,
    .article__cta-box,
    .article__links-box {
        padding: 14px 16px;
        border-radius: 10px;
    }
}

/* Маленький телефон ≤420px */
@media (max-width: 420px) {
    .article__title {
        font-size: 18px;
    }

    .article__body h2 {
        font-size: 16px;
    }

    .article__body p,
    .article__body li {
        font-size: 14px;
    }

    .article__callout {
        font-size: 13px;
        padding: 10px 12px;
    }

    .article__mistake-num {
        font-size: 20px;
    }
}

/* =============================================
   ARTICLE PAGE — отступ под фиксированный хедер
   ============================================= */
.article-page {
    margin-top: 80px;
}

@media (max-width: 900px) {
    .article-page {
        margin-top: 70px;
    }
}
