/**
 * Best fit for teams — orbit diagram, Figma 1920 base (883px ring).
 */

.home-v2 .v2-section--best-fit,
.v2-section--best-fit {
  --best-fit-ring: clamp(288px, 41.4vw, 795px); /* ~10% smaller than 883px */
  --best-fit-r: calc(var(--best-fit-ring) / 2);
  --best-fit-label: clamp(14px, 1.25vw, 24px);
  --best-fit-title: clamp(36px, 3.646vw, 70px);
  --best-fit-badge: clamp(40px, 3.646vw, 70px);
  --best-fit-dot: clamp(16px, 1.51vw, 29px);
  --best-fit-green: #64db69;
  padding-block: clamp(48px, 6.25vw, 120px);
  overflow: visible;
}

.v2-section--best-fit .container {
  overflow: visible;
}

.v2-best-fit__diagram {
  position: relative;
  width: min(100%, var(--layout-width));
  max-width: 1440px;
  height: calc(var(--best-fit-ring) + clamp(48px, 4.17vw, 80px));
  margin-inline: auto;
}

.v2-best-fit__orbit {
  position: absolute;
  inset: 0;
}

.v2-best-fit__shape {
  display: none;
}

/* Dashed orbit */
.v2-best-fit__ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--best-fit-ring);
  height: var(--best-fit-ring);
  transform: translate(-50%, -50%);
  border: 1px dashed rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  pointer-events: none;
}

/* Center badge + title */
.v2-best-fit__core {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: translate(-50%, -42%);
  pointer-events: none;
}

.v2-best-fit__badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--best-fit-badge);
  height: var(--best-fit-badge);
  margin-bottom: clamp(12px, 1.25vw, 24px);
  border-radius: 50%;
  background: var(--best-fit-green);
  flex-shrink: 0;
}

.v2-best-fit__badge span {
  font-size: clamp(18px, 1.563vw, 30px);
  font-weight: 500;
  line-height: 1;
  color: #ffffff;
}

.v2-best-fit__title {
  margin: 0;
  font-size: var(--best-fit-title);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.v2-best-fit__title-accent {
  color: var(--best-fit-green);
}

.v2-best-fit__title-muted {
  color: #202020;
}

/* Nodes on orbit */
.v2-best-fit__nodes {
  list-style: none;
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
}

.v2-best-fit__node {
  position: absolute;
  width: 0;
  height: 0;
  z-index: 3;
}

.js-v2 .v2-section--best-fit.is-scroll-animated .v2-best-fit__node {
  opacity: 0;
  transform: translate3d(0, 18px, 0);
  transition:
    opacity 480ms ease,
    transform 560ms cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--best-fit-delay, 0ms);
}

.js-v2 .v2-section--best-fit.is-scroll-animated .v2-best-fit__dot {
  opacity: 0;
  transform: scale(0.35);
  transition:
    opacity 420ms ease,
    transform 520ms cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--best-fit-delay, 0ms);
}

.js-v2 .v2-section--best-fit.is-scroll-animated .v2-best-fit__label {
  opacity: 0;
  transition:
    opacity 480ms ease;
  transition-delay: calc(var(--best-fit-delay, 0ms) + 70ms);
}

.js-v2 .v2-section--best-fit.is-scroll-animated.is-revealed .v2-best-fit__node {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.js-v2 .v2-section--best-fit.is-scroll-animated.is-revealed .v2-best-fit__dot {
  opacity: 1;
  transform: scale(1);
}

.js-v2 .v2-section--best-fit.is-scroll-animated.is-revealed .v2-best-fit__label {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .js-v2 .v2-section--best-fit.is-scroll-animated .v2-best-fit__node,
  .js-v2 .v2-section--best-fit.is-scroll-animated .v2-best-fit__dot,
  .js-v2 .v2-section--best-fit.is-scroll-animated .v2-best-fit__label {
    transition: none;
  }
}

.v2-best-fit__dot {
  position: absolute;
  left: calc(var(--best-fit-dot) / -2);
  top: calc(var(--best-fit-dot) / -2);
  width: var(--best-fit-dot);
  height: var(--best-fit-dot);
  border-radius: 50%;
  background: var(--best-fit-green);
  transform-origin: 50% 50%;
}

.v2-best-fit__label {
  position: absolute;
  margin: 0;
  font-size: var(--best-fit-label);
  font-weight: 500;
  line-height: 1.2;
  color: #202020;
  white-space: nowrap;
  will-change: transform, opacity, filter;
}

.v2-best-fit__label--right {
  left: calc(var(--best-fit-dot) / 2 + clamp(8px, 1.563vw, 30px));
  top: 50%;
  transform: translateY(-50%);
  text-align: left;
}

.v2-best-fit__label--left {
  right: calc(var(--best-fit-dot) / 2 + clamp(8px, 1.563vw, 30px));
  top: 50%;
  transform: translateY(-50%);
  text-align: right;
}

.v2-best-fit__label--top {
  left: 50%;
  bottom: calc(var(--best-fit-dot) / 2 + clamp(8px, 1.46vw, 28px));
  transform: translateX(-50%);
  text-align: center;
}

.v2-best-fit__label--bottom {
  left: 50%;
  top: calc(var(--best-fit-dot) / 2 + clamp(8px, 1.46vw, 28px));
  transform: translateX(-50%);
  text-align: center;
}

.v2-best-fit__label-short {
  display: none;
}

@media (min-width: 1024px) {
  .is-lang-uk .v2-best-fit__title {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: calc(100vw * 58 / 1920);
    line-height: 1.02;
    white-space: normal;
  }

  .is-lang-uk .v2-best-fit__title-accent,
  .is-lang-uk .v2-best-fit__title-muted {
    display: block;
    white-space: nowrap;
  }

  .is-lang-uk .v2-best-fit__title-muted {
    margin-top: 0.06em;
  }

  .is-lang-uk .v2-best-fit__label--left,
  .is-lang-uk .v2-best-fit__label--right {
    max-width: none;
    white-space: nowrap;
  }

  .is-lang-uk .v2-best-fit__label {
    font-size: clamp(14px, calc(100vw * 20 / 1920), 20px);
    line-height: 1.18;
  }
}

/* Positions — ratios from 883px ring (radius 441.5px) */
.v2-best-fit__node--top {
  left: 50%;
  top: calc(50% - var(--best-fit-r));
}

.v2-best-fit__node--right-top {
  left: calc(50% + var(--best-fit-r) * 0.7067);
  top: calc(50% - var(--best-fit-r) * 0.7067);
}

.v2-best-fit__node--right {
  left: calc(50% + var(--best-fit-r));
  top: 50%;
}

.v2-best-fit__node--right-bottom {
  left: calc(50% + var(--best-fit-r) * 0.6116);
  top: calc(50% + var(--best-fit-r) * 0.7928);
}

.v2-best-fit__node--left-bottom {
  left: calc(50% - var(--best-fit-r) * 0.6116);
  top: calc(50% + var(--best-fit-r) * 0.7928);
}

.v2-best-fit__node--left {
  left: calc(50% - var(--best-fit-r));
  top: 50%;
}

.v2-best-fit__node--left-top {
  left: calc(50% - var(--best-fit-r) * 0.7814);
  top: calc(50% - var(--best-fit-r) * 0.6342);
}

.v2-best-fit__node--bottom {
  left: 50%;
  top: calc(50% + var(--best-fit-r));
}

@media (max-width: 1023px) {
  .home-v2 .v2-section--best-fit,
  .v2-section--best-fit {
    --best-fit-ring: calc(100vw * 220 / 390);
    --best-fit-r: calc(var(--best-fit-ring) / 2);
    --best-fit-label: calc(100vw * 13 / 390);
    --best-fit-title: calc(100vw * 30 / 390);
    --best-fit-badge: calc(100vw * 40 / 390);
    --best-fit-dot: calc(100vw * 9 / 390);
    --best-fit-diag: 0.7071;
    padding-top: var(--v2-section-gap);
    padding-bottom: 0;
    overflow-x: clip;
    overflow-y: visible;
  }

  .v2-best-fit__diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: none;
    min-width: 0;
    height: auto;
    margin-inline: auto;
    transform: none;
    gap: calc(100vw * 50 / 390);
  }

  .v2-best-fit__core {
    position: relative;
    left: auto;
    top: auto;
    z-index: 2;
    transform: none;
    pointer-events: none;
  }

  .v2-best-fit__badge {
    margin-bottom: calc(100vw * 12 / 390);
  }

  .v2-best-fit__badge span {
    font-size: calc(100vw * 18 / 390);
  }

  .v2-best-fit__title {
    display: flex;
    align-items: baseline;
    justify-content: center;
    white-space: nowrap;
    line-height: 1;
  }

  .v2-best-fit__title .split-line {
    display: inline-block;
  }

  .v2-best-fit__title-muted {
    margin-left: 0.16em;
  }

  .is-lang-uk .v2-best-fit__title {
    flex-direction: column;
    align-items: center;
    white-space: normal;
  }

  .is-lang-uk .v2-best-fit__title-muted {
    margin-left: 0;
  }

  .v2-best-fit__orbit {
    position: relative;
    width: calc(100vw * 330 / 390);
    height: calc(100vw * 330 / 390);
    max-width: calc(100% - (var(--container-pad) * 2));
    max-height: calc(100% - (var(--container-pad) * 2));
    margin-inline: auto;
    margin-bottom: 0;
    flex-shrink: 0;
    transform: none;
    transform-origin: center top;
  }

  .v2-best-fit__ring {
    z-index: 2;
    border-color: rgba(32, 32, 32, 0.16);
  }

  .v2-best-fit__shape {
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 1;
    /* Figma 460px, but cap at viewport — uncapped width caused ~35px horizontal scroll */
    width: min(100vw, calc(100vw * 460 / 390));
    max-width: 100%;
    transform: translate(-50%, -50%);
    pointer-events: none;
  }

  .v2-best-fit__shape-video {
    display: block;
    width: 100%;
    height: auto;
  }

  .v2-best-fit__label-full {
    display: none;
  }

  .v2-best-fit__label-short {
    display: block;
  }

  .v2-best-fit__label {
    letter-spacing: -0.02em;
    color: rgba(32, 32, 32, 0.4);
  }

  .is-lang-uk .v2-best-fit__label {
    font-size: calc(100vw * 12 / 390);
    white-space: normal;
  }

  .is-lang-uk .v2-best-fit__node--m-left .v2-best-fit__label--m-left {
    right: calc(var(--best-fit-dot) / 2 + calc(100vw * 2 / 390));
    font-size: calc(100vw * 11 / 390);
  }

  .v2-best-fit__node.v2-best-fit__node--m-top {
    left: 50%;
    top: calc(50% - var(--best-fit-r));
  }

  .v2-best-fit__node.v2-best-fit__node--m-right-top {
    left: calc(50% + var(--best-fit-r) * var(--best-fit-diag));
    top: calc(50% - var(--best-fit-r) * var(--best-fit-diag));
  }

  .v2-best-fit__node.v2-best-fit__node--m-right {
    left: calc(50% + var(--best-fit-r));
    top: calc(50% + var(--best-fit-r) * 0.12);
  }

  .v2-best-fit__node.v2-best-fit__node--m-right-bottom {
    left: calc(50% + var(--best-fit-r) * 0.48);
    top: calc(50% + var(--best-fit-r) * 0.88);
  }

  .v2-best-fit__node.v2-best-fit__node--m-left-bottom {
    left: calc(50% - var(--best-fit-r) * 0.48);
    top: calc(50% + var(--best-fit-r) * 0.88);
  }

  .v2-best-fit__node.v2-best-fit__node--m-left {
    left: calc(50% - var(--best-fit-r));
    top: calc(50% + var(--best-fit-r) * 0.12);
  }

  .v2-best-fit__node.v2-best-fit__node--m-left-top {
    left: calc(50% - var(--best-fit-r) * var(--best-fit-diag));
    top: calc(50% - var(--best-fit-r) * var(--best-fit-diag));
  }

  .v2-best-fit__label.v2-best-fit__label--m-right {
    left: calc(var(--best-fit-dot) / 2 + calc(100vw * 10 / 390));
    right: auto;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    text-align: left;
    max-width: calc(100vw * 86 / 390);
  }

  .v2-best-fit__label.v2-best-fit__label--m-left {
    right: calc(var(--best-fit-dot) / 2 + calc(100vw * 10 / 390));
    left: auto;
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
    text-align: right;
    max-width: calc(100vw * 86 / 390);
  }

  .v2-best-fit__label.v2-best-fit__label--m-top {
    left: 50%;
    right: auto;
    bottom: calc(var(--best-fit-dot) / 2 + calc(100vw * 12 / 390));
    top: auto;
    transform: translateX(-50%);
    text-align: center;
    max-width: calc(100vw * 132 / 390);
  }

  .v2-best-fit__node.v2-best-fit__node--m-left-top .v2-best-fit__label {
    left: auto;
    right: calc(var(--best-fit-dot) / 2 + calc(100vw * 10 / 390));
    top: auto;
    bottom: calc(var(--best-fit-dot) / 2 + calc(100vw * 12 / 390));
    transform: none;
    text-align: right;
    max-width: calc(100vw * 116 / 390);
  }

  .v2-best-fit__node.v2-best-fit__node--m-right-top .v2-best-fit__label {
    left: calc(var(--best-fit-dot) / 2 + calc(100vw * 10 / 390));
    right: auto;
    top: auto;
    bottom: calc(var(--best-fit-dot) / 2 + calc(100vw * 12 / 390));
    transform: none;
    text-align: left;
    max-width: calc(100vw * 116 / 390);
  }

  .v2-best-fit__node.v2-best-fit__node--m-left-bottom .v2-best-fit__label,
  .v2-best-fit__node.v2-best-fit__node--m-right-bottom .v2-best-fit__label {
    left: 50%;
    right: auto;
    top: calc(var(--best-fit-dot) / 2 + calc(100vw * 12 / 390));
    bottom: auto;
    transform: translateX(-50%);
    text-align: center;
    max-width: calc(100vw * 110 / 390);
  }
}
