/*
  Страницы юридических документов (Views/Shared/_LegalDocument.cshtml, legal-doc.js).
  Раскладка повторяет документы SchoolAI: оглавление слева, текущий раздел подсвечен,
  нумерованные разделы и пункты с номером в отдельной колонке. Цвета — токены alebystro.
*/
.ld-page {
    --ld-bg: #fff;
    --ld-text: #131740;
    --ld-muted: #5a5d79;
    --ld-subtle: #8d8fa5;
    --ld-line: #e7e8ec;
    --ld-surface: #f5f5f8;
    --ld-accent: #8358ff;
    --ld-accent-text: #6b3df5;
    --ld-accent-soft: rgb(131 88 255 / 12%);
    --ld-accent-ring: rgb(131 88 255 / 42%);
    --ld-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --ld-sticky-top: 6.75rem;
    background: var(--ld-bg);
    color: var(--ld-text);
}

.dark .ld-page {
    --ld-bg: #101436;
    --ld-text: #fff;
    --ld-muted: #c4c5cf;
    --ld-subtle: #8d8fa5;
    --ld-line: #2a2e57;
    --ld-surface: #171b45;
    --ld-accent-text: #b39cff;
    --ld-accent-soft: rgb(131 88 255 / 18%);
    --ld-accent-ring: rgb(131 88 255 / 50%);
}

/* ---------- Layout ---------- */
.ld-shell {
    width: min(1200px, 100% - 2.5rem);
    margin: 0 auto;
    padding: 2.5rem 0 6rem;
    display: grid;
    gap: 2rem;
}

.ld-shell--toc {
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 1024px) {
    .ld-shell {
        padding-top: 4rem;
    }

    .ld-shell--toc {
        grid-template-columns: 260px minmax(0, 1fr);
        gap: 4rem;
    }
}

.ld-article {
    min-width: 0;
    max-width: 820px;
}

/* ---------- Table of contents ---------- */
.ld-toc {
    display: none;
}

@media (min-width: 1024px) {
    .ld-toc {
        display: block;
        position: sticky;
        top: var(--ld-sticky-top);
        align-self: start;
        max-height: calc(100dvh - var(--ld-sticky-top) - 1rem);
        overflow-y: auto;
        padding-bottom: 1.5rem;
        scrollbar-width: thin;
    }
}

.ld-toc__title,
.ld-toc-mobile summary {
    margin: 0 0 1rem;
    font: 500 0.75rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ld-subtle);
}

.ld-toc__list {
    display: grid;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ld-toc__link {
    display: grid;
    grid-template-columns: 2rem minmax(0, 1fr);
    gap: 0.5rem;
    padding: 0.625rem 0.75rem;
    border-radius: 0.75rem;
    color: var(--ld-muted);
    font-size: 0.9375rem;
    line-height: 1.4;
    text-decoration: none;
    transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.ld-toc__num {
    padding-top: 0.15em;
    font: 400 0.75rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--ld-subtle);
    transition: color 0.25s ease;
}

@media (hover: hover) {
    .ld-toc__link:hover {
        color: var(--ld-text);
        background: var(--ld-surface);
    }
}

.ld-toc__link:focus-visible {
    outline: 2px solid var(--ld-accent);
    outline-offset: 2px;
}

.ld-toc__link.is-active {
    color: var(--ld-text);
    font-weight: 500;
    background: var(--ld-accent-soft);
    box-shadow: inset 0 0 0 1px var(--ld-accent-ring);
}

.ld-toc__link.is-active .ld-toc__num {
    color: var(--ld-accent-text);
}

.ld-toc-mobile {
    border: 1px solid var(--ld-line);
    border-radius: 1rem;
    background: var(--ld-surface);
    padding: 0.875rem 1rem;
}

.ld-toc-mobile summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    cursor: pointer;
    list-style: none;
}

.ld-toc-mobile summary::-webkit-details-marker {
    display: none;
}

.ld-toc-mobile summary svg {
    width: 1rem;
    height: 1rem;
    margin-left: auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    transition: transform 0.25s var(--ld-ease);
}

.ld-toc-mobile[open] summary svg {
    transform: rotate(180deg);
}

.ld-toc-mobile .ld-toc__list {
    margin-top: 0.75rem;
}

@media (min-width: 1024px) {
    .ld-toc-mobile {
        display: none;
    }
}

/* ---------- Header ---------- */
.ld-head {
    display: grid;
    gap: 1.25rem;
    padding-bottom: 2.5rem;
    border-bottom: 1px solid var(--ld-line);
}

.ld-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    font: 500 0.75rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ld-accent-text);
}

.ld-eyebrow::after {
    content: "";
    width: 2.5rem;
    height: 1px;
    background: var(--ld-accent);
}

.ld-title {
    margin: 0;
    font-family: var(--font-display, "CalSans-SemiBold", sans-serif);
    font-size: clamp(2rem, 1.4rem + 2.6vw, 3.25rem);
    line-height: 1.05;
    color: var(--ld-text);
    text-wrap: balance;
}

.ld-subtitle {
    margin: 0;
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--ld-muted);
}

.ld-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ld-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.875rem;
    border: 1px solid var(--ld-line);
    border-radius: 999px;
    font-size: 0.875rem;
    color: var(--ld-muted);
}

.ld-chip b {
    font-weight: 600;
    color: var(--ld-text);
}

.ld-chip__dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #8358ff, #ff6ad5);
}

/* ---------- Sections ---------- */
.ld-intro,
.ld-section {
    padding: 2.5rem 0;
    border-bottom: 1px solid var(--ld-line);
}

.ld-section {
    scroll-margin-top: var(--ld-sticky-top);
}

.ld-section:last-of-type {
    border-bottom: 0;
}

.ld-section__title {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin: 0 0 1.5rem;
    font-family: var(--font-display, "CalSans-SemiBold", sans-serif);
    font-size: clamp(1.375rem, 1.15rem + 0.9vw, 1.75rem);
    line-height: 1.2;
    color: var(--ld-text);
}

.ld-section__num {
    flex: none;
    font: 400 0.875rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--ld-accent-text);
}

/* ---------- Document body (HTML from the admin editor) ---------- */
.ld-body {
    display: grid;
    gap: 1.25rem;
    font-size: 1.0625rem;
    line-height: 1.75;
    color: var(--ld-text);
    overflow-wrap: anywhere;
}

.ld-body > * {
    margin: 0;
}

/* Пункты «1.1.», свёрстанные списком: номер в своей колонке вместо маркера. */
.ld-body ul:has(> li.ld-clause),
.ld-body ol:has(> li.ld-clause) {
    padding-left: 0;
    list-style: none;
    gap: 1.25rem;
}

.ld-body li.ld-clause::marker {
    content: none;
}

.ld-body h3,
.ld-body h4,
.ld-body h5 {
    margin-top: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--ld-text);
}

.ld-body ul,
.ld-body ol {
    display: grid;
    gap: 0.75rem;
    padding-left: 3.5rem;
}

.ld-body ul {
    list-style: disc;
}

.ld-body ol {
    list-style: decimal;
}

.ld-body li::marker {
    color: var(--ld-accent-text);
}

.ld-body a {
    color: var(--ld-text);
    text-decoration: underline;
    text-decoration-color: var(--ld-accent-ring);
    text-underline-offset: 4px;
    transition: color 0.2s ease;
}

@media (hover: hover) {
    .ld-body a:hover {
        color: var(--ld-accent-text);
    }
}

.ld-body strong,
.ld-body b {
    font-weight: 600;
}

.ld-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.ld-body td,
.ld-body th {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--ld-line);
    vertical-align: top;
}

.ld-clause {
    display: grid;
    grid-template-columns: 2.75rem minmax(0, 1fr);
    column-gap: 0.75rem;
}

.ld-clause__num {
    padding-top: 0.2em;
    font: 400 0.875rem/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--ld-accent-text);
}

.ld-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
    padding: 0.625rem 1.125rem;
    border: 1px solid var(--ld-line);
    border-radius: 999px;
    color: var(--ld-text);
    font-size: 0.9375rem;
    text-decoration: none;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.ld-back svg {
    width: 1rem;
    height: 1rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

@media (hover: hover) {
    .ld-back:hover {
        border-color: var(--ld-accent-ring);
        background: var(--ld-surface);
    }
}

@media (max-width: 640px) {
    .ld-body ul,
    .ld-body ol {
        padding-left: 1.5rem;
    }

    .ld-clause {
        grid-template-columns: 2.25rem minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .ld-toc__link,
    .ld-toc__num,
    .ld-toc-mobile summary svg {
        transition: none;
    }
}
