@use '../../00-settings/settings' as *;
@use '../../00-mixins/mixins' as *;
@use '../../11-base/fonts/icons' as *;

/* stylelint-disable no-descending-specificity */

//
// Basic teaser theming.
//
.teaser {
  position: relative;
  list-style: none;

  h3.bg-none {
    position: relative;
    z-index: 3;
    margin: -13px 0 20px;

    span {
      @include theme('background-color', 'color-secondary');

      padding: 2.5px 10px;
    }
  }

  p,
  ul,
  ol {
    hyphens: auto;
    hyphenate-limit-chars: 10 3 4;
  }

  .date {
    @include small-text;
    @include theme('color', 'color-zero', 'help-text-color');

    position: relative;
    z-index: 3;
    margin: 10px 0;

    span {
      @include icon('calendar');

      display: grid;
      grid-template-columns: auto 1fr;
      align-items: start;
      column-gap: 5px;
      line-height: 1.2;

      &::before {
        position: relative;
        margin-right: 0;
        font-size: 1.2rem;
        line-height: 1;
      }

      time {
        grid-column: 2;
        min-width: 0;
      }

      time:first-of-type {
        padding-top: calc((24px - (1em * 1.2)) / 2);
      }
    }
  }

  .tag-list-wrapper {
    margin: 15px 0 -5px;

    // Override default tag behaviour that has 100% width on mobile.
    li {
      width: auto;
    }
  }

  ul {
    margin: 20px 0 20px 20px;
  }

  .teaser-links,
  ol {
    margin: 20px 0;
  }

  .teaser-links {
    list-style-type: none;
  }

  a.read-more {
    @include bold-text;
  }

  a.teaser-overlay-link {
    @include reset-link-background;
    @include element-states(transparent, transparent, background-color);

    position: absolute;
    z-index: z('teaser', 'overlay-link');
    inset: -20px 0 0;
    overflow: hidden;
    text-indent: 200%;
    white-space: nowrap;
  }

  .teaser-content {
    @include medium-text;

    display: flex;
    flex-direction: column;
    height: 100%;

    a {
      position: relative;
      z-index: z('teaser', 'content-link');
    }

    .content__first {
      position: relative;
      order: 1;

      .tags-label-wrapper {
        display: flex;
        position: absolute;
        z-index: 3;
        top: -15px;
        left: 20px;
        flex-flow: row wrap;
        margin: 0;
        padding: 0 20px 0 0;

        .label {
          margin: 0 10px 10px 0;
        }

        ul {
          margin: 0;

          > li {
            margin: 0 10px 10px 0;
          }
        }

        .tag-list-wrapper {
          display: inline-block;
          position: relative;
          margin: 0;
        }
      }
    }

    .content__second {
      position: relative;
      order: 2;
      height: 100%;
      padding: 0 20px 20px;
      font-size: .9rem;

      > i {
        float: left;
        line-height: 1;

        &::before {
          display: block;
          font-size: 1.9rem;

          @include phablet {
            margin-bottom: 20px;
          }
        }

        @include phablet {
          float: none;
        }

        + h3 {
          margin-left: 53px;

          @include phablet {
            margin-left: 0;
          }
        }
      }
    }
  }

  figcaption {
    display: none;
  }

  &.no-image,
  .teaser--no-images & {
    h3 {
      margin: 0 0 20px;
    }

    .content__second {
      padding: 0;
    }

    // Make sure the image is hidden. But it's better not to load it.
    .figure-wrapper {
      display: none;
    }
  }

  &.teaser--background {
    .content__second {
      @include theme('background-color', 'color-none');

      padding: 0 20px 20px;
    }

    &.no-image,
    .teaser--no-images & {
      h3 {
        margin: 0 0 20px;
      }

      .content__second {
        padding: 20px;
      }
    }

    a.teaser-overlay-link {
      top: 0;
    }
  }

  &.teaser--square {
    .content__first {
      order: 2;
    }

    .content__second {
      display: flex;
      position: absolute;
      bottom: 0;
      flex-direction: column;
      align-items: flex-start;
      order: 1;
      width: 100%;
      height: auto;
      padding: 20px 100px 20px 20px;

      h3 {
        margin: 0;

        span {
          @include theme('background-color', 'color-none', 'heading-with-light-bg-background-color');
        }
      }

      .date {
        z-index: 1;
        margin: 0;

        span {
          @include theme('background-color', 'color-none', 'heading-with-light-bg-background-color');

          padding: 5px 10px;
          line-height: 1.2;
          box-decoration-break: clone;
        }

        &::before {
          @include theme('background-color', 'color-none', 'heading-with-light-bg-background-color');
        }
      }

      .read-more {
        @include read-more-icon-link;

        position: absolute;
        right: 0;
        bottom: 0;
      }
    }
  }

  &.teaser--square--double {
    .figure-wrapper__mobile {
      @include desktop {
        display: none;
      }
    }

    .figure-wrapper__desktop {
      display: none;

      @include desktop {
        display: block;
      }
    }

    h3 {
      @include desktop-and-below {
        font-size: .9rem;
        line-height: 1.15rem;
      }
    }
  }

  &.teaser--simple {
    .content__second {
      @include theme('background-color', 'color-none');

      position: static;
      padding: 20px 60px 20px 20px;

      @include phablet {
        padding: 30px 60px 30px 30px;
      }

      h3 {
        display: flex;
        align-items: center;
        height: 100%;
        margin: 0;

        @include phablet {
          display: block;
          height: auto;
          margin: 0 15px 20px 0;
        }

        span {
          padding: 0;
          background-color: transparent;
        }
      }

      p,
      .opening-hours-accordion {
        display: none;

        @include tablet {
          display: block;
        }
      }

      .teaser-links {
        display: none;
        margin: 0;

        @include tablet {
          display: block;
        }
      }

      .read-more {
        @include read-more-icon-link;

        position: absolute;
        right: 0;
        bottom: 0;
      }
    }

    a.teaser-overlay-link {
      top: 0;
    }
  }

  &.teaser--with--address{
    .content__second {
      @include theme('background-color', 'color-none');

      position: static;
      padding: 20px 60px 20px 20px;

      @include phablet {
        padding: 30px 60px 30px 30px;
      }

      h3 {
        display: flex;
        align-items: center;
        margin: 10px 0;

        @include phablet {
          display: block;
          height: auto;
          margin: 0 15px 20px 0;
        }

        span {
          padding: 0;
          background-color: transparent;
        }
      }

      p,
      .opening-hours-accordion {
        display: block;
      }

      .teaser-links {
        display: block;
      }

      .read-more {
        @include read-more-icon-link;

        position: absolute;
        right: 0;
        bottom: 0;
      }
    }

    a.teaser-overlay-link {
      top: 0;
    }
  }

  &.teaser--inverted {
    .content__second {
      @include theme('background-color', 'color-tertiary-light');
    }
  }

  &.teaser--wide {
    @include theme('border-color', 'color-primary', 'teaser-wide-border-color');

    margin: 0 0 40px;
    padding: 0 0 30px;
    border-bottom: 1px solid coloring('blue');

    h3 {
      margin: 0 0 20px;

      &.bg-none span {
        padding-right: 0;
        padding-left: 0;
      }
    }

    .tag-list-wrapper {
      margin: 20px 0;
    }

    .icon-list,
    .location {
      @include small-text;
      @include theme('color', 'help-text-color', 'teaser-location-color');

      margin: 0 0 10px;
    }

    .location {
      @include bold-text;

      i {
        margin-right: 6px;
        font-size: 1.5rem;
        vertical-align: middle;
      }
    }

    .teaser-content {
      display: flex;
      flex-flow: row wrap;

      @include tablet {
        flex-wrap: nowrap;
      }
    }

    .content__first,
    .content__second {
      flex-basis: 100%;
    }

    .content__first {
      order: 1;
      margin-bottom: $gutter-width;

      @include tablet {
        flex: 0 0 230px;
        margin-right: 30px;
        margin-bottom: 0;
      }
    }

    .content__second {
      order: 2;
      padding: 0;

      .dash-separated-list {
        @include medium-text;
        @include theme('color', 'default-text-color', 'help-text-color');

        margin: 10px 0;

        li {
          margin-bottom: 0;
        }
      }

      p {
        @include medium-text;

        margin-top: 10px;
      }
    }
  }
}
