@charset 'UTF-8';

$stroke: 6px;

$circle-size: (
  '1': 175px,
  '2': 125px,
  '3': 100px,
);

$desktop-width: 1140px;
$desktop-height: 750px;
$desktop-spacer-x: 245px;
$desktop-spacer-y: 165px;

$tablet-width: 720px;
$tablet-height: 900px;
$tablet-spacer-x: 195px;
$tablet-spacer-y: 250px;

$phone-width: 315px;
$phone-height: 650px;
$phone-spacer-x: 145px;
$phone-spacer-y: 145px;

.diagram {
  position: relative;
  margin: 0 auto;

  &-horizontal {
    display: none;
    width: $desktop-width;
    height: $desktop-height;

    @media screen and (min-width: $screen-lg-min) {
      display: block;
    }
  }

  &-vertical {
    width: $phone-width;
    height: $phone-height;
    overflow-x: auto;
    max-width: 100%;

    @media screen and (min-width: $screen-xs-min) {
      overflow-x: visible;
      max-width: initial;
    }

    @media screen and (min-width: $screen-sm-min) {
      width: $tablet-width;
      height: $tablet-height;
    }

    @media screen and (min-width: $screen-lg-min) {
      display: none;
    }
  }
}

%diagram-circle-margins {
  @each $i, $size in $circle-size {
    &.diagram-circle-#{$i} {
      margin-top: -$size * 0.7 / 2;
      margin-left: -$size * 0.7 / 2;

      @media screen and (min-width: $screen-sm-min) {
        margin-top: -$size / 2;
        margin-left: -$size / 2;
      }
    }
  }
}

.diagram-circle {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  text-align: center;
  border: $stroke solid $black;
  border-radius: 100%;
  background-color: white;

  @each $i, $size in $circle-size {
    &-#{$i} {
      width: $size * 0.7;
      height: $size * 0.7;

      @media screen and (min-width: $screen-sm-min) {
        width: $size;
        height: $size;
      }
    }
  }

  > img {
    max-width: 80%;
    z-index: 2;

    &.tiny {
      max-width: calc(80% - 20px);
    }
  }

  &:hover {
    cursor: pointer;
    .circle-ring { transform: scale(1); border-width: $stroke; }

    .inner-text {
      &:before {
        top: 30%;
        transform: translate(-50%, -30%);
      }

      &:after {
        top: 70%;
        transform: translate(-50%, -70%);
      }
    }
  }

  .circle-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
  }

  .inner-text {
    padding: 0 10px;
    font-family: $font-family-sans-serif;
    font-weight: bold;
    font-size: 1.2rem;
    line-height: 1em;
    z-index: 2;

    @media screen and (min-width: $screen-sm-min) {
      font-size: 1.6rem;
    }

    &:before,
    &:after {
      @media screen and (min-width: $screen-sm-min) {
        content: "";
      }

      position: absolute;
      left: 50%;
      width: calc(80% - 20px);
      height: $stroke / 1.5;
      background: currentColor;
      transition: all 0.25s ease-in-out,
    }

    &:before {
      top: 25%;
      transform: translate(-50%, -25%);
    }

    &:after {
      top: 75%;
      transform: translate(-50%, -75%);
    }
  }
}

.circle-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 10px solid;
  border-radius: 100%;
  z-index: 2;
  transform: scale(0.85);
  transition:
    transform 0.25s ease-in-out,
    border 0.25s ease-out;

  &-outer {
    background-color: white !important;
    transform: scale(0.94);
  }

  &-sawi {
    background-color: $brand-primary;
    border-color: $brand-primary;
  }

  &-polycom {
    background-color: map-get($schools-color, polycom-background-color);
    border-color: map-get($schools-color, polycom-background-color);
  }

  &-procom {
    background-color: map-get($schools-color, procom-btn-primary-background-color);
    border-color: map-get($schools-color, procom-btn-primary-background-color);
  }

  &-supdeluxe {
    background-color: map-get($schools-color, supdeluxe-background-color);
    border-color: map-get($schools-color, supdeluxe-background-color);
  }

  &-arc {
    background-color: map-get($schools-color, arc-background-color);
    border-color: map-get($schools-color, arc-background-color);
  }

  &-sms {
    background-color: map-get($schools-color, sms-background-color);
    border-color: map-get($schools-color, sms-background-color);
  }

  &:hover { transform: scale(1); }
}

.diagram-position {
  position: absolute;

  &:before,
  &:after {
    content: "";
    position: absolute;
    background-color: currentColor;
    z-index: -1;
  }

  &.no-line {
    &:before,
    &:after {
      display: none;
    }
  }

  @extend %diagram-circle-margins
}

.diagram-horizontal {
  .diagram-position-center-center {
    top: $desktop-height/2;
    left: $desktop-width/2;

    &:before,
    &:after {
      top: 50%;
      width: $desktop-width/2;
      height: $stroke * 2;
    }

    &:after { left: 0; }
    &:before { right: 0; }

    &.half-line {
      &:after,
      &:before {
        width: $desktop-width/2 - $desktop-spacer-x;
      }
    }
  }

  .diagram-position-center-top {
    top: $desktop-height/2 - $desktop-spacer-y * 1.6;
    left: $desktop-width/2;

    &:after {
      top: 0;
      left: 50%;
      width: $stroke * 2;
      height: $desktop-height/2;
      margin-left: -$stroke;
    }
  }

  .diagram-position-left-center {
    top: $desktop-height/2;
    left: $desktop-width/2 - $desktop-spacer-x;

    &:after {
      top: -100%;
      left: 50%;
      width: $stroke * 2;
      height: $desktop-height/2;
      margin-left: -$stroke;
    }
  }

  .diagram-position-left-center-1,
  .diagram-position-left-center-3 {
    left: $desktop-width/2 - $desktop-spacer-x;
  }

  .diagram-position-left-center-1 {
    top: $desktop-height/2 - $desktop-spacer-y;
  }

  .diagram-position-left-center-2 {
    top: $desktop-height/2;
    left: $desktop-width/2 - $desktop-spacer-x * 1.8;
  }

  .diagram-position-left-center-3 {
    top: $desktop-height/2 + $desktop-spacer-y;
  }

  .diagram-position-right-center {
    top: $desktop-height/2;
    left: $desktop-width/2 + $desktop-spacer-x;

    &:after {
      top: -100%;
      left: 50%;
      width: $stroke * 2;
      height: $desktop-height/2;
      margin-left: -$stroke;
    }
  }

  .diagram-position-right-center-1,
  .diagram-position-right-center-3 {
    left: $desktop-width/2 + $desktop-spacer-x;
  }

  .diagram-position-right-center-1 {
    top: $desktop-height/2 - $desktop-spacer-y;
  }

  .diagram-position-right-center-2 {
    top: $desktop-height/2;
    left: $desktop-width/2 + $desktop-spacer-x * 1.8;
  }

  .diagram-position-right-center-3 {
    top: $desktop-height/2 + $desktop-spacer-y;
  }

  .diagram-position-center-bottom-left,
  .diagram-position-center-bottom-right {
    top: $desktop-height/2 + $desktop-spacer-y * 1.6;

    &:after {
      bottom: 0;
      left: 50%;
      width: $stroke * 2;
      height: $desktop-height/2;
      transform-origin: 100% 100%;
    }
  }

  .diagram-position-center-bottom-left {
    left: $desktop-width/2 - $desktop-spacer-x * 0.3;

    &:after {
      margin-left: -$stroke * 2;
      transform: rotate(12deg);
    }
  }

  .diagram-position-center-bottom-right {
    left: $desktop-width/2 + $desktop-spacer-x * 0.3;

    &:after {
      margin-left: $stroke;
      transform: rotate(-12deg);
    }
  }
}

.diagram-vertical {
  .diagram-position-center-center {
    top: $phone-height/2;
    left: $phone-width/2;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2;
      left: $tablet-width/2;
    }

    &:after {
      top: 50%;
      left: 50%;
      width: $stroke * 2;
      height: $phone-height - 100;
      margin-left: -$stroke;
      margin-top: -($phone-height - 100) / 2;

      @media screen and (min-width: $screen-sm-min) {
        height: $tablet-height - 100;
        margin-top: -($tablet-height - 100) / 2;
      }
    }

    &.half-line {
      &:after {
        height: $phone-height/2;
        margin-top: -($phone-height/2) / 2;

        @media screen and (min-width: $screen-sm-min) {
          height: $tablet-height/2;
          margin-top: -($tablet-height/2) / 2;

        }
      }
    }
  }

  .diagram-position-center-top {
    top: $phone-height/2 - $phone-spacer-y;
    left: $phone-width/2;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2 - $tablet-spacer-y;
      left: $tablet-width/2;
    }

    &:after {
      top: 50%;
      left: 50%;
      width: map-get($circle-size, '1');
      height: $stroke * 2;
      margin-top: -$stroke;
      margin-left: -(map-get($circle-size, '1')) / 2;
    }
  }

  .diagram-position-center-top-1 {
    top: $phone-height/2 - $phone-spacer-y * 1.7;
    left: $phone-width/2;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2 - $tablet-spacer-y * 1.5;
      left: $tablet-width/2;
    }
  }

  .diagram-position-center-top-2,
  .diagram-position-center-top-3 {
    top: $phone-height/2 - $phone-spacer-y;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2 - $tablet-spacer-y;
    }
  }

  .diagram-position-center-top-2 {
    left: $phone-width/2 - $phone-spacer-x * 0.7;

    @media screen and (min-width: $screen-sm-min) {
      left: $tablet-width/2 - $tablet-spacer-x * 0.7;
    }
  }

  .diagram-position-center-top-3 {
    left: $phone-width/2 + $phone-spacer-x * 0.7;

    @media screen and (min-width: $screen-sm-min) {
      left: $tablet-width/2 + $tablet-spacer-x * 0.7;
    }
  }

  .diagram-position-center-bottom {
    top: $phone-height/2 + $phone-spacer-y;
    left: $phone-width/2;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2 + $tablet-spacer-y;
      left: $tablet-width/2;
    }

    &:after {
      top: 50%;
      left: 50%;
      width: map-get($circle-size, '1');
      height: $stroke * 2;
      margin-top: -$stroke;
      margin-left: -(map-get($circle-size, '1')) / 2;
    }
  }

  .diagram-position-center-bottom-1 {
    top: $phone-height/2 + $phone-spacer-y * 1.7;
    left: $phone-width/2;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2 + $tablet-spacer-y * 1.5;
      left: $tablet-width/2;
    }
  }

  .diagram-position-center-bottom-2,
  .diagram-position-center-bottom-3 {
    top: $phone-height/2 + $phone-spacer-y;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2 + $tablet-spacer-y;
    }
  }

  .diagram-position-center-bottom-2 {
    left: $phone-width/2 - $phone-spacer-x * 0.7;

    @media screen and (min-width: $screen-sm-min) {
      left: $tablet-width/2 - $tablet-spacer-x * 0.7;
    }
  }

  .diagram-position-center-bottom-3 {
    left: $phone-width/2 + $phone-spacer-x * 0.7;

    @media screen and (min-width: $screen-sm-min) {
      left: $tablet-width/2 + $tablet-spacer-x * 0.7;
    }
  }

  .diagram-position-left-center {
    top: $phone-height/2;
    left: $phone-width/1.7 - $phone-spacer-x;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2;
      left: $tablet-width/2 - $tablet-spacer-x;
    }

    &:after {
      top: 50%;
      left: 0;
      width: $phone-spacer-x;
      height: $stroke * 2;
      margin-top: -$stroke;

      @media screen and (min-width: $screen-sm-min) {
        width: $tablet-spacer-x;
      }
    }
  }

  .diagram-position-right-top,
  .diagram-position-right-bottom {
    left: $phone-width/2.7 + $phone-spacer-x;

    @media screen and (min-width: $screen-sm-min) {
      left: $tablet-width/2 + $tablet-spacer-x;
    }

    &:after {
      top: 50%;
      right: 100%;
      width: $phone-spacer-x / 2;
      height: $stroke * 2;
      transform-origin: 100% 100%;

      @media screen and (min-width: $screen-sm-min) {
        width: $tablet-spacer-x;
      }
    }
  }

  .diagram-position-right-top {
    top: $phone-height/2 + $phone-spacer-y * 0.35;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2 + $tablet-spacer-y * 0.3;
    }

    &:after { transform: rotate(25deg); }
  }

  .diagram-position-right-bottom {
    top: $phone-height/2 - $phone-spacer-y * 0.35;

    @media screen and (min-width: $screen-sm-min) {
      top: $tablet-height/2 - $tablet-spacer-y * 0.3;
    }

    &:after { transform: rotate(-25deg); }
  }
}

