/*
 * The login page (core/login.html), after the Canva's login mock: an avatar ring beside
 * two pill fields on the band colour. The password field ends in knowei.nl's arrow, which
 * signs in (as Enter does). Below the fields: a wrong password with the tries left, or the
 * lockout (ADR 0014).
 */

@layer components {
  /* The footer (layout.css) on the screen's bottom edge, a hairline above it, as the band
     around it has its colour. */
  main:has(> .login) {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--size-header-band));
    background: var(--band);
  }

  main:has(> .login) > .page-footer {
    flex: none;
    margin-top: auto;
    border-top: var(--stroke-hairline) solid color-mix(in srgb, var(--rule) 60%, transparent);
  }

  .login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding-top: 22vh;
  }

  .login__avatar {
    width: 120px;
    height: 120px;
    color: var(--color-30);
  }

  .login__fields {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: 432px;
  }

  .login__field {
    height: 48px;
    width: 100%;
    /* The same on both sides, so the text stays centred and clear of the arrow. */
    padding: 0 var(--space-12);
    border: var(--stroke-frame) solid var(--color-30);
    border-radius: var(--radius-pill);
    font: var(--type-popup-title);
    color: var(--color-90);
    text-align: center;
    text-overflow: ellipsis; /* a long value ends in … while the field isn't focused */
    background: var(--color-70);
    transition: border-color var(--kn-dur) var(--kn-ease);
  }

  .login__field::placeholder {
    color: var(--color-90);
    text-transform: uppercase;
    opacity: 1;
  }

  /* The label hides while the field has focus and returns when it is left empty. */
  .login__field:focus::placeholder {
    color: transparent;
  }

  .login__field:focus-visible {
    border-color: var(--white);
    outline: none;
  }

  .login__error {
    font: var(--type-body);
    color: var(--color-90);
    text-align: center;
  }

  .login__password {
    position: relative;
  }

  .login__submit {
    position: absolute;
    top: 50%;
    right: var(--space-2);
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--color-90);
    cursor: pointer;
    background: none;
    border: 0;
    translate: 0 -50%;
    transition: color var(--kn-dur) var(--kn-ease);
  }

  :where(:root[data-input="mouse"]) .login__submit:hover,
  .login__submit:focus-visible {
    color: var(--white);
    outline: none;
  }

  .login__submit svg {
    width: 20px;
    height: 20px;
  }

  /* Labels: read by screen readers, not shown. */
  .login__hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /*
   * A phone or portrait tablet (the page's viewport meta is device-width here): the avatar
   * above the fields (the header and the page's minimum width: layout.css).
   */
  @media (width < 1024px), (orientation: portrait), (max-device-width: 1023px) {
    .login {
      flex-direction: column;
      gap: var(--space-6);
      padding: var(--space-12) var(--space-4) var(--space-8);
    }

    .login__fields {
      width: 100%;
      max-width: 432px;
    }
  }
}
