@use 'sass:map';
@use '~@angular/material' as mat;

@mixin color($theme) {
  $config: mat.get-color-config($theme);
  $primary: map.get($config, primary);
  $accent: map.get($config, accent);
  $warn: map.get($config, warn);
  $foreground: map.get($config, foreground);

  [mtnaOverlineIconHeading] {
    color: mat.get-color-from-palette($foreground, secondary-text);

    .mtna-overline-icon-heading-centered-line {
      border-top-color: mat.get-color-from-palette($foreground, divider);
    }

    .mtna-overline-icon-heading-value {
      color: mat.get-color-from-palette($foreground, text);
    }

    &.mat-primary {
      @include _mtna-overline-icon-heading-color($primary);
    }
    &.mat-accent {
      @include _mtna-overline-icon-heading-color($accent);
    }
    &.mat-warn {
      @include _mtna-overline-icon-heading-color($warn);
    }
  }
}

@mixin typography($theme) {
  // Get the typography config from the theme.
  $config: mat.get-typography-config($theme);

  .mtna-overline-icon-heading-text {
    font-family: mat.font-family($config, 'title');
    font-size: 12px;
    font-weight: mat.font-weight($config, 'title');
    letter-spacing: 1px;
  }

  .mtna-overline-icon-heading-value {
    font-family: mat.font-family($config, 'body-1');
    font-size: 12px;
    font-weight: mat.font-weight($config, 'body-1');
  }
}

@mixin theme($theme) {
  $config: mat.get-color-config($theme);
  @if $config != null {
    @include color($theme);
  }

  $typography-config: mat.get-typography-config($theme);
  @if $typography-config != null {
    @include typography($theme);
  }
}

@mixin _mtna-overline-icon-heading-color($palette) {
  background: mat.get-color-from-palette($palette, default);
  color: mat.get-color-from-palette($palette, default-contrast);
  .mtna-overline-icon-heading-value {
    color: mat.get-color-from-palette($palette, default-contrast);
  }
  .mtna-overline-icon-heading-centered-line {
    border-top-color: mat.get-color-from-palette($palette, default-contrast);
  }
}
