/* pages/auth.css
 *
 * Authentication screens - "Ledger pages", an extension of the landing's
 * editorial vocabulary. Slim masthead, centered column, hairline-framed
 * form. Brass shows up once per page on a single underlined word in the
 * H1. Everything else is forest ink on warm paper.
 *
 * Composes NanoUI primitives (nano-input, nano-btn, nano-alert) for
 * field-level styling; this file provides only the page shell and the
 * editorial type/space treatment.
 */

.auth {
  --auth-gutter:    clamp(1.5rem, 5vw, 4rem);
  --auth-column:    26rem;
  --auth-control-h: 2.75rem;

  font-feature-settings: "ss01", "cv11", "tnum";
  color: hsl(var(--color-foreground));
  background-color: hsl(var(--color-background));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Masthead (slim variant of marketing-masthead) ---------- */

.auth-masthead {
  padding-block: var(--space-8);

  .auth-masthead__inner {
    max-width: 72rem;
    margin-inline: auto;
    padding-inline: var(--auth-gutter);
  }

  .auth-masthead__wordmark {
    font-weight: 800;
    font-size: var(--text-xl);
    letter-spacing: -0.03em;
    text-decoration: none;
    line-height: 1;
    display: inline-block;
  }

  .auth-masthead__wordmark-fore {
    color: hsl(var(--color-primary));
  }

  .auth-masthead__wordmark-accent {
    color: hsl(var(--color-accent-bright));
  }

  .auth-masthead__wordmark:hover {
    .auth-masthead__wordmark-fore   { color: hsl(var(--color-primary) / 0.8); }
    .auth-masthead__wordmark-accent { color: hsl(var(--color-accent-bright) / 0.85); }
  }
}

/* ---------- Main column ---------- */

.auth-main {
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-block: clamp(1.5rem, 5vw, 4rem) clamp(3rem, 8vw, 5rem);
  padding-inline: var(--auth-gutter);
}

.auth-shell {
  width: 100%;
  max-width: var(--auth-column);
}

/* ---------- Editorial type stack ---------- */

.auth-headline {
  font-size: clamp(2rem, 4.5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.02;
  color: hsl(var(--color-primary));
  margin: 0 0 var(--space-4);
  max-width: 18ch;
  text-wrap: balance;
}

.auth-headline__emphasis {
  color: hsl(var(--color-accent-bright));
  white-space: nowrap;
}

.auth-sub {
  font-size: var(--text-base);
  line-height: 1.55;
  color: hsl(var(--color-muted-foreground));
  margin: 0 0 var(--space-8);
  max-width: 36ch;
  text-wrap: pretty;
}

/* ---------- Hairline-framed form ---------- */

.auth-card {
  border-top: 1px solid hsl(var(--color-border));
  border-bottom: 1px solid hsl(var(--color-border));
  padding-block: var(--space-8);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);

  .auth-field__label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: hsl(var(--color-muted-foreground));
  }

  .auth-field__control {
    position: relative;
    display: block;
  }

  .auth-field__input {
    min-height: var(--auth-control-h);
    font-size: var(--text-base);
    padding-inline: var(--space-4);
  }

  .auth-field__input--password {
    padding-right: var(--auth-control-h);
  }

  .auth-field__hint {
    font-size: var(--text-sm);
    color: hsl(var(--color-muted-foreground));
    margin: 0;
  }
}

.auth-field__reveal {
  /* Reset the global button defaults from nanoui/components/button.css */
  position: absolute;
  top: 0;
  right: 0;
  width: var(--auth-control-h);
  height: var(--auth-control-h);
  padding: 0;
  background: transparent;
  color: hsl(var(--color-muted-foreground));
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--duration-fast) var(--ease-default);

  &:hover {
    background: transparent;
    color: hsl(var(--color-foreground));
  }

  &:focus-visible {
    outline: 2px solid hsl(var(--color-ring));
    outline-offset: -3px;
    color: hsl(var(--color-foreground));
  }

  .auth-field__reveal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .auth-field__reveal-icon[hidden] {
    display: none;
  }
}

.auth-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: hsl(var(--color-muted-foreground));

  input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: hsl(var(--color-primary));
  }
}

.auth-actions {
  margin-top: var(--space-2);
}

.auth-actions__submit {
  width: 100%;
  min-height: var(--auth-control-h);
  font-size: var(--text-base);
  font-weight: 600;
}

/* ---------- Error block ---------- */

.auth-errors {
  margin-bottom: var(--space-2);

  .auth-errors__title {
    margin: 0 0 var(--space-2);
    font-size: var(--text-sm);
    font-weight: 600;
  }

  .auth-errors__list {
    margin: 0;
    padding-left: var(--space-5);
    font-size: var(--text-sm);
    line-height: 1.5;

    li + li { margin-top: var(--space-1); }
  }
}

/* ---------- Footer meta links ---------- */

.auth-meta {
  list-style: none;
  padding: 0;
  margin: var(--space-6) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.auth-meta__item {
  color: hsl(var(--color-muted-foreground));
}

.auth-meta__link {
  color: hsl(var(--color-primary));
  text-decoration: none;
  border-bottom: 1px solid hsl(var(--color-primary) / 0.3);
  padding-bottom: 2px;
  transition: border-color var(--duration-fast) var(--ease-default);

  &:hover {
    border-bottom-color: hsl(var(--color-primary));
  }

  &:focus-visible {
    outline: 2px solid hsl(var(--color-ring));
    outline-offset: 3px;
  }
}

/* ---------- Danger zone (account delete) ---------- */

.auth-danger {
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid hsl(var(--color-border));

  .auth-danger__title {
    margin: 0 0 var(--space-2);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: hsl(var(--color-destructive));
  }

  .auth-danger__copy {
    margin: 0 0 var(--space-4);
    font-size: var(--text-sm);
    color: hsl(var(--color-muted-foreground));
  }
}

/* ---------- Colophon (matches marketing) ---------- */

.auth-colophon {
  padding-block: var(--space-10) var(--space-12);
  padding-inline: var(--auth-gutter);

  .auth-colophon__inner {
    max-width: 72rem;
    margin-inline: auto;
  }

  .auth-colophon__rule {
    height: 1px;
    background-color: hsl(var(--color-border));
    margin-bottom: var(--space-8);
  }

  .auth-colophon__copy {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: hsl(var(--color-muted-foreground));
    text-align: center;
  }
}

/* ---------- Global flashes (renders above main) ---------- */

.flashes {
  padding-inline: var(--auth-gutter, clamp(1.5rem, 5vw, 4rem));
  padding-block: var(--space-4);
  max-width: 72rem;
  margin-inline: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .auth *,
  .auth *::before,
  .auth *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
