//
// Copyright 2019 Stijn de Witt. Some rights reserved.
// Licensed under the MIT Open Source license. 
// https://opensource.org/licenses/MIT
// See LICENSE for details.
//
// Based on code copyright 2018 Google Inc. All Rights Reserved.
// Licensed under the Apache License, Version 2.0.
// http://www.apache.org/licenses/LICENSE-2.0
// See LICENSE-MDC for details.
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under these licenses is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the licenses for the specific language governing permissions and
// limitations under these licenses.
// 

@import "../ripple/common";
@import "../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_;
}

// 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--unbounded .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
