.ecosystem {
  font-size: 1rem;
  margin-bottom: 2rem;
  padding-top: 1rem;

  @media (min-width: 951px) {
    display: grid;
    grid-gap: 1rem;
  }

  &:not(.expand-left):not(.expand-right) {
    @media (min-width: 951px) {
      grid-template-columns: 144px auto 144px;

      .ecosystem__submodules {
        padding-top: 2.5rem;
      }
    }

    @media (max-width: 950px) {
      .ecosystem__submodules {
        display: flex;
        justify-content: space-between;
      }
    }
  }

  &.expand-left {
    grid-template-columns: 50% auto;

    .ecosystem__submodules:last-of-type,
    .ecosystem__submodule:not(.active) {
      display: none;
    }
  }

  &.expand-right {
    grid-template-columns: auto 50%;

    .ecosystem__submodules:first-of-type,
    .ecosystem__submodule:not(.active) {
      display: none;
    }
  }
}

.ecosystem__modules {
  @media (max-width: 950px) {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
}

.ecosystem__module {
  width: 100%;
  position: relative;

  > * {
    z-index: 1;
  }

  h2 {
    width: 100%;
    position: relative;

    > div {
      font-size: 1rem;
      padding-top: 1.95rem;
      position: relative;

      @media (min-width: 951px) {
        float: right;
        padding-right: 3rem;
        text-align: right;
      }

      &::before {
        @include font-serif;
        width: 100%;
        top: 0.9rem;

        content: "key repositories";
        font-size: 80%;
        font-style: italic;
        opacity: 0.3;
        position: absolute;

        @media (min-width: 951px) {
          right: 3rem;
          text-align: right;
        }

        @media (max-width: 950px) {
          left: 0;
        }
      }

      span {
        cursor: pointer;
        display: inline-block;
        position: relative;

        &:not(:last-of-type) {
          margin-right: 1rem;

          &::after {
            top: 0; right: -0.7rem;

            color: $lbry-gray-1;
            content: "/";
            font-style: italic;
            position: absolute;
          }
        }
      }
    }
  }

  h3 {
    position: relative;
  }

  &::before {
    width: 100%; height: 100%;
    top: 0; left: 0;

    content: "";
    position: absolute;
    z-index: 0;
  }

  &:not(.active) {
    @include center;

    h2 {
      font-size: 1.5rem;
      text-align: center;

      > span {
        padding: 1.9rem 2rem;

        cursor: pointer;
        display: block;

        em {
          display: block;
          font-size: 70%;
          font-weight: normal;
        }
      }

      > div {
        display: none;
      }
    }

    .ecosystem__module__details {
      display: none;
    }

    .__close {
      transform: translateY(-0.25rem) rotate(45deg);
      z-index: 0;

      @media (max-width: 950px) {
        display: none;
      }
    }
  }

  &.active {
    padding: 2rem;

    h2 {
      margin-bottom: 1rem;

      @media (min-width: 951px) {
        font-size: 3rem;
      }

      @media (max-width: 950px) {
        font-size: 1.5rem;
      }

      > span {
        cursor: default;

        em {
          display: none;
        }
      }
    }

    &::before {
      background-color: $lbry-white;
    }

    .__close {
      transform: translateY(-0.25rem);
      z-index: 3;
    }
  }

  &.lbrycrd,
  &.lbry {
    margin-bottom: 1rem;
  }

  &.lbrycrd,
  &.lbry,
  &.applications {
    &:not(.active) {
      h2 {
        margin-bottom: 0.5rem;

        &::after {
          width: 100%;
          bottom: 1rem; left: 0;

          font-size: 0.5rem;
          letter-spacing: 0.1rem;
          position: absolute;
          z-index: -1;
        }
      }
    }
  }

  &.lbrycrd {
    &:not(.active) {
      &::before {
        background-color: $lbry-red-3;
      }

      h2::after {
        content: "◼︎";
      }
    }

    &.active::before {
      border: 2px solid $lbry-red-3;
    }
  }

  &.lbry {
    &:not(.active) {
      &::before {
        background-color: $lbry-blue-3;
      }

      h2::after {
        content: "◼︎◼︎";
      }
    }

    &.active::before {
      border: 2px solid $lbry-blue-3;
    }
  }

  &.applications {
    &:not(.active) {
      &::before {
        background-color: $lbry-green-3;
      }

      h2::after {
        content: "◼︎◼︎◼︎︎";
      }
    }

    &.active::before {
      border: 2px solid $lbry-green-3;
    }
  }
}

.ecosystem__module__details,
.ecosystem__submodule__markdown {
  @extend %markdown;
}

.ecosystem__module__piece {
  width: 80%; left: 10%;

  background-color: $lbry-white;
  line-height: 2;
  position: relative;

  &:not(:last-of-type) {
    margin-bottom: 0.5rem;
  }
}

.ecosystem__submodule {
  border-width: 2px;
  cursor: default;
  position: relative;
  transition: border-color 0.2s;
  z-index: 2;

  &:not(:last-of-type) {
    @media (min-width: 951px) {
      margin-bottom: 1rem;
    }
  }

  &:not(.on):not(.active) {
    color: $lbry-gray-1;
  }

  &:not(.active) {
    @include center;
    width: 144px; height: 144px;

    border-radius: 50%;
    border-style: dashed;

    .ecosystem__submodule__title {
      width: 100%; height: 100%;

      line-height: 140px;
      text-align: center;
    }

    .ecosystem__submodule__description {
      display: none;
    }
  }

  &.active {
    width: 100%; height: 100%;
    padding: 2rem;

    border-style: solid;
    overflow-y: auto;

    .ecosystem__submodule__title {
      line-height: 1.33;
      margin-bottom: 1rem;
    }
  }

  &:not(.blue):not(.green):not(.red) {
    border-color: $lbry-gray-1;
  }

  &.blue,
  &.green,
  &.red {
    &:not(.active) {
      cursor: pointer;
    }
  }

  &.blue {
    background-color: rgba($lbry-blue-1, 0.05);
    border-color: $lbry-blue-3;
  }

  &.green {
    background-color: rgba($lbry-green-1, 0.05);
    border-color: $lbry-green-3;
  }

  &.red {
    background-color: rgba($lbry-red-1, 0.05);
    border-color: $lbry-red-3;
  }
}

.ecosystem__submodule__title {
  font-size: 1.15rem;
}

.ecosystem__submodule__description {
  margin-bottom: 2rem;

  .__close {
    width: 1.3rem;
    top: -0.7rem; left: 0;
  }
}

.__parents {
  font-size: 1.15rem;
  line-height: 1.33;
  list-style-type: none;
  padding-left: 6.5rem;
  position: relative;
  z-index: 1;

  &::before,
  &::after {
    position: absolute;
  }

  &::before {
    @include font-serif;
    top: 0.3rem; left: 3rem;

    color: $lbry-gray-4;
    content: "back to";
    font-size: 0.8rem;
    font-style: italic;
    font-weight: 700;
  }

  &::after {
    width: 2px; height: 100%;
    top: 0; left: 2rem;

    background-color: $lbry-gray-1;
    content: "";
  }

  .single & {
    &::before,
    &::after {
      display: none;
    }
  }
}

.__parent {
  font-weight: 700;

  &:not(.active) {
    display: none;
  }

  &.active {
    cursor: pointer;
  }
}

.__close {
  right: 2rem;

  cursor: pointer;
  font-size: 2rem;
  position: absolute;
  transition: all 0.2s;
}
