/* Секция «География» — карта стран присутствия (перенос с брендовыми цветами REDIT) */
.geo-section#geo {
  /* Отступ под шапку задаётся только scroll-padding на html — без второго scroll-margin */
  scroll-margin-top: 0;
  /* Чётче граница блока на лендинге — секция читается как отдельный модуль */
  outline: 1px solid rgba(255, 26, 31, 0.16);
  outline-offset: -1px;
  /* После scrollIntoView(block:start) — меньше «пустого» поля между шапкой и заголовком */
  padding-top: clamp(12px, 2.4vh, 28px);
  padding-bottom: clamp(24px, 4.5vh, 52px);
}

.geo-section {
  --geo-accent: var(--red, #e90408);
  --geo-accent-bright: var(--red-bright, #ff1a1f);
  --geo-surface: var(--surface, #121417);
  --geo-bg: var(--bg-deep, #050506);
  --geo-line: rgba(233, 4, 8, 0.12);
  --geo-line-strong: rgba(255, 26, 31, 0.22);
  --geo-glow: rgba(233, 4, 8, 0.06);
  /* Короче по вертикали — заголовок + карта + теги + цифры чаще помещаются в один экран */
  --geo-map-max-h: min(38dvh, 340px);
  background: var(--geo-bg);
  padding: clamp(24px, 4.5vh, 52px) 0;
  position: relative;
  z-index: 10;
  border-top: 1px solid var(--geo-line);
  border-bottom: 1px solid var(--geo-line);
  overflow: visible;
}

.geo-section::before {
  content: '';
  position: absolute;
  top: -20%;
  left: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--geo-glow) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.geo-section::after {
  content: '';
  position: absolute;
  bottom: -10%;
  right: -5%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(233, 4, 8, 0.04) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.geo-container {
  box-sizing: border-box;
  width: 100%;
  max-width: var(--site-max, 1180px);
  margin: 0 auto;
  padding-inline: var(--gutter, 14px) var(--gutter-r, 14px);
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: stretch;
  align-content: start;
}

.geo-header {
  text-align: left;
  margin-bottom: clamp(10px, 2vh, 18px);
  width: 100%;
  min-width: 0;
}

.geo-header .section__label {
  margin-bottom: 10px;
}

/* Заголовок блока — те же классы, что у секций (.section__*); здесь только отличия гео-блока */
.geo-header .section__title.geo-title {
  text-transform: uppercase;
  letter-spacing: -0.03em;
  line-height: 1.08;
  font-size: clamp(1.35rem, 2.6vw + 0.55rem, 2.35rem);
  margin-bottom: 0.35em;
  max-width: min(42rem, 100%);
  text-shadow: 0 0 24px rgba(233, 4, 8, 0.18);
}

.geo-title span {
  color: var(--geo-accent-bright);
  position: relative;
  display: inline-block;
}

.geo-title span::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 0;
  width: 100%;
  height: 5px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, rgba(233, 4, 8, 0.42), transparent);
  box-shadow: 0 0 20px rgba(233, 4, 8, 0.35);
  z-index: -1;
}

.geo-header .section__subtitle.geo-lead {
  margin-top: 0;
  margin-bottom: clamp(6px, 1.2vh, 14px);
  font-size: clamp(0.875rem, 1.35vw + 0.35rem, 1rem);
}

/* Карта: отдельная «карточка», картинка в потоке (без absolute + object-fit на SVG — в части браузеров даёт растяжение) */
.geo-section > .geo-glitch-map {
  box-sizing: border-box;
  width: min(var(--site-max, 1180px), calc(100% - 2 * var(--gutter, 14px)));
  margin: clamp(8px, 1.5vh, 18px) auto clamp(10px, 2vh, 20px);
  padding: clamp(8px, 1.4vw, 14px);
  border-radius: clamp(18px, 2.5vw, 28px);
  overflow: hidden;
  /* Как у rect/svg-background в MapChart_Map.svg — иначе видна «рамка» вокруг картинки */
  background: var(--bg, #0c0c0d);
  border: 1px solid var(--geo-line-strong);
  box-shadow: 0 16px 40px -24px rgba(0, 0, 0, 0.72);
  contain: layout paint;
  isolation: isolate;
}

.geo-map-inner {
  position: relative;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
  background: var(--bg, #0c0c0d);
}

.geo-mapchart-map {
  position: relative;
  z-index: 0;
  display: block;
  width: auto;
  max-width: 100%;
  max-height: var(--geo-map-max-h);
  height: auto;
  margin-inline: auto;
  object-fit: contain;
}

.geo-no-js {
  padding: 2rem;
  text-align: center;
  color: var(--muted, #9b9d9f);
  font-size: 0.9rem;
}

.map-base-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    radial-gradient(circle at 30% 40%, rgba(233, 4, 8, 0.08) 0%, transparent 30%),
    radial-gradient(circle at 70% 60%, rgba(255, 26, 31, 0.06) 0%, transparent 30%),
    radial-gradient(circle at 50% 30%, rgba(233, 4, 8, 0.04) 0%, transparent 40%);
  z-index: 1;
}

.map-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(233, 4, 8, 0.04) 0 1px,
      transparent 1px 40px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(233, 4, 8, 0.04) 0 1px,
      transparent 1px 40px
    );
  z-index: 2;
  opacity: 0.45;
}

.map-continents {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.continent {
  position: absolute;
  background: rgba(233, 4, 8, 0.04);
  border: 1px solid rgba(233, 4, 8, 0.14);
  border-radius: 50% 40% 60% 30%;
  filter: blur(2px);
  transition: background 0.35s ease, border-color 0.35s ease, filter 0.35s ease;
}

.continent:hover {
  background: rgba(233, 4, 8, 0.1);
  border-color: var(--geo-accent-bright);
  filter: blur(1px);
}

.continent.na {
  top: 20%;
  left: 15%;
  width: 18%;
  height: 22%;
  border-radius: 40% 30% 50% 20%;
  transform: rotate(-5deg);
}

.continent.sa {
  top: 45%;
  left: 20%;
  width: 12%;
  height: 25%;
  border-radius: 30% 20% 40% 10%;
  transform: rotate(-2deg);
}

.continent.eu {
  top: 18%;
  left: 42%;
  width: 12%;
  height: 15%;
  border-radius: 40% 30% 20% 30%;
}

.continent.af {
  top: 35%;
  left: 45%;
  width: 14%;
  height: 22%;
  border-radius: 30% 40% 20% 30%;
}

.continent.as {
  top: 15%;
  left: 58%;
  width: 25%;
  height: 30%;
  border-radius: 40% 30% 50% 20%;
}

.continent.au {
  top: 65%;
  left: 72%;
  width: 12%;
  height: 12%;
  border-radius: 40% 30% 20% 40%;
  transform: rotate(10deg);
}

.continent.an {
  top: 80%;
  left: 30%;
  width: 40%;
  height: 10%;
  border-radius: 50% 50% 20% 20%;
  background: rgba(233, 4, 8, 0.03);
}

.map-markers {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.marker {
  position: absolute;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  cursor: default;
  z-index: 5;
}

.marker-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  background: var(--geo-accent);
  border-radius: 50%;
  box-shadow: 0 0 18px var(--geo-accent-bright);
  transition: transform 0.3s ease, background 0.3s ease;
  z-index: 2;
}

.marker-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border: 1px solid var(--geo-accent-bright);
  border-radius: 50%;
  animation: geo-marker-pulse 2s infinite;
  z-index: 1;
}

.marker:hover .marker-dot {
  transform: translate(-50%, -50%) scale(1.45);
  background: var(--text, #fff);
}

.marker:hover .marker-ring {
  border-color: var(--text, #fff);
  animation: none;
}

.marker-label {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 12, 13, 0.94);
  border: 1px solid var(--geo-line-strong);
  border-radius: 20px;
  padding: 4px 12px;
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  color: var(--text, #f5f7fa);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, bottom 0.3s ease;
  margin-bottom: 8px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  z-index: 10;
}

.marker:hover .marker-label {
  opacity: 1;
  visibility: visible;
  bottom: 150%;
}

.marker-1 {
  top: 35%;
  left: 75%;
}

.marker-2 {
  top: 40%;
  left: 62%;
}

.marker-3 {
  top: 25%;
  left: 52%;
}

.marker-4 {
  top: 22%;
  left: 65%;
}

.marker-5 {
  top: 48%;
  left: 78%;
}

.marker-6 {
  top: 18%;
  left: 20%;
}

.marker-7 {
  top: 28%;
  left: 22%;
}

.marker-8 {
  top: 25%;
  left: 48%;
}

.marker-9 {
  top: 32%;
  left: 58%;
}

.marker-10 {
  top: 26%;
  left: 50%;
}

.marker-11 {
  top: 55%;
  left: 82%;
}

.map-glitch {
  position: absolute;
  inset: 0;
  /* Без mix-blend-mode: меньше композитинга при скролле мимо крупного SVG */
  background: repeating-linear-gradient(
    0deg,
    rgba(233, 4, 8, 0.045) 0 2px,
    transparent 2px 8px
  );
  pointer-events: none;
  z-index: 6;
  opacity: 0.26;
}

.geo-list-wrapper {
  position: relative;
  overflow: hidden;
  width: 100%;
  margin-bottom: clamp(10px, 2vh, 20px);
}

/* Мягкое затухание по краям без mask-composite (дешевле при анимации трека) */
.geo-list-wrapper::before,
.geo-list-wrapper::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: clamp(36px, 8vw, 56px);
  z-index: 2;
  pointer-events: none;
}

.geo-list-wrapper::before {
  left: 0;
  background: linear-gradient(to right, var(--geo-bg) 0%, transparent 100%);
}

.geo-list-wrapper::after {
  right: 0;
  background: linear-gradient(to left, var(--geo-bg) 0%, transparent 100%);
}

.geo-list-track {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  width: max-content;
  animation: geo-marquee 50s linear infinite;
}

/* Пауза вне вьюпорта — класс вешает main.js (IntersectionObserver) */
.geo-section.geo-section--marquee-paused .geo-list-track {
  animation-play-state: paused;
}

.geo-section:not(.geo-section--marquee-paused) .geo-list-track {
  will-change: transform;
}

@media (prefers-reduced-motion: reduce) {
  .geo-list-track {
    animation: none;
    flex-wrap: wrap;
    width: 100%;
    justify-content: center;
    row-gap: 10px;
    will-change: auto;
  }
}

@keyframes geo-marquee {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

.geo-country-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  /* Непрозрачный фон вместо backdrop-filter — десятки размытий тянули композитор */
  background: rgba(22, 24, 28, 0.94);
  border: 1px solid var(--geo-line);
  border-radius: 40px;
  padding: 6px 14px 6px 8px;
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: rgba(245, 247, 250, 0.88);
  letter-spacing: 0.06em;
  transition:
    border-color 0.3s ease,
    color 0.3s ease,
    transform 0.3s ease,
    box-shadow 0.3s ease;
  cursor: default;
  position: relative;
  overflow: hidden;
}

.geo-country-flag {
  display: block;
  width: 24px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.geo-country-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 26, 31, 0.18), transparent);
  transition: left 0.5s ease;
}

.geo-country-item:hover {
  border-color: var(--geo-accent-bright);
  color: var(--text, #f5f7fa);
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -12px rgba(233, 4, 8, 0.35);
}

.geo-country-item:hover::before {
  left: 100%;
}

.geo-country-item::after {
  content: '•';
  color: var(--geo-accent);
  margin-left: 4px;
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0.65;
}

.geo-stats {
  display: flex;
  justify-content: center;
  gap: clamp(18px, 4vw, 44px);
  padding-top: clamp(12px, 2.2vh, 22px);
  border-top: 1px solid var(--geo-line);
}

.geo-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.geo-stat-item::after {
  content: '';
  position: absolute;
  right: -30px;
  top: 10%;
  bottom: 10%;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--geo-accent), transparent);
}

.geo-stat-item:last-child::after {
  display: none;
}

.geo-stat-number {
  font-family: var(--font-head, system-ui, sans-serif);
  font-size: clamp(1.35rem, 2.6vw, 1.85rem);
  font-weight: 800;
  color: var(--geo-accent-bright);
  line-height: 1;
  margin-bottom: 4px;
  text-shadow: 0 0 20px rgba(233, 4, 8, 0.35);
}

.geo-stat-label {
  font-family: ui-monospace, monospace;
  font-size: 0.7rem;
  color: var(--muted, #9b9d9f);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

@keyframes geo-marker-pulse {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    opacity: 0.45;
    transform: translate(-50%, -50%) scale(1.75);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes geo-glitch-once {
  0%,
  100% {
    transform: translate(0);
  }
  20% {
    transform: translate(-2px, 1px);
  }
  40% {
    transform: translate(2px, -1px);
  }
  60% {
    transform: translate(-1px, 1px);
  }
  80% {
    transform: translate(1px, -1px);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .geo-glitch-map:hover .map-glitch {
    /* Одноразовый «глитч» вместо бесконечной анимации при hover */
    animation: geo-glitch-once 0.48s ease-out 1;
    opacity: 0.4;
  }
}

/* Низкий экран (ноутбук): карта ниже, теги стран — перенос, без обрезки по краям */
@media (max-height: 820px) {
  .geo-section {
    --geo-map-max-h: min(30dvh, 240px);
    padding: clamp(16px, 3vh, 28px) 0;
  }

  .geo-list-wrapper {
    margin-bottom: 10px;
  }

  .geo-list-track {
    animation: none;
    flex-wrap: wrap;
    width: 100%;
    justify-content: center;
    row-gap: 6px;
    will-change: auto;
  }

  .geo-stats {
    padding-top: 10px;
  }
}

@media (min-height: 960px) {
  .geo-section {
    --geo-map-max-h: min(42dvh, 400px);
  }
}

@media (max-width: 992px) {
  .geo-stats {
    gap: 40px;
  }

  .geo-stat-item::after {
    right: -20px;
  }

  .continent {
    filter: blur(3px);
  }
}

@media (max-width: 768px) {
  .geo-section {
    padding: clamp(28px, 5vh, 40px) 0;
  }

  .geo-header .section__title.geo-title {
    font-size: clamp(1.25rem, 4.2vw + 0.4rem, 1.75rem);
  }

  .marker {
    width: 20px;
    height: 20px;
  }

  .marker-dot {
    width: 8px;
    height: 8px;
  }

  .marker-ring {
    width: 20px;
    height: 20px;
  }

  .marker-label {
    font-size: 0.62rem;
    padding: 3px 8px;
  }

  .geo-list-track {
    gap: 8px;
  }

  .geo-country-item {
    padding: 6px 15px;
    font-size: 0.72rem;
  }

  .geo-stats {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: stretch;
    gap: 0;
    padding: 12px 8px;
    margin-top: 12px;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-sm, 18px);
  }

  .geo-stat-item {
    flex: 1;
    padding: 10px 8px;
    min-width: 0;
  }

  .geo-stat-item::after {
    display: block;
    position: absolute;
    right: 0;
    top: 18%;
    bottom: 18%;
    width: 1px;
    background: rgba(255, 255, 255, 0.06);
  }

  .geo-stat-item:last-child::after {
    display: none;
  }

  .geo-stat-number {
    font-size: clamp(1.1rem, 4vw, 1.35rem);
    font-weight: 800;
    margin-bottom: 4px;
    text-shadow: none;
  }

  .geo-stat-label {
    font-size: 0.55rem;
    letter-spacing: 0.06em;
    color: rgba(155, 157, 159, 0.9);
    font-family: var(--font-body, system-ui, sans-serif);
  }
}

@media (max-width: 480px) {
  .geo-section {
    padding: clamp(22px, 5vh, 32px) 0;
  }

  .geo-header .section__title.geo-title {
    font-size: 1.35rem;
  }

  .geo-country-item {
    padding: 5px 12px;
    font-size: 0.66rem;
  }

  .geo-stats {
    padding: 12px 8px;
  }

  .geo-stat-item {
    padding: 8px 6px;
  }

  .geo-stat-number {
    font-size: clamp(1rem, 4.5vw, 1.2rem);
  }

  .geo-stat-label {
    font-size: 0.5rem;
  }
}
