/* Правила ТАК — только внутри #page-rules, без глобальных переопределений */

body.rules-full-view .site-header {
  position: static;
}

.rules-full-page {
  padding: 0 0 clamp(2rem, 6vw, 3rem);
}

.rules-full-toolbar,
.rules-full-wrap {
  max-width: min(1180px, calc(100% - 1.25rem));
  margin-inline: auto;
}

/* ── Прикреплённая зона: только поиск ── */
.rules-full-toolbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 95;
  padding: 0.4rem var(--page-gutter, 1rem) 0.35rem;
  background: linear-gradient(180deg, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.rules-full-sticky-row {
  display: flex;
  align-items: center;
}

.rules-full-search-wrap {
  flex: 0 0 clamp(148px, 22vw, 240px);
  max-width: 240px;
  margin: 0;
}

.rules-full-search-wrap .search-icon {
  left: 0.55rem;
  font-size: 0.95rem;
  opacity: 0.55;
}

.rules-full-search-input {
  padding: 0.35rem 1.85rem 0.35rem 1.75rem;
  font-size: 0.875rem;
  min-height: 34px;
  line-height: 1.3;
}

.rules-full-search-clear {
  position: absolute;
  right: 0.2rem;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.rules-full-search-clear:hover {
  color: var(--gold);
  background: rgba(212, 168, 75, 0.1);
}

.rules-full-search-results {
  max-height: min(50vh, 300px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.rules-full-search-results .rules-full-result {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
}

.rules-full-search-empty {
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.rules-full-search-hint {
  margin: 0.2rem 0 0;
  padding: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.rules-full-search-hint[hidden] {
  display: none;
}

.rules-search-flash {
  animation: rules-search-flash 2s ease-out;
}

@keyframes rules-search-flash {
  0%, 15% { box-shadow: 0 0 0 3px rgba(212, 168, 75, 0.55); }
  100% { box-shadow: none; }
}

/* ── Содержание: вертикальное меню в потоке контента ── */
.rules-full-wrap nav.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1.75rem;
}

.rules-full-wrap nav.toc .label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.65rem;
}

.rules-full-wrap nav.toc .chips {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rules-full-wrap .toc-chip {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  touch-action: manipulation;
}

.rules-full-wrap .toc-chip:hover {
  background: var(--teal-soft);
  color: var(--teal);
}

/* ── Видео правил (Kinescope, вертикальное 9:16) ── */
.rules-full-video {
  max-width: min(1180px, calc(100% - 1.25rem));
  margin: 0.75rem auto 0;
  padding: 0 1rem;
}

.rules-full-video-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.rules-full-video-card {
  width: min(100%, calc(min(70vh, 560px) * 9 / 16), 380px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.rules-full-video-frame {
  position: relative;
  aspect-ratio: 9 / 16;
  background: #000;
}

.rules-full-video-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.rules-full-video-mobile-label {
  margin: 0;
  padding: 0.65rem 0.9rem 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.4;
  text-align: center;
  color: var(--text-muted);
}

.rules-full-video-intro {
  display: none;
}

/* Desktop: двухколоночный hero — видео слева, intro справа */
@media (min-width: 768px) {
  .rules-full-video-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: clamp(1.5rem, 4vw, 2.75rem);
  }

  .rules-full-video-card {
    width: min(100%, calc(min(75vh, 580px) * 9 / 16), 340px);
    justify-self: center;
  }

  .rules-full-video-mobile-label {
    display: none;
  }

  .rules-full-video-intro {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0;
    min-width: 0;
  }

  .rules-full-video-intro header {
    padding: 0 0 0.85rem;
  }

  .rules-full-video-intro header h1 {
    margin: 0;
    font-size: clamp(1.5rem, 2.2vw, 2rem);
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
  }

  .rules-full-video-intro .gold-bar {
    width: 56px;
    height: 3px;
    background: var(--gold);
    border-radius: 2px;
    margin-top: 10px;
  }

  .rules-full-video-intro .welcome {
    background: var(--teal-soft);
    border: 1px solid var(--border);
    border-left: 3px solid var(--teal);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 1rem 1.15rem;
    font-size: 0.95rem;
    line-height: 1.65;
    color: var(--text-muted);
  }

  /* Intro уже в hero — не дублируем в контенте */
  .rules-full-wrap > .wrap > header,
  .rules-full-wrap > .wrap > .welcome {
    display: none;
  }
}

/* ── Контент правил в стиле сайта ── */
.rules-full-wrap {
  padding: 0 1rem 2rem;
  color: var(--text);
  font-family: var(--font);
}

.rules-full-wrap .wrap {
  max-width: none;
  margin: 0;
}

.rules-full-wrap header {
  padding: 1.25rem 0 0.85rem;
}

.rules-full-wrap header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.rules-full-wrap .gold-bar {
  width: 56px;
  height: 3px;
  background: var(--gold);
  border-radius: 2px;
  margin-top: 10px;
}

.rules-full-wrap .welcome {
  background: var(--teal-soft);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.15rem;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.rules-full-wrap .section {
  margin: 2.5rem 0;
  scroll-margin-top: calc(var(--rules-sticky-h, 52px) + 10px);
}

.rules-full-wrap .section h2 {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.rules-full-wrap .stats {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 1.25rem;
}

.rules-full-wrap .stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 140px;
}

.rules-full-wrap .stat .sv {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}

.rules-full-wrap .stat .sl {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.rules-full-wrap .rule-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
}

.rules-full-wrap .rule-label {
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.rules-full-wrap .subhead {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.rules-full-wrap .label {
  margin: 8px 0 4px;
  font-weight: 600;
  color: var(--text);
  font-size: 0.95rem;
}

.rules-full-wrap .body {
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.7;
}

.rules-full-wrap .bullet {
  margin: 0 0 4px 8px;
  font-size: 0.95rem;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  line-height: 1.65;
}

.rules-full-wrap .bullet .mark {
  color: var(--gold);
  flex-shrink: 0;
  opacity: 0.7;
}

.rules-full-wrap .spacer {
  height: 8px;
}

.rules-full-wrap .intro-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}

.rules-full-wrap details.card-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--bg-card);
}

.rules-full-wrap details.card-block summary {
  padding: 12px 16px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  color: var(--gold);
  touch-action: manipulation;
}

.rules-full-wrap details.card-block summary::-webkit-details-marker {
  display: none;
}

.rules-full-wrap details.card-block summary::before {
  content: "▸";
  margin-right: 8px;
  color: var(--gold);
  transition: transform 0.15s;
}

.rules-full-wrap details.card-block[open] summary::before {
  transform: rotate(90deg);
}

.rules-full-wrap .card-body {
  padding: 4px 16px 14px 28px;
  border-top: 1px solid var(--border);
}

.rules-full-wrap .glossary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
}

.rules-full-wrap .gloss-row {
  display: grid;
  grid-template-columns: minmax(140px, 180px) 1fr;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.rules-full-wrap .gloss-row:last-child {
  border-bottom: none;
}

.rules-full-wrap .gloss-term {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--gold);
}

.rules-full-wrap .gloss-def {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.rules-full-wrap .footer {
  text-align: center;
  font-weight: 600;
  padding: 1.25rem 1rem;
  background: var(--teal-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

@media print {
  .rules-full-video {
    display: none;
  }
  .rules-full-toolbar {
    position: static;
  }
  .rules-full-wrap .toc-chip {
    font-size: 11px;
    padding: 4px 8px;
  }
  .rules-full-wrap details.card-block {
    break-inside: avoid;
  }
  .rules-full-wrap .section {
    break-inside: avoid-page;
  }
}

/* ── Mobile ── */
@media (max-width: 767px) {
  .rules-full-page {
    padding-bottom: 2rem;
  }

  .rules-full-toolbar,
  .rules-full-wrap,
  .rules-full-video {
    max-width: 100%;
  }

  .rules-full-video {
    margin-top: 0.5rem;
    padding: 0 0.85rem;
  }

  .rules-full-video-card {
    width: min(100%, calc(min(65vh, 520px) * 9 / 16), 340px);
  }

  .rules-full-video-mobile-label {
    font-size: 0.78rem;
    padding: 0.6rem 0.75rem 0.7rem;
  }

  .rules-full-toolbar {
    padding: 0.35rem var(--page-gutter, 1rem) 0.3rem;
  }

  .rules-full-sticky-row {
    flex-direction: column;
    align-items: stretch;
  }

  .rules-full-search-wrap {
    flex: none;
    max-width: none;
    width: 100%;
  }

  .rules-full-search-input {
    font-size: 16px;
    min-height: 36px;
  }

  .rules-full-wrap {
    padding: 0 0.85rem 1.5rem;
  }

  .rules-full-wrap header {
    padding: 1rem 0 0.65rem;
  }

  .rules-full-wrap header h1 {
    font-size: clamp(1.35rem, 5.5vw, 1.65rem);
  }

  .rules-full-wrap .welcome {
    padding: 12px 14px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
  }

  .rules-full-wrap nav.toc {
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
  }

  .rules-full-wrap .toc-chip {
    padding: 0.5rem 0.6rem;
    font-size: 0.88rem;
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  .rules-full-wrap .section {
    margin: 2rem 0;
    scroll-margin-top: calc(var(--rules-sticky-h, 78px) + 8px);
  }

  .rules-full-wrap .section h2 {
    font-size: 1.05rem;
    padding: 12px 14px;
  }

  .rules-full-wrap .stats {
    flex-direction: column;
    gap: 8px;
  }

  .rules-full-wrap .stat {
    min-width: 0;
    width: 100%;
    padding: 10px 12px;
  }

  .rules-full-wrap .rule-block {
    padding: 12px 14px;
    margin-bottom: 10px;
  }

  .rules-full-wrap .subhead,
  .rules-full-wrap .body,
  .rules-full-wrap .bullet {
    font-size: 0.9rem;
  }

  .rules-full-wrap details.card-block summary {
    padding: 14px 12px;
    min-height: 44px;
  }

  .rules-full-wrap .card-body {
    padding: 4px 12px 12px 20px;
  }

  .rules-full-wrap .gloss-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px 0;
  }

  .rules-full-wrap .gloss-term {
    font-size: 0.9rem;
  }

  .rules-full-wrap .gloss-def {
    font-size: 0.88rem;
  }

  .rules-full-wrap .footer {
    padding: 16px 12px;
    font-size: 0.9rem;
    margin-top: 1.5rem;
  }

  .rules-full-search-results {
    max-height: min(45vh, 260px);
  }
}
