/* ═══ Документы сайта: /terms и /privacy (pages/legal.js) ══════════════════
   Спокойная страница для долгого чтения. Под текстом остаются общий фон
   сайта и живой перламутр с реакцией на курсор (aurora-field.js), сам текст —
   на плотной тёмной панели без backdrop-filter. Колонка ~72ch, 17/1.7 на
   компьютере и 16 px на телефоне, номера пунктов висят слева.
   Оглавление: от 1100 px — липкое сбоку с подсветкой текущего раздела, уже —
   свёрнутый список, прилипающий под шапкой. --lg-top (высота шапки сайта)
   ставит legal.js: на телефоне шапка в две строки и её высота не равна --nav-h.
   Печать (кнопка «Печать и PDF») — белый лист, чёрный текст, без фона и
   навигации: правила в конце файла. Всё — под body[data-page="legal"] или .lg,
   потому что файл остаётся подключённым и после ухода со страницы. */

.lg {
    --lg-top: var(--nav-h);
    --lg-ink: rgba(244, 244, 247, 0.86);
    --lg-num: rgba(244, 244, 247, 0.5);
    --lg-paper: rgba(9, 9, 13, 0.9);
    position: relative;
}
/* Перламутр с курсором — на весь экран, а не на всю высоту документа: слой в
   полторы страницы высотой был бы огромной текстурой. Координаты слой берёт из
   своего getBoundingClientRect, так что фиксированное положение ему не мешает. */
.lg > .af { position: fixed; inset: 0; }

.lg-wrap {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 36px var(--gutter) 72px;
}

/* ── Шапка: переключатель документов и печать ────────────────────────── */
.lg-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.lg-switch {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    border-radius: var(--r-pill);
    background: var(--panel-solid);
    border: 1px solid var(--line);
    max-width: 100%;
}
.lg-switch a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 16px;
    border-radius: var(--r-pill);
    color: var(--text-2);
    font-size: var(--fs-md);
    font-weight: var(--fw-medium);
    white-space: nowrap;
    transition: color var(--dur-2) ease, background-color var(--dur-2) ease;
}
.lg-switch a:hover { color: var(--text); }
.lg-switch a[aria-current="page"] { color: var(--text); background: var(--glass-4); }
.lg-switch .lg-s-short { display: none; }
.lg-print svg { width: 17px; height: 17px; }

/* ── Сетка: оглавление + лист ─────────────────────────────────────────── */
.lg-grid { display: block; }
.lg-side { display: none; }
.lg-main { min-width: 0; }

.lg-paper {
    position: relative;
    background: var(--lg-paper);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--sh-2);
    padding: clamp(24px, 4.4vw, 60px) clamp(18px, 5vw, 64px) clamp(28px, 4.4vw, 56px);
}
.lg-body { min-height: 60vh; }
.lg-body .lg-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 50vh;
    color: var(--text-3);
    text-align: center;
}

.lg-note {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    max-width: 72ch;
    margin: 0 auto 22px;
    padding: 10px 14px;
    border-radius: var(--r-md);
    background: var(--glass-2);
    color: var(--text-2);
    font-size: var(--fs-md);
    line-height: 1.5;
}
.lg-note button {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    font-size: inherit;
    text-decoration: underline;
    text-decoration-color: var(--line-3);
    text-underline-offset: 3px;
}

/* ── Текст документа (фрагмент static/site/legal/*.html) ───────────────── */
.lg-doc {
    max-width: 72ch;
    margin: 0 auto;
    color: var(--lg-ink);
    font-size: 17px;
    line-height: 1.7;
    overflow-wrap: break-word;
    hyphens: manual;
}
.lg-doc h1 {
    font-family: var(--font-display);
    font-weight: var(--fw-semibold);
    font-size: clamp(25px, 2.7vw, 34px);
    line-height: 1.22;
    letter-spacing: -0.012em;
    color: var(--text);
    text-wrap: balance;
}
.lg-doc .lg-edition {
    display: inline-block;
    margin-top: 16px;
    padding: 3px 12px;
    border-radius: var(--r-pill);
    border: 1px solid var(--line-2);
    color: var(--text-3);
    font-size: var(--fs-sm);
    line-height: 1.6;
}
/* Строка перевода «при расхождениях действует русская редакция» (p.lg-tr во
   фрагментах *.en/es/pt/fr.html). На экране то же говорит плашка .lg-note
   с кнопкой — строку прячем; в печати плашки нет — строка остаётся. */
.lg-doc .lg-tr {
    margin: 12px 0 0;
    padding-left: 0;
    color: var(--text-3);
    font-size: var(--fs-sm);
    line-height: 1.5;
}
.lg-note:not([hidden]) + .lg-body .lg-tr { display: none; }
.lg-doc section {
    margin-top: 2.2em;
    padding-top: 1.7em;
    border-top: 1px solid var(--line);
    scroll-margin-top: calc(var(--lg-top) + 20px);
}
.lg-doc section:first-of-type { margin-top: 2em; }
.lg-doc h2 {
    margin-bottom: 0.9em;
    color: var(--text);
    font-size: 1.24em;
    font-weight: var(--fw-semibold);
    line-height: 1.32;
    letter-spacing: -0.005em;
    text-wrap: balance;
    outline: none;
}
/* Пункт: номер висит в левом поле, текст идёт ровной колонкой. */
.lg-doc p {
    position: relative;
    margin: 0 0 0.8em;
    padding-left: 3.3em;
    text-wrap: pretty;
}
.lg-doc .lg-n {
    position: absolute;
    left: 0;
    top: 0;
    color: var(--lg-num);
    font-variant-numeric: tabular-nums;
}
.lg-doc .lg-example {
    margin: 0.2em 0 1em 3.3em;
    padding: 12px 16px;
    border-left: 2px solid var(--line-3);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
    background: var(--glass-1);
    color: var(--text-2);
    font-size: 0.94em;
    line-height: 1.6;
}
.lg-doc ul {
    margin: -0.2em 0 1em 3.3em;
    padding-left: 1.2em;
    list-style: none;
}
.lg-doc li {
    position: relative;
    margin-bottom: 0.45em;
}
.lg-doc li::before {
    content: '';
    position: absolute;
    left: -1.05em;
    top: 0.78em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--lg-num);
}
.lg-doc a {
    color: var(--text);
    text-decoration: underline;
    text-decoration-color: var(--line-3);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: text-decoration-color var(--dur-2) ease;
}
.lg-doc a:hover { text-decoration-color: var(--text); }
/* Реквизиты: подпись слева, значение справа; на телефоне — друг под другом. */
.lg-doc .lg-req { margin: 0; }
.lg-doc .lg-req div {
    display: grid;
    grid-template-columns: minmax(0, 13em) minmax(0, 1fr);
    gap: 2px 20px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
}
.lg-doc .lg-req div:last-child { border-bottom: 1px solid var(--line); }
.lg-doc .lg-req dt { color: var(--text-3); }
.lg-doc .lg-req dd { margin: 0; color: var(--text); }

/* ── Оглавление ───────────────────────────────────────────────────────── */
.lg-toc { list-style: none; margin: 0; padding: 0; }
.lg-toc a {
    position: relative;
    display: block;
    padding: 7px 10px 7px 14px;
    border-radius: var(--r-xs);
    color: var(--text-3);
    font-size: var(--fs-md);
    line-height: 1.4;
    transition: color var(--dur-2) ease, background-color var(--dur-2) ease;
}
.lg-toc a::before {
    content: '';
    position: absolute;
    left: 0;
    top: 9px;
    bottom: 9px;
    width: 2px;
    border-radius: 2px;
    background: var(--text);
    opacity: 0;
    transition: opacity var(--dur-2) ease;
}
.lg-toc a:hover { color: var(--text); background: var(--glass-1); }
.lg-toc a.is-active { color: var(--text); }
.lg-toc a.is-active::before { opacity: 1; }

/* Телефон и планшет: свёрнутое оглавление прилипает под шапкой сайта. */
.lg-mtoc {
    position: sticky;
    top: var(--lg-top);
    z-index: var(--z-sticky);
    margin: 0 0 12px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-md);
    background: var(--pop-bg);
    box-shadow: 0 10px 28px -16px rgba(0, 0, 0, 0.9);
}
/* Пока документ грузится, место под оглавлением уже занято, но его не видно:
   иначе оглавление появляется над текстом и сдвигает его на 62 px (CLS 0,16). */
.lg-mtoc[data-wait] { visibility: hidden; }
.lg-mtoc summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 14px;
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.lg-mtoc summary::-webkit-details-marker { display: none; }
.lg-mtoc-l { flex: 0 0 auto; color: var(--text-3); font-size: var(--fs-sm); }
.lg-mtoc-cur {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: var(--fs-md);
    font-weight: var(--fw-medium);
    white-space: nowrap;
    text-overflow: ellipsis;
}
.lg-mtoc summary svg { flex: 0 0 auto; width: 18px; height: 18px; color: var(--text-3); transition: transform var(--dur-2) var(--ease-out); }
.lg-mtoc[open] summary svg { transform: rotate(180deg); }
.lg-mtoc .lg-toc {
    max-height: min(60vh, 460px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 4px 6px 8px;
    border-top: 1px solid var(--line);
}
.lg-mtoc .lg-toc a { padding: 10px 10px 10px 14px; }

@media (min-width: 1100px) {
    .lg-wrap { padding-top: 48px; }
    .lg-grid {
        display: grid;
        grid-template-columns: 250px minmax(0, 1fr);
        gap: 44px;
        align-items: start;
    }
    .lg-head { padding-left: calc(250px + 44px); }
    .lg-side {
        display: block;
        position: sticky;
        top: calc(var(--lg-top) + 28px);
        max-height: calc(100vh - var(--lg-top) - 56px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding: 6px 4px 6px 0;
        scrollbar-width: thin;
    }
    .lg-side-t {
        margin: 0 0 10px 14px;
        color: var(--text-3);
        font-size: var(--fs-xs);
        font-weight: var(--fw-semibold);
        letter-spacing: 0.12em;
        text-transform: uppercase;
    }
    .lg-mtoc { display: none; }
}

@media (max-width: 640px) {
    .lg-wrap { padding-top: 18px; padding-bottom: 48px; }
    .lg-head { margin-bottom: 14px; }
    .lg-switch { display: flex; width: 100%; }
    .lg-switch a { flex: 1 1 0; justify-content: center; padding: 0 10px; }
    .lg-switch .lg-s-long { display: none; }
    .lg-switch .lg-s-short { display: inline; }
    .lg-print { margin-left: auto; }
    .lg-paper { border-radius: var(--r-lg); }
    .lg-doc { font-size: 16px; line-height: 1.68; }
    .lg-doc p { padding-left: 2.9em; }
    .lg-doc ul, .lg-doc .lg-example { margin-left: 2.9em; }
    .lg-doc .lg-req div { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 380px) {
    .lg-doc p { padding-left: 2.7em; }
    .lg-doc ul, .lg-doc .lg-example { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .lg-switch a, .lg-toc a, .lg-toc a::before, .lg-mtoc summary svg { transition: none; }
}

/* ── Печать и «Сохранить как PDF» ─────────────────────────────────────── */
@media print {
    @page { margin: 16mm 15mm 18mm; }
    :root:has(body[data-page="legal"]) { color-scheme: light; background: #fff; }
    body[data-page="legal"] { background: #fff !important; color: #000; min-height: 0; }
    body[data-page="legal"] .aurora,
    body[data-page="legal"] #topbar,
    body[data-page="legal"] .skip-link,
    body[data-page="legal"] #overlay-root,
    body[data-page="legal"] .toast-stack,
    body[data-page="legal"] .site-foot,
    .lg > .af,
    .lg-head,
    .lg-side,
    .lg-mtoc,
    .lg-note { display: none !important; }
    body[data-page="legal"] .page-root { min-height: 0; }
    .lg-wrap { max-width: none; padding: 0; }
    .lg-grid { display: block; }
    .lg-paper { background: none; border: 0; border-radius: 0; box-shadow: none; padding: 0; }
    .lg-body { min-height: 0; }
    .lg-doc { max-width: none; color: #000; font-size: 11pt; line-height: 1.5; }
    .lg-doc h1 { color: #000; font-size: 18pt; }
    .lg-doc .lg-edition { border-color: #999; color: #333; }
    /* .lg-note в печати display:none, но не [hidden] — правило экрана
       выше всё ещё прятало бы строку перевода. */
    .lg-doc .lg-tr { display: block !important; color: #333; }
    .lg-doc section { margin-top: 14pt; padding-top: 10pt; border-top-color: #bbb; }
    .lg-doc h2 { color: #000; font-size: 13pt; break-after: avoid; }
    .lg-doc p, .lg-doc li, .lg-doc .lg-req div { break-inside: avoid; }
    .lg-doc .lg-n { color: #444; }
    .lg-doc li::before { background: #444; }
    .lg-doc .lg-example { background: none; border-left-color: #999; color: #222; }
    .lg-doc a { color: #000; text-decoration-color: #999; }
    .lg-doc .lg-req div { border-color: #bbb; }
    .lg-doc .lg-req dt { color: #444; }
    .lg-doc .lg-req dd { color: #000; }
}
