/* Auth-page scaffold.
 *
 * Used by /auth/signup, /auth/login, /auth/forgot, /auth/reset,
 * /auth/verify-email and the post-login device pages. Loaded *instead
 * of* the main workspace stylesheets — auth pages stand alone, they
 * don't render inside the workspace shell. Re-uses variables.css
 * tokens so nothing diverges from the Eclipse dark theme.
 */

/* ---------------- Layout shell ---------------- */

.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;            /* iOS Safari url-bar correction */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px 48px;
  background: linear-gradient(180deg, var(--bg), var(--bg-tint));
  color: var(--fg);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  text-decoration: none;
  color: inherit;
}
.auth-brand img {
  width: 32px;
  height: 32px;
  border-radius: 7px;
}
.auth-brand__name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.auth-brand__hint {
  font-size: 11.5px;
  color: var(--fg-dim);
  margin-top: -1px;
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: linear-gradient(180deg, var(--surface-1), var(--bg-tint));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 28px 28px 22px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: auth-rise var(--t-med) var(--ease);
}
.auth-card__glow {
  position: absolute;
  top: -80px; left: -80px;
  width: 320px; height: 320px;
  background: radial-gradient(circle, rgba(124, 140, 255, 0.30), transparent 60%);
  filter: blur(20px);
  pointer-events: none;
}
.auth-card.is-shake { animation: auth-shake 320ms var(--ease); }

@keyframes auth-rise {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(3px); }
}

.auth-card__title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.auth-card__sub {
  font-size: 13px;
  color: var(--fg-muted);
  margin-bottom: 22px;
  line-height: 1.5;
}

.auth-card__footer {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--fg-muted);
  display: grid;
  gap: 6px;
  text-align: center;
}
.auth-card__footer a {
  color: var(--accent-strong);
  text-decoration: none;
}
.auth-card__footer a:hover { text-decoration: underline; }

/* ---------------- Form fields ---------------- */

.auth-form { display: grid; gap: 16px; }

.auth-field {
  display: grid;
  gap: 6px;
}
.auth-field__label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg);
  letter-spacing: 0.005em;
}
.auth-field__hint {
  font-size: 11.5px;
  color: var(--fg-dim);
  line-height: 1.45;
}
.auth-field__error {
  font-size: 11.5px;
  color: var(--danger);
  line-height: 1.45;
  min-height: 0;
}
.auth-field__error:empty { display: none; }

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.auth-input {
  width: 100%;
  appearance: none;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 11px 12px;
  font: inherit;
  font-size: 14px;
  color: var(--fg);
  caret-color: var(--accent-strong);
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              background var(--t-fast) var(--ease);
}
.auth-input::placeholder {
  color: var(--fg-dim);
}
.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: rgba(0, 0, 0, 0.45);
}
.auth-input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(255, 122, 138, 0.18);
}

/* Password-reveal toggle. Own focus target separate from input —
 * users tapping the input still get the input focused, users tapping
 * the eye get the reveal. */
.auth-input-wrap--password .auth-input { padding-right: 52px; }
.auth-reveal {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease);
}
.auth-reveal:hover { color: var(--fg); background: rgba(255, 255, 255, 0.04); }
.auth-reveal:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.auth-reveal[aria-pressed="true"] { color: var(--accent-strong); }

/* ---------------- Strength meter ---------------- */

.auth-strength {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}
.auth-strength__bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  height: 6px;
}
.auth-strength__segment {
  background: var(--surface-3);
  border-radius: 2px;
  transition: background var(--t-fast) var(--ease);
}
.auth-strength[data-level="1"] .auth-strength__segment:nth-child(-n+1),
.auth-strength[data-level="2"] .auth-strength__segment:nth-child(-n+2),
.auth-strength[data-level="3"] .auth-strength__segment:nth-child(-n+3),
.auth-strength[data-level="4"] .auth-strength__segment:nth-child(-n+4) {
  background: var(--danger);
}
.auth-strength[data-level="2"] .auth-strength__segment { background: var(--warning); }
.auth-strength[data-level="2"] .auth-strength__segment:nth-child(n+3) { background: var(--surface-3); }
.auth-strength[data-level="3"] .auth-strength__segment { background: var(--warning); }
.auth-strength[data-level="3"] .auth-strength__segment:nth-child(n+4) { background: var(--surface-3); }
.auth-strength[data-level="4"] .auth-strength__segment { background: var(--success); }
.auth-strength__label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}
.auth-strength[data-level="1"] .auth-strength__label { color: var(--danger); }
.auth-strength[data-level="2"] .auth-strength__label,
.auth-strength[data-level="3"] .auth-strength__label { color: var(--warning); }
.auth-strength[data-level="4"] .auth-strength__label { color: var(--success); }

/* ---------------- Submit button + form-level error ---------------- */

.auth-submit {
  appearance: none;
  background: linear-gradient(135deg, var(--accent), #4c5cff);
  color: white;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-glow);
  transition: filter var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.auth-submit:hover:not(:disabled) { filter: brightness(1.06); }
.auth-submit:active:not(:disabled) { transform: translateY(1px); }
.auth-submit:disabled { opacity: 0.7; cursor: progress; }

.auth-submit--ghost {
  background: var(--surface-2);
  color: var(--fg);
  border-color: var(--border-strong);
  box-shadow: none;
}
.auth-submit--ghost:hover:not(:disabled) { background: var(--surface-3); }

.auth-submit--danger {
  background: linear-gradient(135deg, var(--danger), #d04a5a);
  box-shadow: 0 0 0 1px rgba(255, 122, 138, 0.25), 0 0 18px rgba(255, 122, 138, 0.18);
}

.auth-form__error {
  background: rgba(255, 122, 138, 0.08);
  border: 1px solid rgba(255, 122, 138, 0.30);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--danger);
  line-height: 1.45;
}
.auth-form__error:empty { display: none; }

/* ---------------- "Help text always visible" — login Q4 escape valve ---------------- */

.auth-helpline {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.5;
}
.auth-helpline a {
  color: var(--accent-strong);
  text-decoration: none;
}
.auth-helpline a:hover { text-decoration: underline; }

/* ---------------- Coming-soon ghost button ---------------- */

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 14px;
  color: var(--fg-dim);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  appearance: none;
  background: var(--surface-2);
  color: var(--fg-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: not-allowed;
  position: relative;
}
.auth-oauth-btn__pill {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px 7px;
}

/* ---------------- Post-submit "check your inbox" view ---------------- */

.auth-status {
  text-align: center;
  display: grid;
  gap: 14px;
}
.auth-status__icon {
  font-size: 40px;
  line-height: 1;
}
.auth-status__icon[data-tone="success"] { color: var(--success); }
.auth-status__icon[data-tone="warning"] { color: var(--warning); }
.auth-status__icon[data-tone="danger"]  { color: var(--danger); }
.auth-status__title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.auth-status__body {
  font-size: 13px;
  color: var(--fg-muted);
  line-height: 1.55;
}
.auth-status__body strong { color: var(--fg); font-weight: 600; }
.auth-status__actions {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}
.auth-status__cooldown {
  font-size: 11.5px;
  color: var(--fg-dim);
  font-variant-numeric: tabular-nums;
}

/* ---------------- Mobile — sticky submit + bigger inputs ---------------- */

@media (max-width: 720px) {
  .auth-shell {
    padding: 24px 12px 12px;
    justify-content: flex-start;
  }
  .auth-card {
    max-width: 100%;
    padding: 22px 18px 18px;
    border-radius: var(--radius-md);
  }
  .auth-input { font-size: 16px; padding: 13px 12px; }   /* 16px prevents iOS auto-zoom on focus */
  .auth-input-wrap--password .auth-input { padding-right: 56px; }
  .auth-submit { font-size: 15px; padding: 14px; }
  .auth-form { gap: 14px; }

  /* Sticky-bottom submit so the soft keyboard never covers it.
     Reserve space at the form bottom equal to the sticky height. */
  .auth-form--sticky {
    padding-bottom: 72px;
  }
  .auth-form--sticky .auth-submit-row {
    position: sticky;
    bottom: 0;
    background: linear-gradient(180deg, transparent, var(--bg-tint) 24%);
    padding: 12px 0 4px;
    margin: 0 -18px;
    padding-left: 18px;
    padding-right: 18px;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .auth-card.is-shake,
  .auth-input,
  .auth-submit,
  .auth-reveal,
  .auth-strength__segment {
    animation: none !important;
    transition: none !important;
  }
}
