/* ═══════════════════════════════════════════════════════
   Auth Modal — login / register
   ═══════════════════════════════════════════════════════ */

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

.auth-overlay.active {
  opacity: 1;
  visibility: visible;
}

.auth-modal {
  position: relative;
  width: min(92vw, 400px);
  padding: 32px 28px 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  background: rgba(20, 20, 30, 0.95);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-overlay.active .auth-modal {
  transform: translateY(0) scale(1);
}

/* Close button */
.auth-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.4);
  font-size: 18px;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
}

.auth-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
}

/* Tabs */
.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.4);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.2s,
    color 0.2s;
}

.auth-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
}

/* Form */
.auth-form {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.auth-form.active {
  display: flex;
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.9);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition:
    border-color 0.2s,
    background 0.2s;
}

.auth-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.auth-input:focus {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
}

.auth-input.error,
.auth-input.is-error {
  border-color: rgba(255, 80, 80, 0.5);
}

.auth-input.is-valid {
  border-color: rgba(34, 197, 94, 0.4);
}

/* Input wrap with status indicator */
.input-wrap {
  position: relative;
}

.input-wrap .auth-input {
  padding-right: 42px;
}

.input-status {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s;
}

.input-status.show {
  opacity: 1;
}

.input-status.loading::after {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Field hint (below input) */
.field-hint {
  font-size: 12px;
  min-height: 16px;
  margin: -4px 0 0;
  padding: 0 4px;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.35);
  transition: color 0.2s;
}

.field-hint.is-error {
  color: rgba(255, 80, 80, 0.9);
}

.field-hint.is-valid {
  color: rgba(34, 197, 94, 0.8);
}

/* TOS checkbox */
.auth-tos {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  line-height: 1.4;
  margin: 4px 0 0;
}

.auth-tos input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  margin-top: 1px;
  transition:
    background 0.2s,
    border-color 0.2s;
  position: relative;
}

.auth-tos input[type="checkbox"]:checked {
  background: #22c55e;
  border-color: #22c55e;
}

.auth-tos input[type="checkbox"]:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  color: #fff;
}

.auth-tos a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-tos a:hover {
  color: #fff;
}

/* Submit button */
.auth-submit {
  width: 100%;
  padding: 14px;
  margin-top: 4px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, hsl(330, 52%, 58%), hsl(15, 80%, 55%));
  color: #1a0810;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition:
    opacity 0.2s,
    transform 0.15s;
}

.auth-submit:hover {
  opacity: 0.9;
}

.auth-submit:active {
  transform: scale(0.98);
}

.auth-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Error message */
.auth-error {
  font-size: 13px;
  color: rgba(255, 80, 80, 0.9);
  text-align: center;
  min-height: 20px;
}

/* Turnstile CAPTCHA widget */
.turnstile-box {
  display: flex;
  justify-content: center;
  min-height: 0;
  margin: 4px 0 0;
}

/* Password strength meter */
.pwd-strength {
  margin: -4px 0 0;
}

.pwd-bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.pwd-bar__fill {
  height: 100%;
  width: 0;
  border-radius: 2px;
  transition:
    width 0.3s ease,
    background 0.3s ease;
}

.pwd-bar__fill[data-level="1"] {
  width: 25%;
  background: #ef4444;
}

.pwd-bar__fill[data-level="2"] {
  width: 50%;
  background: #ef4444;
}

.pwd-bar__fill[data-level="3"] {
  width: 75%;
  background: #22c55e;
}

.pwd-bar__fill[data-level="4"] {
  width: 100%;
  background: #22c55e;
}

/* Password criteria checklist */
.pwd-checks {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.pwd-checks li {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  line-height: 1.5;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 5px;
}

.pwd-checks li::before {
  content: "✗";
  font-size: 11px;
  color: rgba(255, 80, 80, 0.5);
  transition:
    color 0.2s,
    content 0.2s;
}

.pwd-checks li.passed {
  color: rgba(34, 197, 94, 0.85);
}

.pwd-checks li.passed::before {
  content: "✓";
  color: #22c55e;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.auth-divider span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
  text-transform: lowercase;
}

/* Telegram button */
.auth-tg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s;
}

.auth-tg:hover {
  background: rgba(42, 171, 238, 0.12);
  border-color: rgba(42, 171, 238, 0.3);
  color: #2aabee;
}

.auth-tg__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: #2aabee;
}

/* ── Responsive ── */

@media (max-width: 480px) {
  .auth-overlay {
    align-items: flex-end;
  }

  .auth-modal {
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    padding: 20px 20px 24px;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .auth-overlay.active .auth-modal {
    transform: translateY(0) scale(1);
  }

  /* Prevent iOS zoom on input focus — font must be ≥ 16px */
  .auth-input {
    font-size: 16px;
    padding: 12px 14px;
  }

  .input-wrap .auth-input {
    padding-right: 38px;
  }

  .auth-tabs {
    margin-bottom: 16px;
  }

  .auth-tab {
    padding: 8px;
    font-size: 13px;
  }

  .auth-form {
    gap: 10px;
  }

  .auth-close {
    top: 12px;
    right: 12px;
  }

  .auth-submit {
    padding: 12px;
    font-size: 14px;
    margin-top: 4px;
  }

  .auth-divider {
    margin: 12px 0;
  }

  .auth-tg {
    padding: 10px;
    font-size: 13px;
  }

  .pwd-checks li {
    font-size: 11px;
  }

  .auth-tos {
    font-size: 11px;
  }

  .auth-error {
    font-size: 12px;
  }

  .field-hint {
    font-size: 11px;
  }

  /* Scrollbar inside modal */
  .auth-modal::-webkit-scrollbar {
    width: 3px;
  }

  .auth-modal::-webkit-scrollbar-track {
    background: transparent;
  }

  .auth-modal::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
  }
}
