/* ==========================================================================
   Halden Auth Kit — components.css
   Logo, type, fields, buttons, checkbox, strength meter, OTP, toasts.
   Designed & built by EdinStack
   ========================================================================== */

/* Logo -------------------------------------------------------------------- */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.035em;
  text-decoration: none;
}
.logo__mark { width: 22px; height: 22px; color: var(--brand); }
.logo__mark .cut { fill: none; stroke: var(--bg); }
.solo .logo__mark .cut { stroke: var(--bg-soft); }

/* Type -------------------------------------------------------------------- */
.title {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.022em;
}
.lede { margin-top: 8px; color: var(--muted); }
.lede strong { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }

.step-count {
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--brand);
}

.fine { font-size: 13px; color: var(--muted); }

.link {
  color: var(--brand);
  font-weight: 500;
  text-decoration: none;
}
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link--quiet { color: var(--muted); font-weight: 400; }
.link--quiet:hover { color: var(--text); }

/* Fields ------------------------------------------------------------------ */
.form { display: grid; gap: 16px; }

.field { display: grid; gap: 6px; }
.field__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.field__label { font-size: 14px; font-weight: 500; color: var(--text-2); }
.field__label .link { font-size: 13px; }

.field__error {
  display: none;
  font-size: 13px;
  color: var(--danger);
}
.field.has-error .field__error,
.otp__error:not([hidden]) { display: block; }

.input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  outline: none;
  font-size: 15px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder { color: var(--muted); opacity: 0.8; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.field.has-error .input { border-color: var(--danger); }
.field.has-error .input:focus { box-shadow: 0 0 0 3px var(--danger-ring); }
.input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 100px var(--bg) inset;
  -webkit-text-fill-color: var(--text);
}

.input-wrap { position: relative; }
.input-wrap .input { padding-right: 60px; }
.input-wrap__btn {
  position: absolute;
  top: 1px;
  right: 1px;
  bottom: 1px;
  padding: 0 12px;
  border: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
.input-wrap__btn:hover { color: var(--text); }

/* Buttons ----------------------------------------------------------------- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn--primary { background: var(--brand); color: var(--on-brand); }
.btn--primary:hover { background: var(--brand-hover); }
.btn--secondary {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}
.btn--secondary:hover { background: var(--bg-soft); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn.is-loading { color: transparent !important; opacity: 1; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--on-brand);
  border-right-color: transparent;
  animation: spin 0.6s linear infinite;
}
.btn--secondary.is-loading::after { border-color: var(--text); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Checkbox (native, brand-tinted) ---------------------------------------- */
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
}
.check input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.check a { color: var(--brand); text-decoration: none; font-weight: 500; }
.check a:hover { text-decoration: underline; }

/* Divider + social -------------------------------------------------------- */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  font-size: 13px;
  color: var(--muted);
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.social { display: grid; gap: 10px; }

/* Password strength -------------------------------------------------------- */
.strength { display: grid; gap: 8px; margin-top: 4px; }
.strength__bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.strength__bar span { height: 4px; border-radius: 2px; background: var(--border); transition: background 0.2s; }
.strength[data-score="1"] .strength__bar span:nth-child(-n+1) { background: var(--danger); }
.strength[data-score="2"] .strength__bar span:nth-child(-n+2) { background: var(--warn); }
.strength[data-score="3"] .strength__bar span:nth-child(-n+3) { background: var(--good); }
.strength[data-score="4"] .strength__bar span { background: var(--success); }

.strength__meta { font-size: 13px; color: var(--muted); }
.strength__label { font-weight: 500; color: var(--text-2); }

.rules {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px 12px;
  font-size: 13px;
  color: var(--muted);
}
.rules li { display: flex; align-items: center; gap: 6px; }
.rules li::before {
  content: "";
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  transition: background 0.15s, border-color 0.15s;
}
.rules li.is-met { color: var(--text-2); }
.rules li.is-met::before {
  border-color: var(--success);
  background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3.2 6.2l1.8 1.8 3.8-4' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 12px no-repeat;
}

/* OTP ---------------------------------------------------------------------- */
.otp-field { display: grid; gap: 8px; }
.otp { display: flex; align-items: center; gap: 8px; }
.otp__sep { flex: none; width: 8px; height: 2px; border-radius: 1px; background: var(--border-strong); }
.otp__cell {
  width: 100%;
  min-width: 0;
  height: 52px;
  padding: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  caret-color: var(--brand);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.otp__cell:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); }
.otp.is-error .otp__cell { border-color: var(--danger); background: var(--danger-soft); }
.otp.is-error { animation: shake 0.35s ease; }
.otp.is-success .otp__cell { border-color: var(--success); background: var(--success-soft); color: var(--success); }

@keyframes shake {
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

.resend { margin-top: 18px; font-size: 14px; color: var(--muted); }
.resend__btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.resend__btn:hover:not([disabled]) { text-decoration: underline; text-underline-offset: 3px; }
.resend__btn[disabled] { color: var(--muted); cursor: default; }

/* Toasts ------------------------------------------------------------------- */
.toasts {
  position: fixed;
  z-index: 50;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
@media (min-width: 640px) {
  .toasts { left: auto; right: 24px; bottom: 24px; width: 340px; }
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  box-shadow: var(--shadow-card);
  font-size: 14px;
  animation: toast-in 0.2s ease-out;
}
.toast__dot { flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--muted); }
.toast--success .toast__dot { background: #4cc08f; }
.toast--error .toast__dot { background: #f07a6e; }
.toast.is-leaving { animation: toast-out 0.18s ease-in forwards; }

@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes toast-out { to { opacity: 0; } }
