/* TOP-NOZHI v2 - статья в раскладке Википедии (30.11.2026), шаблон v2/tpl/page_article.php.
   ПК (от 75rem): содержание и рубрики | текст | карточка-справка и «См. также».
   64-75rem: текст | правая колонка, содержание в тексте. До 64rem одна колонка,
   порядок блоков задан order: шапка, карточка, содержание, текст, разделы, «См. также», категории. */

.wiki {
    display: flex;
    flex-direction: column;
    gap: var(--gap-3);
}

/* --- телефон и планшет: колонки раскрываются в общий поток --- */
@media (max-width: 63.99rem) {
    .wiki__left {
        display: none;
    }

    .wiki__main, .wiki__right {
        display: contents;
    }

    .wiki .article-head { order: 1; }
    .wiki__lead { order: 2; }
    .wiki__box { order: 3; }
    .wiki__toc { order: 4; }
    .wiki .prose { order: 5; }
    .wiki__more { order: 5; }
    .wiki__see { order: 6; }
    .wiki .catlinks { order: 7; }

    .wiki .catlinks {
        margin-top: 0;
    }

    .wiki__more, .wiki .prose, .wiki__lead, .wiki__toc {
        margin-block: 0;
    }

    .wiki .prose > :first-child {
        margin-top: 0;
    }

    /* карточка на телефоне - фото на всю ширину, таблица под ним */
    .wiki__box {
        max-width: 26rem;
        width: 100%;
    }
}

/* --- две колонки: текст и справка --- */
@media (min-width: 64rem) {
    .wiki {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 18.5rem;
        gap: var(--gap-4);
        align-items: start;
    }

    .wiki__left {
        display: none;
    }

    .wiki__main {
        max-width: none;
    }

    .wiki__right {
        display: flex;
        flex-direction: column;
        gap: var(--gap-3);
        min-width: 0;
    }

    .wiki__toc {
        margin-block: var(--gap-3);
    }
}

/* --- три колонки --- */
@media (min-width: 75rem) {
    .wiki {
        grid-template-columns: 14rem minmax(0, 1fr) 18.5rem;
        gap: var(--gap-4);
    }

    /* колонка во всю высоту статьи - иначе содержанию некуда ехать */
    .wiki__left {
        display: block;
        min-width: 0;
        align-self: stretch;
    }

    .wiki__sticky {
        position: sticky;
        top: 1.25rem;
        max-height: calc(100vh - 2.5rem);
        overflow-y: auto;
        scrollbar-width: thin;
        padding-right: .25rem;
    }

    .wiki__toc {
        display: none;
    }
}

/* карточка-справка в колонке - без обтекания, вся ширина колонки */
.wiki .infobox {
    float: none;
    width: auto;
    margin: 0;
}

.wiki .infobox img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.wiki .infobox picture {
    display: block;
}

/* в тексте больше нечего обтекать - заголовки и рисунки идут подряд */
.wiki .prose .fig, .wiki .prose .note, .wiki .prose h2, .wiki .prose .table-wrap, .wiki .prose .scale {
    clear: none;
}

@media (min-width: 64rem) {
    .wiki .prose > :first-child {
        margin-top: var(--gap-3);
    }

    .wiki__lead {
        margin: var(--gap-3) 0 0;
    }
}

/* --- боковой блок --- */
.wside + .wside {
    margin-top: var(--gap-3);
}

.wside__title {
    margin: 0 0 .5rem;
    padding-bottom: .5rem;
    border-bottom: 2px solid var(--accent);
    font-size: .75rem;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.wside__title a {
    color: inherit;
    text-decoration: none;
}

.wside__title a:hover {
    color: var(--ink);
}

/* --- содержание слева, как в Википедии: тонкая линия, текущий раздел подсвечен --- */
.wtoc, .wcats, .wsee {
    margin: 0;
    padding: 0;
    list-style: none;
}

.wtoc {
    counter-reset: wtoc;
}

.wtoc li {
    counter-increment: wtoc;
    display: flex;
    gap: .5rem;
    font-size: .875rem;
    line-height: 1.35;
}

.wtoc li::before {
    content: counter(wtoc, decimal-leading-zero);
    flex: none;
    width: 1.5rem;
    padding-top: .4rem;
    font: 500 .6875rem/1.35 var(--font-mono);
    color: var(--ink-3);
}

.wtoc li.wtoc__top {
    counter-increment: none;
}

.wtoc li.wtoc__top::before {
    content: "";
}

.wtoc a {
    display: block;
    flex: 1;
    padding: .35rem 0 .35rem .6rem;
    border-left: 2px solid var(--line);
    color: var(--ink-2);
    text-decoration: none;
}

.wtoc a:hover {
    color: var(--ink);
    border-left-color: var(--ink-3);
}

.wtoc a[aria-current] {
    color: var(--ink);
    font-weight: 600;
    border-left-color: var(--accent);
}

.wtoc li[data-on]::before {
    color: var(--accent-ink);
}

/* --- рубрики раздела --- */
.wcats li {
    border-bottom: 1px solid var(--line);
}

.wcats li:last-child {
    border-bottom: 0;
}

.wcats a {
    display: block;
    padding: .4rem 0;
    font-size: .875rem;
    line-height: 1.35;
    color: var(--ink-2);
    text-decoration: none;
}

.wcats a:hover {
    color: var(--ink);
}

.wcats a[aria-current] {
    color: var(--ink);
    font-weight: 600;
    box-shadow: inset 2px 0 0 var(--accent);
    padding-left: .6rem;
}

/* --- «См. также»: миниатюра и название --- */
.wiki__see {
    margin: 0;
}

.wsee li {
    border-bottom: 1px solid var(--line);
}

.wsee li:last-child {
    border-bottom: 0;
}

.wsee a {
    display: grid;
    grid-template-columns: 4.5rem minmax(0, 1fr);
    gap: .75rem;
    align-items: center;
    padding: .6rem 0;
    font-size: .875rem;
    line-height: 1.35;
    color: var(--ink);
    text-decoration: none;
}

.wsee a:hover span {
    text-decoration: underline;
}

.wsee picture {
    display: block;
}

.wsee img, .wsee i {
    display: block;
    width: 4.5rem;
    height: 3.375rem;
    object-fit: cover;
    border: 1px solid var(--line);
    background: var(--surface);
}

.wsee__all {
    display: inline-block;
    margin-top: .75rem;
    font-size: .75rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

/* --- фото под тему: пара из images/more/v2/ (v2/lib/content.php, tn2_theme_photos) --- */
img[data-th="d"] {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) img[data-th="l"] {
        display: none;
    }

    :root:not([data-theme="light"]) img[data-th="d"] {
        display: block;
    }
}

:root[data-theme="dark"] img[data-th="l"] {
    display: none;
}

:root[data-theme="dark"] img[data-th="d"] {
    display: block;
}

/* фото пары лежит на фоне точно цвета страницы (tools/photos/compose.py) - без рамки и подложки, шва нет */
.fig img[data-th] {
    border: 0;
    background: none;
}

/* --- без рамок у фото (30.11.2026, просьба Виталия): карточка-справка, «См. также», рисунки статьи --- */
.wiki .infobox {
    border: 0;
    background: none;
}

.wiki .infobox__title {
    padding: 0 0 .6rem;
    border-bottom: 2px solid var(--accent);
    font-size: 1.0625rem;
    text-align: left;
}

.wiki .infobox img {
    border: 0;
    margin-top: .75rem;
}

.wiki .infobox table {
    margin-top: .25rem;
}

.wiki .infobox th, .wiki .infobox td {
    padding-inline: 0;
}

.wiki .infobox th {
    padding-right: .75rem;
}

.wsee img, .wsee i {
    border: 0;
}

.wiki .fig img {
    border: 0;
}

/* --- ПК: лист на 95 % ширины окна; колонки расходятся, строка текста не длиннее 56rem --- */
@media (min-width: 64rem) {
    .sheet {
        max-width: 95%;
    }

    .wrap {
        width: calc(100% - 2 * clamp(1.5rem, 2.5vw, 3rem));
    }
}

@media (min-width: 75rem) {
    .wiki {
        grid-template-columns: 14rem minmax(0, 56rem) 18.5rem;
        justify-content: space-between;
    }
}

@media (min-width: 110rem) {
    .wiki {
        grid-template-columns: 16rem minmax(0, 58rem) 22rem;
    }
}
