/* BackToTop v3 — общая кнопка «Наверх» для MODX.
   Стандартно: [[$BackToTop]] внутри .container.
   У нижнего левого края ВСЕЙ секции:
     <section class="section section--back-corner">
       <div class="container">...</div>
       [[$BackToTop]]
     </section>
   JS back-to-top.js не меняется.
*/

/* Стандартная кнопка — в потоке после контента */
.back-to-top-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 30px;
}

.back-to-top-link {
  box-sizing: border-box;
  display: inline-flex;
  flex: 0 0 46px;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid #cad6ce;
  border-radius: 50%;
  background-color: #fff;
  color: var(--primary, #214c3b);
  box-shadow: 0 4px 14px rgba(21, 52, 38, 0.12);
  text-decoration: none;
  line-height: 1;
  opacity: 1;
  transition: background-color .2s ease, color .2s ease,
              border-color .2s ease, transform .2s ease;
}

.back-to-top-icon {
  display: block;
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  color: inherit;
}

@media (hover: hover) and (pointer: fine) {
  .back-to-top-link:hover {
    background-color: var(--primary, #214c3b);
    color: #fff;
    border-color: var(--primary, #214c3b);
    transform: translateY(-2px);
  }
}

.back-to-top-link:focus-visible {
  outline: 3px solid var(--accent, #88a77d);
  outline-offset: 3px;
}

/* Угол секции: контент остаётся в .container, стрелка — вне его.
   При этом никакого нижнего padding под стрелкой. display:flex и
   margin-top:auto позволяют разместить стрелку в самом низу даже
   у секций с min-height (и при этом не перекрывать содержимое).
*/
.section.section--back-corner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding-bottom: 0;
}

.section.section--back-corner > .back-to-top-row {
  position: static;
  inset: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex: 0 0 auto;
  width: 100%;
  margin: auto 0 0;
  padding: 24px 0 0;
}
/* Обычные секции со стрелкой */
.section:has(> .back-to-top-row) {
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

/* Стрелка вне container, внизу секции */
.section:has(> .back-to-top-row) > .back-to-top-row {
  position: static;
  flex: 0 0 auto;
  width: 100%;
  margin: auto 0 0;
  padding: 16px 0 0;
}

/* Полноширинные split-section */
.split-section:has(> .back-to-top-row) {
  position: relative;
}

.split-section:has(> .back-to-top-row) > .back-to-top-row {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 3;
  margin: 0;
  padding: 0;
}
/* Обычная секция .section */
.section:has(> .back-to-top-row) > .back-to-top-row {
  padding: 16px 0 12px 12px;
}

/* Полноширинная секция .split-section */
.split-section:has(> .back-to-top-row) > .back-to-top-row {
  left: 12px;
  bottom: 12px;
  padding: 0;
}

/* На время 500-мс JS-анимации отключаем стандартный scroll-behavior:smooth. */
html.is-back-to-top-scrolling {
  scroll-behavior: auto !important;
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top-link { transition: none; }
}
