/* Цвета */
:root {
    --bs-body-bg: #f8f9fa;
    --bs-body-color: #212529;
    --bs-card-bg: #ffffff;
    --bs-card-border-color: #ffffff;
    --bs-link-color: #0d6efd;
    --bs-link-hover-color: #0a58ca;
    --bs-primary: #4a90e2;
    --bs-secondary: #6c757d;
    --bs-light: #f1f3f5;
    --bs-dark: #212529;
}

/* Общий фон сайта */
body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/* Навигация */
.navbar {
    background-color: #ffffff;
    border-bottom: 1px solid #dee2e6;
}

/* Карточки */
.card {
    background-color: var(--bs-card-bg);
    border-color: var(--bs-card-border-color);
}

/* Таблицы */
.table {
    background-color: var(--bs-light);
}

/* Заголовки */
h1,
h2,
h3,
h4,
h5 {
    color: #333333;
}

/* Кнопка "вверх" */
#backToTop {
    background-color: var(--bs-primary);
    color: #fff;
}

#backToTop:hover {
    background-color: #357ABD;
}

#backToTop {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: none;
    z-index: 1030;
}

/* карточки и таблицы */
.card {
    border-radius: 1rem;
}

.table th,
.table td {
    vertical-align: middle;
}

h1,
h2,
h3 {
    scroll-margin-top: 84px;
}

a {
    color: inherit;
    text-decoration: none;
}

a:hover,
a:focus {
    text-decoration: underline;
}

/* Резюме */
.resume-card {
    border-radius: 1rem;
    overflow: hidden;
}

.resume-row {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1rem;
    padding: .85rem 1rem;
    align-items: start;
    border-top: 1px dashed rgba(0, 0, 0, .08);
}

.resume-row:first-child {
    border-top: 0;
}

@media (max-width: 768px) {
    .resume-row {
        grid-template-columns: 1fr;
    }
}

.resume-key {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 600;
    background: #f1f3f5;
    border: 1px solid #e9ecef;
    border-radius: 999px;
    padding: .35rem .75rem;
    width: max-content;
}

.resume-key i {
    color: #4a90e2;
}

/* акцент иконки */

.resume-val p {
    margin: 0;
}

.resume-val ol,
.resume-val ul {
    margin: 0;
    padding-left: 1.2rem;
}

.resume-val li {
    margin: .15rem 0;
}

.resume-row:nth-child(even) {
    background: rgba(0, 0, 0, .02);
}

.resume-row:hover {
    background: rgba(74, 144, 226, .06);
}

.resume-row:hover .resume-key {
    border-color: #d0e3ff;
    background: #eaf3ff;
}

.resume-badges .badge {
    margin: .15rem .25rem .15rem 0;
}

.toc-sticky {
    position: sticky;
    top: calc(var(--nav-height, 64px) + 16px);
    max-height: calc(100vh - var(--nav-height, 64px) - 24px);
    overflow: auto;
}

/* реферат */
.article-content p,
.article-content li {
    text-align: justify;
}

.article-content h2,
.article-content h3 {
    margin-top: 2rem;
    margin-bottom: .75rem;
}



.article-content .figure-caption,
.article-content figure .figure-caption {
    text-align: center;
}

:root {
    --figure-max-width: 75vh;
    --figure-max-height: 75vh;
}

.article-content figure,
.figure {
    width: min(var(--figure-max-width), 95vw);
    margin-left: auto;
    margin-right: auto;
}

.article-content img,
.article-content .figure img,
.article-content figure img,
.figure img {
    display: block;
    max-width: 100%;
    width: auto;
    height: auto;
    margin-left: auto;
    margin-right: auto;
    max-height: var(--figure-max-height);
    object-fit: contain;
}

/* Подпись таблицы над таблицей и справа */
.table caption {
    caption-side: top;
    text-align: right;
    padding-bottom: .5rem;
    color: inherit;
}

/* Стили для многоуровневого нумерованного списка */
.toc-list,
.toc-list ol {
    list-style: none;
    margin: 0;
    padding-left: 0;
    counter-reset: item;
}

.toc-list li {
    counter-increment: item;
    position: relative;
    margin: .25rem 0;
    line-height: 1.35;
}

/* Все номера */
.toc-list li::before {
    content: counters(item, ".");
    display: inline-block;
    min-width: 1.2rem;
    /* столбик под номер */
    padding-right: .3rem;
    font-weight: 600;
}

/* Верхний уровень — добавляем точку */
.toc-list>li::before {
    content: counters(item, ".") ".";
}

/* Вложенные уровни */
.toc-list>li>ol>li {
    padding-left: 2rem;
}

.toc-list>li>ol>li::before {
    min-width: 2rem;
}

.toc-list>li>ol>li>ol>li {
    padding-left: 3rem;
}

.toc-list>li>ol>li>ol>li::before {
    min-width: 2.5rem;
}

/* Без номера (Введение/Заключение/Источники) */
.toc-list li.no-num {
    counter-increment: none;
}

.toc-list li.no-num::before {
    display: inline-block;
    min-width: 2rem;
    content: none;
    margin: 0;
    padding-right: .3rem;
}

.tag-list-inline {
    list-style: none;
    margin: 0;
    padding-left: 1.5rem;
}

.tag-list-inline strong {
    color: #787d83;
}

strong {
    color: #787d83;
}


/* обычные маркеры li */
.tag-list-inline li {
    position: relative;
    margin-bottom: .6rem;
}

.tag-list-inline li::before {
    content: "";
    position: absolute;
    left: -1.2rem;
    top: 0.6em;
    width: .55rem;
    height: .55rem;
    border: 2px solid #979797;
    border-radius: 50%;
    background: transparent;
}

/* контейнер с тегами */
.tags-inline {
    display: inline;
}

/* обёртка одного тега */
.tag-wrap {
    display: inline-flex;
    align-items: center;
    margin: 0 .12rem;
}

/* тег */
.tag {
    display: inline-block;
    font-weight: 400;
    font-size: .9rem;
    padding: .18rem .55rem;
    border: 1px solid #dee2e6;
    border-radius: 999px;
    background: #f8f9fa;
    color: #333;
    white-space: nowrap;
}

/* разделители: запятая после каждого, точка после последнего */
.tag-wrap::after {
    content: ", ";
    color: #666;
    margin-left: .15rem;
}

.tag-wrap:last-child::after {
    content: ".";
}

/* Кружок под телеграм-видео */
.video-circle {
    width: clamp(180px, 40vw, 360px);
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto;
    background: var(--bs-light);
    border: 6px solid #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
    display: grid;
    place-items: center;
}

.video-circle video,
.video-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lang-btn {
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 0.9rem;
}

/* плавная смена языка */
#i18n-root {
    transition: opacity .25s ease;
}

#i18n-root.is-fading {
    opacity: 0;
}

.i18n-swap {
    display: inline-block;
    vertical-align: top;
    position: relative;
}

.i18n-frame {
    display: grid;
    align-items: start;
    justify-items: start;
    position: relative;
    width: 100%;
}

.i18n-layer {
    grid-area: 1 / 1;
    width: 100%;
}

/* навбар  */
.navbar {
    --bs-navbar-padding-y: .5rem;
    min-height: 56px;
}

.navbar .container {
    align-items: center;
}

.navbar .nav-link,
.lang-btn {
    white-space: nowrap;
}

:root {
    --accent: #0d6efd;
    --ink: #252a32;
    --muted: #6b7280;
    --panel: #ffffff;
    --panel-border: rgba(13, 110, 253, .15);
}

/* карточка */
.card.reading-card {
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .04);
}

/* индивидуальный раздел */
.prose {
    max-width: 78ch;
    margin-inline: auto;
    color: var(--ink);
    font-size: 1.025rem;
    line-height: 1.75;
    letter-spacing: .005em;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    hyphens: auto;
}

.prose p {
    margin: 0 0 1rem;
}

.prose p+p {
    margin-top: .25rem;
}

.prose .text-muted {
    color: var(--muted) !important;
}

/* вступление */
.lead-dropcap::first-letter {
    all: unset;
}

.lead-kicker {
    font-size: 1.05rem;
    line-height: 1.8;
    padding: .25rem 0 .25rem 1rem;
    border-left: 4px solid var(--accent);
    background:
        linear-gradient(180deg, rgba(13, 110, 253, .06), rgba(13, 110, 253, 0)) 0 0/100% 60% no-repeat;
    border-radius: 6px;
    color: var(--ink);
    margin-bottom: 1rem;
}

.prose h2,
.prose h3 {
    color: #1f2430;
    letter-spacing: .01em;
    margin: 1.25rem 0 .75rem;
}

/* Маршрутные карточки  */
.route-card {
    border: 1px solid rgba(0, 0, 0, .06);
    border-radius: 14px;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.route-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .06);
    border-color: var(--panel-border);
}

/* бейджи */

.badge-soft {
    padding: .35em .65em;
    font-size: .75rem;
    font-weight: 500;
    border-radius: .5rem;
}

.badge-easy {
    background: rgba(25, 135, 84, .15);
    color: #198754;
}

.badge-medium {
    background: rgba(13, 110, 253, .15);
    color: #0d6efd;
}

.badge-hard {
    background: rgba(220, 53, 69, .15);
    color: #dc3545;
}

/* Галерея  */
.photo-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.photo-card img {
    height: 200px;
    object-fit: cover;
    width: 100%;
}

.photo-card figcaption {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: .75rem;
}

.photo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 26px rgba(0, 0, 0, .07);
    border-color: var(--panel-border);
}

.figure-caption {
    font-size: .92rem;
    color: var(--muted);
}

.prose ul {
    padding-left: 1.15rem;
}

.prose li {
    margin: .35rem 0;
}

#photoModal img {
    max-height: 90vh;
    max-width: 95vw;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: .85;
    background: rgba(0, 0, 0, .35);
    color: #fff;
}

.modal-nav-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, .55);
}

.modal-nav-prev {
    left: .75rem;
}

.modal-nav-next {
    right: .75rem;
}

/* модальное для фото */
#photoModal .modal-content:hover .modal-nav-btn {
    opacity: .95;
}

#photoModal .modal-dialog {
    --bs-modal-width: auto;
    max-width: 95vw;
    margin: 0 auto;
}

#photoModal .modal-content {
    background: transparent !important;
    border: 0;
    box-shadow: none;
}

#photoModal .modal-body {
    padding: 0.25rem 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}

#photoModal img#modalImage {
    max-height: 90vh;
    max-width: 95vw;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

#modalCaption {
    max-width: 90vw;
    text-align: center;
    color: #f2f2f2;
    font-size: .95rem;
    line-height: 1.45;
    background: rgba(0, 0, 0, .55);
    padding: .4rem .75rem;
    border-radius: .5rem;
    backdrop-filter: blur(2px);
}

.photo-wrapper {
    position: relative;
    display: inline-block;
}

/* Крестик поверх фото */
.photo-wrapper .btn-close {
    position: absolute;
    top: 12px;
    right: 12px;

    width: 40px;
    height: 40px;
    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.75);
    border-radius: 50%;
    color: #fff;

    opacity: 1;
    background-image: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 20;
    font-size: 1.4rem;
}

.photo-wrapper .btn-close:hover {
    background: rgba(0, 0, 0, .7);
}

.gpa-icon {
    font-size: 1.5rem;
    color: #32363a;
    line-height: 1;
    display: inline-block;
    position: relative;
    top: 7px;
}

.video-player {
    position: relative;
}

.video-player video {
    cursor: pointer;
}

.video-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(rgba(0, 0, 0, .25), rgba(0, 0, 0, .35));
    border: 0;
    padding: 0;
    margin: 0;
    color: #fff;
    cursor: pointer;
}

.video-play i {
    font-size: 3.2rem;
    line-height: 1;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .35));
}

.video-player[data-playing="true"] .video-play {
    display: none;
}

.video-play:hover {
    background: radial-gradient(rgba(0, 0, 0, .22), rgba(0, 0, 0, .42));
}

.mermaid svg {
    display: block;
    margin-inline: auto;
}

svg {
    width: min(780px, 95vw);
    height: auto;
    max-height: 75vh;
    display: block;
    margin-inline: auto;
}

.article-content img,
.article-content svg,
.article-content video,
.article-content iframe,
.prose img,
.prose svg,
.prose video,
.prose iframe {
    max-width: 100%;
    height: auto;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.article-content figure,
.prose figure {
    max-width: 100%;
}

.article-content mjx-container {
    max-width: 100%;
    overflow-x: auto;
}

.article-content mjx-container[display="true"] {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

.eq-desktop {
    display: block;
}

.eq-mobile {
    display: none;
}

@media screen and (max-device-width: 768px) {

    mjx-container[jax="CHTML"][display="true"],
    .MathJax_Display,
    span.MJXc-display,
    span.mjx-chtml.MJXc-display {
        display: block;
        max-width: 100%;
        text-align: left !important;
        overflow-x: auto;
        box-sizing: border-box;
        padding-right: .5rem;
        font-size: 0.9em !important;
    }
}