/* CKT login — dark, centered ClickUp-inspired layout */

:root {
  --login-bg: #0e0f12;
  --login-surface: #16171c;
  --login-border: #2a2d36;
  --login-border-focus: #7b68ee;
  --login-text: #f2f3f5;
  --login-text-muted: #9aa0ae;
  --login-accent: #7b68ee;
  --login-accent-hover: #6a58e0;
  --login-accent-disabled: #3a3d48;
  --login-danger: #f87171;
  --login-danger-bg: rgba(248, 113, 113, 0.1);
  --login-danger-border: rgba(248, 113, 113, 0.28);
  --font-sans: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --radius-md: 10px;
  --stack-max: 400px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  /* svh = visible area with mobile chrome; dvh tracks chrome show/hide.
     Do not set height:100% — iOS PWA shrinks the layout viewport with the
     keyboard, recenters the flex form, and immediately steals focus. */
  min-height: 100%;
  min-height: 100svh;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--login-text);
  background: var(--login-bg);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

/* Installed PWA only — kill rubber-band / pull-to-refresh on the page chrome */
@media (display-mode: standalone) {
  html,
  body {
    overscroll-behavior: none;
  }
}

/* Old Safari without svh/dvh — do not put this after 100dvh or it wins and shortens the page */
@supports not (height: 100dvh) {
  html,
  body {
    min-height: -webkit-fill-available;
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-page {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  /* Fill the visible viewport so flex centering works on phone (not just desktop) */
  min-height: 100%;
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Balanced safe-area so PWA chrome does not bias the stack upward */
  padding:
    max(24px, env(safe-area-inset-top, 0px))
    16px
    max(24px, env(safe-area-inset-bottom, 0px));
  /* Do not use overflow:hidden — it clips the blurred glow into a hard edge after paint/animation settles */
  overflow-x: clip;
  overflow-y: auto;
  background: var(--login-bg);
}

@supports not (height: 100dvh) {
  .login-page {
    min-height: -webkit-fill-available;
  }
}

/* Phones: lock to the small viewport so the form stays optically middle while URL bar is open.
   svh does not shrink with the virtual keyboard (dvh does). */
@media (max-width: 767px) {
  html,
  body,
  .login-page {
    min-height: 100svh;
  }
}

/* Full-bleed wash lives on a fixed layer so mobile chrome / 100vh changes cannot crop it */
.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255, 120, 180, 0.14) 0%, transparent 55%),
    radial-gradient(90% 70% at 85% -5%, rgba(80, 180, 255, 0.16) 0%, transparent 50%),
    radial-gradient(70% 50% at 10% 0%, rgba(123, 104, 238, 0.12) 0%, transparent 45%),
    var(--login-bg);
}

.login-page__glow {
  position: fixed;
  top: calc(-48px - env(safe-area-inset-top, 0px));
  left: -10%;
  right: -10%;
  height: calc(260px + env(safe-area-inset-top, 0px));
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(90deg,
      rgba(255, 110, 170, 0.22) 0%,
      rgba(123, 104, 238, 0.18) 45%,
      rgba(64, 180, 255, 0.22) 100%);
  filter: blur(48px);
  opacity: 0.85;
  /* Fade only — avoid translateY which shifts the blur under mobile overflow clipping */
  animation: login-glow-in 1.1s ease-out both;
}

.login-stack {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--stack-max);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 20px;
  /* backwards (not both): iOS will not open the keyboard for inputs inside
     an ancestor that still has transform after the animation settles */
  animation: login-stack-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
  animation: login-fade-up 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.08s backwards;
}

.login-brand__mark {
  display: block;
}

.login-brand__name {
  width: 100%;
  min-height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--login-text);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
}

.login-brand__typed {
  display: inline;
}

.login-brand__fixed {
  display: inline;
  white-space: pre;
}

.login-brand__cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 3px;
  vertical-align: -0.08em;
  background: var(--login-accent);
  border-radius: 1px;
  animation: login-cursor-blink 0.9s steps(1, end) infinite;
}

@media (min-width: 480px) {
  .login-brand__name {
    min-height: 2.75rem;
    font-size: 2.05rem;
  }
}

@keyframes login-cursor-blink {
  0%,
  45% { opacity: 1; }
  50%,
  100% { opacity: 0; }
}

.login-header {
  text-align: center;
  margin: 0 0 4px;
  animation: login-fade-up 0.65s cubic-bezier(0.22, 1, 0.36, 1) 0.16s backwards;
}

.login-header__title {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--login-text);
}

.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  animation: login-fade-up 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.2s backwards;
}

.alert-banner--danger {
  background: var(--login-danger-bg);
  border: 1px solid var(--login-danger-border);
  color: var(--login-danger);
}

.alert-banner__message {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form .form-field:nth-of-type(1) {
  animation: login-fade-up 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.24s backwards;
}

.login-form .form-field:nth-of-type(2) {
  animation: login-fade-up 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.32s backwards;
}

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

.form-field__control {
  position: relative;
}

.email-suggest {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 14px;
  z-index: 1;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  font-size: 16px;
  font-family: var(--font-sans);
  color: var(--login-text-muted);
  pointer-events: none;
  opacity: 0;
  white-space: pre;
  user-select: none;
}

.email-suggest.is-visible {
  animation: email-suggest-in 0.38s ease-out forwards;
}

@keyframes email-suggest-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 0.62;
  }
}

.form-field__input {
  display: block;
  width: 100%;
  height: 48px;
  padding: 0 14px;
  /* 16px+ avoids iOS focus zoom in PWA / Safari */
  font-size: 16px;
  -webkit-user-select: text;
  user-select: text;
  font-family: var(--font-sans);
  color: var(--login-text);
  background: var(--login-surface);
  border: 1px solid var(--login-border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.form-field__input::placeholder {
  color: var(--login-text-muted);
}

.form-field__input--password {
  padding-right: 48px;
}

.form-field__input:hover {
  border-color: color-mix(in srgb, var(--login-border) 55%, var(--login-text-muted));
}

.form-field__input:focus {
  outline: none;
  border-color: var(--login-border-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--login-accent) 28%, transparent);
  background: #1a1b22;
}

.form-field--error .form-field__input {
  border-color: var(--login-danger);
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: var(--login-text-muted);
  line-height: 0;
  border-radius: 6px;
  appearance: none;
  -webkit-appearance: none;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--login-text);
  outline: none;
}

.password-toggle__icon {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}

.password-toggle__icon--hide {
  display: none;
}

.password-toggle.is-revealed .password-toggle__icon--show {
  display: none;
}

.password-toggle.is-revealed .password-toggle__icon--hide {
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 48px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.login-form__submit {
  width: 100%;
  margin-top: 4px;
  background: var(--login-accent);
  border-color: var(--login-accent);
  color: #fff;
  animation: login-fade-up 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.4s backwards;
}

.login-form__submit:hover:not(:disabled) {
  background: var(--login-accent-hover);
  border-color: var(--login-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(123, 104, 238, 0.28);
}

.login-form__submit:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}

.login-form__submit:disabled {
  cursor: not-allowed;
  background: var(--login-accent-disabled);
  border-color: var(--login-accent-disabled);
  color: color-mix(in srgb, var(--login-text) 55%, transparent);
  box-shadow: none;
}

@keyframes login-glow-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 0.85;
  }
}

@keyframes login-stack-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes login-fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {

  .login-page__glow,
  .login-stack,
  .login-brand,
  .login-header,
  .alert-banner,
  .login-form .form-field,
  .login-form__submit {
    animation: none !important;
  }

  .login-brand__cursor {
    animation: none !important;
    opacity: 1;
  }

  .login-form__submit:hover:not(:disabled) {
    transform: none;
  }

  .email-suggest {
    animation: none !important;
  }

  .email-suggest.is-visible {
    opacity: 0.62;
  }
}

/* —— PWA update / install toasts (injected by pwa-register.js) —— */
.pwa-toast-host {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  pointer-events: none;
}

.pwa-toast,
.pwa-install {
  pointer-events: auto;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  border-radius: 12px;
  background: #16171c;
  color: #f2f3f5;
  border: 1px solid #2a2d36;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.pwa-toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
}

.pwa-toast__text {
  font-size: 0.9rem;
  font-weight: 600;
}

.pwa-toast__btn,
.pwa-install__btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
}

.pwa-toast__btn {
  background: #7b68ee;
  color: #fff;
}

.pwa-install {
  padding: 0.85rem 0.9rem;
}

.pwa-install__row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.pwa-install__icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

.pwa-install__copy--full {
  margin-bottom: 0.75rem;
}

.pwa-install__title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.pwa-install__sub {
  margin-top: 0.2rem;
  font-size: 0.8rem;
  color: #9aa0ae;
  line-height: 1.4;
}

.pwa-install__steps {
  margin: 0.65rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.82rem;
  color: #d1d5db;
  line-height: 1.55;
}

.pwa-install__steps li + li {
  margin-top: 0.25rem;
}

.pwa-install__share-icon {
  display: inline-block;
  vertical-align: -3px;
  color: #7b68ee;
}

.pwa-install__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.pwa-install__btn--primary {
  background: #7b68ee;
  color: #fff;
}

.pwa-install__btn--ghost {
  background: transparent;
  color: #9aa0ae;
}

@media (min-width: 992px) {
  .pwa-install {
    display: none !important;
  }
}