/* --------------------------------

File#: _1_password
Title: Password Visibility Control
Descr: Password input field with option to toggle password visibility
Usage: codyhouse.co/license

-------------------------------- */

/* variables */
:root {
  /* colors */
  --po6-color-primary-hsl: 250, 84%, 54%;
  --po6-color-bg-hsl: 0, 0%, 100%;
  --po6-color-contrast-high-hsl: 230, 7%, 23%;
  --po6-color-contrast-higher-hsl: 230, 13%, 9%;
  --po6-color-bg-dark-hsl: 240, 4%, 95%;
  --po6-color-contrast-lower-hsl: 240, 4%, 85%;
  --po6-color-contrast-low-hsl: 240, 4%, 65%;

  /* spacing */
  --po6-space-2xs: 0.375rem;
  --po6-space-sm: 0.75rem;
  --po6-space-xs: 0.5rem;

  /* typography */
  --po6-text-sm: 0.833rem;
}

@media(min-width: 64rem){
  :root {
    /* spacing */
    --po6-space-2xs: 0.5625rem;
    --po6-space-sm: 1.125rem;
    --po6-space-xs: 0.75rem;

    /* typography */
    --po6-text-sm: 1rem;
  }
}

/* form elements */
.po6-form-control {
  font-size: 1em;
  padding: var(--po6-space-2xs) var(--po6-space-xs);
  background: hsl(var(--po6-color-bg-dark-hsl));
  line-height: 1.2;
  box-shadow: inset 0px 0px 0px 1px hsl(var(--po6-color-contrast-lower-hsl));
  transition: all 0.2s ease;
  border-radius: 0.25em;
}

.po6-form-control::placeholder {
  opacity: 1;
  color: hsl(var(--po6-color-contrast-low-hsl));
}

.po6-form-control:focus, .po6-form-control:focus-within {
  background: hsl(var(--po6-color-bg-hsl));
  box-shadow: inset 0px 0px 0px 1px hsla(var(--po6-color-contrast-lower-hsl), 0), 0px 0px 0px 2px hsl(var(--po6-color-primary-hsl)), 0 0.3px 0.4px rgba(0, 0, 0, 0.025),0 0.9px 1.5px rgba(0, 0, 0, 0.05), 0 3.5px 6px rgba(0, 0, 0, 0.1);
  outline: none;
}

.po6-form-label {
  display: inline-block;
  font-size: var(--po6-text-sm);
}

/* icons */
.po6-icon {
  height: var(--po6-size, 1em);
  width: var(--po6-size, 1em);
  display: inline-block;
  color: inherit;
  fill: currentColor;
  line-height: 1;
  flex-shrink: 0;
  max-width: initial;
}

/* component */
:root {
  --password-btn-width: 3.5em;
  --password-icon-size: 1.5em;
}

.password {
  position: relative;
}

.password__input {
  height: 100%;
}

.password__btn {
  background-color: transparent;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: inherit;
  line-height: inherit;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  position: absolute;
  z-index: 1;
  top: 0;
  right: 0;
  height: 100%;
  width: var(--password-btn-width);
  background-color: rgba(255, 255, 255, 0);
  justify-content: center;
  align-items: center;
  display: none;
}
.password__btn:focus {
  color: hsl(var(--po6-color-primary-hsl));
}

.password__btn-label:last-child {
  display: none;
}
.password__btn-label svg {
  width: var(--password-icon-size);
  height: var(--password-icon-size);
}

.password--text-is-visible .password__btn-label:first-child {
  display: none;
}
.password--text-is-visible .password__btn-label:last-child {
  display: inline-block;
}

.password__input {
  padding-right: calc(var(--po6-space-sm) + var(--password-btn-width));
}

.password__input::-ms-reveal {
  display: none;
}

.password__btn {
  display: flex;
}

/* utility classes */
.po6-text-sm {
  font-size: var(--po6-text-sm);
}

.po6-flex-center {
  justify-content: center;
  align-items: center;
}

.po6-flex {
  display: flex;
}

.po6-width-100\% {
  width: 100%;
}

.po6-margin-bottom-2xs {
  margin-bottom: var(--po6-space-2xs);
}

.po6-block {
  display: block;
}
