/* ============================================================
   ПАПЕРКА — база: сброс, типографика, утилиты, rich-text
   Подключается после tokens.css
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* отступ при переходе по якорю — под залипающий хедер */
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* страховка от горизонтального скролла; clip (а не hidden) не ломает sticky */
  overflow-x: clip;
}

/* место под нижнюю мобильную навигацию */
@media (max-width: 899px) {
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  /* длинные слова не должны рвать вёрстку на 360px */
  /* рвём слово только если оно само не влезает, а не где попало */
  overflow-wrap: break-word;
  word-break: normal;
  text-wrap: balance;
  text-wrap: balance;
}
h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); line-height: var(--lh-snug); }
h4 { font-size: var(--fs-md); line-height: var(--lh-snug); }

p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-700); text-decoration: none; }
a:hover { color: var(--brand-600); }

ul, ol { margin: 0 0 var(--sp-4); padding-left: 1.3em; }
li + li { margin-top: var(--sp-1); }

img, picture, video, svg { display: block; max-width: 100%; }
img { height: auto; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

table { border-collapse: collapse; }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-7) 0; }

strong, b { font-weight: 650; }

::selection { background: var(--brand-100); color: var(--ink); }

/* --- фокус: видимый всегда, но без рамки на мышиный клик --- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* --- скрытое для глаз, доступное для скринридеров --- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* --- ссылка «К содержимому» --- */
.skip-link {
  position: fixed;
  top: var(--sp-2);
  left: var(--sp-2);
  z-index: 500;
  padding: 12px 18px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r-md);
  font-weight: 600;
  box-shadow: var(--sh-3);
  transform: translateY(-160%);
  transition: transform var(--t);
}
.skip-link:focus-visible { transform: translateY(0); color: #fff; }

/* --- утилиты --- */
.u-mt-0 { margin-top: 0; }
.u-mb-0 { margin-bottom: 0; }
.u-center { text-align: center; }
.u-nowrap { white-space: nowrap; }
.u-muted { color: var(--ink-500); }
.u-small { font-size: var(--fs-sm); }
.is-hidden { display: none !important; }

/* --- появление секций (IntersectionObserver добавляет .is-in) --- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--t-slow), transform var(--t-slow);
  will-change: opacity, transform;
}
.reveal.is-in { opacity: 1; transform: none; }
/* если JS не сработал — контент всё равно виден */
.no-js .reveal, html:not(.js) .reveal { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1 !important; transform: none !important; }
}

/* ============================================================
   RICH-TEXT — HTML из базы (описания услуг, новости, статьи, FAQ)
   Задача: любой вложенный мусор выглядит опрятно и не ломает мобильную вёрстку
   ============================================================ */
.rich-text {
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--ink-700);
  overflow-wrap: break-word;
}
.rich-text > :first-child { margin-top: 0; }
.rich-text > :last-child { margin-bottom: 0; }

.rich-text p { margin: 0 0 var(--sp-4); }
.rich-text h2, .rich-text h3, .rich-text h4 {
  margin: var(--sp-7) 0 var(--sp-3);
  color: var(--ink);
}
.rich-text h2 { font-size: var(--fs-lg); }
.rich-text h3 { font-size: var(--fs-md); }
.rich-text h4 { font-size: var(--fs-base); }

.rich-text strong { color: var(--ink); font-weight: 650; }

.rich-text ul, .rich-text ol { margin: 0 0 var(--sp-4); padding-left: 1.25em; }
.rich-text li { margin-bottom: var(--sp-2); }
.rich-text ul li::marker { color: var(--brand); }

.rich-text a { color: var(--brand-700); text-decoration: underline; text-underline-offset: 2px; }
.rich-text a:hover { color: var(--brand-600); }

.rich-text img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-md);
  margin: var(--sp-4) 0;
  background: var(--surface);
}

.rich-text blockquote {
  margin: var(--sp-5) 0;
  padding: var(--sp-4) var(--sp-5);
  border-left: 3px solid var(--brand);
  background: var(--brand-50);
  border-radius: 0 var(--r-md) var(--r-md) 0;
}

/* таблицы внутри описаний — JS оборачивает их в .table-scroll */
.table-scroll {
  margin: var(--sp-5) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--bg);
}
.rich-text table {
  width: 100%;
  min-width: 420px;
  font-size: var(--fs-sm);
  background: var(--bg);
}
.rich-text table th,
.rich-text table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.rich-text table th { background: var(--surface-2); font-weight: 650; color: var(--ink); }
.rich-text table tr:first-child td { background: var(--surface); font-weight: 600; color: var(--ink); }
.rich-text table td:last-child,
.rich-text table th:last-child { border-right: 0; }
.rich-text table tr:last-child td { border-bottom: 0; }
.rich-text table p { margin: 0; }

/* подсказка «таблица скроллится» */
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
