@import '../../_global/styles/mixins';
@import '../../_global/styles/vars';

.survey {
  position: relative;
  display: block;
  margin: var(--section-margin) 0;
  background-color: var(--theme-color-secondary-dimmed);
  border-bottom: var(--border-width) solid var(--theme-color-secondary);

  .text-box {
    padding: var(--content-box-padding);
    padding-bottom: 0;
    font-size: var(--font-size-small);

    .kicker {
      margin-top: -0.3em;
    }

    h2, h3 {
      margin-top: 0.2em;
      margin-bottom: 0.3em;
    }

    p:last-child {
      margin-bottom: 0;
    }

    @media(max-width: 567px) {
      padding-top: calc(var(--content-box-padding) * 1.5);
    }
  }

  .form-box {
    position: relative;
    padding: var(--content-box-padding);
    transition: height 0.5s $easeInOutCubic;

    @media(max-width: 567px) {
      padding-bottom: calc(var(--content-box-padding) * 1.5);
    }
  }

  form {
    @include show;
    transform: translate3d(0, 0, 0) scale(1);

    &:not(:last-child) {
      height: 0;
    }
  }

  h3, h4 {
    @media(max-width: 767px) {
      font-size: 26px;
    }
  }

  legend {
    @include h4;
    color: var(--theme-color-primary);
    margin: 1em 0 0.5em;
    padding: 0;
    border-bottom: 0;
  }

  ul {
    list-style: none;
    padding: 0;
    margin: 0 -2px;

    li {
      position: relative;
      padding: 0;

      + li {
        margin-top: 15px;
      }
    }
  }

  input[type="radio"] {
    position: absolute;
    display: block;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    border-radius: var(--border-radius-md);
    margin: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: 0.25s ease;
    cursor: pointer;
    opacity: 0.000001;
    @include focus-visible();

    &:checked + label {
      background-color: var(--theme-color-secondary-intensed);
      color: var(--theme-color-white);
    }

    &:hover + label::after {
      opacity: var(--button-hover-shadow-opacity);
      box-shadow: 0 0 0 var(--button-hover-shadow-size) var(--button-bg-color);
    }
  }

  label.btn {
    width: 100%;
    transition: 0.3s ease;
    margin: 0;
    text-align: center;
    line-height: 1.2;
    min-height: 48px;

    @media(max-width: 999px) {
      min-height: 44px;
    }
  }

  fieldset {
    border: 0;
    padding: 0;
    margin: 0;
  }

  fieldset + fieldset {
    margin-top: calc(20px + 2%);
  }

  .btn-wrapper {
    display: none;
  }

  .survey-result > .title {
    display: none;
  }

  .result-wrapper {
    .title {
      @include h4;
    }
  }

  .sub-result-wrapper {
    position: relative;
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-copy);
    line-height: 1.1;
    padding: 10px 15px;
    align-items: center;
    font-family: "Korb", sans-serif;
    min-height: 48px;

    @media(max-width: 999px) {
      min-height: 44px;
    }

    @media(max-width: 767px) {
      padding: 5px 5px 5px 10px;
    }

    + .sub-result-wrapper {
      margin-top: 15px;
    }

    div {
      position: relative;
      display: block;

      &.answer {
        overflow: hidden;
        max-width: calc(100% - 60px);

        @media(max-width: 767px) {
          max-width: calc(100% - 50px);
        }
      }
    }

    .bar {
      position: absolute;
      display: block;
      left: 0;
      width: 0;
      top: 0;
      bottom: 0;
      transition: 0.8s $easeInOutCubic;
      min-width: 1px;
      background-color: #9AD7A3;
    }
  }

  .survey-result {
    @include hide;
    transform: translate3d(0, 0, 0) scale(0.9);

    h3 {
      margin-bottom: 0.9em;
    }
  }

  &.show-result {
    .survey-result {
      @include show(0.3s);
      transform: translate3d(0, 0, 0) scale(1);
    }

    form {
      @include hide();
      transform: translate3d(0, 0, 0) scale(0.9);
    }
  }

  &[data-size='md'] {
    .text-box {
      margin: 0 0 -1em;
    }
  }

  &[data-size='lg'] {
    display: flex;
    align-items: center;

    .text-box, .form-box {
      flex: 1 1 100%;
      max-width: 50%;
    }

    .text-box {
      padding: var(--content-box-padding);
      margin-bottom: 0.1em;
    }

    .form-box {
      padding-left: 0;
    }
  }
}
