// colors
@backgroundColor: @white;
@primaryBorderColor: @grey-400;
@secondaryBorderColor: @grey-300;

@primaryTextColor: @black;
@secondaryTextColor: @grey-800;
@thirdTextColor: @grey-700;

.visualization {
  height: 100%;
  // width: 100%;
  position: relative;
}
.content {
  height: 100%;
  width: 100%;
  overflow: auto;
  padding: 1em;
  // padding-left: 1em;
  // padding-top: 1em;

  // for auto scrolling
  position: relative;
  // neccessary for border
  display: flex;
  // the default value is stretch, undesirable
  align-items: flex-start;
  // align-content: flex-start;
  // justify-content: flex-start;

  // * { .ease-out(); }

  .errorMessage {
    flex: 1 0 auto;
    align-self: center;
    text-align: center;
    .mui-font-style-button;
    .monoFont;
  }

  >.goal {
    padding-right: 2em;
  }
}

.goal {
  background-color: transparent;

  .longestPlaceholder {
    display: flex;
    flex-direction: column;
    height: 0;
    visibility: hidden;
  }

  color: @grey-900;
  display: flex;
  flex: 0 0 auto;
  align-items: baseline;
  // flex-wrap: nowrap;

  white-space: pre;

  // for duplicated current goals
  position: relative;

  .monoFont;
  font-size: 12px;

  >.labels {
    margin-right: 1em;
    display: flex;
    flex: 0 0 auto;

    align-items: flex-start;
    flex-direction: column;

    >.contents {
      display: flex;
      flex-direction: column;

      >.goals {
        display: flex;
        flex-direction: column;
        align-items: baseline;

        .currentGoal {
          font-weight: bold;
        }

        .firstNonLastestGoal:not(:only-child) {
          border-top: 1px dashed @primaryBorderColor;
        }
      }

      >.goals.highlightLatest {
        .latestGoal {
          .highlightRuleSuccess;
        }
      }

      >.subst:not(:empty) {
        border-top: 1px solid @secondaryBorderColor;
      }

      >.subst {
        color: @secondaryTextColor;
      }

    }
  }

  >.rulesAndChildren {

    > * {
      padding-left: 1em;
      border-left: 1px solid @primaryBorderColor;
    }

    flex: 1 0 auto;
    display: flex;
    flex-direction: column;

    .ruleAndChild+.ruleAndChild > .goalWrapper:not(.hideMargin) > .goal > .rulesAndChildren > .ruleAndChild:first-child {
      margin-top: 1em;
    }

    .ruleAndChild+.ruleAndChild > .goalWrapper.hideMargin {
      margin-top: 1em;
    }

    .ruleAndChild {
      flex: 0 0 auto;
      display: flex;
      align-items: baseline;
      // align-content: center;
      // position: relative;
      // justify-content: center;

      .ruleWrapper {
        display: flex;
        flex-direction: column;
        align-items: baseline;

        >.duplicatedCurrentGoal {
          position: absolute;
          left: 0;
          font-weight: bold;
          color: @grey-500;
        }
        >.duplicatedCurrentGoal.overlapped {
          display: none;
        }

        >.rule {
          display: flex;
          flex-direction: column;
          align-items: baseline;

          .originalRule {
            display: flex;
            position: relative;

            .originalRuleBody {
              position: absolute;
              // top: 0;
            }
          }
          > .substituting {
            color: @thirdTextColor;
          }
        }
        >.rule.shouldStrike {
          text-decoration: line-through;
          background-color: transparent;
        }
      }
    }
  }
}

.goal.currentEnv {
  > .labels > .contents {
    outline: @primaryBorderColor dashed 1px;

    >.goals.highlightCurrent {
      >.currentGoal {
        .highlightRuleBefore;
      }
    }
    >.goals.highlightCurrent.succeeded {
      >.currentGoal {
        .highlightRuleSuccess;
      }
    }
    >.goals.highlightCurrent.failed {
      >.currentGoal {
        .highlightRuleFailure;
      }
    }
  }
  >.rulesAndChildren {
    >.ruleAndChild {
      >.ruleWrapper {
        .rule.highlight {
          .highlightRuleBefore;
        }

        .rule.highlight.succeeded {
          .highlightRuleSuccess;

          .substituting {
            color: @deep-orange-900;
          }
        }
        .rule.highlight.failed {
          .highlightRuleFailure;
        }
      }
    }
  }
}

.goal:not(.currentEnv):not(.isLastFrame) {
  > .labels > .contents {
    .goals.highlightCurrent {
      .currentGoal {
        .highlightRulePath;
      }
    }
  }
  >.rulesAndChildren {
    >.ruleAndChild {
      >.ruleWrapper {
        .rule.highlight.succeeded {
          .highlightRulePath;
        }
      }
    }
  }
}

.solution {
  color: @green-600;
  font-weight: bold;
  margin-left: 1em;
}

.goal.shouldHideRulesAndChildren {
  .rulesAndChildren {
    display: none;
  }
}

.content {
  cursor: default;

  .tooltip {
    font-weight: normal;
    background: #333;
    background: rgba(0,0,0,.8);
    border-radius: 0.25em;
    color: #fff;
    padding: 0.25em 0.5em;
    position: absolute;
    z-index: 98;
    display: block;
    pointer-events: none;
  }

  // .goalLabel.currentGoal:hover:before {
  //   .callout;
  // }

  // goals
  .goalLabel.latestGoal:hover:after {
    .tooltip;
    content: "⇧ latest goal";
  }

  .goalLabel.currentGoal:hover:after {
    .tooltip;
    content: "⇧ current goal";
  }

  .goalLabel:hover:after {
    .tooltip;
    content: "⇧ a goal";
  }

  .solution:hover:after {
    .tooltip;
    content: "⇧ a solution";
  }

  .subst:hover:after {
    .tooltip;
    content: "⇧ partial solution";
  }

  // rules
  .rule.highlight:hover:after {
    .tooltip;
    content: "⇧ rule coming from";
  }

  .rule.succeeded:hover:after {
    .tooltip;
    content: "⇧ succeeded rule";
  }

  .rule:hover:after {
    .tooltip;
    content: "⇧ unexplored rule";
  }

  .rule.shouldStrike:hover:after {
    .tooltip;
    content: "⇧ failed rule";
  }

  .duplicatedCurrentGoal:hover:after {
    .tooltip;
    content: "⇧ duplicated current goal";
  }

  .goal.currentEnv {
    .goals.highlightCurrent {
      >.currentGoal:hover:after {
        .tooltip;
        content: "⇧ Unifying with goal";
      }
    }
    .goals.highlightCurrent.succeeded {
      >.currentGoal:hover:after {
        .tooltip;
        content: "⇧ Unification succeeded";
      }
    }
    .goals.highlightCurrent.failed {
      >.currentGoal:hover:after {
        .tooltip;
        content: "⇧ Unification failed";
      }
    }

    .rule.highlight.succeeded:hover:after {
      .tooltip;
      content: "⇧ Unification succeeded";
    }

    .rule.highlight.failed:hover:after {
      .tooltip;
      content: "⇧ Unification failed";
    }

    .rule.highlight:not(.succeeded):not(.failed):hover:after {
      .tooltip;
      content: "⇧ Unifying with rule";
    }

  }

}

.highlightRuleSuccess {
  background-color: @green-200 !important;
}
.highlightRuleFailure {
  background-color: @red-200 !important;
}
.highlightRuleBefore {
  background-color: @yellow-200 !important;
}
.highlightRulePath {
  // text-decoration: underline;
  background-color: @grey-200 !important;
}
