/* Auth screens (login, forgot password). Pre-authenticated, no sidebar.
 * Consumes tokens.css. Centred card on a soft background. */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--c-bg);
  font-family: var(--font-ui);
}

.auth__card {
  position: relative;
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.auth__title {
  text-align: center;
  font-family: var(--font-brand);
  font-size: 28px;
  font-weight: var(--fw-bold);
  font-style: normal;
  line-height: 1.2;
  color: var(--c-primary);
  margin: 0;
  letter-spacing: -0.4px;
}

.auth__subtitle {
  text-align: center;
  color: var(--c-text-secondary);
  font-size: var(--fs-body);
  margin: 0 0 10px;
  line-height: 1.4;
}

.auth__input {
  width: 100%;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  padding: 14px 18px;
  font: inherit;
  font-size: var(--fs-body);
  color: var(--c-text);
}
.auth__input::placeholder { color: var(--c-text-hint); }

/* Password field with show/hide toggle. Wrapper keeps the input full-width;
 * the eye button floats inside on the right. */
.auth__field {
  position: relative;
  display: flex;
  align-items: stretch;
}
.auth__field .auth__input { padding-right: 48px; }
.auth__toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--c-text-hint);
  border-radius: 0 14px 14px 0;
}
.auth__toggle:hover { color: var(--c-text-secondary); }
.auth__toggle svg { width: 20px; height: 20px; }
.auth__toggle [data-eye-off] { display: none; }
.auth__toggle[aria-pressed="true"] [data-eye-on] { display: none; }
.auth__toggle[aria-pressed="true"] [data-eye-off] { display: block; }
.auth__input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-soft);
}

.auth__submit {
  width: 100%;
  background: var(--c-primary);
  color: var(--c-primary-on);
  border: none;
  border-radius: 14px;
  padding: 14px 24px;
  font: inherit;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  cursor: pointer;
  margin-top: 8px;
}
.auth__submit:hover { background: var(--c-primary-hover); }

.auth__link {
  display: block;
  width: 100%;
  text-align: center;
  color: var(--c-primary);
  text-decoration: none;
  font: inherit;
  font-size: var(--fs-body);
  background: transparent;
  border: none;
  padding: 0;
  margin-top: 4px;
  cursor: pointer;
}
.auth__link:hover { text-decoration: underline; }

/* The Figma node is a 240 × 560 composition reference, not a phone-shaped
 * card. Desktop keeps a compact form; the phone override below expands the
 * same composition to the actual viewport. */
.auth__card--login {
  width: min(240px, 100%);
  min-height: min(560px, calc(100vh - 48px));
  justify-content: center;
  gap: 10px;
  padding: 10px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 24px;
  overflow: hidden;
}
.auth__card--login .auth__subtitle { margin-bottom: 10px; }

@media (min-width: 700px) {
  .auth__card--login {
    width: min(360px, 100%);
    min-height: 0;
    padding: 0;
    gap: 14px;
    overflow: visible;
    border: 0;
    border-radius: 0;
    background: transparent;
  }
}

.bind-flow,
.bind-done {
  width: min(240px, 100%);
  min-height: min(560px, calc(100vh - 48px));
  justify-content: flex-start;
  padding: 10px;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 24px;
  overflow: hidden;
}
.bind-flow__back {
  position: absolute;
  top: 22px;
  left: 11px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: transparent;
  border: 0;
  padding: 0;
  background: transparent;
  text-decoration: none;
  font-size: 0;
  line-height: 1;
}
.bind-flow__back img { display: block; width: 26px; height: 26px; }
.bind-flow__back:hover { filter: brightness(0.98); }
.bind-flow__back:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }
.bind-flow__prompt { margin: 2px 0 12px; }
.bind-flow__screen {
  min-height: 538px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 180px;
}
.bind-flow__screen[hidden] { display: none; }
.bind-flow__screen .auth__input,
.bind-flow__screen .auth__submit { min-height: 39px; border-radius: 14px; }
.bind-flow__screen .auth__submit { margin-top: 1px; }
.bind-flow__link-button {
  display: grid;
  place-items: center;
  text-align: center;
  text-decoration: none;
  margin-top: auto;
}
.bind-flow__branches {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.bind-flow__branch {
  min-height: 44px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--c-text-secondary);
  background: rgba(181, 184, 191, 0.2);
  border: 0;
  border-radius: 14px;
  text-decoration: none;
  font-size: var(--fs-body);
  font-weight: var(--fw-semibold);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.bind-flow__branch:hover { border-color: var(--c-primary); }
.bind-flow__branch--create {
  background: var(--c-card);
  border: 1px solid var(--c-border);
}
.bind-flow__pin {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: transparent;
  background: transparent;
  font-size: 0;
}
.bind-flow__pin img { display: block; max-width: 12px; max-height: 12px; }
.bind-flow__chevron {
  width: 13px;
  height: 13px;
  color: transparent;
  background: transparent;
  font-size: 0;
}
.bind-flow__chevron img { display: block; width: 13px; height: 13px; }
.bind-flow__screen[data-bind-screen="branch"] > .auth__submit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: -5px;
  color: var(--c-text-secondary);
  background: var(--c-card);
  border: 1px solid var(--c-border);
}
.bind-flow__screen[data-bind-screen="branch"] > .auth__submit::before {
  content: "";
  width: 12px;
  height: 12px;
  background: url("/admin/static/figma-bind-plus.svg") center / contain no-repeat;
}

/* Binding success, Figma 281:75 / 281:96. */
.bind-done { gap: 12px; padding-top: 136px; }
.bind-done__lead {
  text-align: center;
  color: var(--c-text-secondary);
  font-size: var(--fs-body);
  line-height: 1.5;
  margin: 0;
}
.bind-done__pin {
  background: rgba(181, 184, 191, 0.2);
  border-radius: 14px;
  padding: 16px 12px;
}
.bind-done__pin-label {
  text-align: center;
  color: var(--c-text-secondary);
  font-size: var(--fs-body);
  line-height: 1.4;
  margin: 0 0 12px;
}
.bind-done__cells { display: flex; justify-content: center; gap: 5px; }
.bind-done__cell {
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  color: var(--c-text-secondary);
  font-size: 16px;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.12px;
}
.bind-done__copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 4px 0;
  cursor: pointer;
  color: var(--c-text-secondary);
  font: inherit;
  font-size: var(--fs-body);
}
.bind-done__copy img { width: 14px; height: 14px; flex: none; }
.bind-done__copy:hover { color: var(--c-primary); }
.bind-done__copy:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; border-radius: var(--radius-button); }
.bind-done__copy.is-copied { color: var(--c-ok); }
.bind-done__copy.is-copied img { display: none; }
.bind-done__cta {
  display: grid;
  place-items: center;
  text-align: center;
  text-decoration: none;
  margin-top: auto;
}

/* Camera setup shell. Its data-camera-state contract is intentionally tiny:
 * ready | requesting | scanning | denied | found.
 *
 * Визуально это ТОТ ЖЕ экран, что в этот момент горит на приставке
 * (``#setup-overlay`` в apps/tv/index.html): тот же запечённый блюр-фон
 * world-picker'а, тот же градиент поверх, та же навигационная карточка
 * (--su-navy-card), тот же розовый и тот же логотип-SVG. Оператор держит
 * телефон рядом с телевизором — два экрана обязаны читаться как один шаг
 * одного флоу, поэтому токены ниже скопированы с приставки, а не
 * подобраны заново. Блюр ЗАПЕЧЁН в jpg: рантайм-фильтров нет (дёшево и
 * на слабом телефоне, и на киоске). */
.setup-camera {
  --su-navy-card: rgba(18, 38, 66, 0.78);
  --su-ink-dim: rgba(255, 255, 255, 0.72);
  --su-pink: #fd6b9c;
  --su-pink-hover: #ff85af;

  position: fixed;
  inset: 0;
  display: flex;
  overflow-y: auto;
  padding: 16px;
  color: #fff;
  font-family: var(--font-ui);
  background:
    radial-gradient(120% 90% at 50% 42%,
      rgba(8, 16, 34, 0) 0%,
      rgba(8, 16, 34, 0.35) 58%,
      rgba(6, 12, 26, 0.78) 100%),
    #0d1830 url("/static/tv/assets/world-picker/background-blurred.jpg") center / cover no-repeat;
}
/* Портрет — ОТДЕЛЬНЫЙ запечённый кадр. `cover` на телефоне вырезает из
 * 16:9-рендера узкую центральную колонку, а центр у него — пустая вода:
 * фон вырождался в плоскую синюю заливку. Портретный бейк собран так,
 * что песок и кораллы остаются в кадре — scripts/build_setup_backdrop.py. */
@media (max-aspect-ratio: 3 / 4) {
  .setup-camera {
    background-image:
      radial-gradient(120% 70% at 50% 40%,
        rgba(8, 16, 34, 0) 0%,
        rgba(8, 16, 34, 0.22) 55%,
        rgba(6, 12, 26, 0.62) 100%),
      url("/static/tv/assets/world-picker/background-blurred-portrait.jpg");
  }
}
/* margin:auto, не place-items — центрированный grid-элемент выше вьюпорта
 * обрезается сверху и до него нельзя доскроллить. */
.setup-camera__panel {
  position: relative;
  z-index: 1;
  margin: auto;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 44px 4px 4px;
}
.setup-camera__back {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 2;
}
/* Официальный лого приставки (бело-розовый), а не сиреневый .auth__title:
 * фиолетовый на тёмном фоне не читался и расходился с экраном ТВ. */
.setup-camera__brand { margin: 0 0 2px; }
.setup-camera__brand img {
  display: block;
  width: min(232px, 60%);
  height: auto;
  margin: 0 auto;
  user-select: none;
  pointer-events: none;
}
.setup-camera__intro { display: grid; justify-items: center; gap: 16px; }
.setup-camera__intro h2,
.setup-camera__copy h2 {
  margin: 0;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-shadow: 0 2px 14px rgba(8, 24, 48, 0.45);
}
.setup-camera__qr {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  color: var(--su-pink);
  background: var(--su-navy-card);
  box-shadow: 0 14px 40px rgba(4, 19, 37, 0.28);
}
.setup-camera__qr svg { display: block; width: 44px; height: 44px; }
.setup-camera__steps {
  width: 100%;
  display: grid;
  padding: 18px 20px;
  border-radius: 22px;
  color: #fff;
  background: var(--su-navy-card);
  box-shadow: 0 20px 60px rgba(4, 19, 37, 0.24);
}
.setup-camera__steps h3 {
  margin: 0 0 8px;
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.3;
}
.setup-camera__steps p {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 9px 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}
.setup-camera__steps p:last-child { border-bottom: 0; }
.setup-camera__steps b {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--su-pink);
  font-size: 15px;
  font-weight: 800;
}
.setup-camera__copy { display: grid; gap: 8px; text-align: center; }
.setup-camera__copy p,
.setup-camera__privacy {
  margin: 0;
  color: var(--su-ink-dim);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}
.setup-camera__viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 56vh;
  overflow: hidden;
  border-radius: 22px;
  background: #0a1424;
  box-shadow: 0 20px 60px rgba(4, 19, 37, 0.34);
}
.setup-camera[data-camera-state="ready"] .setup-camera__scanner-copy,
.setup-camera[data-camera-state="ready"] .setup-camera__viewport { display: none; }
.setup-camera:not([data-camera-state="ready"]) .setup-camera__intro { display: none; }
.setup-camera__video { width: 100%; height: 100%; display: block; object-fit: cover; }
.setup-camera__shade { position: absolute; inset: 0; background: rgba(6, 12, 26, 0.28); }
.setup-camera__finder {
  position: absolute;
  top: 50%; left: 50%;
  width: min(68%, 224px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
}
.setup-camera__finder i { position: absolute; width: 42px; height: 42px; border-color: #fff; border-style: solid; }
.setup-camera__finder i:nth-child(1) { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 14px 0 0; }
.setup-camera__finder i:nth-child(2) { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 14px 0 0; }
.setup-camera__finder i:nth-child(3) { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 14px; }
.setup-camera__finder i:nth-child(4) { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 14px; }
.setup-camera__state {
  position: absolute;
  inset: 0;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 30px;
  color: #fff;
  text-align: center;
  background: rgba(6, 12, 26, 0.55);
}
.setup-camera__state span { font-size: 14px; line-height: 1.4; }
.setup-camera__state strong { font-size: 16px; font-weight: 800; }
.setup-camera[data-camera-state="ready"] .setup-camera__state--ready,
.setup-camera[data-camera-state="requesting"] .setup-camera__state--requesting,
.setup-camera[data-camera-state="denied"] .setup-camera__state--denied,
.setup-camera[data-camera-state="found"] .setup-camera__state--found { display: grid; }
.setup-camera[data-camera-state="scanning"] .setup-camera__shade { display: none; }
.setup-camera__camera-icon,
.setup-camera__check { width: 48px; height: 48px; display: grid; place-items: center; border: 2px solid currentColor; border-radius: 50%; font-size: 24px; }
.setup-camera__check { color: #3ddc84; }
.setup-camera__spinner { width: 38px; height: 38px; border: 3px solid rgba(255, 255, 255, 0.3); border-top-color: #fff; border-radius: 50%; animation: camera-spin 0.8s linear infinite; }
@keyframes camera-spin { to { transform: rotate(360deg); } }
.setup-camera__start {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  margin-top: 2px;
  border-radius: 16px;
  color: #fff;
  background: var(--su-pink);
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(253, 107, 156, 0.28);
}
.setup-camera__start:hover { background: var(--su-pink-hover); }
.setup-camera__start:disabled { opacity: 0.6; cursor: default; }
.setup-camera__start svg { width: 20px; height: 20px; }
.setup-camera__later {
  display: grid;
  place-items: center;
  min-height: 52px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
  font-weight: 700;
}
.setup-camera__later:hover { border-color: #fff; background: rgba(255, 255, 255, 0.12); text-decoration: none; }
.setup-camera[data-camera-state="scanning"] .setup-camera__start,
.setup-camera[data-camera-state="found"] .setup-camera__start { visibility: hidden; }

.auth__error {
  text-align: center;
  background: var(--c-err-soft);
  color: var(--c-err);
  border: 1px solid var(--c-err-border);
  padding: 8px 14px;
  border-radius: 14px;
  font-size: var(--fs-ui);
  margin: 0;
}

.auth__channels {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.auth__notice {
  text-align: center;
  background: var(--c-primary-soft);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  padding: 14px 18px;
  font-size: var(--fs-body);
  line-height: 1.45;
  margin: 0;
}

.auth__channel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 18px;
  border: 1px solid var(--c-border);
  border-radius: 14px;
  background: var(--c-card);
  color: var(--c-text);
  text-decoration: none;
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
}
.auth__channel:hover { border-color: var(--c-primary); color: var(--c-primary); }
.auth__channel svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Phone: auth and binding are the page itself, not a fixed Figma frame placed
 * inside the page. 100dvh follows the visible browser viewport while the svh
 * fallback keeps older mobile browsers usable. Inputs stay at 16px so iOS
 * Safari does not zoom on focus. */
@media (max-width: 699px) {
  .auth {
    width: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    place-items: stretch;
    padding: 0;
    background: var(--c-card);
  }
  .auth__card {
    width: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    justify-content: center;
    gap: 14px;
    padding:
      max(28px, env(safe-area-inset-top))
      max(24px, env(safe-area-inset-right))
      max(28px, env(safe-area-inset-bottom))
      max(24px, env(safe-area-inset-left));
    background: var(--c-card);
  }
  .auth__title { font-size: 30px; letter-spacing: -0.6px; }
  .auth__subtitle { font-size: 16px; line-height: 1.45; margin-bottom: 10px; }
  .auth__input {
    font-size: 16px;       /* prevents iOS zoom-on-focus */
    min-height: 44px;
    padding: 11px 13px;
    border-radius: 14px;
  }
  .auth__field .auth__input { padding-right: 44px; }
  .auth__toggle { width: 44px; border-radius: 0 12px 12px 0; }
  .auth__submit {
    font-size: 16px;
    min-height: 44px;
    padding: 11px 18px;
    border-radius: 12px;
    margin-top: 4px;
  }
  .auth__link { font-size: 15px; margin-top: 4px; padding: 4px 0; }
  .auth__error { font-size: 14px; padding: 10px 16px; }
  .auth__channel { font-size: 15px; padding: 14px 20px; border-width: 1.5px; }
  .auth__notice { font-size: 15px; padding: 16px 20px; border-width: 1.5px; }
  .auth__card--login,
  .bind-flow,
  .bind-done {
    width: 100%;
    min-height: 100svh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .auth__card--login {
    padding:
      max(28px, env(safe-area-inset-top))
      max(24px, env(safe-area-inset-right))
      max(28px, env(safe-area-inset-bottom))
      max(24px, env(safe-area-inset-left));
    gap: 14px;
    overflow: visible;
  }
  .bind-flow,
  .bind-done {
    justify-content: flex-start;
    padding:
      max(24px, env(safe-area-inset-top))
      max(24px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(24px, env(safe-area-inset-left));
  }
  .bind-flow__back {
    top: max(24px, env(safe-area-inset-top));
    left: max(24px, env(safe-area-inset-left));
  }
  .bind-flow__screen {
    flex: 1;
    min-height: 0;
    padding-top: clamp(150px, 28dvh, 236px);
    padding-bottom: 4px;
  }
  .auth__card--login .auth__title,
  .bind-flow .auth__title,
  .bind-done .auth__title { font-size: 30px; letter-spacing: -0.5px; }
  .auth__card--login .auth__subtitle,
  .bind-flow .auth__subtitle,
  .bind-done .auth__subtitle { font-size: 16px; }
  .auth__card--login .auth__input,
  .bind-flow .auth__input { min-height: 50px; padding: 13px 16px; font-size: 16px; }
  .auth__card--login .auth__submit,
  .bind-flow .auth__submit { min-height: 50px; padding: 13px 18px; font-size: 16px; border-radius: 14px; }
  .auth__card--login .auth__link { font-size: 15px; }
  .bind-flow__branch { min-height: 54px; padding: 11px 14px; font-size: 16px; }
  .bind-done { padding-top: clamp(132px, 21dvh, 184px); }
  .bind-done__lead,
  .bind-done__pin-label,
  .bind-done__copy { font-size: 16px; }
  .bind-done__cell { width: 48px; height: 48px; font-size: 20px; }
  /* Без своей заливки: панель — только раскладка, фон один на страницу. */
  .setup-camera__panel {
    width: 100%;
    padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  }
  .setup-camera__viewport { min-height: 300px; }
}

@media (min-width: 700px) and (max-height: 620px) {
  .auth__card--login,
  .bind-flow,
  .bind-done { min-height: calc(100vh - 24px); }
  .bind-flow__screen { min-height: calc(100vh - 46px); padding-top: 72px; }
  .bind-done { padding-top: 64px; }
}
