/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

@use '@material/theme/custom-properties';
@use '@material/notched-outline' as notchedoutline;
@use '@material/theme/theme';
@use '@material/theme/theme-color';
@use '@material/rtl';

@include notchedoutline.core-styles();

:host {
  display: block;
  position: absolute;
  right: 0;
  left: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  height: 100%;
  /* @noflip */
  text-align: left;
  pointer-events: none;

  @include rtl.rtl() {
    /* @noflip */
    text-align: right;
  }
}

::slotted(.mdc-floating-label) {
  display: inline-block;
  position: relative;
  top: 17px;
  bottom: auto;
  max-width: 100%;
}

::slotted(.mdc-floating-label--float-above) {
  text-overflow: clip;
}

.mdc-notched-outline--upgraded ::slotted(.mdc-floating-label--float-above) {
  max-width: calc(100% / 0.75);
}

.mdc-notched-outline {
  // Normally shape-radius is included by textfield/select's shape radius mixin
  @include notchedoutline.shape-radius(small);
}

.mdc-notched-outline__leading,
.mdc-notched-outline__notch,
.mdc-notched-outline__trailing {
  border-color: var(
    --mdc-notched-outline-border-color,
    var(--mdc-theme-primary, #{theme-color.$primary})
  );

  @include theme.property(
    border-width,
    (
      varname: --mdc-notched-outline-stroke-width,
      fallback: 1px,
    )
  );
}

.mdc-notched-outline--notched .mdc-notched-outline__notch {
  @include theme.property(
    padding-top,
    (
      // TODO: Collapse this to also use the --mdc-notched-outline-stroke-widt
      // variable and update default value to 1px to correct textfield notche
      // label misalignment (currently ~1px higher than center-aligned)
      // Currently this is only overridden in mwc-select
      // Context: go/mwc-textfield-label-misalignmen
      varname: --mdc-notched-outline-notch-offset,
      fallback: 0
    )
  );
}
