/* ==========================================================================
   Экран «Правила» (11.5)
   Статичная страница: оглавление слева (якоря) + читаемый текст ~720px.
   Только токены из tokens.css, компоненты из app.css, анимации из motion.css.
   ========================================================================== */

/* Полноширинный каркас без форумного сайдбара — центрируем колонку чтения */
.layout.layout-wide { max-width: 1040px; justify-content: center; }

.rules {
  flex: 1;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* --- Шапка экрана --- */
.rl-hero { display: flex; flex-direction: column; gap: 8px; }
.rl-hero .strip { margin-bottom: 2px; }
.rl-hero h1 { font-size: 26px; line-height: 1.15; }
.rl-lede { font-size: 14px; line-height: 1.55; max-width: 620px; }
.rl-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.rl-meta .badge { padding: 4px 10px; }

/* --- Раскладка: оглавление + текст --- */
.rl-body {
  display: flex;
  gap: 40px;
  align-items: flex-start;
}

/* ==========================================================================
   Оглавление (якоря)
   ========================================================================== */
.rl-toc {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rl-toc-label {
  font-size: 10.5px;
  color: var(--text-3);
  margin: 0 0 8px 12px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
}
.rl-toc-item {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r);
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.rl-toc-n {
  font-size: 11px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  transition: color var(--dur-fast) var(--ease);
}
.rl-toc-item:hover {
  background: var(--s2);
  color: var(--text);
  border-left-color: var(--border-2);
}
.rl-toc-item:hover .rl-toc-n { color: var(--pink); }
.rl-toc-support {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 0 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--pink);
  cursor: pointer;
}
.rl-toc-support .ico { color: var(--pink); }
.rl-toc-support:hover { color: var(--text); }

/* ==========================================================================
   Статья
   ========================================================================== */
.rl-article {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}
.rl-sec {
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-margin-top: 88px;
}
.rl-sec-head { display: flex; align-items: center; gap: 12px; }
.rl-num {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 500;
  color: var(--pink);
  background: var(--pink-soft);
  border-radius: var(--r);
  padding: 4px 9px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.rl-sec-head h2 { font-size: 19px; line-height: 1.2; }

/* --- Читаемый текст --- */
.rl-prose { display: flex; flex-direction: column; gap: 12px; }
.rl-prose p {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text-2);
}
.rl-prose b { color: var(--text); font-weight: 600; }
.rl-intro { color: var(--text-2); font-size: 14px; line-height: 1.6; }

/* --- Круглая иконка-плашка (переиспользуется в принципах, ветках, апелляции) --- */
.rl-pic {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rl-pic .ico { width: 21px; height: 21px; }
.rl-pic.pink   { background: var(--pink-soft);   color: var(--pink); }
.rl-pic.violet { background: var(--violet-soft); color: var(--violet); }
.rl-pic.blue   { background: var(--blue-soft);   color: var(--blue); }
.rl-pic.amber  { background: var(--amber-soft);  color: var(--warn-text); }
.rl-pic.green  { background: var(--green-soft);  color: var(--ok-text); }

/* ==========================================================================
   02 Принципы — сетка карточек
   ========================================================================== */
.rl-principles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.rl-principle {
  display: flex;
  gap: 13px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 16px;
}
.rl-principle-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.rl-principle-text h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.rl-principle-text p { font-size: 12.5px; line-height: 1.55; color: var(--text-2); }

/* ==========================================================================
   03 Что запрещено — нумерованный список
   ========================================================================== */
.rl-bans, .rl-steps, .rl-log { list-style: none; }
.rl-bans {
  display: flex;
  flex-direction: column;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
}
.rl-ban {
  display: flex;
  gap: 13px;
  padding: 15px 16px;
  align-items: flex-start;
}
.rl-ban + .rl-ban { border-top: 1px solid var(--border); }
.rl-ban-n {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.rl-ban-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rl-ban-text h3 { font-size: 13.5px; font-weight: 600; color: var(--text); }
.rl-ban-text p { font-size: 12.5px; line-height: 1.55; color: var(--text-2); }

/* ==========================================================================
   04 Модерация — шаги + пороги + апелляция
   ========================================================================== */
.rl-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rl-step {
  display: flex;
  gap: 14px;
  position: relative;
  padding-bottom: 18px;
}
/* соединительная линия между шагами */
.rl-step::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 30px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.rl-step:last-child { padding-bottom: 0; }
.rl-step:last-child::before { display: none; }
.rl-step-n {
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: var(--s3);
  border: 1px solid var(--border-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  flex-shrink: 0;
  z-index: 1;
}
.rl-step-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-top: 3px; }
.rl-step-text h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.rl-step-text p { font-size: 13px; line-height: 1.6; color: var(--text-2); }
.rl-step-text b { color: var(--text); font-weight: 600; }

/* Пороги баллов */
.rl-thresholds {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 4px;
}
.rl-thresh {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 13px 14px;
}
.rl-thresh-n {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 3px;
}
.rl-thresh-n.amber  { color: var(--warn-text); }
.rl-thresh-n.danger { color: var(--danger-text); }
.rl-thresh-label { font-size: 11px; color: var(--text-3); }
.rl-thresh-cons {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.35;
  margin-top: 3px;
}

/* Апелляция */
.rl-appeal {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--green-soft);
  border: 1px solid transparent;
  border-radius: var(--r-card);
  padding: 16px;
  margin-top: 4px;
}
.rl-appeal-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.rl-appeal-text h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.rl-appeal-text p { font-size: 12.5px; line-height: 1.55; color: var(--text-2); }
.rl-appeal-btn { flex-shrink: 0; white-space: nowrap; }

/* ==========================================================================
   05 Ветки
   ========================================================================== */
.rl-branches { display: flex; flex-direction: column; gap: 10px; }
.rl-branch {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 15px 16px;
}
.rl-branch-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rl-branch-text h3 { font-size: 14px; font-weight: 600; color: var(--text); }
.rl-branch-text p { font-size: 12.5px; line-height: 1.6; color: var(--text-2); }

/* ==========================================================================
   06 История изменений — таймлайн
   ========================================================================== */
.rl-log {
  display: flex;
  flex-direction: column;
}
.rl-log-item {
  display: flex;
  gap: 16px;
  position: relative;
  padding-bottom: 18px;
}
.rl-log-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 16px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.rl-log-item:last-child { padding-bottom: 0; }
.rl-log-item:last-child::before { display: none; }
.rl-log-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--s3);
  border: 2px solid var(--border-2);
  flex-shrink: 0;
  margin-top: 4px;
  z-index: 1;
}
.rl-log-item.is-current .rl-log-dot {
  background: var(--pink);
  border-color: var(--pink-soft);
}
.rl-log-content { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rl-log-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rl-log-ver { font-size: 13px; font-weight: 600; color: var(--text); }
.rl-log-content p { font-size: 12.5px; line-height: 1.55; color: var(--text-2); }

/* ==========================================================================
   Motion: staged entrance, scroll reveal and anchor feedback
   ========================================================================== */
@keyframes rl-anchor-arrive {
  0% { opacity: 0.35; transform: translateX(-12px); }
  48% { opacity: 1; transform: translateX(3px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes rl-number-pulse {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  42% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--pink) 15%, transparent); }
}

.rules.rules-motion .rl-hero,
.rules.rules-motion .rl-toc {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity 0.64s var(--ease-out),
    transform 0.64s var(--ease-out);
  will-change: opacity, transform;
}

.rules.rules-motion .rl-hero.is-visible,
.rules.rules-motion .rl-toc.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.rules.rules-motion .rl-hero > *,
.rules.rules-motion .rl-toc > * {
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.48s var(--ease-out),
    transform 0.48s var(--ease-out);
}

.rules.rules-motion .rl-hero.is-visible > *,
.rules.rules-motion .rl-toc.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}

.rules.rules-motion .rl-hero.is-visible > :nth-child(2),
.rules.rules-motion .rl-toc.is-visible > :nth-child(2) { transition-delay: 0.06s; }
.rules.rules-motion .rl-hero.is-visible > :nth-child(3),
.rules.rules-motion .rl-toc.is-visible > :nth-child(3) { transition-delay: 0.12s; }
.rules.rules-motion .rl-hero.is-visible > :nth-child(4),
.rules.rules-motion .rl-toc.is-visible > :nth-child(4) { transition-delay: 0.18s; }
.rules.rules-motion .rl-toc.is-visible > :nth-child(5) { transition-delay: 0.24s; }
.rules.rules-motion .rl-toc.is-visible > :nth-child(6) { transition-delay: 0.3s; }
.rules.rules-motion .rl-toc.is-visible > :nth-child(7) { transition-delay: 0.36s; }
.rules.rules-motion .rl-toc.is-visible > :nth-child(8) { transition-delay: 0.42s; }

.rules.rules-motion .rl-sec[data-reveal] {
  opacity: 1;
  transform: none;
  transition: none;
}

.rules.rules-motion .rl-sec > *,
.rules.rules-motion .rl-principle,
.rules.rules-motion .rl-ban,
.rules.rules-motion .rl-step,
.rules.rules-motion .rl-thresh,
.rules.rules-motion .rl-branch,
.rules.rules-motion .rl-log-item {
  opacity: 0;
  transform: translateY(16px) scale(0.988);
  transition:
    opacity 0.52s var(--ease-out),
    transform 0.62s var(--ease-out),
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}

.rules.rules-motion .rl-sec.is-visible > *,
.rules.rules-motion .rl-sec.is-visible .rl-principle,
.rules.rules-motion .rl-sec.is-visible .rl-ban,
.rules.rules-motion .rl-sec.is-visible .rl-step,
.rules.rules-motion .rl-sec.is-visible .rl-thresh,
.rules.rules-motion .rl-sec.is-visible .rl-branch,
.rules.rules-motion .rl-sec.is-visible .rl-log-item {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.rules.rules-motion .rl-sec.is-visible > :nth-child(2) { transition-delay: 0.08s; }
.rules.rules-motion .rl-sec.is-visible > :nth-child(3) { transition-delay: 0.14s; }
.rules.rules-motion .rl-sec.is-visible > :nth-child(4) { transition-delay: 0.2s; }

.rules.rules-motion .rl-sec.is-visible :is(.rl-principle, .rl-ban, .rl-step, .rl-thresh, .rl-branch, .rl-log-item):nth-child(1) { transition-delay: 0.16s; }
.rules.rules-motion .rl-sec.is-visible :is(.rl-principle, .rl-ban, .rl-step, .rl-thresh, .rl-branch, .rl-log-item):nth-child(2) { transition-delay: 0.22s; }
.rules.rules-motion .rl-sec.is-visible :is(.rl-principle, .rl-ban, .rl-step, .rl-thresh, .rl-branch, .rl-log-item):nth-child(3) { transition-delay: 0.28s; }
.rules.rules-motion .rl-sec.is-visible :is(.rl-principle, .rl-ban, .rl-step, .rl-thresh, .rl-branch, .rl-log-item):nth-child(4) { transition-delay: 0.34s; }
.rules.rules-motion .rl-sec.is-visible :is(.rl-principle, .rl-ban, .rl-step, .rl-thresh, .rl-branch, .rl-log-item):nth-child(5) { transition-delay: 0.4s; }
.rules.rules-motion .rl-sec.is-visible :is(.rl-principle, .rl-ban, .rl-step, .rl-thresh, .rl-branch, .rl-log-item):nth-child(6) { transition-delay: 0.46s; }
.rules.rules-motion .rl-sec.is-visible :is(.rl-principle, .rl-ban, .rl-step, .rl-thresh, .rl-branch, .rl-log-item):nth-child(7) { transition-delay: 0.52s; }

.rl-toc-item.is-active {
  color: var(--text);
  background: var(--pink-soft);
  border-left-color: var(--pink);
}

.rl-toc-item.is-active .rl-toc-n { color: var(--pink); }

.rl-sec.is-arriving .rl-sec-head {
  animation: rl-anchor-arrive 0.72s var(--ease-out) both;
}

.rl-sec.is-arriving .rl-num {
  animation: rl-number-pulse 0.9s var(--ease-out) both;
}

.rl-principle:hover,
.rl-thresh:hover,
.rl-branch:hover,
.rules.rules-motion .rl-sec.is-visible .rl-principle:hover,
.rules.rules-motion .rl-sec.is-visible .rl-thresh:hover,
.rules.rules-motion .rl-sec.is-visible .rl-branch:hover {
  border-color: var(--border-2);
  box-shadow: 0 10px 28px rgb(0 0 0 / 8%);
  transform: translateY(-2px);
}

/* ==========================================================================
   Мобильная адаптивность
   ========================================================================== */
@media (max-width: 760px) {
  .layout.layout-wide { justify-content: flex-start; }
  .rules { gap: 20px; }
  .rl-hero h1 { font-size: 22px; }
  .rl-lede { font-size: 13px; }

  .rl-body { flex-direction: column; gap: 18px; min-width: 0; }

  /* Оглавление -> горизонтальный скролл-ряд чипов */
  .rl-toc {
    position: static;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 0 2px;
  }
  .rl-toc::-webkit-scrollbar { display: none; }
  .rl-toc-label { display: none; }
  .rl-toc-item {
    flex-shrink: 0;
    border: 1px solid var(--border-2);
    border-left: 1px solid var(--border-2);
    border-radius: var(--r-chip);
    padding: 9px 14px;
    min-height: 40px;
    align-items: center;
    white-space: nowrap;
  }
  .rl-toc-item:hover { border-left-color: var(--border-2); }
  .rl-toc-support {
    flex-shrink: 0;
    margin: 0;
    padding: 9px 14px;
    border-top: none;
    border: 1px solid var(--border-2);
    border-radius: var(--r-chip);
    min-height: 40px;
    white-space: nowrap;
  }

  .rl-article { max-width: none; gap: 34px; }
  .rl-sec-head h2 { font-size: 17px; }
  .rl-prose p { font-size: 14px; }

  .rl-principles { grid-template-columns: 1fr; }
  .rl-thresholds { grid-template-columns: 1fr; }
  .rl-thresh {
    flex-direction: row;
    align-items: center;
    gap: 12px;
  }
  .rl-thresh-n { margin-bottom: 0; font-size: 20px; }
  .rl-thresh-cons { margin-top: 0; margin-left: auto; text-align: right; }

  .rl-appeal { flex-direction: column; align-items: flex-start; }
  .rl-appeal-btn { width: 100%; text-align: center; }

  .rl-toc-item.is-active {
    border-color: var(--pink);
    border-left-color: var(--pink);
  }
}

@media (prefers-reduced-motion: reduce) {
  .rules.rules-motion .rl-hero,
  .rules.rules-motion .rl-toc,
  .rules.rules-motion .rl-hero > *,
  .rules.rules-motion .rl-toc > *,
  .rules.rules-motion .rl-sec > *,
  .rules.rules-motion .rl-principle,
  .rules.rules-motion .rl-ban,
  .rules.rules-motion .rl-step,
  .rules.rules-motion .rl-thresh,
  .rules.rules-motion .rl-branch,
  .rules.rules-motion .rl-log-item {
    opacity: 1;
    transform: none;
    transition: none;
    animation: none;
  }
}

@media (forced-colors: active) {
  .rl-toc-item.is-active { border-color: Highlight; }
}
