/// button.scss -*- Mode: scss; indent-tabs-mode: nil; basic-offset: 2 -*-
@import 'extends';

// sometimes fabs get squized
.md-button.md-fab {
  min-width: $button-fab-width;
}

// Buttons for the sidenav folder tree
// ------------------------------------
md-sidenav md-list .md-button,
.view-list md-list .md-button {
  // dirty fix to squash the theme style
  background-color: transparent !important;
}

.view-list md-list .md-button {
  // Gain some space in lists
  padding: 0;
}

// Expandable button for a collapsable list
.sg-expandable {
    width: 100%;
}

///
/// sg-icon-button
/// according to Material design specs:
/// @link www.google.com/design/spec/style/icons.html#icons-system-icons
/// @link www.google.com/design/spec/layout/metrics-keylines.html#metrics-keylines-touch-target-size
/// @link www.google.com/design/spec/layout/structure.html#structure-app-bar
/// @require angular-material/components/button
///
/// Buttons here defined are project-wide, so we don't use mixin but variables
/// ----------------------------------------------------------------------------

// Variables
$iconButton-size: $touch-zone-width;
$iconButton-icon-size: sg-size(title);
$iconButton-menu-size: sg-size(headline);
$iconButton-icon-padding: 2px;
$iconButton-size-cursor-coarse: $iconButton-size;
// Could be use to scale-down buttons if desktop layout suffers too much from touch-size
$iconButton-size-cursor-fine: $iconButton-size;
// convenient wrapper for padding calculation todo: write a mixin or a function for a more generic use
$iconButton-padding: ($iconButton-size - ($iconButton-icon-size + ($iconButton-icon-padding * 2))) / 2;
$iconButton-hover-scale: 1.25;
$iconButton-transition: all $swift-ease-in-duration $swift-ease-in-timing-function;

$button-fab-width: 56px;
$button-fab-height: 56px;

a.md-button.sg-icon-button,
.md-button.sg-icon-button,
md-list md-list-item button.md-button.sg-icon-button {
  z-index: 1;
  //line-height: inherit;
  border-radius: 50%;
  min-width: $iconButton-size;
  transition: $iconButton-transition;
  &:hover,
  &:active {
    background-color: transparent;
    transform: scale($iconButton-hover-scale);
  }
  .md-ripple-container {
    border-radius: 50%;
  }
}

// Center icon button inside md-avatar
.md-avatar {
  .sg-icon-button {
    margin-top: 1px;
    margin-left: 2px;
  }
}

// md-toolbar .md-toolbar-tools:first-of-type .iconButton,
// md-toolbar .md-toolbar-tools:first-child .iconButton,
// md-toolbar .md-toolbar-tools.md-toolbar-tools-top .iconButton,
// md-toolbar .md-toolbar-tools:not(.md-toolbar-tools-bottom) .iconButton {
//   margin-top: ($mg * -1);
// }
// First button must have it's icon align to margin/padding
// md-toolbar .md-toolbar-tools .iconButton:first-child,
// .sg-toolbar-group-last .iconButton:first-child {
//   margin-left: ($mg * -1);
// }
// md-content.md-padding,
// md-card-content {
//   &> .iconButton:first-child {
//     margin-top: ($mg * -1);
//     margin-left: ($mg * -1);
//   }
// }
// Last button must have it's icon align to margin/padding
// md-toolbar .md-toolbar-tools .iconButton:last-child,
// .sg-toolbar-group-last .iconButton:last-child {
//   margin-right: ($mg * -1);
// }

// Icon-bars are for iconButtons, by default they're vertical and at the right
// the modifier class is to reflect those values and leave place to other versions
.sg-icon-bar--vertical {
  display: flex;
  flex-direction: column;
  margin: 0 ($mg * -1) 0 $mg;
  font-size: $sg-font-size-3;
  align-items: center;
  // Containers have padding, we compensate to align according to specs
  justify-content: space-between;

  // for transitions
  @include at(sm) {
    margin-left: $iconButton-padding;
  }
}

// NiceToHave: some horizontal or left hand side variant

.sg-icon-bar *.button {
  display: block;
}

.sg-button-navicon {
  //top: ($mg * -1);
  //margin-left: ($mg * -1);
  width: $touch-zone;
  height: $touch-zone;
  line-height: $touch-zone;
}

// angular-material is overspecifying so we are and so we have to continue
.sg-button-navicon.sg-icon-button md-icon,
.sg-button-navicon.sg-icon-button {
  padding: 0;
  font-size: $iconButton-menu-size;
}
