/*
 * Дизайн-подпись «Гид Электрика» (elektrik-gid.ru)
 * Высокоточная типографика, инженерные акценты, электробезопасность.
 */

:root {
    --gap: 1.5rem;
    --block: 3.5rem;
    --site-signature: "elektrik-gid";
    --radius: 8px;
    --radius-lg: 12px;
    --radius-sm: 6px;
    --btn-radius: 8px;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Логотип и шапка */
.wordmark {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--ink);
}

.wordmark-text {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0F172A;
}

.wordmark-logo {
    height: 36px;
    width: auto;
}

.brand-mark {
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.2));
}

.topbar {
    background: #0F172A;
    color: #CBD5E1;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 0;
    border-bottom: 1px solid #1E293B;
}

.topbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-header {
    border-bottom: 1px solid #E2E8F0;
    background: #FFFFFF;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

/* Полоса быстрых рубрик */
.ruler {
    background: #FFFFFF;
    border-bottom: 1px solid #E2E8F0;
    padding: 6px 0;
}

.ruler-track a {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    padding: 6px 14px;
    border-radius: 9999px;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.ruler-track a:hover,
.ruler-track a[aria-current="page"] {
    background: #EFF6FF;
    color: #2563EB;
}

/* Кнопки */
.btn-primary {
    background: #2563EB;
    color: #FFFFFF;
    font-weight: 700;
    border-radius: 8px;
    padding: 10px 20px;
    transition: background 0.15s ease, transform 0.15s ease;
}

.btn-primary:hover {
    background: #1D4ED8;
    transform: translateY(-1px);
}

/* Блоки статьи */
.toc {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-left: 4px solid #2563EB;
    border-radius: 8px;
    padding: 20px 24px;
    margin: 28px 0;
}

.toc-title {
    font-size: 16px;
    font-weight: 700;
    color: #0F172A;
    margin-bottom: 12px;
}

.key-points-box {
    background: #FEF3C7;
    border: 1px solid #FCD34D;
    border-left: 5px solid #F59E0B;
    border-radius: 8px;
    padding: 20px 24px;
    margin: 28px 0;
}

.key-points-title {
    font-size: 16px;
    font-weight: 800;
    color: #92400E;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bio-card {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    padding: 20px 24px;
    margin: 36px 0;
}

/* Подвал */
.site-base {
    background: #0B132B;
    color: #94A3B8;
    padding: 56px 0 32px;
    border-top: 3px solid #2563EB;
}

.site-base a {
    color: #CBD5E1;
    text-decoration: none;
    transition: color 0.15s;
}

.site-base a:hover {
    color: #FBBF24;
}

.base-cap {
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.base-line {
    border-top: 1px solid #1E293B;
    padding-top: 24px;
    margin-top: 40px;
    font-size: 13px;
    color: #64748B;
}

/* =============================================
   ТАБЛИЦЫ: ИНЖЕНЕРНЫЕ СТАНДАРТЫ И СКРОЛЛ
   ============================================= */
.table-wrap {
    position: relative;
    margin: 32px 0;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.05);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #94A3B8 #F1F5F9;
}

.article-body table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--font-sans, "Inter", sans-serif);
    font-size: 14.5px;
    line-height: 1.55;
    text-align: left;
    margin: 0;
}

.article-body table:not(.table-stack) {
    min-width: 680px;
}

/* Шапка таблицы */
.article-body th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #0F172A;
    color: #FFFFFF;
    font-family: var(--font-serif, "Manrope", sans-serif);
    font-size: 12.5px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 14px 18px;
    border: 0;
    border-bottom: 3px solid #2563EB;
    white-space: nowrap;
}

/* Фиксированная первая колонка (ПАРАМЕТР) для широких таблиц */
.article-body table:not(.table-stack) th:first-child,
.article-body table:not(.table-stack) td:first-child {
    position: sticky;
    left: 0;
    z-index: 4;
    min-width: 190px;
    max-width: 240px;
    font-weight: 700;
    color: #0F172A;
    border-right: 2px solid #CBD5E1;
    box-shadow: 4px 0 10px -2px rgba(15, 23, 42, 0.08);
}

.article-body table:not(.table-stack) th:first-child {
    z-index: 10;
    background: #0B132B;
    color: #FFFFFF;
    border-right: 2px solid #1E293B;
}

.article-body table:not(.table-stack) td:first-child {
    background: #F8FAFC;
    color: #0F172A;
}

.article-body table:not(.table-stack) td:first-child strong {
    color: inherit;
    font-weight: inherit;
}

.article-body table:not(.table-stack) tbody tr:nth-child(even) td:first-child {
    background: #F1F5F9;
}

.article-body table:not(.table-stack) tbody tr:hover td:first-child {
    background: #EFF6FF !important;
    color: #1D4ED8;
}

/* Обычные ячейки данных */
.article-body td {
    padding: 13px 18px;
    border: 0;
    border-bottom: 1px solid #E2E8F0;
    color: #334155;
    vertical-align: middle;
    background: #FFFFFF;
    transition: background-color 0.15s ease;
}

.article-body tbody tr:nth-child(even) td {
    background: #F8FAFC;
}

.article-body tbody tr:hover td {
    background: #EFF6FF !important;
}

.article-body tbody tr:last-child td {
    border-bottom: 0;
}

/* Стилизация скроллбара таблицы */
.table-wrap::-webkit-scrollbar {
    height: 8px;
}
.table-wrap::-webkit-scrollbar-track {
    background: #F1F5F9;
    border-radius: 0 0 12px 12px;
}
.table-wrap::-webkit-scrollbar-thumb {
    background: #94A3B8;
    border-radius: 4px;
    border: 2px solid #F1F5F9;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
    background: #64748B;
}

/* Карточный режим для узких таблиц (до 4 колонок) на мобильных */
@media (max-width: 639px) {
    .table-wrap:has(.table-stack) {
        overflow: visible;
        border: 0;
        background: none;
        box-shadow: none;
        margin: 20px 0;
    }
    .table-stack tr {
        margin-bottom: 14px;
        padding: 12px 16px;
        background: #FFFFFF;
        border: 1px solid #E2E8F0;
        border-radius: 10px;
        box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    }
    .article-body .table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 14px;
        padding: 9px 0;
        border: 0;
        border-top: 1px solid #F1F5F9;
        text-align: right;
        background: transparent !important;
        box-shadow: none !important;
        position: static !important;
        min-width: 0 !important;
        max-width: none !important;
    }
    .article-body .table-stack td:first-child {
        border-top: 0;
        color: #0F172A;
        font-weight: 800;
    }
    .table-stack td::before {
        content: attr(data-label);
        flex: 0 0 45%;
        font-weight: 700;
        color: #64748B;
        text-align: left;
        font-size: 13px;
    }
}

/* =============================================
   ПЛАВАЮЩИЙ ТОСТ: «ЧИТАЙТЕ ДАЛЬШЕ»
   ============================================= */
#next-article-toast {
    position: fixed !important;
    left: auto !important;
    right: max(24px, calc((100vw - var(--container, 1240px)) / 2 + 24px)) !important;
    bottom: 84px !important;
    z-index: 85 !important;
    max-width: 340px !important;
    background: #FFFFFF !important;
    border: 1px solid #CBD5E1 !important;
    border-left: 5px solid #F59E0B !important;
    border-radius: 12px !important;
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.06) !important;
    padding: 16px 42px 16px 18px !important;
    transform: translateY(140%) !important;
    visibility: hidden !important;
    transition: transform .35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear .35s !important;
}

#next-article-toast.toast-visible {
    transform: none !important;
    visibility: visible !important;
    transition: transform .35s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

#toast-close-btn {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    width: 28px !important;
    height: 28px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #64748B !important;
    border-radius: 6px !important;
    border: 0 !important;
    background: transparent !important;
    cursor: pointer !important;
    padding: 0 !important;
}
#toast-close-btn:hover {
    background: #F1F5F9 !important;
    color: #0F172A !important;
}

.toast-label {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin-bottom: 6px !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    letter-spacing: 0.08em !important;
    text-transform: uppercase !important;
    color: #D97706 !important;
    font-family: var(--font-serif, "Manrope", sans-serif) !important;
}
.toast-label::before {
    content: "⚡" !important;
    font-size: 12px !important;
}

.toast-title {
    font-size: 15px !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    color: #0F172A !important;
    text-decoration: none !important;
    display: block !important;
    font-family: var(--font-serif, "Manrope", sans-serif) !important;
}
.toast-title:hover {
    color: #2563EB !important;
    text-decoration: underline !important;
}

#back-to-top-btn {
    position: fixed !important;
    right: max(24px, calc((100vw - var(--container, 1240px)) / 2 + 24px)) !important;
    bottom: 24px !important;
    z-index: 80 !important;
    width: 44px !important;
    height: 44px !important;
    background: #0F172A !important;
    color: #FFFFFF !important;
    border: 1px solid #334155 !important;
    border-radius: 10px !important;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: background-color 0.15s ease, transform 0.15s ease, opacity 0.2s !important;
}
#back-to-top-btn:hover {
    background: #2563EB !important;
    border-color: #2563EB !important;
    transform: translateY(-2px) !important;
}

@media (max-width: 639px) {
    #next-article-toast {
        left: 12px !important;
        right: 12px !important;
        bottom: 12px !important;
        max-width: none !important;
    }
    #back-to-top-btn {
        right: 16px !important;
        bottom: 96px !important;
    }
}

/* =============================================
   МОБИЛЬНАЯ ШАПКА: ПОЛНОЕ НАЗВАНИЕ И ЧИСТАЯ НАВИГАЦИЯ
   ============================================= */

/* Логотип: без обрезки и сжатия на любых экранах */
.site-header-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 12px !important;
}

.wordmark {
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    text-decoration: none !important;
    color: var(--ink) !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

.wordmark-text {
    font-family: var(--font-serif, "Manrope", sans-serif) !important;
    font-size: 21px !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
    color: #0F172A !important;
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.1 !important;
}

.wordmark .brand-mark {
    flex-shrink: 0 !important;
    width: 34px !important;
    height: 34px !important;
    filter: drop-shadow(0 2px 4px rgba(37, 99, 235, 0.2)) !important;
}

.header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    margin-left: auto !important;
    flex-shrink: 0 !important;
}

.header-actions .icon-btn {
    width: 38px !important;
    height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
}

/* На экранах планшетов и мобильных (<1024px) */
@media (max-width: 1023px) {
    /* Убираем дублирование меню: скрываем горизонтальную полосу рубрик под шапкой */
    .ruler {
        display: none !important;
    }
}

/* На смартфонах (<640px) */
@media (max-width: 639px) {
    .site-header-row {
        gap: 8px !important;
    }
    .wordmark {
        gap: 8px !important;
    }
    .wordmark-text {
        font-size: 19px !important;
    }
    .wordmark .brand-mark {
        width: 30px !important;
        height: 30px !important;
    }
    .header-actions {
        gap: 2px !important;
    }
    .header-actions .icon-btn {
        width: 36px !important;
        height: 36px !important;
    }
    /* Скрываем кнопку «поделиться» в шапке на мобильных, чтобы не загромождать строку */
    .header-actions .js-share-btn {
        display: none !important;
    }
    .topbar {
        padding: 5px 0 !important;
        font-size: 11.5px !important;
        line-height: 1.35 !important;
        text-align: center !important;
    }
}

/* На узких смартфонах (<380px, например iPhone SE) */
@media (max-width: 380px) {
    .wordmark-text {
        font-size: 17.5px !important;
    }
    .wordmark {
        gap: 6px !important;
    }
    .wordmark .brand-mark {
        width: 26px !important;
        height: 26px !important;
    }
}

/* На ультра-узких (<330px) */
@media (max-width: 330px) {
    .wordmark-text {
        font-size: 16px !important;
    }
}
