/* Экран входа — токены и вёрстка по хендоффу «Экран 1 — Вход»
   (docs/work/technical-plan.md, Приложение D). Только светлая тема —
   тёмная (tokens/theme-dark.css в архиве) не заказывалась отдельно.
   Источник токенов: design_handoff_login/README.md, раздел Design Tokens. */

:root {
  --pk-black: #111111;
  --pk-pink: #EA699B;
  --accent: #FFF029;
  --n-0: #FFFFFF;
  --n-50: #F5F5F7;
  --n-100: #ECECEF;
  --n-200: #DFDFE4;
  --n-300: #C8C8CF;
  --n-400: #A2A2AC;
  --n-500: #7B7B85;
  --n-600: #5A5A63;
  --n-800: #26262B;
  --sem-danger: #D64545;
  --sem-danger-bg: #FBEAEA;

  --surface-page: var(--n-50);
  --surface-card: var(--n-0);
  --surface-sunken: var(--n-100);
  --surface-inverse: var(--pk-black);
  --surface-disabled: var(--n-100);
  --surface-hover: var(--n-50);
  --text-primary: var(--pk-black);
  --text-secondary: var(--n-600);
  --text-tertiary: var(--n-400);
  --text-disabled: var(--n-400);
  --text-inverse: #FAFAFC;
  --text-inverse-secondary: rgba(250, 250, 252, .62);
  --text-danger: var(--sem-danger);
  --border-subtle: var(--n-200);
  --border-default: var(--n-300);
  --border-strong: var(--n-500);
  --border-danger: var(--sem-danger);

  --r-pill: 9999px;
  --r-md: 8px;
  --ease-standard: cubic-bezier(.2, 0, .2, 1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-page);
  color: var(--text-primary);
  font-family: 'Geologica', system-ui, sans-serif;
  font-weight: 300;
}

.login-root {
  display: flex;
  min-height: 100vh;
}

/* ── левая колонка ── */

.login-brand {
  width: 520px;
  flex: none;
  background: var(--surface-inverse);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

@media (max-width: 960px) {
  .login-brand { display: none; }
}

.brand-lockup { display: flex; align-items: center; gap: 8px; }

.brand-avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: var(--r-pill);
  overflow: hidden;
  background: var(--n-800);
}

.brand-avatar img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: center 42%;
}

.brand-lockup-text { display: flex; align-items: baseline; gap: 4px; }

.brand-name {
  font-size: 20px; line-height: 1; font-weight: 700;
  letter-spacing: -.01em; color: var(--text-inverse);
}

.brand-product {
  font-size: 14px; line-height: 1; font-weight: 300;
  color: var(--text-inverse-secondary);
}

.brand-copy { display: flex; flex-direction: column; gap: 16px; }

.brand-copy h1 {
  margin: 0; font-size: 40px; line-height: 1.05; font-weight: 700;
  letter-spacing: -.02em; color: var(--text-inverse);
}

.brand-copy p {
  margin: 0; font-size: 14px; line-height: 1.5; font-weight: 300;
  color: var(--text-inverse-secondary); max-width: 340px;
}

.brand-head { width: 168px; height: auto; align-self: flex-end; }

/* ── правая область и карточка ── */

.login-stage {
  flex: 1; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 32px;
}

.login-card {
  width: 440px; max-width: 100%; min-width: 0;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  padding: 32px;
  display: flex; flex-direction: column; gap: 20px;
}

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

.card-header h2 {
  margin: 0; font-size: 26px; line-height: 1.15; font-weight: 700;
  letter-spacing: -.015em; color: var(--text-primary);
}

.card-header p {
  margin: 0; font-size: 14px; line-height: 1.5; font-weight: 300;
  color: var(--text-secondary);
}

/* ── плашка-нотис (1d/1e) ── */

.notice {
  display: none;
  gap: 12px; padding: 12px; border-radius: var(--r-md);
  background: var(--surface-sunken);
}

.notice svg { flex: none; width: 20px; height: 20px; color: currentColor; }

.notice-title { font-size: 14px; font-weight: 500; color: var(--text-primary); margin: 0 0 2px; }
.notice-text { font-size: 13px; line-height: 1.45; font-weight: 300; color: var(--text-secondary); margin: 0; }

.notice.danger { background: var(--sem-danger-bg); color: var(--text-danger); }
.notice.danger .notice-title,
.notice.danger .notice-text { color: var(--text-primary); }

[data-phase="expired"] .notice.expired,
[data-phase="locked"] .notice.locked { display: flex; }

/* ── поля ── */

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

.field label { font-size: 13px; line-height: 1.3; font-weight: 500; color: var(--text-primary); }

.field input[type="email"] {
  height: 44px; padding: 0 12px;
  border: 1px solid var(--border-default); border-radius: var(--r-md);
  background: var(--surface-card);
  font-family: inherit; font-size: 14px; font-weight: 300; color: var(--text-primary);
  transition: border-color 120ms var(--ease-standard), box-shadow 120ms var(--ease-standard);
}

.field input[type="email"]:hover { border-color: var(--border-strong); }

.field input[type="email"]:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 240, 41, .28);
}

.field input[type="email"].is-error { border-color: var(--border-danger); }

.field input[type="email"]:disabled {
  background: var(--surface-disabled); color: var(--text-disabled); cursor: not-allowed;
}

.field-error {
  margin-top: 6px; font-size: 13px; line-height: 1.35; font-weight: 300; color: var(--text-danger);
}

/* сводка «письмо отправлено» вместо поля почты (1b) */

.email-summary {
  display: none; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--r-md); background: var(--surface-sunken);
}

[data-phase="sent"] .email-summary { display: flex; }
[data-phase="sent"] .field-email { display: none; }

.email-summary svg { flex: none; width: 20px; height: 20px; color: var(--text-secondary); }

.email-summary .addr {
  flex: 1; min-width: 0; font-size: 14px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.email-summary button {
  flex: none; background: none; border: none; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 300; color: var(--text-secondary);
  text-decoration: underline;
}

/* ── кнопки ── */

button.btn {
  height: 44px; width: 100%; border-radius: var(--r-pill);
  font-family: inherit; font-size: 14px; font-weight: 500;
  border: none; cursor: pointer;
  transition: transform 80ms var(--ease-standard), background 120ms var(--ease-standard);
}

button.btn:active:not(:disabled) { transform: translateY(1px); }

button.btn.primary { background: var(--pk-pink); color: var(--pk-black); }

button.btn.secondary {
  background: var(--surface-card); border: 1px solid var(--border-default); color: var(--text-primary);
}

button.btn.secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }

button.btn:disabled { background: var(--surface-disabled); color: var(--text-disabled); cursor: not-allowed; }

.resend-hint {
  margin-top: 8px; text-align: center;
  font-size: 13px; font-weight: 300; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

#resend-submit, .resend-hint { display: none; }
[data-phase="sent"] #email-submit { display: none; }
[data-phase="sent"] #resend-submit { display: block; }
[data-phase="sent"] .resend-hint { display: block; }

/* ── разделитель ── */

.divider {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; font-weight: 300; color: var(--text-tertiary);
}

.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }

.explain { margin: 0; font-size: 13px; line-height: 1.5; font-weight: 300; color: var(--text-secondary); }

/* ── код ── */

.code-field label { display: block; margin-bottom: 6px; }

.code-cells { display: flex; align-items: center; gap: 8px; min-width: 0; }

.code-cells .sep { width: 8px; height: 1px; background: var(--border-default); flex: none; }

.code-cells input {
  width: 40px; height: 48px; min-width: 0; text-align: center;
  border: 1px solid var(--border-default); border-radius: var(--r-md);
  background: var(--surface-card);
  font-family: inherit; font-size: 16px; font-weight: 500; color: var(--text-primary);
  padding: 0;
  transition: border-color 120ms var(--ease-standard), box-shadow 120ms var(--ease-standard);
}

.code-cells input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 240, 41, .28);
}

.code-cells input:disabled { background: var(--surface-disabled); color: var(--text-disabled); cursor: not-allowed; }

.code-hint {
  margin: 8px 0 0; font-size: 13px; line-height: 1.45; font-weight: 300; color: var(--text-tertiary);
}

[data-phase="sent"] #code-submit { background: var(--pk-pink); color: var(--pk-black); border: none; }

/* ── locked (1e) ── */

[data-phase="locked"] input,
[data-phase="locked"] button.btn { pointer-events: none; }

.locked-footnote {
  display: none; margin: 0; font-size: 13px; line-height: 1.45; font-weight: 300; color: var(--text-tertiary);
}

[data-phase="locked"] .locked-footnote { display: block; }

/* ── узкие экраны: без этого 8 полей кода упираются в 40px и толкают
   страницу вбок (min-width:0 выше глушит скролл, но без сужения отступов
   поля схлопнутся до ~19px — нечитаемо) ── */

@media (max-width: 480px) {
  .login-stage { padding: 16px; }
  .login-card { padding: 20px; }
  .code-cells { gap: 6px; }
  .code-cells .sep { width: 6px; }
}
