/* ============================================================
   TOKSY — tx-gate.css
   Экран входа: боковая панель, телефон, код, email.
   Всё под .tx-gate, чтобы не влиять на остальное приложение.
   ============================================================ */

/* ---------- Токены ---------- */

:root {
  --tx-accent: #007aff;
  --tx-accent-ink: #0062cc;       /* фон под белым текстом: контраст 5.9:1 */
  --tx-signal: #34c759;
  --tx-alert:  #ff3b30;

  --tx-bg-void:  #f5f5f7;
  --tx-bg-panel: #ffffff;
  --tx-bg-input: rgba(118, 118, 128, 0.12);

  --tx-gate-text:   #1d1d1f;
  --tx-gate-text-2: #5f5f64;
  --tx-gate-line:   rgba(0, 0, 0, 0.12);
  --tx-gate-ok:     #1f8a3f;
  --tx-gate-bad:    #c42a20;

  --tx-r-sm: 10px;
  --tx-r-md: 14px;
  --tx-r-full: 999px;

  --tx-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --tx-dur-fast: 0.15s;
  --tx-dur-base: 0.25s;

  --tx-font-display: 'Unbounded', 'Inter', system-ui, sans-serif;
}

/* Темы переключает core.js классом на <html> */
html.theme-dark {
  --tx-bg-void:  #000000;
  --tx-bg-panel: #2c2c2e;
  --tx-bg-input: rgba(118, 118, 128, 0.24);
  --tx-gate-text:   #f5f5f7;
  --tx-gate-text-2: #a1a1a6;
  --tx-gate-line:   rgba(255, 255, 255, 0.16);
  --tx-gate-ok:     #34c759;
  --tx-gate-bad:    #ff6b62;
}
html.theme-nord {
  --tx-bg-void:  #eceff4;
}

/* ---------- Каркас ---------- */

.tx-gate {
  position: fixed; inset: 0; z-index: 1000;
  display: grid;
  grid-template-columns: minmax(340px, 5fr) minmax(0, 7fr);
  background: var(--tx-bg-void);
  color: var(--tx-gate-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px; line-height: 1.5;
  overflow-y: auto;
}
.tx-gate *, .tx-gate *::before, .tx-gate *::after { box-sizing: border-box; }
.tx-gate [hidden] { display: none !important; }
:where(.tx-gate) button, :where(.tx-gate) input { font: inherit; color: inherit; border: 0; background: none; margin: 0; }
:where(.tx-gate) button { cursor: pointer; }
.tx-gate :focus-visible { outline: 3px solid var(--tx-accent); outline-offset: 2px; }

/* ---------- Боковая панель ---------- */

.tx-gate__panel {
  display: flex; flex-direction: column; justify-content: space-between;
  gap: 48px; padding: 48px;
  background: var(--tx-bg-panel); color: var(--tx-gate-text);
  border-right: 1px solid var(--tx-gate-line);
}
.tx-gate__brand { display: inline-flex; align-items: center; gap: 12px; align-self: flex-start; font-family: var(--tx-font-display); font-weight: 600; font-size: 20px; letter-spacing: -0.02em; color: var(--tx-gate-text); text-decoration: none; }
.tx-gate__brand img { width: 36px; height: 36px; border-radius: 10px; }
.tx-gate__verbs { font-family: var(--tx-font-display); font-weight: 600; font-size: clamp(32px, 3.8vw, 54px); line-height: 1.04; letter-spacing: -0.04em; }
.tx-gate__facts { margin-top: 32px; display: flex; flex-direction: column; gap: 10px; font-size: 16px; list-style: none; padding: 0; color: var(--tx-gate-text-2); }

/* ---------- Форма ---------- */

.tx-gate__main { display: flex; align-items: center; justify-content: center; padding: 48px 32px; min-width: 0; }
.tx-gate__box { width: 100%; max-width: 400px; }

.tx-gate__back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 20px -6px; padding: 8px 12px 8px 6px; border-radius: var(--tx-r-full); font-weight: 600; font-size: 15px; color: var(--tx-accent); transition: background var(--tx-dur-base); }
.tx-gate__back:hover { background: rgba(0, 122, 255, 0.1); }

.tx-gate__title { font-family: var(--tx-font-display); font-weight: 600; font-size: clamp(26px, 3vw, 32px); line-height: 1.12; letter-spacing: -0.035em; }
.tx-gate__lead { text-wrap: balance; margin-top: 10px; color: var(--tx-gate-text-2); font-size: 16px; }
.tx-gate__head { margin-bottom: 32px; }

.tx-gate__step { animation: txGateIn 0.25s var(--tx-ease) both; }
@keyframes txGateIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Кнопки ---------- */

.tx-gate .tx-btn {
  opacity: 1;
  display: flex; align-items: center; justify-content: center; width: 100%;
  min-height: 56px; padding: 0 20px;
  border-radius: var(--tx-r-md);
  font-weight: 600; font-size: 16px;
  transition: background var(--tx-dur-base), opacity var(--tx-dur-base), transform var(--tx-dur-fast);
}
.tx-gate .tx-btn:active:not(:disabled) { transform: scale(0.98); }
.tx-gate .tx-btn--primary { background: var(--tx-accent-ink); color: #fff; }
.tx-gate .tx-btn--primary:hover:not(:disabled) { background: #0057b8; }
.tx-gate .tx-btn--primary:disabled { background: var(--tx-bg-input); color: var(--tx-gate-text-2); cursor: not-allowed; }
.tx-gate .tx-btn--ghost { background: transparent; color: var(--tx-gate-text); box-shadow: inset 0 0 0 1.5px var(--tx-gate-line); }
.tx-gate .tx-btn--ghost:hover { background: var(--tx-bg-input); }
.tx-gate__alt { margin-top: 12px; }

.tx-gate .tx-link { padding: 8px 4px; font-weight: 600; font-size: 15px; color: var(--tx-accent); border-radius: var(--tx-r-sm); }
.tx-gate .tx-link:hover { text-decoration: underline; }

/* ---------- Телефон ---------- */

.tx-gate .tx-phone { position: relative; display: flex; gap: 8px; }
.tx-gate .tx-country { position: relative; flex-shrink: 0; }
.tx-gate .tx-country__btn { display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 14px; border-radius: var(--tx-r-md); background: var(--tx-bg-input); font-weight: 600; color: var(--tx-gate-text); }
.tx-gate .tx-country__btn:hover { background: rgba(118, 118, 128, 0.2); }
.tx-gate .tx-country__iso { display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 5px; border-radius: 6px; background: var(--tx-bg-panel); box-shadow: inset 0 0 0 1px var(--tx-gate-line); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.tx-gate .tx-country__list { position: absolute; z-index: 10; top: calc(100% + 8px); left: 0; width: 280px; margin: 0; padding: 6px; list-style: none; background: var(--tx-bg-panel); border-radius: var(--tx-r-md); box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22), 0 0 0 1px var(--tx-gate-line); }
.tx-gate .tx-country__item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--tx-r-sm); cursor: pointer; }
.tx-gate .tx-country__item:hover, .tx-gate .tx-country__item:focus-visible { background: var(--tx-bg-input); outline-offset: -3px; }
.tx-gate .tx-country__item[aria-selected='true'] .tx-country__name { color: var(--tx-accent); }
.tx-gate .tx-country__name { flex: 1; font-weight: 500; }
.tx-gate .tx-country__dial { color: var(--tx-gate-text-2); font-weight: 500; }

.tx-gate .tx-phone__input, .tx-gate .tx-field__input {
  width: 100%; min-width: 0; height: 56px; padding: 0 16px;
  border-radius: var(--tx-r-md);
  background: var(--tx-bg-input);
  box-shadow: inset 0 0 0 2px transparent;
  font-size: 17px; font-weight: 500;
  transition: box-shadow var(--tx-dur-fast), background var(--tx-dur-fast);
}
.tx-gate .tx-phone__input { flex: 1; font-size: 19px; letter-spacing: 0.01em; font-variant-numeric: tabular-nums; }
.tx-gate .tx-phone__input:focus, .tx-gate .tx-field__input:focus { outline: none; background: var(--tx-bg-panel); box-shadow: inset 0 0 0 2px var(--tx-accent); }
.tx-gate .tx-phone__input::placeholder { color: var(--tx-gate-text-2); opacity: 0.7; }

.tx-gate .tx-hint { min-height: 24px; margin: 10px 2px 18px; font-size: 14px; color: var(--tx-gate-text-2); }
.tx-gate .tx-hint.is-ready { color: var(--tx-gate-ok); font-weight: 600; }
.tx-gate .tx-hint.is-error { color: var(--tx-gate-bad); font-weight: 600; }

.tx-gate__legal { margin-top: 28px; font-size: 13px; line-height: 1.6; color: var(--tx-gate-text-2); }
.tx-gate__legal a { color: var(--tx-gate-text); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--tx-gate-line); }
.tx-gate__legal a:hover { text-decoration-color: currentColor; }

/* ---------- Код из SMS ---------- */

.tx-gate .tx-code__sent { color: var(--tx-gate-text-2); }
.tx-gate .tx-code__sent strong { color: var(--tx-gate-text); font-weight: 600; }
.tx-gate .tx-code { display: flex; gap: 8px; margin: 24px 0 8px; }
.tx-gate .tx-code__cell {
  flex: 1 1 0; min-width: 0; max-width: 56px; height: 64px;
  border-radius: var(--tx-r-md);
  background: var(--tx-bg-input);
  box-shadow: inset 0 0 0 2px transparent;
  text-align: center; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums;
  transition: box-shadow var(--tx-dur-fast), background var(--tx-dur-fast);
}
.tx-gate .tx-code__cell:focus { outline: none; background: var(--tx-bg-panel); box-shadow: inset 0 0 0 2px var(--tx-accent); }
.tx-gate .tx-code__cell.is-filled { box-shadow: inset 0 0 0 2px var(--tx-gate-line); }
.tx-gate .tx-code__cell.is-filled:focus { box-shadow: inset 0 0 0 2px var(--tx-accent); }
.tx-gate .tx-code.is-wrong .tx-code__cell { box-shadow: inset 0 0 0 2px var(--tx-alert); }
.tx-gate .tx-code__timer { margin-top: 12px; font-size: 14px; color: var(--tx-gate-text-2); }

.tx-gate .tx-sms { display: flex; align-items: center; gap: 12px; width: 100%; margin-bottom: 24px; padding: 14px 16px; border-radius: var(--tx-r-md); background: rgba(0, 122, 255, 0.1); text-align: left; }
.tx-gate .tx-sms__code { font-size: 20px; font-weight: 700; letter-spacing: 0.14em; font-variant-numeric: tabular-nums; color: var(--tx-accent); }
.tx-gate .tx-sms__src { flex: 1; font-size: 13px; color: var(--tx-gate-text-2); }
.tx-gate .tx-sms__act { padding: 6px 14px; border-radius: var(--tx-r-full); background: var(--tx-accent-ink); color: #fff; font-size: 14px; font-weight: 600; }

.tx-gate .tx-err { min-height: 22px; margin-top: 6px; font-size: 14px; font-weight: 500; color: var(--tx-gate-bad); }

/* ---------- Email ---------- */

.tx-gate .tx-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 24px; border-radius: var(--tx-r-md); background: var(--tx-bg-input); }
.tx-gate .tx-tabs__tab { flex: 1; min-height: 44px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--tx-gate-text-2); transition: background var(--tx-dur-base), color var(--tx-dur-base); }
.tx-gate .tx-tabs__tab[aria-selected='true'] { background: var(--tx-bg-panel); color: var(--tx-gate-text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }

.tx-gate .tx-form { display: flex; flex-direction: column; gap: 16px; }
.tx-gate .tx-form .tx-err { margin: -6px 0 -4px; }
.tx-gate .tx-field__label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.tx-gate .tx-field__wrap { position: relative; }
.tx-gate .tx-field__wrap .tx-field__input { padding-right: 52px; }
.tx-gate .tx-field__eye { position: absolute; top: 0; right: 0; width: 52px; height: 56px; display: grid; place-items: center; color: var(--tx-gate-text-2); border-radius: var(--tx-r-md); }
.tx-gate .tx-field__eye:hover { color: var(--tx-gate-text); }
.tx-gate .tx-field__eye-off { display: none; }
.tx-gate .tx-field__eye[aria-pressed='true'] .tx-field__eye-on { display: none; }
.tx-gate .tx-field__eye[aria-pressed='true'] .tx-field__eye-off { display: block; }
.tx-gate .tx-field__hint { margin-top: 6px; font-size: 13px; color: var(--tx-gate-text-2); }

/* ---------- Планшет и телефон ---------- */

@media (max-width: 900px) {
  .tx-gate { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .tx-gate__panel { flex-direction: row; align-items: center; padding: 20px 24px 0; background: transparent; border-right: 0; }
  .tx-gate__pitch { display: none; }
  .tx-gate__main { align-items: flex-start; padding: 32px 24px 40px; }
}

@media (max-width: 380px) {
  .tx-gate__main { padding: 24px 16px 32px; }
  .tx-gate .tx-code { gap: 6px; }
  .tx-gate .tx-code__cell { height: 56px; font-size: 22px; }
  .tx-gate .tx-phone__input { font-size: 17px; padding: 0 12px; }
  .tx-gate .tx-country__btn { padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .tx-gate__step { animation: none; }
  .tx-gate * { transition-duration: 0.01ms !important; }
}

/* ---------- Защита от общих правил приложения ---------- */

.tx-gate button, .tx-gate input { opacity: 1; }
