/* Юридические документы: один шаблон для оферты, политики и согласия.
   Общие токены, шапка и подвал из ../styles.css, здесь только документ. */

.legal { background: var(--paper); color: var(--ink); }
.legal .foot { background: var(--ink); color: var(--cream); }
html:has(.legal) { scroll-padding-top: calc(var(--cap-top) + var(--cap) + 24px); }

/* Шапка документа: цветная сцена и характер бренда */
.doc-head {
  --scene: var(--yellow); --scene-t: var(--ink); --scene-dim: rgb(27 13 43 / .7);
  background: var(--scene); color: var(--scene-t);
  padding: calc(var(--head) + clamp(36px, 6vw, 88px)) var(--gutter) clamp(36px, 4.4vw, 60px);
}
.doc-head[data-scene="pink"] { --scene: var(--pink); }
.doc-head[data-scene="blue"] { --scene: var(--blue); --scene-t: var(--cream); --scene-dim: rgb(255 243 214 / .78); }
.doc-head h1 {
  font: 900 clamp(64px, 8.4vw, 136px)/.86 var(--display);
  max-width: 24ch; text-wrap: balance; overflow-wrap: break-word; hyphens: manual;
  margin: 0 0 22px;
}
.doc-head__sub { font-size: clamp(18px, 1.6vw, 22px); line-height: 1.35; max-width: 34em; text-wrap: pretty; }
.doc-head__meta {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 28px;
  margin-top: clamp(28px, 3.6vw, 48px); padding-top: 16px; border-top: 2px solid currentColor;
  font-size: 15px; color: var(--scene-dim);
}
.doc-head__meta p { margin-right: auto; }
.doc-head__br { display: none; }
.doc-print { color: var(--scene-t); font-size: 15px; }

/* Переключатель документов: обычные текстовые ссылки, текущий подчёркнут */
.doc-switch { display: flex; flex-wrap: wrap; gap: 6px 26px; margin-bottom: clamp(28px, 4vw, 56px); font-weight: 500; }
.doc-switch a { text-decoration: none; padding: 4px 0; }
.doc-switch a:hover, .doc-switch a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.doc-switch a[aria-current="page"] { pointer-events: none; }

/* Тело: оглавление слева, текст колонкой удобной ширины */
.doc {
  display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: clamp(32px, 6vw, 110px);
  padding: clamp(40px, 5vw, 72px) var(--gutter) clamp(72px, 8vw, 120px);
  max-width: 1440px;
}
.doc__text { max-width: 68ch; font-size: 18px; line-height: 1.65; counter-reset: none; }
.doc__text p, .doc__text ul, .doc__text .req { margin: 0 0 1em; }
.doc__text strong { font-weight: 600; }
.doc__text ul { list-style: none; padding: 0 0 0 1.4em; }
.doc__text li { position: relative; margin-bottom: .35em; }
.doc__text li::before { content: "—"; position: absolute; left: -1.4em; opacity: .55; }
.part { padding-top: 8px; }
.part + .part { margin-top: clamp(36px, 3.6vw, 52px); }
.part h2 {
  position: relative;
  font: 900 clamp(34px, 3.2vw, 46px)/.98 var(--display); text-wrap: balance;
  margin: 0 0 18px; padding-bottom: 12px; border-bottom: 2px solid var(--ink);
}
.part h2 .num { color: var(--violet); }
.doc__text p, .doc__text h2 { scroll-margin-top: calc(var(--cap-top) + var(--cap) + 24px); }

/* Якорь у каждого пункта: виден при наведении и фокусе */
.doc__text p, .doc__text dl { position: relative; }
.anchor {
  position: absolute; left: -34px; top: 0; width: 26px; height: 1.65em;
  display: grid; place-items: center; text-decoration: none; color: var(--violet);
  opacity: 0; transition: opacity .15s; font: 600 16px/1 var(--text);
}
.anchor::before { content: "#"; }
.part h2 .anchor { top: 2px; height: 1em; font-size: 20px; }
p:hover > .anchor, h2:hover > .anchor, .anchor:focus-visible { opacity: 1; }
.anchor.is-copied::after {
  content: "Ссылка скопирована"; position: absolute; left: 30px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; background: var(--ink); color: var(--cream); font: 500 13px/1 var(--text);
  padding: 7px 10px; border-radius: 8px; z-index: 2;
}
/* Пункт, на который пришли по ссылке, подсвечен маркером, как слово в демо */
.doc__text p:target, .doc__text dl:target {
  background: var(--yellow); box-shadow: 0 0 0 10px var(--yellow); border-radius: 2px;
}
.part:target h2 { color: var(--violet); }

/* Реквизиты: строки «название — значение» */
.req { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 24px; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.req dt { font-weight: 600; }
.req dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.req--lines { display: block; }

/* Оглавление: липкое на десктопе */
.toc { position: relative; font-size: 15px; line-height: 1.35; }
.toc__box { position: sticky; top: calc(var(--cap-top) + var(--cap) + 24px); max-height: calc(100vh - var(--cap-top) - var(--cap) - 48px); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.toc summary { list-style: none; font: 900 26px/1 var(--display); margin-bottom: 14px; cursor: default; }
.toc summary::-webkit-details-marker { display: none; }
.toc__now { display: none; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.toc li a {
  display: block; padding: 7px 0 7px 16px; margin-left: -2px; border-left: 2px solid transparent;
  text-decoration: none; color: rgb(27 13 43 / .74); text-wrap: pretty;
}
.toc li a:hover { color: var(--ink); }
.toc li a[aria-current="true"] { color: var(--ink); font-weight: 600; border-left-color: var(--ink); }
.toc .num { font-variant-numeric: tabular-nums; }

/* Наверх */
.to-top {
  position: fixed; right: var(--gutter); bottom: 20px; z-index: 15;
  min-height: 48px; padding: 0 20px; display: inline-flex; align-items: center; gap: 8px;
  border-radius: 999px; background: var(--ink); color: var(--cream); text-decoration: none; font-weight: 500; font-size: 15px;
  box-shadow: 0 0 0 2px var(--paper);
  transition: opacity .2s, transform .2s;
}
.to-top::before { content: "↑"; }
.to-top[hidden] { display: inline-flex; opacity: 0; transform: translateY(10px); pointer-events: none; visibility: hidden; }
.to-top:hover { background: var(--violet); }

@media (max-width: 1023px) {
  .doc { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 0; }
  .doc__text { max-width: 68ch; }
  /* Оглавление сворачивается в полосу под капсулой и показывает текущий раздел */
  .toc { position: sticky; top: calc(var(--cap-top) + var(--cap) + 8px); z-index: 12; margin: 0 calc(var(--gutter) * -1) 28px; }
  .toc__box {
    position: relative; top: auto; max-height: none; overflow: visible;
    background: var(--paper); border-bottom: 2px solid var(--ink);
  }
  /* Прилипшая полоса закрывает и зазор над собой, чтобы текст не просвечивал вокруг капсулы */
  .toc.is-stuck .toc__box::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: calc(var(--cap-top) + var(--cap) + 8px); background: var(--paper); }
  .toc summary {
    display: flex; align-items: center; gap: 12px; min-height: 52px; margin: 0; padding: 0 var(--gutter);
    font: 500 16px/1.2 var(--text); cursor: pointer;
  }
  .toc summary::after { content: ""; margin-left: auto; flex: none; width: 10px; height: 10px; border: solid currentColor; border-width: 0 2px 2px 0; transform: translateY(-3px) rotate(45deg); transition: transform .2s; }
  .toc__box[open] summary::after { transform: translateY(2px) rotate(-135deg); }
  .toc__label { font-weight: 600; flex: none; }
  .toc__now { display: block; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .7; }
  .toc__box[open] .toc__now { display: none; }
  .toc ol { border: 0; padding: 4px var(--gutter) 14px; max-height: min(60vh, 520px); overflow: auto; overscroll-behavior: contain; }
  .toc li a { padding: 10px 0; margin: 0; border: 0; border-top: 1px solid var(--line); font-size: 16px; }
  .toc li a[aria-current="true"] { border: 0; border-top: 1px solid var(--line); }
  .toc li a[aria-current="true"]::before { content: "→ "; }
  .anchor { left: auto; right: 100%; width: 22px; }
}
@media (max-width: 680px) {
  .doc-head h1 { font-size: clamp(54px, 16.5vw, 96px); max-width: none; }
  .doc-head__meta { font-size: 14px; }
  .doc-head__meta span { display: none; }
  .doc-head__br { display: inline; }
  .doc__text { font-size: 17px; line-height: 1.6; }
  .part h2 { font-size: 32px; }
  .req { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .req dd { margin-bottom: 10px; }
  .req dd:last-child { margin-bottom: 0; }
  /* На телефоне слева нет поля: якорь не показываем, пункт открывается по ссылке из оглавления */
  .anchor { display: none; }
  .to-top { bottom: 16px; width: 48px; min-height: 48px; padding: 0; justify-content: center; font-size: 20px; }
  .to-top span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .anchor, .to-top, .toc summary::after { transition: none; }
}

/* Печать: только документ, чёрным по белому */
@media print {
  @page { margin: 18mm 16mm 20mm; }
  html, body, .legal { background: #fff !important; color: #000 !important; }
  .skip, .bar, .doc-switch, .doc-print, .toc, .to-top, .foot, .anchor { display: none !important; }
  .doc-head { background: none !important; color: #000 !important; padding: 0 0 6mm; border-bottom: 1.5pt solid #000; }
  .doc-head::before { content: "Secret Voicer · secretvoicer.ru"; display: block; margin-bottom: 4mm; font: 600 9pt/1 var(--text); }
  .doc-head h1 { font-size: 30pt; line-height: 1; max-width: none; margin-bottom: 3mm; }
  .doc-head__sub { font-size: 12pt; }
  .doc-head__meta { color: #000; border: 0; padding: 0; margin-top: 3mm; font-size: 9.5pt; }
  .doc-head__meta span { display: inline; }
  .doc-head__br { display: none; }
  .doc { display: block; padding: 6mm 0 0; max-width: none; }
  .doc__text { max-width: none; font-size: 10.5pt; line-height: 1.45; }
  .part + .part { margin-top: 6mm; }
  .part h2 { font-size: 15pt; border-bottom-width: 1pt; padding-bottom: 1.5mm; margin-bottom: 3mm; break-after: avoid; page-break-after: avoid; }
  .part h2 .num { color: #000; }
  .doc__text p, .doc__text li { orphans: 3; widows: 3; }
  .doc__text p:target, .doc__text dl:target { background: none; box-shadow: none; }
  .req { break-inside: avoid; border-color: #999; }
}
