@import "./item";
@import "./item.ios.vars";

// iOS Item
// --------------------------------------------------

.item-ios {
  @include padding-horizontal($item-ios-padding-start, null);
  @include safe-area-padding-horizontal($item-ios-padding-start, null);
  @include border-radius(0);

  position: relative;

  font-family: $item-ios-font-family;

  font-size: $item-ios-font-size;
  color: $item-ios-text-color;
  background-color: $item-ios-background-color;
  transition: background-color 200ms linear;
}

.item-ios.activated {
  background-color: $item-ios-background-color-active;
  transition-duration: 0ms;
}

.item-ios h1 {
  @include margin(0, 0, 2px);

  font-size: 24px;
  font-weight: normal;
}

.item-ios h2 {
  @include margin(0, 0, 2px);

  font-size: 17px;
  font-weight: normal;
}

.item-ios h3,
.item-ios h4,
.item-ios h5,
.item-ios h6 {
  @include margin(0, 0, 3px);

  font-size: 14px;
  font-weight: normal;
  line-height: normal;
}

.item-ios p {
  @include margin($item-ios-paragraph-margin-top, $item-ios-paragraph-margin-end, $item-ios-paragraph-margin-bottom, $item-ios-paragraph-margin-start);

  overflow: inherit;

  font-size: $item-ios-paragraph-font-size;
  line-height: normal;
  text-overflow: inherit;
  color: $item-ios-paragraph-text-color;
}

.item-ios h2:last-child,
.item-ios h3:last-child,
.item-ios h4:last-child,
.item-ios h5:last-child,
.item-ios h6:last-child,
.item-ios p:last-child {
  @include margin(null, null, 0, null);
}

.item-ios .item-inner {
  @include padding-horizontal(null, $item-ios-padding-end / 2);

  @media screen and (orientation: landscape) {
    @include safe-area-padding-horizontal(null, $item-ios-padding-end / 2);
  }

  border-bottom: $hairlines-width solid $item-ios-border-color;
}


// iOS Items in Lists
// --------------------------------------------------
// Removed the requirement that their immmediate
// parent is listed this adds support for other list components

ion-list,
ion-reorder-group > ion-gesture {
  > ion-item:first-child .item-ios,
  > ion-item-sliding:first-child .item-ios {
    border-top: $hairlines-width solid $item-ios-border-color;
  }

  > ion-item:last-child .item-ios,
  > ion-item-sliding:last-child .item-ios {
    border-bottom: $hairlines-width solid $item-ios-border-color;
  }

  > ion-item:last-child .item-ios .item-inner,
  > ion-item-sliding:last-child .item-ios .item-inner {
    border-bottom: 0;
  }
}

// iOS Item Slots
// --------------------------------------------------

.item-ios [slot="start"] {
  @include margin($item-ios-slot-start-margin-top, $item-ios-slot-start-margin-end, $item-ios-slot-start-margin-bottom, $item-ios-slot-start-margin-start);
}

.item-ios [slot="end"] {
  @include margin($item-ios-slot-end-margin-top, $item-ios-slot-end-margin-end, $item-ios-slot-end-margin-bottom, $item-ios-slot-end-margin-start);
}

.item-ios > ion-icon[slot="start"],
.item-ios > ion-icon[slot="end"] {
  @include margin($item-ios-icon-slot-margin-top, $item-ios-icon-slot-margin-end, $item-ios-icon-slot-margin-bottom, $item-ios-icon-slot-margin-start);
}

.item-ios.item-label-stacked [slot="end"],
.item-ios.item-label-floating [slot="end"] {
  @include margin($item-ios-label-slot-end-margin-top, $item-ios-label-slot-end-margin-end, $item-ios-label-slot-end-margin-bottom, $item-ios-label-slot-end-margin-start);
}


// iOS Item Button
// --------------------------------------------------

.item-ios .button-small-ios {
  @include padding(0, .5em);

  height: 24px;

  font-size: 13px;
}

.item-ios .button-small-ios ion-icon[slot="icon-only"] {
  @include padding(0, 1px);
}


// iOS Item Avatar & Thumbnail
// --------------------------------------------------

.item-ios ion-avatar {
  width: $item-ios-avatar-width;
  height: $item-ios-avatar-height;
}

.item-ios ion-thumbnail {
  width: $item-ios-thumbnail-width;
  height: $item-ios-thumbnail-height;
}

.item-ios ion-avatar[slot="end"],
.item-ios ion-thumbnail[slot="end"] {
  @include margin(($item-ios-padding-end / 2));
}


// iOS Item Detail Push
// --------------------------------------------------

// Only show the forward arrow icon if true
.item-ios.item-detail-push .item-inner {
  $safe-area-position: calc(#{$item-ios-padding-end - 2} + constant(safe-area-inset-right));
  $safe-area-position-env: calc(#{$item-ios-padding-end - 2} + env(safe-area-inset-right));

  @include item-push-svg-url($item-ios-detail-push-color);
  @include padding-horizontal(null, 32px);
  @include background-position(end, $item-ios-padding-end - 2, center);
  @include background-position(end, $safe-area-position, center);
  @include background-position(end, $safe-area-position-env, center);

  background-repeat: no-repeat;
  background-size: 14px 14px;
}


// Generate iOS Item and Item Divider Colors
// --------------------------------------------------

@each $color-name, $color-value in $colors-ios {
  $color-base: ion-color($colors-ios, $color-name, base, ios);
  $color-contrast: ion-color($colors-ios, $color-name, contrast, ios);
  $color-shade: ion-color($colors-ios, $color-name, shade, ios);
  $color-tint: ion-color($colors-ios, $color-name, tint, ios);

  .item-ios-#{$color-name} {
    color: $color-contrast;
    background-color: $color-base;

    .item-inner {
      border-bottom-color: $color-shade;
    }

    p {
      color: $color-contrast;
    }

    &.activated {
      background-color: $color-tint;
    }
  }

  .item-ios-#{$color-name}.item-detail-push .item-inner {
    @include item-push-svg-url($color-shade);
  }
}
