/*
 * Sign-in, sign-up and password pages (templates/auth_base.html).
 * Colours, light/dark and the scrollbar come from ui/tokens.css; this file is
 * the auth layout plus form styling scoped to .kp-auth.
 */

body.kp-auth {
  margin: 0;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--kp-page);
  color: var(--kp-text);
  -webkit-font-smoothing: antialiased;
}

.kp-auth .kp-sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- layout ---------- */
.kp-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
}

.kp-art {
  position: sticky; top: 0; height: 100vh; height: 100dvh; align-self: start; overflow: hidden;
  display: grid; place-items: center;
  background: var(--kp-art-bg);
  border-right: 1px solid var(--kp-divider);
}
.kp-rails { position: absolute; inset: 0; width: 100%; height: 100%; }
.kp-rails path { fill: none; stroke: #F56E0F; stroke-linecap: round; }
.kp-rails .kp-pulse { stroke-dasharray: 90 1400; animation: kp-travel 7s linear infinite; }
@keyframes kp-travel { from { stroke-dashoffset: 1490; } to { stroke-dashoffset: 0; } }

.kp-brand { position: relative; text-align: center; padding: 0 24px; }
.kp-brand img { height: 76px; width: auto; margin: 0 auto; }
.kp-brand .kp-logo-light { display: var(--kp-logo-light); }
.kp-brand .kp-logo-dark { display: var(--kp-logo-dark); }
.kp-brand p {
  margin: 18px 0 0; font-size: 18px; font-weight: 300; letter-spacing: 0.01em;
  color: var(--kp-muted);
}

.kp-panel { display: grid; place-items: center; padding: clamp(16px, 4vh, 48px) 24px; }
.kp-panel-inner { width: 100%; max-width: 360px; }

/* ---------- type ---------- */
.kp-auth h1 {
  margin: 0; font-size: 26px; line-height: 1.25; font-weight: 500;
  letter-spacing: -0.01em; text-align: center; color: var(--kp-text);
}
.kp-auth .kp-lede {
  margin: 8px 0 0; font-size: 15px; line-height: 1.5; text-align: center; color: var(--kp-muted);
}

.kp-auth a { color: var(--kp-link); font-weight: 500; text-decoration: none; }
.kp-auth a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- fields (also restyles tailwindtheme form partials) ---------- */
.kp-auth label {
  display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; color: var(--kp-text);
}
.kp-auth input[type="text"],
.kp-auth input[type="email"],
.kp-auth input[type="password"],
.kp-auth input[type="tel"],
.kp-auth input[type="number"],
.kp-auth input[type="url"],
.kp-auth input[type="date"],
.kp-auth select,
.kp-auth textarea {
  width: 100%; height: 50px; padding: 0 18px; box-sizing: border-box;
  font: 400 15px "DM Sans", system-ui, sans-serif; color: var(--kp-text);
  background: var(--kp-field); border: 1px solid var(--kp-field-line); border-radius: 12px;
  box-shadow: none; transition: border-color .15s, box-shadow .15s;
}
.kp-auth textarea { height: auto; min-height: 100px; padding: 14px 18px; }
.kp-auth input:hover, .kp-auth select:hover, .kp-auth textarea:hover { border-color: var(--kp-field-line-hover); }
.kp-auth input::placeholder, .kp-auth textarea::placeholder { color: var(--kp-muted); opacity: .8; }
.kp-auth input:focus, .kp-auth select:focus, .kp-auth textarea:focus {
  outline: none; border-color: var(--kp-ember); box-shadow: 0 0 0 4px var(--kp-focus-ring);
}
.kp-auth input[type="checkbox"], .kp-auth input[type="radio"] { accent-color: var(--kp-ember); }

/* Field errors from tailwindtheme/fields/form-group.html */
.kp-auth .bg-red-500 { background: none; color: var(--kp-danger); padding: 6px 2px 0; font-size: 13px; }
.kp-auth .errorlist { margin: 0; padding: 0; list-style: none; color: var(--kp-danger); font-size: 13px; }

/* ---------- buttons ---------- */
.kp-auth .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 50px; min-height: 50px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent;
  font: 600 15px "DM Sans", system-ui, sans-serif; text-transform: none; cursor: pointer;
  background: var(--kp-ember); color: var(--kp-on-ember); box-shadow: none;
  transition: background-color .15s, border-color .15s, transform .05s;
}
.kp-auth .btn:hover { background: var(--kp-ember-hover); text-decoration: none; }
.kp-auth .btn:active { transform: translateY(1px); }
.kp-auth .btn-neutral, .kp-auth .btn-light {
  background: transparent; color: var(--kp-text); border-color: var(--kp-field-line);
}
.kp-auth .btn-neutral:hover, .kp-auth .btn-light:hover { background: transparent; border-color: var(--kp-field-line-hover); }
.kp-auth .btn-w-full { width: 100%; }

.kp-auth :is(.btn, a, button):focus-visible { outline: 3px solid var(--kp-ember); outline-offset: 3px; }

/* ---------- messages ---------- */
.kp-auth .alert {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; margin-bottom: 16px;
  border-radius: 12px; border: 0; font-size: 14px; line-height: 1.5;
  background: var(--kp-info-bg); color: var(--kp-text);
}
.kp-auth .alert svg { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.kp-auth .alert-error { background: var(--kp-danger-bg); color: var(--kp-danger); }

/* ---------- sign-in form ---------- */
.kp-stack { display: grid; gap: 12px; margin-top: 32px; }
.kp-pw { position: relative; }
.kp-auth .kp-pw input { padding-right: 68px; }
.kp-pw button {
  position: absolute; right: 7px; top: 7px; height: 36px; padding: 0 11px;
  border: 0; border-radius: 8px; background: none; cursor: pointer;
  font: 500 13px "DM Sans", system-ui, sans-serif; color: var(--kp-muted);
}
.kp-pw button:hover { color: var(--kp-text); }
.kp-forgot { justify-self: end; font-size: 13px; }
.kp-captcha { display: flex; justify-content: center; }
.kp-captcha-status { margin: 8px 0 0; font-size: 13px; line-height: 1.4; text-align: center; color: var(--kp-muted); }
.kp-captcha-status.is-error { color: var(--kp-danger); }
.kp-captcha-retry { padding: 0; border: 0; background: none; font: inherit; font-weight: 600; color: var(--kp-ember); text-decoration: underline; cursor: pointer; }
.kp-alt { margin: 28px 0 0; text-align: center; font-size: 14px; color: var(--kp-muted); }
.kp-legal { margin: 48px 0 0; text-align: center; font-size: 12px; line-height: 1.6; color: var(--kp-muted); }
.kp-legal a { color: var(--kp-link); white-space: nowrap; }
.kp-divider {
  display: flex; align-items: center; gap: 12px; margin: 20px 0; font-size: 13px; color: var(--kp-muted);
}
.kp-divider::before, .kp-divider::after { content: ""; flex: 1; height: 1px; background: var(--kp-divider); }

/* ---------- sign-up ---------- */
.kp-stack-tight { gap: 14px; margin-top: 24px; }
.kp-auth .kp-field label { font-size: 13px; color: var(--kp-muted); }
.kp-optional { font-weight: 400; opacity: .8; }
.kp-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.kp-auth select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 40px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%239C98A8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}

.kp-auth [aria-invalid="true"] { border-color: var(--kp-danger); }

.kp-rules {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
  margin: 8px 2px 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--kp-muted);
}
.kp-rules li { display: flex; align-items: center; gap: 6px; }
.kp-rules li::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: currentColor; opacity: .5;
}
.kp-rules li.is-met { color: var(--kp-ok); }
.kp-rules li.is-met::before { opacity: 1; }

.kp-auth .kp-check {
  display: flex; align-items: center; gap: 10px; margin: 2px 0 0;
  font-size: 14px; font-weight: 400; line-height: 1.4; color: var(--kp-text); cursor: pointer;
}
.kp-check input[type="checkbox"] {
  flex: none; width: 18px; height: 18px; margin: 0; cursor: pointer;
}
.kp-check a { color: var(--kp-link); }

/* Password inputs from tailwindtheme/fields/input.html keep room for the eye icon */
.kp-auth .relative > input[type="password"],
.kp-auth .relative > input[type="text"] { padding-right: 48px; }
.kp-auth .relative > button { color: var(--kp-muted); }

/* ---------- quiet secondary actions (2FA fallbacks) ---------- */
.kp-alt-actions { margin-top: 24px; text-align: center; font-size: 13px; color: var(--kp-muted); }
.kp-alt-actions p { margin: 6px 0 0; }
.kp-auth .kp-linkbtn {
  padding: 0; border: 0; background: none; cursor: pointer;
  font: 500 13px "DM Sans", system-ui, sans-serif; color: var(--kp-link);
}
.kp-auth .kp-linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- back link (wizard steps) ---------- */
.kp-auth .kp-back {
  display: inline-flex; align-items: center; gap: 4px; margin: 0 0 6px -6px; padding: 6px 10px 6px 4px;
  border: 0; border-radius: 8px; background: none; cursor: pointer;
  font: 500 14px "DM Sans", system-ui, sans-serif; color: var(--kp-muted);
}
.kp-auth .kp-back:hover { color: var(--kp-text); background: var(--kp-info-bg); }

/* Denser layout for the longer business-details step */
.kp-stack-compact { gap: 12px; margin-top: 16px; }
.kp-stack-compact .kp-field label { margin-bottom: 4px; }
.kp-stack-compact input, .kp-stack-compact select, .kp-stack-compact .kp-select-trigger { height: 46px; }
.kp-stack-compact .btn { margin-top: 6px; }

/* ---------- small screens: artwork becomes a band above the form ---------- */
@media (max-width: 900px) {
  .kp-grid-2 { grid-template-columns: 1fr; }
  .kp-layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .kp-art { position: relative; height: auto; min-height: 180px; border-right: 0; border-bottom: 1px solid var(--kp-divider); }
  .kp-brand img { height: 48px; }
  .kp-brand p { margin-top: 10px; font-size: 15px; }
  .kp-panel { padding: 40px 16px 64px; place-items: start center; }
}

@media (prefers-reduced-motion: reduce) {
  .kp-rails .kp-pulse { animation: none; opacity: 0; }
}
