@use '../../_global/styles/mixins' as *;
@use '../../_global/styles/vars' as *;

.teaser {
  //--hero-background: var(--swatches-neutrals-white);
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  font-size: var(--font-size-small);
  container-type: inline-size;

  &::before {
    content: '';
    @include full-size;
    margin: -6px;
    border-radius: var(--border-radius-xs);
    transition: 0.2s ease;
  }

  &:focus {
    outline: none;
  }
  &.focus-visible:focus::before {
    @include focus-standalone;
  }
  &:focus-visible::before, &.-moz-focusring::before {
    @include focus-standalone;
  }

  &.text {
    margin-bottom: 0;
  }

  .teaser--link {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
  }

  .image-box {
    position: relative;
    display: block;
    border-radius: var(--border-radius-xs);
    background-color: var(--color-button-tertiary-background);
    overflow: hidden;
    flex-grow: 0;
    flex-shrink: 0;

    &::before {
      content: "";
      position: relative;
      display: block;
      padding-top: 66.6667%;
      margin-bottom: 7px;
    }

    &::after {
      content: "";
      position: absolute;
      left: 0;
      bottom: 0;
      width: 100%;
      display: block;
      height: 8px;
      background-color: var(--color-border);
      transition: 0.3s ease;
      z-index: 1;
      border-bottom-right-radius: 4px;
      border-bottom-left-radius: 4px;
    }

    &.chart {
      display: flex;
      align-items: center;
      justify-content: center;
      @include gradient;
    }
  }

  img {
    position: absolute;
    top: 0;
    left: 0;
    max-width: 100%;
    width: 100%;
    height: calc(100% - 7px);
    object-fit: cover;
    opacity: 1;
    transition: 0.3s linear;

    &.loading {
      opacity: 0;
    }
  }

  .copyright {
    @include copyright;
    bottom: 8px;
  }

  .picto-box {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    .icon {
      width: 90px;
      height: 90px;
      overflow: hidden;
      position: relative;
      margin: 0 auto;
      @media(min-width: 568px) {
        width: 100px;
        height: 100px;
      }
      &:before {
        display: block;
        position: absolute;
        left: 0;
        top: 0;
        font-family: "Pictograms", sans-serif;
        color: var(--color-text);
        font-size: 90px;
        line-height: 1;
        @media(min-width: 568px) {
          font-size: 100px;
        }
      }
    }
    .picto-title {
      @include h3;
      margin: 10px 0 0 0;
      width: calc(100vw - 80px);
      overflow: hidden;
      height: 38px;
      display: block;
      font-weight: 400 !important;
      color: var(--color-text) !important;
      text-decoration-color: transparent !important;
      text-align: center;

      @media(max-width: 999px) {
        font-size: 28px;
        height: 32px;
      }
    }
  }

  &.pictoHero {
    .picto-box {
      margin-top: -20px;
      .icon {
        @media(min-width: 568px) {
          width: 150px;
          height: 150px;
        }
        &:before {
          @media(min-width: 568px) {
            font-size: 150px;
          }
        }
      }
    }
  }

  .chart-title {
    @include h3;
    display: block;
    font-weight: 500 !important;
    padding: 30px;
    margin: 0 0 0.4em;
    color: var(--color-text) !important;
    text-decoration-color: transparent !important;
    text-align: center;

    @media(max-width: 999px) {
      font-size: 28px;
      margin-bottom: 0;
      padding: 20px;
    }
  }

  .kicker + .text-box {
    margin-top: 0;
    border-top: 8px solid var(--color-decoration);
  }

  .text-box {
    position: relative;

    &:not(:last-child) {
      padding-bottom: 20px;

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

        &::after {
          content: '';
          position: relative;
          float: right;
          height: 0.75em;
          display: inline-block;
          width: 150px;
        }
      }
    }
  }

  .title {
    text-decoration: underline;
    text-underline-offset: 0.07em;
    text-decoration-thickness: 0.08em;
    margin: 0.5em 0;
  }

  &:has(.teaser--link):hover {
    .image-box::after {
      height: var(--border-width-hover);
    }
    .copyright {
      bottom: 14px;
      @media(max-width: 767px) {
        bottom: 10px;
      }
    }
  }
}

[date-type='hero'], .teaser.hero, .teaser.pictoHero {
  .image-box ~ .text-box {
    padding-top: 0.9em;

    .title {
      position: absolute;
      bottom: 100%;
      z-index: 1;
      background-color: var(--swatches-neutrals-white);
      //background-color: var(--hero-background);
      margin-right: 40px;
      padding-top: 0.4em;
      padding-right: 0.8em;
      margin-bottom: -0.05em;
    }
  }
}

.col.extern, .col.download, .col.intranet, .col.extranet, .col.gallery, .col.interaction, .col.video,
.teaser.extern, .teaser.gallery, .teaser.interaction, .teaser.video, .teaser.download, .teaser.intranet, .teaser.extranet {
  &:before {
    display: none;
  }

  .title:after {
    @include icon-small-stern;
    font-family: 'Icons', sans-serif;
    position: relative;
    font-size: var(--icon-size-small);
    line-height: 1;
    text-decoration: none;
    display: inline-block;
    vertical-align: top;
    margin-left: 0.2em;
    @media(min-width: 983px) {
      margin-top: 0.1rem;
    }
    @media(min-width: 1340px) {
      margin-top: 0.27rem;
    }
  }
}

.col.extern .title:after,
.teaser.extern .title:after {
  @include icon-small-link-external;
}

.col.download .title:after,
.teaser.download .title:after {
  @include icon-small-download;
}

.col.intranet .title:after,
.teaser.intranet .title:after {
  @include icon-small-schloss;
}

.col.gallery .title:after,
.teaser.gallery .title:after {
  @include icon-galerie-small;
}

.col.interaction .title:after,
.teaser.interaction .title:after {
  @include icon-interaction-small;
}

.col.video .title:after,
.teaser.video .title:after {
  @include icon-video-small;
}

@media(min-width: 568px) {
  .teaser[data-image-size="l"],
  .teaser[data-image-size="m"],
  .teaser[data-image-size="s"] {
    .reading-time {
      position: absolute;
      right: 0;
      bottom: 0;
      width: auto;
    }
  }
}

.teaser[data-image-size="l"] .like-h4,
.teaser[data-image-size="m"] .like-h4,
.teaser[data-image-size="s"] .like-h4,
.teaser[data-image-size="l"] .like-h4.title,
.teaser[data-image-size="m"] .like-h4.title,
.teaser[data-image-size="s"] .like-h4.title {
  @include h2;
  text-decoration-thickness: 0.07em;
  margin-top: 0;
}

@media(min-width: 568px) {
  [date-type='fullwidth'], .teaser.fullwidth, .teasers[data-items="1"] {
    display: block;

    &::after {
      content: '';
      display: block;
      clear: both;
    }

    .title {
      @include h4;
      margin-top: 0.25em;
    }

    .image-box {
      float: left;
    }

    .kicker, .text-box {
      float: right;
    }

    &[data-image-size='s'] {

      .image-box::before {
        padding-top: 100%;
      }
    }

    &[data-image-size='l'] {

      .image-box::before {
        padding-top: 55%;
      }
    }

    @media(max-width: 999px) {
      :has(> .image-box) .kicker,
      :has(> .image-box) .text-box,
      :has(> .image-box) .image-box {
        width: calc(50% - var(--col-padding));

        @media (min-width: 568px) {
          max-width: calc(50% - var(--col-padding));
          min-width: calc(50% - var(--col-padding));
        }
      }
    }

    @media(min-width: 1000px) {
      &[data-image-size='s'] {
        .image-box {
          width: calc((100% + var(--col-padding) * 2) / 12 * 5 - var(--col-padding) * 2);
        }

        .kicker, .text-box {
          width: calc((100% + var(--col-padding) * 2) / 12 * 7 - var(--col-padding) * 2);
        }
      }

      &[data-image-size='m'] {
        .image-box, .kicker, .text-box {
          width: calc(50% - var(--col-padding));
        }
      }

      &[data-image-size='l'] {
        .image-box {
          width: calc((100% + var(--col-padding) * 2) * 2 / 3 - var(--col-padding) * 2);
        }

        .kicker, .text-box {
          width: calc((100% + var(--col-padding) * 2) / 3 - var(--col-padding) * 2);
        }
      }
    }
  }
}

[data-background='lightblue'] .teaser {
  //--hero-background: var(--swatches-primary-100);

  .image-box {
    background-color: rgba(#fff, 0.4);
  }
}
