@import "../../themes/ionic.globals.ios";

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

/// @prop - Font size of the item text
$item-ios-body-text-font-size:            1.7rem !default;

// deprecated
$item-ios-paragraph-margin:               null !default;

/// @prop - Margin top of the item paragraph
$item-ios-paragraph-margin-top:           0 !default;

/// @prop - Margin end of the item paragraph
$item-ios-paragraph-margin-end:           0 !default;

/// @prop - Margin bottom of the item paragraph
$item-ios-paragraph-margin-bottom:        2px !default;

/// @prop - Margin start of the item paragraph
$item-ios-paragraph-margin-start:         $item-ios-paragraph-margin-end !default;

/// @prop - Font size of the item paragraph
$item-ios-paragraph-font-size:            1.4rem !default;

/// @prop - Color of the item paragraph
$item-ios-paragraph-text-color:           #8e9093 !default;

/// @prop - Size of the avatar in the item
$item-ios-avatar-size:                    36px !default;

/// @prop - Border radius of the avatar in the item
$item-ios-avatar-border-radius:           50% !default;

/// @prop - Size of the thumbnail in the item
$item-ios-thumbnail-size:                 56px !default;

/// @prop - Shows the detail arrow icon on an item
$item-ios-detail-push-show:               true !default;

/// @prop - Color of the detail arrow icon
$item-ios-detail-push-color:              $list-ios-border-color !default;

/// @prop - Icon for the detail arrow
$item-ios-detail-push-svg:                "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 20'><path d='M2,20l-2-2l8-8L0,2l2-2l10,10L2,20z' fill='#{$item-ios-detail-push-color}'/></svg>" !default;

/// @prop - Background for the divider
$item-ios-divider-background:             #f7f7f7 !default;

/// @prop - Color for the divider
$item-ios-divider-color:                  #222 !default;

/// @prop - Background for the sliding content
$item-ios-sliding-content-background:     $list-ios-background-color !default;


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

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

  position: relative;

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

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

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

  font-size: 2.4rem;
  font-weight: normal;
}

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

  font-size: 1.7rem;
  font-weight: normal;
}

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

  font-size: 1.4rem;
  font-weight: normal;
  line-height: normal;
}

.item-ios p {
  overflow: inherit;

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

  @include deprecated-variable(margin, $item-ios-paragraph-margin) {
    @include margin($item-ios-paragraph-margin-top, $item-ios-paragraph-margin-end, $item-ios-paragraph-margin-bottom, $item-ios-paragraph-margin-start);
  }
}

.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-block .item-inner {
  @include padding-horizontal(null, $item-ios-padding-end / 2);

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


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

.item-ios [item-left], // deprecated
.item-ios [item-start] {
  @include margin($item-ios-padding-media-top, $item-ios-padding-start, $item-ios-padding-media-bottom, 0);
}

.item-ios [item-right], // deprecated
.item-ios [item-end] {
  @include margin($item-ios-padding-media-top, ($item-ios-padding-start / 2), $item-ios-padding-media-bottom, ($item-ios-padding-end / 2));
}

.item-ios ion-icon[item-left], // deprecated
.item-ios ion-icon[item-right], // deprecated
.item-ios ion-icon[item-start],
.item-ios ion-icon[item-end] {
  @include margin($item-ios-padding-icon-top, null, $item-ios-padding-icon-bottom, 0);
}

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

  height: 24px;

  font-size: 1.3rem;
}

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

.item-ios ion-avatar[item-left], // deprecated
.item-ios ion-thumbnail[item-left], // deprecated
.item-ios ion-avatar[item-start],
.item-ios ion-thumbnail[item-start] {
  @include margin(($item-ios-padding-end / 2), $item-ios-padding-end, ($item-ios-padding-end / 2), 0);
}

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


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

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

.item-ios ion-avatar ion-img,
.item-ios ion-avatar img {
  @include border-radius($item-ios-avatar-border-radius);

  overflow: hidden;

  width: $item-ios-avatar-size;
  height: $item-ios-avatar-size;
}


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

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

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


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

// Only show the forward arrow icon if true
@if $item-ios-detail-push-show == true {
  .item-ios[detail-push] .item-inner,
  button.item-ios:not([detail-none]) .item-inner,
  a.item-ios:not([detail-none]) .item-inner {
    @include svg-background-image($item-ios-detail-push-svg, true);
    @include padding-horizontal(null, 32px);
    @include background-position(end, $item-ios-padding-end - 2, center);

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


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

ion-item-group .item-ios:first-child .item-inner {
  border-top-width: 0;
}

ion-item-group .item-ios:last-child .item-inner,
ion-item-group .item-wrapper:last-child .item-ios .item-inner {
  border: 0;
}


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

.item-divider-ios {
  @include padding-horizontal($item-ios-padding-start, null);

  color: $item-ios-divider-color;
  background-color: $item-ios-divider-background;
}


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

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
  // If there is text with a color it should use this color
  // and override whatever item sets it to
  .item-ios .text-ios-#{$color-name} {
    color: $color-base;
  }

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

    p {
      color: $color-contrast;
    }

    &.activated {
      background-color: color-shade($color-base);
    }
  }
}


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

.list-ios ion-item-sliding {
  background-color: $item-ios-sliding-content-background;
}
