/* Layer: ds.components.global (@canonical/styles README, "Cascade layers"). */

@layer ds.components.global {
  /* Generated by @canonical/summon-component:react v0.1.0 */

  /* Masked secret entry with a reveal/mask (eye) toggle in the suffix position;
   * no prefix. Chrome mirrors the text input; the toggle uses the show/hide icons
   * from @canonical/ds-assets, masked so they take `currentColor`. */
  .ds.input.password {
    direction: inherit;
    display: flex;
    align-items: stretch;
    position: relative;
    padding: 0;

    & > input {
      flex: 1;
      min-width: 0;
      border: none;
      background: transparent;
      color: inherit;
      font-family: inherit;
      outline: none;
      /* Baseline engine provides font-size, line-height, padding via `.p` */
      padding-inline: var(--form-input-padding-inline);
    }

    & > .reveal-toggle {
      display: flex;
      align-items: center;
      justify-content: center;
      padding-inline: var(--form-field-inline-gap);
      border: none;
      background: transparent;
      color: var(--color-icon);
      cursor: pointer;

      & > .reveal-icon {
        width: var(--dimension-200); /* 16px */
        height: var(--dimension-200);
        background-color: currentColor;
        mask-repeat: no-repeat;
        mask-position: center;
        mask-size: contain;
        -webkit-mask-repeat: no-repeat;
        -webkit-mask-position: center;
        -webkit-mask-size: contain;

        &[data-state="masked"] {
          mask-image: url("/icons/show.svg#show");
          -webkit-mask-image: url("/icons/show.svg#show");
        }

        &[data-state="revealed"] {
          mask-image: url("/icons/hide.svg#hide");
          -webkit-mask-image: url("/icons/hide.svg#hide");
        }
      }

      /* No hover colour change: the reveal toggle keeps `--color-icon` in all
       * pointer states (per design review). */

      &:focus-visible {
        outline: none;
        box-shadow: 0 0 0 1px var(--color-focus-ring);
        border-radius: var(--form-input-border-radius);
      }
    }
  }
}
