//
// CivicTheme Navigation Card component styles.
//

@use 'sass:map';

.ct-navigation-card {
  $root: &;

  & {
    @include ct-elevation(2);

    position: relative;
    border-radius: var(--ct-navigation-card-border-radius);
    width: 100%;

    // Prevent image from "spilling" over the border radius.
    overflow: hidden;
    display: flex;
    flex-direction: column;

    &:hover {
      outline: 1px solid transparent;
    }
  }

  &--card-clickable {
    @include ct-elevation-interaction();

    #{$root}__title-link {
      @include ct-link-cover-parent();
    }
  }

  @container (min-width: #{$ct-navigation-card-orientation-threshold}) {
    flex-direction: row;
  }

  #{$root}__image {
    @include ct-image-fit-container();

    & {
      height: var(--ct-navigation-card-image-height-mobile);
      width: auto;
      min-width: var(--ct-navigation-card-image-width-mobile);
    }

    @container (min-width: #{$ct-navigation-card-orientation-threshold}) {
      width: var(--ct-navigation-card-image-max-width-desktop);
      min-width: var(--ct-navigation-card-image-min-width-desktop);
      height: auto;
      min-height: var(--ct-navigation-card-image-min-height-desktop);
      flex-shrink: 0;
    }
  }

  #{$root}__content {
    width: 100%;
    padding: ct-spacing(3);
    box-sizing: border-box;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: ct-spacing(2);
  }

  #{$root}__icon {
    margin-bottom: ct-spacing(2);
    color: inherit;
  }

  #{$root}__icon__image {
    @include ct-image-fit-text-size();
  }

  #{$root}__title {
    @include ct-typography('heading-4');
  }

  #{$root}__title-link {
    @include ct-font-size-inherit();

    text-decoration: none;

    &:focus-visible {
      @include ct-outline();
      @include ct-outline-border();
    }

    &:hover {
      text-decoration: underline;
    }

    &:visited {
      color: inherit;
    }
  }

  #{$root}__tags {
    margin-top: auto;
  }

  #{$root}__link-graphic {
    @include ct-flex-align-right();

    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: ct-spacing(4);
    height: ct-spacing(4);
    pointer-events: none;

    &::before {
      content: '';
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      right: 0;
      opacity: var(--ct-navigation-card-link-graphic-hover-opacity);
      border-radius: 100%;
    }
  }

  @include ct-component-theme($root) using($root, $theme) {
    @include ct-component-property($root, $theme, background-color);

    &#{$root}--card-clickable {
      &:hover {
        @include ct-component-property($root, $theme, hover, outline-color);

        #{$root}__title-link {
          @include ct-component-property($root, $theme, title, hover, color);
        }

        #{$root}__link-graphic {
          &::before {
            @include ct-component-property($root, $theme, link, graphic, hover, background-color);
          }
        }
      }
    }

    &:not(#{$root}--card-clickable) {
      #{$root}__title-link {
        &:hover {
          @include ct-component-property($root, $theme, title, hover, color);
        }
      }
    }

    #{$root}__title,
    #{$root}__title-link {
      @include ct-component-property($root, $theme, title, color);
    }

    #{$root}__link-graphic {
      @include ct-component-property($root, $theme, link, graphic, color);
    }

    @include ct-component-property($root, $theme, icon, color);
  }
}
