/* Боковые слоты рекламы ATLAS — место под баннеры (AdSense и т.п.). */
:root {
  /* Колонка контента — должна совпадать с max-width секций на страницах */
  --atlas-content-max: 880px;
  --atlas-ad-slot: 160px;
  --atlas-ad-gap: 1.25rem;
}

.atlas-ad-rail {
  position: fixed;
  top: 5.75rem;
  z-index: 12;
  width: var(--atlas-ad-slot);
  max-height: calc(100vh - 7rem);
  pointer-events: none;
}

.atlas-ad-rail--left {
  left: max(
    0.5rem,
    calc((100vw - var(--atlas-content-max)) / 2 - var(--atlas-ad-slot) - var(--atlas-ad-gap))
  );
}

.atlas-ad-rail--right {
  right: max(
    0.5rem,
    calc((100vw - var(--atlas-content-max)) / 2 - var(--atlas-ad-slot) - var(--atlas-ad-gap))
  );
}

/*
  Пустой слот невидим. Появляется, когда:
  — добавили класс is-filled, или
  — внутри есть iframe / AdSense (ins) / картинка / видео.
*/
.atlas-ad-slot {
  display: none;
  pointer-events: auto;
  align-items: center;
  justify-content: center;
  width: var(--atlas-ad-slot);
  min-height: 600px;
  max-height: calc(100vh - 7rem);
  border-radius: 4px;
  overflow: hidden;
}

.atlas-ad-slot.is-filled,
.atlas-ad-slot:has(iframe, ins, img, video, object, embed) {
  display: flex;
}

.atlas-ad-slot > * {
  max-width: 100%;
}

/* Плейсхолдер «Реклама» не показываем */
.atlas-ad-slot > span:only-child {
  display: none;
}

/*
  Скрываем рельсы, пока не хватает места под колонку + два слота:
  880 + 2×(160 + 20) ≈ 1240 → порог 1360 с запасом от края.
*/
@media (max-width: 1359px) {
  .atlas-ad-rail {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .atlas-ad-rail {
    scroll-margin: 0;
  }
}
