/* Estilos compartidos por login, signup, confirmación y recuperación. */

@layer features {
  .auth {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    /*
      top − bottom = alto del navbar: el desbalance corre el centro óptico
      hacia abajo para compensar la barra fija, y justify-content: center
      hace el resto. Antes citaba 6rem suelto; ahora la barra y el aire
      quedan separados y auditables por separado.
    */
    padding: calc(var(--navbar-height) + 3rem) 1.5rem 3rem;
    background-color: var(--color-background);
  }

  .auth__card {
    width: 100%;
    max-width: 460px;
    min-inline-size: 0;
    text-align: center;
  }

  .auth__title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    margin-bottom: 0.5rem;
    background: var(--gradient-heading);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .auth__subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
  }

  .auth__status {
    min-inline-size: 0;
    margin-bottom: 1.25rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-field);
    color: var(--color-text-muted);
    line-height: 1.4;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .auth__status[hidden] {
    display: none;
  }

  .auth__status--error {
    border-color: #ff5c5c;
    color: #ffb4b4;
  }

  .auth__status--success {
    border-color: var(--color-success);
    color: #9ee8b9;
  }

  .auth__oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-field);
    background: var(--color-field);
    color: var(--color-text);
    font: inherit;
    cursor: pointer;
  }

  .auth__oauth-icon {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
  }

  .auth__oauth[aria-busy="true"] {
    cursor: wait;
    opacity: 0.65;
  }

  .auth__separator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    color: var(--color-text-muted);
    font-size: 0.85rem;
  }

  .auth__separator::before,
  .auth__separator::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--color-border);
  }

  .auth__form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-inline-size: 0;
  }

  .auth__form[hidden] {
    display: none;
  }

  .auth__field-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    text-align: left;
  }

  .auth__label {
    color: var(--color-text-muted);
    font-size: 0.85rem;
  }

  /* La casilla de "Recordarme".
   *
   * Mismo patrón que `.portal__checkbox`, que es el precedente del sitio: el
   * `<label>` envuelve al input, así que el texto también alterna la casilla —
   * en una pantalla táctil, la diferencia entre un blanco de 17px y uno de
   * toda la línea.
   *
   * `text-align: left` porque la tarjeta de auth centra su contenido y sin
   * esto el par casilla+texto quedaría flotando en el medio, desalineado de
   * los campos que tiene encima. */
  .auth__checkbox {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-align: left;
    color: var(--color-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
  }

  .auth__checkbox input[type="checkbox"] {
    inline-size: 1.1rem;
    block-size: 1.1rem;
    accent-color: var(--color-accent);
    cursor: pointer;
  }

  .auth__phone-row {
    display: flex;
    gap: 0.5rem;
  }

  .auth__phone-prefix {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 3.5rem;
    padding: 1rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-field);
    background: var(--color-field);
    color: var(--color-text-muted);
  }

  .auth__phone-input {
    flex: 1;
    min-width: 0;
  }

  .auth__submit {
    align-self: center;
    margin-top: 0.5rem;
    padding: 0.9rem 2.5rem;
  }

  .auth__submit:disabled,
  .auth__submit--loading {
    cursor: wait;
    opacity: 0.65;
  }

  .auth__actions {
    width: 100%;
    min-inline-size: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
  }
  /* El `display: flex` de arriba le gana al `[hidden]` del navegador. El portal
     nace con este bloque oculto y sólo un fallo de reauth lo revela; sin esta
     regla los dos botones se veían siempre, encima de un portal cargado. */
  .auth__actions[hidden] {
    display: none;
  }

  .auth__link,
  .auth__link-button {
    max-inline-size: 100%;
    border: 0;
    background: transparent;
    color: var(--color-accent);
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    overflow-wrap: anywhere;
  }

  .auth__link:hover,
  .auth__link-button:hover {
    text-decoration: underline;
  }

  .auth__link-button[hidden] {
    display: none;
  }

  .auth__legal {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    line-height: 1.5;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .password-field {
    position: relative;
  }

  .password-field__input {
    padding-right: 2.75rem;
  }

  .password-field__input::-ms-reveal,
  .password-field__input::-ms-clear {
    display: none;
  }

  .password-field__toggle {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-accent);
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.2s ease;
  }

  .password-field__toggle:hover,
  .password-field__toggle:focus-visible {
    opacity: 1;
  }

  .password-field__icon {
    width: 1.25rem;
    height: 1.25rem;
  }

  .password-field__icon--hide {
    display: none;
  }

  .password-field__toggle--showing .password-field__icon--show {
    display: none;
  }

  .password-field__toggle--showing .password-field__icon--hide {
    display: block;
  }

  .password-requirements {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin: -0.4rem 0 0;
    padding: 0;
    list-style: none;
    text-align: left;
  }

  .password-requirements__item {
    color: #888;
    font-size: 0.8rem;
    transition: color 0.2s ease;
  }

  .password-requirements__item::before {
    content: "○ ";
  }

  .password-requirements__item--valid {
    color: var(--color-success);
  }

  .password-requirements__item--valid::before {
    content: "✓ ";
  }

  .password-requirements__item--invalid {
    color: var(--color-error);
  }

  .password-requirements__item--invalid::before {
    content: "✕ ";
  }

  .password-match {
    font-size: .8rem;
    color: #888;
    transition: color .2s ease;
    margin: -0.4rem 0 0;
  }

  .password-match--ok {
    color: var(--color-success);
  }

  .password-match--error {
    color: var(--color-error);
  }

  .auth__spinner {
    width: 2rem;
    height: 2rem;
    margin: 0 auto 1rem;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: auth-spin 0.8s linear infinite;
  }

  .auth__section[hidden] {
    display: none;
  }

  @keyframes auth-spin {
    to {
      transform: rotate(360deg);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .auth__spinner {
      animation: none;
    }
  }
}
