/* Auth Pages — Login, Signup, Password Reset */

.auth-wrapper {
  /* Fill the flex parent (.main-content) which spans header→footer. No magic
     100vh-Npx constant to drift from the real header/footer heights. */
  /* `flex: 1 0 auto`, not `flex: 1` + `min-height: 0`: with a 0 basis and a
     zero min-height this box could size BELOW its content, and `overflow: clip`
     then cut the bottom of the form off - on signup that clipped the submit
     button itself. Grow to fill spare space, never shrink past the content. */
  flex: 1 0 auto;
  display: grid;
  /* The second column is the form panel's own width. It used to be a 0.9fr
     share while .auth-form-section was separately capped at 560px, so on wide
     screens the column was ~245px wider than the panel inside it. The old
     opaque wrapper gradient painted that leftover strip; once the wrapper went
     transparent it showed as a bare band of app backdrop beside the panel. */
  grid-template-columns: minmax(0, 1fr) minmax(420px, 560px);
  /* Decorative tints only. The opaque `linear-gradient(var(--bg-primary),
     var(--bg-secondary))` base that used to sit under these repainted the app
     backdrop, so the auth pages were the only screens with no grid or glow
     behind them - the same defect as the six page wrappers fixed in
     docs/design/2026-08-18-design-system-audit.md, just written as a gradient
     instead of a flat colour. The tints are translucent, so the shell shows
     through. */
  background:
    radial-gradient(circle at top left, var(--craft-indigo-tint), transparent 36%),
    radial-gradient(circle at right 18%, var(--craft-pink-tint), transparent 24%);
  margin: 0;
  /* Horizontal only. `overflow: clip` also clipped the vertical axis, which is
     what removed the bottom of a form too tall for the viewport. */
  overflow-x: clip;
}

.auth-wrapper,
.auth-hero,
.auth-form-section,
.auth-form {
  min-width: 0;
}

.auth-hero,
.auth-form-section {
  position: relative;
}

.auth-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(2.5rem, 5vw, 5rem);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.14)),
    linear-gradient(180deg, var(--bg-secondary), var(--bg-tertiary));
  border-right: 1px solid var(--border-dark);
  overflow: hidden;
}

body.dark-mode .auth-hero {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
    linear-gradient(180deg, var(--bg-secondary), var(--bg-tertiary));
}

.auth-hero::before,
.auth-hero::after {
  content: "";
  position: absolute;
  inset: auto;
  border-radius: 999px;
  pointer-events: none;
}

.auth-hero::before {
  width: 22rem;
  height: 22rem;
  top: -6rem;
  left: -7rem;
  background: radial-gradient(circle, var(--craft-indigo-tint), transparent 68%);
  filter: blur(2px);
}

.auth-hero::after {
  width: 18rem;
  height: 18rem;
  right: -5rem;
  bottom: -4rem;
  background: radial-gradient(circle, var(--craft-pink-tint), transparent 68%);
}

.auth-hero-content {
  position: relative;
  z-index: 1;
  width: min(100%, 520px);
  text-align: left;
}

/* Brand globe above the hero text — full opacity, in normal flow so the text
   sits clear below it. Bobs once while the green grid flashes twice, then rests. */
.auth-logo {
  width: clamp(150px, 32%, 240px);
  aspect-ratio: 1 / 1;
  margin: 0 0 1.5rem;
  display: grid;
  place-items: center;
  /* One bob, 5 s, then at rest (0% and 100% are the resting pose). */
  animation: auth-logo-float 5s ease-in-out 1;
}

.auth-logo__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* Two flashes, 4.8 s in all. `forwards` keeps the faint glow the last
     keyframe ends on, so it does not snap off when the animation finishes. */
  animation: auth-logo-grid-flash 2.4s ease-in-out 2 forwards;
}

@keyframes auth-logo-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}

/* Pulse + flash the green grid: the green lines are the brightest pixels on the
   dark navy globe, so animating brightness/saturation + a green glow makes the
   grid flash while the navy stays put. Low frequency (~0.4 Hz) for a11y safety.
   (The drop-shadow glow was silently dropped by 3ca572d, an unrelated commit —
   restored here.) */
@keyframes auth-logo-grid-flash {
  0%   { filter: drop-shadow(0 0 10px rgba(83, 232, 103, 0.25)) brightness(1) saturate(1); }
  45%  { filter: drop-shadow(0 0 22px rgba(83, 232, 103, 0.95)) brightness(1.5) saturate(1.8); }
  60%  { filter: drop-shadow(0 0 12px rgba(83, 232, 103, 0.55)) brightness(1.15) saturate(1.3); }
  100% { filter: drop-shadow(0 0 10px rgba(83, 232, 103, 0.25)) brightness(1) saturate(1); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-logo,
  .auth-logo__img {
    animation: none;
  }
}

/* The brand line is a paragraph, not a heading: the page header owns the one
   h1. `.auth-hero p` below is less specific than this selector, so the brand
   states every property it needs from that rule. */
.auth-hero .auth-hero__brand {
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 4vw, 3.75rem);
  font-weight: 700;
  line-height: 0.96;
  letter-spacing: -0.04em;
  color: var(--text-primary);
  margin: 0 0 1rem;
  max-width: none;
}

.auth-hero p {
  font-family: var(--font-body);
  font-size: clamp(1.02rem, 1.4vw, 1.16rem);
  color: var(--text-tertiary);
  margin: 0 0 2rem;
  line-height: 1.75;
  max-width: 40ch;
}

.auth-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
}

.auth-feature {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--craft-indigo-tint);
  box-shadow: var(--shadow-lg);
  color: var(--text-secondary);
  font-size: 0.95rem;
}

body.dark-mode .auth-feature {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.auth-feature svg,
.auth-feature i {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--craft-indigo);
}

.auth-feature span {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-form-section {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(2rem, 4vw, 4rem);
  /* Same surface token as every other card, in both themes. */
  background: var(--bg-card);
}

body.dark-mode .auth-form-section {
  /* Was rgba(15, 15, 25, ...) - a cold near-black belonging to no palette,
     which made this the only panel in the app that did not match the card
     surface beside it. --bg-card is the token every other surface uses. */
  background: var(--bg-card);
}

.auth-form-section::before {
  content: "";
  position: absolute;
  inset: 1.25rem;
  border-radius: 28px;
  border: 1px solid var(--craft-indigo-tint);
  pointer-events: none;
}

.auth-form-section > * {
  position: relative;
  z-index: 1;
}

/* No max-width here: the grid column above is already capped at 560px, and
   capping the panel a second time is what left a bare strip beside it. */

.auth-form-header {
  margin-bottom: 2rem;
}

.auth-form-header p {
  color: var(--text-muted);
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.6;
}

.auth-form .form-group {
  margin-bottom: 1.15rem;
}

.auth-form label,
.auth-form p label {
  font-weight: 600;
  display: block;
  color: var(--text-secondary);
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

/* A plain label sits 0.55rem above its input. A .ds-field label does not: the
   field is a flex column that owns a 4px gap, and a margin here pushed the
   label away from its own control and toward the field above it. */
.auth-form label:not(.ds-field__label),
.auth-form p label {
  margin-bottom: 0.55rem;
}

.auth-form input[type="text"],
.auth-form input[type="password"],
.auth-form input[type="email"],
.auth-form p input {
  width: 100%;
  padding: 0.95rem 1.1rem;
  border: 1px solid var(--border-medium);
  border-radius: 14px;
  font-size: 1rem;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    background var(--transition-fast);
  background: var(--bg-input);
  color: var(--text-primary);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.auth-form input::placeholder {
  color: var(--text-placeholder);
}

.auth-form input:hover {
  border-color: var(--border-strong);
}

.auth-form input:focus,
.auth-form input:focus-visible {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 4px var(--accent-blue-glow);
  background: var(--bg-card-hover);
}

.auth-form .helptext {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.auth-form .helptext ul {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}

.auth-form .helptext li {
  margin-bottom: 0.125rem;
}

.auth-submit-btn {
  width: 100%;
  padding: 1rem 1.15rem;
  background: linear-gradient(135deg, var(--craft-indigo) 0%, var(--craft-accent-partner) 100%);
  border: none;
  border-radius: 14px;
  color: var(--accent-contrast, #0E2233);
  font-weight: 700;
  font-size: 1.02rem;
  cursor: pointer;
  transition:
    transform var(--transition-base),
    box-shadow var(--transition-base),
    filter var(--transition-base);
  margin-top: 0.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  box-shadow: var(--shadow-tinted-md);
}

.auth-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-tinted-lg);
  filter: saturate(1.03);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

.auth-submit-btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px var(--accent-blue-glow),
    var(--shadow-tinted-md);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin: 1.7rem 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-medium), transparent);
}

.auth-footer {
  text-align: center;
  margin-top: 1.6rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.auth-footer a {
  color: var(--craft-green-text);
  font-weight: 700;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-error-alert,
.auth-info-alert {
  border-radius: 16px;
  padding: 1rem 1.15rem;
  margin-bottom: 1.25rem;
  border: 1px solid;
}

.auth-error-alert {
  background: rgba(220, 53, 69, 0.08);
  border-color: rgba(220, 53, 69, 0.18);
  color: var(--status-danger-text);
}

.auth-info-alert {
  background: var(--craft-indigo-tint);
  border-color: var(--craft-indigo);
  color: var(--craft-green-text);
}

.auth-error-alert ul {
  margin: 0;
  padding-left: 1.25rem;
}

.auth-error-alert li {
  margin-bottom: 0.25rem;
}

.auth-error-alert li:last-child {
  margin-bottom: 0;
}

.field-error {
  color: var(--status-danger-text);
  font-size: 0.8125rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.field-error::before {
  content: "\f06a";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.75rem;
}

@media (max-width: 991.98px) {
  .auth-wrapper {
    grid-template-columns: 1fr;
    margin: 0;
  }

  .auth-hero {
    padding: 1.75rem 1.75rem 1.5rem;
    border-right: 0;
    border-bottom: 1px solid var(--border-dark);
  }

  .auth-hero-content {
    width: 100%;
  }

  /* Hero and form are stacked here, so every pixel of hero pushes the first
     input further down. The three cards are decoration: keep them on one
     content-sized row instead of a full-width column each. Flex (not a 3-track
     grid) so "Collaborate" sizes to its text and only wraps if it truly can't
     fit, rather than being squeezed into a 1/3 track on narrow phones. */
  .auth-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .auth-feature {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.7rem;
    border-radius: 12px;
    font-size: 0.82rem;
  }

  .auth-feature svg,
  .auth-feature i {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
  }

  .auth-form-section {
    max-width: none;
    padding: 2rem 1.75rem 2.5rem;
  }
}

@media (max-width: 575.98px) {
  .auth-wrapper {
    margin: 0;
  }

  .auth-hero {
    padding: 1.25rem 1.25rem 1rem;
  }

  .auth-logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    margin-bottom: 0.5rem;
  }

  .auth-hero .auth-hero__brand {
    font-size: 1.5rem;
    margin-bottom: 0.35rem;
  }

  .auth-hero p {
    font-size: 0.9rem;
    line-height: 1.45;
    margin-bottom: 0.85rem;
  }

  /* Tuned so all three chips still share one row at 320px (iPhone SE), where
     they otherwise wrap by ~3px. They wrap gracefully if a translation is
     longer — nothing here depends on them fitting. */
  .auth-features {
    gap: 0.4rem;
  }

  .auth-feature {
    padding: 0.45rem 0.5rem;
    font-size: 0.75rem;
    gap: 0.3rem;
  }

  .auth-form-section {
    padding: 1.1rem 1.25rem 2rem;
  }

  .auth-form-section::before {
    inset: 0.75rem;
    border-radius: 22px;
  }

  /* Trimmed so the password field clears the fold on a ~664px phone viewport,
     not just the username. */
  .auth-form-header {
    margin-bottom: 1rem;
  }

  .auth-form-header p {
    font-size: 0.9rem;
    line-height: 1.4;
  }
}

/* Standalone (hero-less) auth pages — password reset, etc. Centers the single
   form card within the wrapper grid without affecting the login/signup split. */
.auth-wrapper--solo {
  grid-template-columns: 1fr;
  justify-items: center;
}

/* The recovery link is a [data-btn] ghost control (templates/login.html), so
   its height, colour, hover and focus ring come from the button contract and
   follow the pointer tier. This row only places it and keeps it clear of the
   password field above and the submit button below. */
.auth-forgot {
  display: flex;
  justify-content: flex-end;
  margin: var(--space-sm) 0 var(--space-md);
}

.auth-form .form-help {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--text-muted, #6b7280);
}

.auth-form .form-help ul {
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
}

.auth-submit-btn--link {
  text-decoration: none;
}

.settings-segmented {
  display: grid;
  gap: 0.75rem;
}

.settings-segmented__group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(6.5rem, 1fr));
  gap: 0.75rem;
  padding: 0.5rem;
  background: var(--surface-light);
  border: 1px solid var(--border-medium);
  border-radius: 16px;
}

.settings-segmented__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 700;
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.settings-segmented__button:hover {
  transform: translateY(-1px);
}

.settings-segmented__button--active {
  background: var(--accent-blue);
  color: var(--accent-contrast, #0E2233);
  border-color: var(--accent-blue);
  box-shadow: var(--shadow-tinted-md);
}

.settings-segmented__button--inactive {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-medium);
}

.settings-segmented__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}
