//
// Copyright IBM Corp. 2019, 2020
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

$css--plex: true !default;

@import 'carbon-components/scss/components/list/list';

:host(#{$prefix}-ordered-list),
:host(#{$prefix}-unordered-list) {
  display: block;
  padding-left: $carbon--spacing-06;

  .#{$prefix}--list--nested {
    margin-left: 0;
  }
}

:host(#{$prefix}-ordered-list) {
  .#{$prefix}--list--ordered {
    list-style-type: decimal;
  }

  .#{$prefix}--list--ordered.#{$prefix}--list--nested {
    list-style-type: lower-latin;
  }
}

:host(#{$prefix}-unordered-list) {
  --#{$prefix}-ce--list-marker: '\002013'; // – en dash

  &[slot='nested'] {
    --#{$prefix}-ce--list-marker: '\0025AA'; // ▪ square
  }
}

:host(#{$prefix}-unordered-list) ::slotted(#{$prefix}-list-item) {
  position: relative;

  &::before {
    position: absolute;
    left: -$carbon--spacing-05;
    content: '\002013'; // – en dash
  }
}

:host(#{$prefix}-unordered-list[slot='nested']) ::slotted(#{$prefix}-list-item)::before {
  left: -$carbon--spacing-04; // offset to account for smaller ▪ vs –
  content: '\0025AA'; // ▪ square
}

:host(#{$prefix}-list-item) {
  display: list-item;
  color: $text-01;
  margin-bottom: $carbon--spacing-02;

  &::before {
    // Workaround for https://bugs.webkit.org/show_bug.cgi?id=178237.
    // For non-WebKit browsers, `:host(#{$prefix}-unordered-list) ::slotted(#{$prefix}-list-item)` takes this over.
    position: absolute;
    left: -$carbon--spacing-05;
    content: var(--#{$prefix}-ce--list-marker, none);
  }

  .#{$prefix}-ce--list__item__nested-child {
    padding-top: $carbon--spacing-02;
  }
}

:host(#{$prefix}-list-item[nested]) {
  margin-top: 0;
  margin-bottom: 0;

  .#{$prefix}-ce--list__item__nested-child {
    padding-top: 0;
  }
}
