//
// Copyright 2016 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions://
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@import "@material/ripple/common";
@import "@material/ripple/mixins";
@import "./mixins";
@import "./variables";

// postcss-bem-linter: define checkbox

.mdc-checkbox {
  @include mdc-checkbox-base_;
  @include mdc-ripple-surface;
  @include mdc-states($mdc-checkbox-baseline-theme-color);
  @include mdc-ripple-radius-unbounded;
}

@at-root {
  @include mdc-checkbox-ink-color($mdc-checkbox-mark-color);
  @include mdc-checkbox-focus-indicator-color($mdc-checkbox-baseline-theme-color);
  @include mdc-checkbox-container-colors;
  @include mdc-checkbox-disabled-container-color_;
}

@media screen and (-ms-high-contrast: active) {
  .mdc-checkbox__mixedmark {
    margin: 0 1px;  // Extra horizontal space around mixedmark symbol.
  }
}

// Needed to disable hover effects on CSS-only (non-JS) checkboxes
.mdc-checkbox--disabled {
  @include mdc-checkbox--disabled_;
}

.mdc-checkbox__background {
  @include mdc-checkbox__background_;
}

.mdc-checkbox__checkmark {
  @include mdc-checkbox__checkmark_;
}

.mdc-checkbox__checkmark-path {
  @include mdc-checkbox__checkmark-path_;
}

.mdc-checkbox__mixedmark {
  @include mdc-checkbox__mixedmark_;
}

// JS checkbox
.mdc-checkbox--upgraded {
  .mdc-checkbox__background,
  .mdc-checkbox__checkmark,
  .mdc-checkbox__checkmark-path,
  .mdc-checkbox__mixedmark {
    @include mdc-checkbox__child--upgraded_;
  }
}

.mdc-checkbox--anim {
  @include mdc-checkbox--anim_;
}

.mdc-checkbox__native-control:checked ~ .mdc-checkbox__background,
.mdc-checkbox__native-control:indeterminate ~ .mdc-checkbox__background {
  @include mdc-checkbox__background--marked_;

  .mdc-checkbox__checkmark-path {
    @include mdc-checkbox__checkmark-path--marked_;
  }
}

// The frame's ::before element is used as a focus indicator for the checkbox
.mdc-checkbox__background::before {
  @include mdc-checkbox__focus-indicator_;
}

.mdc-ripple-upgraded--background-focused .mdc-checkbox__background::before {
  @include mdc-checkbox__focus-indicator--ripple-upgraded-unbounded_;
}

.mdc-checkbox__native-control:focus ~ .mdc-checkbox__background::before {
  @include mdc-checkbox__focus-indicator--focused_;
}

.mdc-checkbox__native-control {
  @include mdc-checkbox__native-control_;

  &:disabled {
    @include mdc-checkbox--disabled_;
  }
}

.mdc-checkbox__native-control:checked ~ .mdc-checkbox__background {
  .mdc-checkbox__checkmark {
    @include mdc-checkbox__checkmark--checked_;
  }

  .mdc-checkbox__mixedmark {
    @include mdc-checkbox__mixedmark--checked_;
  }
}

.mdc-checkbox__native-control:indeterminate ~ .mdc-checkbox__background {
  .mdc-checkbox__checkmark {
    @include mdc-checkbox__checkmark--indeterminate_;
  }

  .mdc-checkbox__mixedmark {
    @include mdc-checkbox__mixedmark--indeterminate_;
  }
}

// postcss-bem-linter: end
