// TODO(jelbourn): Measure perf benefits for translate3d and will-change.
// TODO(jelbourn): Figure out if anchor hover underline actually happens in any browser.

@import 'button-base';
@import '../core/a11y/a11y';

// TODO(kara): Replace attribute selectors with class selectors when possible
[md-button], [md-icon-button] {
  @extend %md-button-base;

  // Only flat buttons and icon buttons (not raised or fabs) have a hover style.
  &:hover {
    // Use the same visual treatment for hover as for focus.
    .md-button-focus-overlay {
      opacity: 1;
    }
  }

  &[disabled]:hover {
    &.md-primary, &.md-accent, &.md-warn, .md-button-focus-overlay {
      background-color: transparent;
    }
  }
}

[md-raised-button] {
  @extend %md-raised-button;
}

[md-fab] {
  @include md-fab($md-fab-size, $md-fab-padding);
}

[md-mini-fab] {
  @include md-fab($md-mini-fab-size, $md-mini-fab-padding);
}

[md-icon-button] {
  padding: 0;

  // Reset the min-width from the button base.
  min-width: 0;

  width: $md-icon-button-size;
  height: $md-icon-button-size;

  flex-shrink: 0;

  line-height: $md-icon-button-size;
  border-radius: $md-icon-button-border-radius;

  i, md-icon {
    line-height: $md-icon-button-line-height;
  }
}

// The text and icon should be vertical aligned inside a button
[md-button], [md-raised-button], [md-icon-button] {
  .md-button-wrapper > * {
    vertical-align: middle;
  }
}

// The ripple container should match the bounds of the entire button.
.md-button-ripple, .md-button-focus-overlay {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
}

// Overlay to be used as a tint. Note that the same effect can be achieved by using a pseudo
// element, however we use a proper DOM element in order to be able to disable the default
// touch action. This makes the buttons more responsive on touch devices.
.md-button-focus-overlay {
  // The button spec calls for focus on raised buttons (and FABs) to be indicated with a
  // black, 12% opacity shade over the normal color (for both light and dark themes).
  background-color: rgba(black, 0.12);
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;

  @include cdk-high-contrast {
    // Note that IE will render this in the same way, no
    // matter whether the theme is light or dark. This helps
    // with the readability of focused buttons.
    background-color: rgba(white, 0.5);
  }
}

// For round buttons, the ripple container should clip child ripples to a circle.
.md-button-ripple-round {
  border-radius: 50%;
  // z-index needed to make clipping to border-radius work correctly.
  // http://stackoverflow.com/questions/20001515/chrome-bug-border-radius-not-clipping-contents-when-combined-with-css-transiti
  z-index: 1;
}

// Add an outline to make it more visible in high contrast mode.
@include cdk-high-contrast {
  [md-button], [md-raised-button], [md-icon-button], [md-fab], [md-mini-fab] {
    outline: solid 1px;
  }
}
