/* --- 1. Базовые настройки и типографика --- */

@font-face {
    font-family: "IC Open Sans Condensed";
    src: url("/assets/fonts/open-sans-condensed-v12-cyrillic-300.woff2") format("woff2"),
         url("/assets/fonts/open-sans-condensed-v12-cyrillic-300.woff") format("woff"),
         url("/assets/fonts/open-sans-condensed-v12-cyrillic-300.ttf") format("truetype"),
         url("/assets/fonts/open-sans-condensed-v12-cyrillic-300.svg#OpenSansCondensed") format("svg");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-color: #f5f5f7;
    --text-color: #333333;
    --accent-color: #1f3350;
    --link-color: #c62828;
    --sidebar-width: 260px;
    --header-height: 60px;
    --nav-track-color: #e2e2e6;

    /* шрифт заголовков */
    --heading-font: "IC Open Sans Condensed", "Helvetica Neue", Arial, system-ui, sans-serif;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Georgia", "Times New Roman", serif;
    line-height: 1.7;
    color: var(--text-color);
    background-color: var(--bg-color);
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
}

/* --- 2. Глобальная навигация (header) --- */
.global-header {
    background-color: #111827;
    color: #ffffff;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5%;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-sizing: border-box;
    font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
}

.logo {
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

/* Верхнее меню (desktop по умолчанию) */
.top-nav {
    display: flex;
    align-items: center;
    gap: 18px;
}

.top-nav a {
    color: #d4d4dd;
    text-decoration: none;
    font-size: 0.86rem;
    transition: color 0.2s ease;
    letter-spacing: 0.02em;
}

.top-nav a:hover {
    color: #ffffff;
}

/* Кнопка-гамбургер (скрыта на десктопе) */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-left: 16px;
}

.nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: #ffffff;
    margin: 4px 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

/* Состояние открытого бургера */
.nav-toggle.open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* --- 3. Основной макет --- */
.main-container {
    max-width: 1200px;
    margin: 0 auto;
    padding-top: calc(var(--header-height) + 40px);
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    gap: 40px;
    padding-bottom: 80px;
    box-sizing: border-box;
}

/* --- 4. Боковая навигация с ползунком --- */
.sidebar {
    position: sticky;
    top: calc(var(--header-height) + 20px);
    height: fit-content;
}

.article-nav {
    font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
    font-size: 0.9rem;
    position: relative;
    border-left: 2px solid var(--nav-track-color);
    padding-left: 0;
}

.nav-slider {
    position: absolute;
    left: -2px;
    top: 0;
    width: 4px;
    background-color: var(--accent-color);
    transition: transform 0.25s ease, height 0.2s ease;
    height: 0;
    border-radius: 999px;
}

.article-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.article-nav li {
    padding: 10px 18px 10px 24px;
    margin: 0;
    position: relative;
}

.article-nav a {
    text-decoration: none;
    color: #555555;
    display: block;
    transition: color 0.2s ease;
    font-weight: 400;
}

.article-nav a:hover,
.article-nav a.active {
    color: var(--accent-color);
}

/* --- 5. Контент статьи --- */
.article-content {
    background: #ffffff;
    padding: 36px 52px 44px 52px;
    box-shadow: 0 16px 40px rgba(0,0,0,0.03);
    border-radius: 8px;
    box-sizing: border-box;
}

.article-inner {
    max-width: 720px; /* ограничение ширины текста */
    margin: 0 auto;
    padding-left: 1.2em;   /* легкий книжный отступ слева */
}

h1 {
    font-family: var(--heading-font);
    font-size: 2.1rem;
    font-weight: 300;
    margin: 0 0 8px 0;
    color: var(--accent-color);
    line-height: 1.35;
    letter-spacing: 0.01em;
}

/* Заголовок страницы (обертка вокруг h1) */
.page-header {
    margin-bottom: 14px; /* обычный отступ */
}

/* Увеличенный отступ, если текст начинается сразу после h1, без h2 */
.page-header--extra-gap {
    margin-bottom: 36px; /* можно варьировать 24–32 по вкусу */
}

.meta-info {
    font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
    color: #777777;
    font-size: 0.82rem;
    margin-bottom: 24px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e5ea;
}

/* Заголовок с тонкой линией под ним */
h2 {
    font-family: var(--heading-font);
    margin-top: 46px;
    margin-bottom: 18px;
    color: var(--accent-color);
    font-size: 1.7rem;
    font-weight: 300;
    line-height: 1.35;
    letter-spacing: 0.04em;
    text-transform: none;
    position: relative;
    padding-bottom: 10px;
    padding-left: 0;

    max-width: 60%; /* тут вместо битой 5 0%; можно поиграть 55–65% */
}

h2::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;            /* вместо 40% — линия на всю ширину заголовка */
    bottom: 0;
    height: 1px;
    background: linear-gradient(
        to right,
        rgba(31, 51, 80, 0.30),
        rgba(31, 51, 80, 0)
    );
}

/* Дополнительный «воздух» между разделами */
section + section {
    margin-top: 56px;
}

/* Подразделы */
.subsection-heading {
    font-family: var(--heading-font);
    font-size: 1.0rem;
    font-weight: 300;
    margin: 22px 0 8px 0;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.subsection-label {
    flex: 0 0 auto;
    font-size: 0.95rem;
    font-weight: 500;
    color: #555555;
}

.subsection-title-text {
    flex: 1 1 auto;
    color: #333333;
}

h3 {
    font-family: var(--heading-font);
    font-size: 1.6rem;
    margin-top: 24px;
    margin-bottom: 10px;
    font-weight: 300;
    letter-spacing: 0.01em;
}

p {
    margin: 0 0 14px 0;
    font-size: 1.04rem; /* было 0.98rem */
    text-align: left;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
}

/* Ссылки в основном тексте и примечаниях (кроме маркера сноски) */
.article-inner a:not(.footnote-ref) {
    color: var(--accent-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.32em;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.article-inner a:not(.footnote-ref):hover {
    text-decoration: none;
}

/* Структурированные абзацы 1. ... и a) ... */
.para-numbered,
.para-lettered {
    position: relative;
    padding-left: 2.1em;
}

.para-numbered .para-num,
.para-lettered .para-let {
    position: absolute;
    left: 0;
    top: 0;
    font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555555;
}

/* Смещение якорей с учетом фиксированного header */
section {
    scroll-margin-top: 90px;
}

[id^="ref"] {
    scroll-margin-top: 90px;
}

/* --- Сноски --- */
.footnote-ref {
    vertical-align: baseline;                 /* на одной линии с текстом */
    font-size: 0.9em;                         /* чуть компактнее основного текста */
    margin-left: 2px;
    

    /* максимально близко к обычным ссылкам */
    color: var(--accent-color);
    text-decoration: underline;
    text-decoration-style: dotted;            /* здесь главное отличие */
    text-decoration-thickness: 1px;
    text-underline-offset: 0.32em;
    transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.footnote-ref:hover {
    text-decoration: none;                    /* как и у обычных ссылок */
}

.footnotes-section {
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid #dddddd;
    font-size: 0.9rem;
    color: #555555;
    background: #fafafa;
    padding: 22px 22px 16px 22px;
    box-sizing: border-box;
    border-radius: 6px;
}

.footnotes-section ol {
    padding-left: 20px;
    margin: 0;
}

.footnotes-section li {
    margin-bottom: 8px;
}

/* --- Выноски цитат --- */
.pull-quote {
    margin: 22px 0;
    padding: 12px 16px;
    border-left: 2px solid #cbd5f5;
    background: #f7f8ff;
    font-size: 0.96rem;
    font-style: italic;
    color: #444444;
    border-radius: 4px;
}

.pull-quote-source {
    display: block;
    margin-top: 6px;
    font-size: 0.84rem;
    font-style: normal;
    color: #777777;
}

/* Маркированные списки (Markdown "- ...") с маркером "—",
   выравниваем по отступам как структурированные абзацы 1. / a) */
.article-inner ul {
    list-style: none;           /* убираем стандартные кружки */
    margin: 0 0 14px 0;         /* как у p: нижний отступ тот же */
    padding: 0;                 /* убираем стандартный отступ слева */
}

.article-inner ul li {
    position: relative;
    padding-left: 2.1em;        /* как у .para-numbered /.para-lettered */
    margin: 0 0 6px 0;          /* небольшой интервал между строками списка */
    font-size: 1.04rem;         /* как у p */
}

/* Маркер "—" вместо стандартного кружка */
.article-inner ul li::before {
    content: "—";
    position: absolute;
    left: 0;
    top: 0;
    font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
    font-size: 0.9rem;
    font-weight: 500;
    color: #555555;
}

/* Навигация по разделам history */
.history-section-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 32px 0 20px 0; /* больше воздуха сверху и снизу, в т.ч. перед h1 */
    padding: 10px 0 14px 0;
    border-top: 1px solid #e0e0e5;
    border-bottom: 1px solid #e0e0e5;
    font-family: "Helvetica Neue", Arial, system-ui, sans-serif;
    font-size: 0.9rem;
    color: #555555;
}

.history-section-nav-left,
.history-section-nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-nav-home,
.history-nav-prev,
.history-nav-next {
    text-decoration: none;
    color: #555555;
    transition: color 0.2s ease;
    white-space: nowrap;
}

/* убрали жирность, оставляем обычное начертание */
.history-nav-prev,
.history-nav-next {
    font-weight: 400;
}

.history-nav-prev {
    padding-right: 4px;
}

.history-nav-next {
    padding-left: 4px;
}

.history-nav-home:hover,
.history-nav-prev:hover,
.history-nav-next:hover {
    color: var(--accent-color);
}

.history-nav-separator {
    padding: 0 6px;
    color: #b0b0b7;
}

/* --- Оглавление на главной странице history (index.php) --- */

.history-index-toc-section {
    margin-top: 48px;
}

.history-index-toc-list {
    list-style: none;
    margin: 10px 0 0 0;
    padding: 0;
}

/* Убираем любые псевдомаркеры у li в этом блоке */
.history-index-toc-list li::before {
    content: none !important;
}

.history-index-toc-list li {
    margin: 4px 0;
}

.history-index-toc-list a {
    text-decoration: none;
    color: var(--accent-color);
    font-size: 0.98rem;
    line-height: 1.5;
}

.history-index-toc-list a:hover {
    text-decoration: underline;
}

/* Номер раздела слева, фиксированная ширина — аккуратная колонка */
.history-index-number {
    display: inline-block;
    min-width: 3.1em;
}

/* Иерархия по уровням (если нужно визуально показать вложенность) */
.history-index-level-1 .history-index-title {
    padding-left: 0;
    font-weight: 500;
}

.history-index-level-2 .history-index-title {
    padding-left: 1.2em;
}

.history-index-level-3 .history-index-title {
    padding-left: 2.0em;
    font-size: 0.95rem;
}

/* Больше воздуха под заголовком страницы,
   если перед первым h2 есть вступительный текст */
.article-inner.has-intro-before-h2 h1 {
    margin-bottom: 26px; /* можно подогнать по вкусу 24–32px */
}

.history-index-item-unpublished .history-index-title {
    opacity: 0.7;
    font-style: italic;
}

.history-index-badge-unpublished {
    margin-left: 0.5rem;
    font-size: 0.85em;
    text-transform: uppercase;
}

.history-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.history-section-header-main {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.75rem;
}

.history-section-status {
    font-size: 0.9rem;
    font-weight: 600;
}

.history-section-status-unpublished {
    color: #c0392b; /* krasnyj marcer «ne opublikovana» */
}

.history-section-header-actions {
    flex-shrink: 0;
}

.history-edit-button {
    display: inline-block;
    padding: 0.35rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: 4px;
    border: 1px solid #d9e8fb;
    background-color: #f1f7ff;
    color: #fff;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

.history-edit-button:hover {
    background-color: #f1f7ff;
    border-color: #d9e8fb;;
    transform: translateY(-1px);
}

.history-edit-button:active {
    transform: translateY(0);
}

/* --- 6. Адаптивность --- */
@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
        padding: calc(var(--header-height) + 20px) 12px 36px 12px;
        gap: 24px;
    }
    
    .sidebar {
        position: relative;
        top: 0;
        margin-bottom: 10px;
    }

    .article-nav {
        border-left: none;
        border-bottom: 1px solid #dddddd;
        padding-bottom: 4px;
    }

    .nav-slider {
        display: none;
    }

    .article-nav li {
        padding: 8px 0;
        border-bottom: 1px solid #f1f1f1;
    }
    
    .article-content {
        padding: 20px 16px 26px 16px;
        box-shadow: none;
        border-radius: 0;
    }
    
    .article-inner {
        max-width: 100%;
        padding-left: 0.8em;
    }

    /* --- ключевые изменения размеров --- */
    h1 {
        font-size: 1.9rem;
        margin-bottom: 8px;
    }

    h2 {
        font-size: 1.5rem;
        margin-top: 28px;
    }

    h3 {
        font-size: 1.25rem;
    }

    .subsection-heading {
        font-size: 1.15rem;
    }

    p {
        font-size: 1.06rem;
    }

    section,
    [id^="ref"] {
        scroll-margin-top: 80px;
    }

    .nav-toggle {
        display: block;
    }

    .top-nav {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        background-color: #111827;
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 5% 10px 5%;
        box-sizing: border-box;
    }

    .top-nav.open {
        display: flex;
    }
    
    section + section {
        margin-top: 22px;
    }

    .history-section-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        margin: 28px 0 18px 0;
    }

    .history-section-nav-right {
        flex-wrap: wrap;
    }
    /* 1. Скрываем верхнюю навигацию по разделам на мобильных */
    .article-inner .history-section-nav:first-of-type {
        display: none;
    }

    /* 2. Чуть больше воздуха между сайдбаром и статьей */
    .sidebar {
        margin-bottom: 16px;
    }

    /* 3. Немного уменьшим «шум» оглавления слева */
    .article-nav {
        font-size: 0.86rem;
    }
}