@mixin icon-add ($color: black) {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" fill="#{$color}"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
}
@mixin icon-all-out ($color: black) {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M16.21 4.16l4 4v-4zm4 12l-4 4h4zm-12 4l-4-4v4zm-4-12l4-4h-4zm12.95-.95c-2.73-2.73-7.17-2.73-9.9 0s-2.73 7.17 0 9.9 7.17 2.73 9.9 0 2.73-7.16 0-9.9zm-1.1 8.8c-2.13 2.13-5.57 2.13-7.7 0s-2.13-5.57 0-7.7 5.57-2.13 7.7 0 2.13 5.57 0 7.7z" fill="#{$color}"/><path fill="none" d="M.21.16h24v24h-24z"/></svg>');
}
@mixin icon-close ($color: black) {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" fill="#{$color}"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
}
@mixin icon-fullscreen ($color: black) {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" fill="#{$color}"/></svg>');
}
@mixin icon-fullscreen-exit ($color: black) {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z" fill="#{$color}"/></svg>');
}
@mixin icon-navigation ($color: black) {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M0 0h24v24H0z" fill="none"/><path d="M12 2L4.5 20.29l.71.71L12 18l6.79 3 .71-.71z" fill="#{$color}"/></svg>');
}
@mixin icon-remove ($color: black) {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13H5v-2h14v2z" fill="#{$color}"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
}
@mixin icon-search ($color: black) {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#{$color}"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
}
@mixin mat-elevation-2 {
  box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14),
    0 1px 5px 0 rgba(0, 0, 0, 0.12);
}
@mixin lja-map-theme($theme, $typography) {
  $accent: map-get($theme, accent);
  $background: map-get($theme, background);
  $foreground: map-get($theme, foreground);
  .lja-map {
    &.mapboxgl-map {
      @include mat-typography-level-to-styles($typography, body-1);
    }
    .mapboxgl-ctrl-group,
    .mapboxgl-ctrl-icon {
      background-color: mat-color($background, raised-button);
    }
    .mapboxgl-ctrl-group {
      @include mat-elevation-2;
      > button + button {
        border-top: solid 1px mat-color($foreground, divider);
      }
    }
    .mapboxgl-ctrl-icon,
    .mapboxgl-ctrl-icon > span {
      &.mapboxgl-ctrl-zoom-in {
        @include icon-add(mat-color($foreground, icon));
      }
      &.mapboxgl-ctrl-zoom-out {
        @include icon-remove(mat-color($foreground, icon));
      }
      &.mapboxgl-ctrl-fullscreen {
        @include icon-fullscreen(mat-color($foreground, icon));
      }
      &.mapboxgl-ctrl-shrink {
        @include icon-fullscreen-exit(mat-color($foreground, icon));
      }
      &.mapboxgl-ctrl-home {
        @include icon-all-out(mat-color($foreground, icon));
      }
    }
    .mapboxgl-ctrl-icon.mapboxgl-ctrl-compass > .mapboxgl-ctrl-compass-arrow {
      @include icon-navigation(mat-color($foreground, icon));
    }
    .mapboxgl-ctrl > button:hover {
      background-color: mat-color($background, hover);
    }
    .mapboxgl-popup-content {
      background: mat-color($background, card);
      @include mat-elevation-2;
    }
    .mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {
      border-top-color: mat-color($background, card);
    }
    .mapboxgl-popup-anchor-top .mapboxgl-popup-tip {
      border-bottom-color: mat-color($background, card);
    }
    .mapboxgl-popup-anchor-left .mapboxgl-popup-tip {
      border-right-color: mat-color($background, card);
    }
    .mapboxgl-popup-anchor-right .mapboxgl-popup-tip {
      border-left-color: mat-color($background, card);
    }
    .mapboxgl-popup-anchor-top-left .mapboxgl-popup-tip,
    .mapboxgl-popup-anchor-top-right .mapboxgl-popup-tip {
      border-bottom-color: mat-color($background, card);
    }
    .mapboxgl-popup-anchor-bottom-left .mapboxgl-popup-tip,
    .mapboxgl-popup-anchor-bottom-right .mapboxgl-popup-tip {
      border-top-color: mat-color($background, card);
    }
    // Geocoder
    .mapboxgl-ctrl-geocoder {
      font-size: mat-font-size($typography, body-1);
      input[type='text'] {
        @include mat-typography-level-to-styles($typography, input);
        color: mat-color($foreground, text);
        &::placeholder {
          color: mat-color($foreground, secondary-text);
        }
      }
      &,
      & ul {
        background-color: mat-color($background, raised-button);
        @include mat-elevation-2;
      }
      ul {
        @include mat-typography-level-to-styles($typography, body-1);
      }
      ul > li > a {
        @include mat-typography-level-to-styles($typography, body-1);
        color: mat-color($foreground, secondary-text);
        border-bottom: solid 1px mat-color($foreground, divider);
        strong {
          font-weight: normal;
          color: mat-color($accent, 500);
        }
      }
      ul > li.active > a,
      ul > li > a:hover {
        color: mat-color($foreground, text);
        background-color: mat-color($background, hover);
      }
      .geocoder-pin-right * {
        background-color: mat-color($background, raised-button);
      }
    }
    .geocoder-icon-search {
      @include icon-search(mat-color($foreground, icon));
    }
    .geocoder-icon-close {
      @include icon-close(mat-color($foreground, icon));
    }
    .mapboxgl-ctrl-scale {
      background-color: transparent;
      @include mat-typography-level-to-styles($typography, body-1);
      color: mat-color($foreground, text);
      border-color: mat-color($foreground, text);
    }
  }
}
@mixin lja-map-components-theme ($theme, $typography) {
  @include lja-map-theme($theme, $typography);
}
