/* ================================================================
   REVY — Auth pages

   One stylesheet for login, sign-up, forgot-password and the
   registration-disabled notice. Every value is a design-system
   token; the only literals are the focus-ring alphas.
================================================================ */

/* ── Page shell ───────────────────────────────────────────── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
  padding: 64px 20px 88px;
  background: var(--color-surface);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 40px;
  background: var(--color-bg);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

.auth-card--wide {
  max-width: 560px;
}

/* ── Card head ────────────────────────────────────────────── */

.auth-head {
  margin-bottom: 28px;
}

.auth-title {
  margin: 0;
  font-family: var(--f-display);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: var(--ls-tight);
  color: var(--color-ink);
}

.auth-sub {
  margin: 8px 0 0;
  font-family: var(--f-body);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--color-ink-mid);
}

/* ── Alerts ───────────────────────────────────────────────── */

.auth-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 12px 14px;
  font-family: var(--f-body);
  font-size: 0.875rem;
  line-height: 1.45;
  border-radius: var(--radius-sm);
}

.auth-alert svg {
  flex: 0 0 auto;
  margin-top: 2px;
}

.auth-alert--error {
  color: var(--color-red);
  background: var(--color-red-tint);
}

.auth-alert--success {
  color: var(--color-good);
  background: var(--color-good-tint);
}

/* Attribute selector outranks the display rule above on specificity,
   so this works regardless of source order. Kept last for readability. */
.auth-alert[hidden] {
  display: none;
}

/* ── Form ─────────────────────────────────────────────────── */

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-divider {
  height: 1px;
  margin: 4px 0;
  background: var(--color-rule);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.field-label {
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-widest);
  color: var(--color-ink-mid);
}

.field-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.field-forgot {
  font-family: var(--f-body);
  font-size: 0.75rem;
  color: var(--color-ink-mid);
  text-decoration: none;
  transition: color var(--t2) var(--ease);
}

.field-forgot:hover {
  color: var(--color-red);
}

.field-control {
  position: relative;
  display: flex;
  align-items: center;
}

.field-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font-family: var(--f-body);
  font-size: 0.9375rem;
  color: var(--color-ink);
  background: var(--color-bg);
  border: 1px solid var(--color-rule-mid);
  border-radius: var(--radius-sm);
  appearance: none;
  transition:
    border-color var(--t2) var(--ease),
    box-shadow   var(--t2) var(--ease);
}

.field-input::placeholder {
  color: var(--color-ink-dim);
}

/* Focus is ink, never red. A red ring on a valid field reads as a rejection. */
.field-input:focus {
  outline: none;
  border-color: var(--color-ink);
  box-shadow: 0 0 0 3px rgba(22, 19, 15, 0.08);
}

.field--has-toggle .field-input {
  padding-right: 44px;
}

.field-toggle {
  position: absolute;
  right: 8px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--color-ink-dim);
  background: none;
  border: 0;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: color var(--t2) var(--ease);
}

.field-toggle:hover {
  color: var(--color-ink);
}

/* design-system.css sets `img, svg { display: block }`. An author rule beats the UA
   [hidden] rule regardless of specificity, so without this BOTH eye icons render. */
.field-toggle svg[hidden] {
  display: none;
}

.field-toggle:focus-visible {
  outline: none;
  color: var(--color-ink);
  box-shadow: 0 0 0 3px rgba(22, 19, 15, 0.12);
}

/* ── Field error ──────────────────────────────────────────── */

.field-error {
  font-family: var(--f-body);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--color-red);
}

.field-error[hidden] {
  display: none;
}

.field--invalid .field-input,
.field--invalid .field-input:focus {
  border-color: var(--color-red);
}

.field--invalid .field-input:focus {
  box-shadow: 0 0 0 3px var(--color-red-muted);
}

/* Runs when the script unhides the message and flags the wrapper.
   No layout property is animated. */
.field--invalid .field-error {
  animation: auth-error-in var(--t1) var(--ease) both;
}

@keyframes auth-error-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Checkbox (remember me, terms) ────────────────────────── */

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--f-body);
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--color-ink-mid);
  cursor: pointer;
}

.check-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.check-box {
  display: grid;
  place-items: center;
  flex: 0 0 18px;
  height: 18px;
  margin-top: 1px;
  color: transparent;
  background: var(--color-bg);
  border: 1px solid var(--color-rule-strong);
  border-radius: var(--radius-xs);
  transition:
    color            var(--t2) var(--ease),
    background-color var(--t2) var(--ease),
    border-color     var(--t2) var(--ease);
}

.check-input:checked + .check-box {
  color: var(--color-bg);
  background: var(--color-ink);
  border-color: var(--color-ink);
}

.check-input:focus-visible + .check-box {
  box-shadow: 0 0 0 3px rgba(22, 19, 15, 0.12);
}

.field--invalid .check-box {
  border-color: var(--color-red);
}

.check-text a {
  color: var(--color-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--t2) var(--ease);
}

.check-text a:hover {
  color: var(--color-red);
}

/* ── Segmented control (seller type) ──────────────────────── */

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
}

.segmented input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.seg-label {
  display: block;
  padding: 10px 12px;
  font-family: var(--f-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-ink-mid);
  text-align: center;
  border-radius: calc(var(--radius-sm) - 4px);
  cursor: pointer;
  transition:
    color            var(--t2) var(--ease),
    background-color var(--t2) var(--ease),
    box-shadow       var(--t2) var(--ease);
}

.segmented input:checked + .seg-label {
  font-weight: 600;
  color: var(--color-ink);
  background: var(--color-bg);
  box-shadow: var(--shadow-sm);
}

.segmented input:focus-visible + .seg-label {
  box-shadow: 0 0 0 3px rgba(22, 19, 15, 0.12);
}

/* ── Password strength meter ──────────────────────────────── */

.pw-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 2px;
}

.pw-meter[hidden] {
  display: none;
}

.pw-track {
  display: flex;
  flex: 1;
  gap: 4px;
}

.pw-seg {
  flex: 1;
  height: 3px;
  background: var(--color-rule);
  border-radius: var(--radius-pill);
  transition: background-color var(--t2) var(--ease);
}

.pw-label {
  min-width: 3.5rem;
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  text-align: right;
  color: var(--color-ink-mid);
  font-variant-numeric: tabular-nums;
}

/* Red -> ink -> green. --dark-amber is a dark-surface token and is
   unreadable on white, so "medium" is ink, not amber. */
.pw-meter[data-strength="1"] .pw-seg:nth-child(-n + 1) { background: var(--color-red); }
.pw-meter[data-strength="2"] .pw-seg:nth-child(-n + 2) { background: var(--color-ink-mid); }
.pw-meter[data-strength="3"] .pw-seg:nth-child(-n + 3) { background: var(--color-ink-mid); }
.pw-meter[data-strength="4"] .pw-seg                   { background: var(--color-good); }

.pw-meter[data-strength="1"] .pw-label { color: var(--color-red); }
.pw-meter[data-strength="4"] .pw-label { color: var(--color-good); }

/* ── Submit button ────────────────────────────────────────── */

.auth-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 52px;
  margin-top: 4px;
  overflow: hidden;
  font-family: var(--f-body);
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-bg);
  background: var(--color-red);
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition:
    background-color var(--t2) var(--ease),
    transform        var(--t1) var(--spring);
}

.auth-btn:hover {
  background: var(--color-red-hover);
}

.auth-btn:active {
  transform: scale(0.97);
}

.auth-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-red-muted);
}

.auth-btn-arrow {
  transition: transform var(--t2) var(--ease), opacity var(--t2) var(--ease);
}

.auth-btn:hover .auth-btn-arrow {
  transform: translateX(3px);
}

/* Busy: no spinner. The label changes and a hairline sweeps the base. */
.auth-btn[aria-busy="true"] {
  pointer-events: none;
  background: var(--color-red-hover);
}

.auth-btn[aria-busy="true"] .auth-btn-arrow {
  opacity: 0;
}

.auth-btn::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 40%;
  height: 2px;
  background: rgba(255, 255, 255, 0.85);
  opacity: 0;
  transform: translateX(-100%);
}

.auth-btn[aria-busy="true"]::after {
  opacity: 1;
  animation: auth-progress 1.1s var(--ease-in-out) infinite;
}

@keyframes auth-progress {
  from { transform: translateX(-100%); }
  to   { transform: translateX(350%); }
}

/* ── Card foot ────────────────────────────────────────────── */

.auth-foot {
  margin-top: 24px;
  padding-top: 20px;
  font-family: var(--f-body);
  font-size: 0.875rem;
  color: var(--color-ink-mid);
  text-align: center;
  border-top: 1px solid var(--color-rule);
}

.auth-foot a {
  font-weight: 600;
  color: var(--color-ink);
  text-decoration: none;
  border-bottom: 1px solid var(--color-rule-strong);
  transition: color var(--t2) var(--ease), border-color var(--t2) var(--ease);
}

.auth-foot a:hover {
  color: var(--color-red);
  border-color: var(--color-red);
}

/* ── Responsive ───────────────────────────────────────────── */

/* Below 569px the card stops being a card: it goes full-bleed white with no
   border, radius or shadow. The page takes the same white so there is no seam
   against it or against the footer, which is already --color-bg. */
@media (max-width: 568px) {
  .auth-page {
    align-items: flex-start;
    min-height: 0;
    padding: 0;
    background: var(--color-bg);
  }

  .auth-card,
  .auth-card--wide {
    max-width: none;
    padding: 32px 20px 48px;
    background: var(--color-bg);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-title {
    font-size: 1.5rem;
  }

  .field-row {
    grid-template-columns: 1fr;
  }
}

/* ── Reduced motion ───────────────────────────────────────── */
/* design-system.css already clamps durations and strips movement.
   The sweeping hairline would freeze mid-track, so pin it full-width. */

@media (prefers-reduced-motion: reduce) {
  .auth-btn[aria-busy="true"]::after {
    width: 100%;
    animation: none;
    transform: none;
  }
}
