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

.accordion {
  --accordion-toggler-padding: 14px;
  --accordion-icon-width: 60px;
  --accordion-toggler-min-height: 79px;
  margin: var(--section-margin) 0;

  @media(max-width: 767px) {
    --accordion-toggler-padding: 12px;
    --accordion-toggler-min-height: 60px;
  }

  > .linklist, > ul {
    position: relative;
    padding: 0;
    list-style: none;
    border-bottom: 1px solid var(--theme-color-primary-dimmed-02);

    @media(max-width: 567px) {
      margin: 0 calc(var(--container-padding) * -1);
      --accordion-icon-width: var(--container-padding);
    }

    > li {
      border-top: 1px solid var(--theme-color-primary-dimmed-02);
      margin-bottom: 0;
      padding-left: var(--accordion-icon-width);
      /*
      &::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        bottom: 0;
        width: 0.4em;
        background-color: var(--theme-color-secondary-dimmed);
      }
      */
      &.open {
        .accordion-toggler {
          background-color: var(--theme-color-secondary-dimmed);
          color: var(--theme-color-secondary-intensed);

          &::before {
            @include icon-minus;
          }
        }
      }
    }
  }

  .accordion-toggler {
    padding: var(--accordion-toggler-padding) var(--accordion-toggler-padding) calc(var(--accordion-toggler-padding) + 1px) var(--accordion-icon-width);
    min-height: var(--accordion-toggler-min-height);
    display: flex;
    align-items: center;
    margin: 0 0 0 calc(var(--accordion-icon-width) * -1);
    background-color: #fff;
    text-decoration: none;
    @include focus-visible;

    @media(max-width: 567px) {
      --accordion-icon-width: 46px;
      margin-left: calc(var(--container-padding) * -1);
    }

    &::before {
      @include icon-plus;
      font-family: 'Icons', sans-serif;
      font-size: var(--icon-size);
      line-height: 1;
      top: 50%;
      margin-top: calc(var(--icon-size) / -2);
      width: var(--accordion-icon-width);
      text-align: center;
      padding-right: 5px;
    }

    &:hover {
      background-color: var(--theme-color-secondary-dimmed);
    }

    &.focus-visible:focus, &:focus-visible, &.-moz-focusring {
      z-index: 1;
    }
  }

  .accordion-content {
    display: none;
    //padding: 1em 0 1em var(--accordion-icon-width);
    padding: 1em 0;
    margin-left: calc(var(--accordion-icon-width) * -1);

    > *:last-child {
      margin-bottom: 0.1em;
    }
    > *:first-child {
      margin-top: 0;
    }
  }
}

.accordion[data-type='event'] {
  > ul {
    border-bottom: 0;

    > li {
      background-color: var(--theme-color-secondary-dimmed);

      &::before {
        display: none;
      }

      &.open {
        .accordion-toggler {
          color: var(--theme-color-primary);
        }
      }

      + li {
        margin-top: 0.4em;
      }
    }
  }

  .accordion-toggler {
    position: relative;
    box-shadow: 0 1px 0 0 var(--theme-color-primary-dimmed-02);

    &:hover {
      color: var(--theme-color-primary);
    }

    &::before {
      position: absolute;
      left: 0;
      top: 0;
      bottom: 0;
      background-color: var(--theme-color-primary);
      color: var(--theme-color-white);
      margin: -1px 0;
      text-align: center;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 0;
      width: calc(var(--accordion-icon-width) * 0.75);
    }
  }

  .accordion-content {
    padding: 0;
    border-top: 1px solid var(--theme-color-primary-dimmed-02);
    border-bottom: 1px solid var(--theme-color-primary-dimmed-02);
  }

  .date-box {
    display: none;
  }

  .ev-title {
    font-weight: 600;
  }

  .date-wrapper {
    > div {
      display: inline-block;
      font-size: var(--font-size-small);

      &.date {
        font-size: var(--font-size-h4);
        margin-right: 0.3em;
        font-family: 'Korb', sans-serif;
      }
    }
  }

  .event-details {
    display: flex;
    align-items: flex-start;
    padding: 1em 0 1em calc(var(--accordion-icon-width) - 10px);
    margin: 0 10px;

    + .event-details {
      border-top: 1px solid var(--theme-color-primary-dimmed-02);
    }

    .event-locationlink > a {
      font-size: var(--font-size-small);
    }

    @media(max-width: 567px) {
      flex-direction: column;
    }

    &.sign-up {
      align-items: center;
      top: 1.2em;
      padding-bottom: 1.2em;

      @media(max-width: 567px) {
        padding-top: 1em;
      }

      .event-label, .event-content {
        width: 100%;

        @media (min-width: 568px) {
          flex: 1 1 50%;
          max-width: 50%;
        }
      }

      p, .text {
        margin: 0;
      }

      .event-label {
        padding-top: 2px;

        @media(max-width: 567px) {
          &::before {
            left: -1px;
          }
        }
      }

      .event-content {
        margin-top: 1em;
        margin-bottom: 0.2em;

        @media (min-width: 568px) {
          margin: 0;
          text-align: right;

          .btn {
            margin-right: 10px;
          }
        }
      }
    }
  }

  .event-label {
    position: relative;
    padding-right: 20px;
    flex: 1 1 100%;

    @media (min-width: 568px) {
      flex: 1 1 40%;
      max-width: 40%;
    }

    @media (max-width: 767px) {
      padding-left: 30px;
    }

    &:before {
      font-family: 'Icons', sans-serif;
      font-size: var(--icon-size);
      line-height: 1;
      position: absolute;
      top: 50%;
      margin-top: calc(var(--icon-size) / -2);
      left: calc(var(--accordion-icon-width) / -2.4 - var(--icon-size) / 2);

      @media (max-width: 567px) {
        left: -2px;
      }
    }

    &.icon-freie-plaetze:before {
      color: #2E8533;
    }
    &.icon-geschlossen:before {
      color: #EA515A;
    }
    &.icon-liste-1:before {
      left: 9px;
      margin-top: -1px;
    }

    h4 {
      font-size: var(--font-size-copy);
      font-weight: 700;
      margin: 0;
    }
  }

  .event-content {
    padding-right: 20px;
    font-size: var(--font-size-small);
    flex: 1 1 100%;

    @media (min-width: 568px) {
      flex: 1 1 60%;
      max-width: 60%;
      padding-left: 0;
    }

    @media(max-width: 767px) {
      padding-right: 10px;
      margin-top: 0.6em;
    }

    > p:last-child, > .text:last-child {
      margin-bottom: 0;
    }
  }

  .price .amount {
    @include h2;
    line-height: 1.2;
    margin: 0 0.3em 0 -0.05em;
  }

  .price + p {
    margin-top: 0.6em;
  }

  .referees {
    position: relative;
    display: block;
    padding: 0;
    list-style: none;

    &.multiple-events {
      > li {
        margin-bottom: 20px;
      }
      .referees {
        list-style: disc;
        padding-left: 20px;
        margin-top: 10px;
      }
    }

    .image-box {
      margin: 0.8em 0 0.4em;

      img {
        max-width: 100%;
        max-height: 300px;
      }
    }

    > li > a {
      font-weight: 600;

      &:last-child {
        text-decoration: none;
        pointer-events: none;
      }
    }

    .referee-details {
      display: none;
      margin-bottom: 1.2em;

      &:first-child:last-child {
        display: block;
      }
    }
  }
}
