/*
 * Стенд регистрации Первого кубка нейроконтента и Чемпионата «Антифейк».
 * Отдельный файл: общий styles.css этой папки подключают админка, стенд призов и голосование.
 * Макет Лины — 4:3 (планшет 13″ в горизонтальной ориентации), сетка 1440×1080:
 * 1rem = 10px макета, корень масштабируется под экран (см. html ниже).
 * Фон — «живая плата» на canvas (circuit.js), панели — матовое стекло поверх.
 *
 * Шрифты по макету: Onder 500 — капс, Century Gothic 400/700 — остальной текст.
 * Файлы и лицензии — в assets/fonts/; Unbounded и Manrope — запасные, пока
 * фирменные грузятся (font-display: swap; index.html подгружает их заранее).
 */
@font-face {
  font-family: Onder;
  src: url('assets/fonts/onder-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: 'Century Gothic';
  src: url('assets/fonts/century-gothic-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: 'Century Gothic';
  src: url('assets/fonts/century-gothic-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: Unbounded;
  src: url('assets/unbounded-cyrillic.woff2') format('woff2');
  font-weight: 500 700;
  font-display: swap;
  unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Unbounded;
  src: url('assets/unbounded-latin.woff2') format('woff2');
  font-weight: 500 700;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url('assets/manrope-cyrillic.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
  font-family: Manrope;
  src: url('assets/manrope-latin.woff2') format('woff2');
  font-weight: 400 800;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --display: Onder, Unbounded, sans-serif;
  --text: 'Century Gothic', Manrope, Arial, sans-serif;
  --white: #ffffff;
  --soft: #f3ddff; /* второстепенный текст на панели */
  --placeholder: #e2c2f5;
  --pink: #e731a7; /* кнопка «Продолжить» */
  --pink-logo: #ff5cc4; /* подпись «Чемпионат Антифейк» */
  --line: rgba(222, 170, 250, 0.7); /* обводка полей и карточек */
  --panel-line: rgba(214, 120, 240, 0.55);
  --panel: linear-gradient(135deg, rgba(96, 16, 150, 0.5) 0%, rgba(150, 18, 165, 0.5) 100%);
  --field: rgba(70, 14, 130, 0.32);
  --button-idle: rgba(104, 40, 170, 0.75);
  --glow: 0 0 2.2rem rgba(225, 170, 255, 0.75);
  --ground: #2a0a66;

  font-family: var(--text);
  color: var(--white);
  background: var(--ground);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* 1rem = 10px макета 1440×1080 по «тесной» стороне экрана */
html {
  font-size: min(calc(100vw / 144), calc(100vh / 108));
  font-size: min(calc(100vw / 144), calc(100dvh / 108));
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

.backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Кадр макета 1440×1080, по центру экрана. --lift поднимает его над клавиатурой iPad */
.frame {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 144rem;
  height: 108rem;
  transform: translate(-50%, calc(-50% - var(--lift, 0px)));
  transition: transform 0.25s ease;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: screen-in 0.45s ease-out both;
}

@keyframes screen-in {
  from { opacity: 0; transform: translateY(1.6rem); }
}

/* ---------- Панель ---------- */

.panel {
  width: 95.8rem;
  display: flex;
  flex-direction: column;
  border: 0.2rem solid var(--panel-line);
  border-radius: 1.8rem;
  background: var(--panel);
  -webkit-backdrop-filter: blur(1.4rem);
  backdrop-filter: blur(1.4rem);
  box-shadow: 0 2rem 6rem rgba(20, 0, 60, 0.35);
}

.panel--form { padding: 5.8rem 6.6rem 4.4rem; }
.panel--welcome { padding: 5.7rem 6.6rem 5.4rem; }
.panel--draw { padding: 4.2rem 6.6rem 3.6rem; }

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 5.6rem;
}

.brand__antifake {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.1rem; /* у Onder заглавные в 1,2 раза выше кегля */
  line-height: 1.9rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--pink-logo);
}

.brand__antifake img { width: 6rem; height: auto; }
.brand__cup { width: 17.4rem; height: auto; }

.title {
  margin: 7.4rem 0 0; /* верх заглавных на 194 px от края панели, как в макете */
  font-family: var(--display);
  font-weight: 500;
  font-size: 4.2rem; /* Onder широкий: «РЕГИСТРАЦИЯ» во всю ширину панели, как в макете */
  line-height: 6.4rem;
  text-align: center;
  text-transform: uppercase;
  text-shadow: var(--glow);
  outline: none;
}

.title--small { margin-top: 2.6rem; font-size: 3.1rem; line-height: 5rem; }

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

.form { display: flex; flex-direction: column; margin-top: 4.6rem; }

.form__note {
  margin: 0 0 2rem;
  font-size: 1.8rem;
  line-height: 3rem;
  color: var(--soft);
}

.field {
  height: 5.5rem;
  margin-bottom: 1.2rem;
  padding: 0 2rem;
  border: 0.2rem solid var(--line);
  border-radius: 1.8rem;
  background: var(--field);
  font: inherit;
  font-size: 2.1rem;
  color: var(--white);
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field::placeholder { color: var(--placeholder); opacity: 1; }
.field:focus { border-color: var(--white); box-shadow: 0 0 0 0.3rem rgba(255, 120, 220, 0.35); }
.field[aria-invalid='true'] { border-color: #ff8ab0; box-shadow: 0 0 0 0.3rem rgba(255, 92, 140, 0.35); }

.consent {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  margin: 0.4rem 0 1.4rem;
  font-size: 2rem;
  line-height: 3.2rem;
  color: var(--soft);
}

.consent label { margin-left: 0.2rem; }

.consent__box {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 3.2rem;
  height: 3.2rem;
  margin: 0;
  border: 0.2rem solid #e6c4fa;
  border-radius: 50%;
  background: transparent center / 1.6rem no-repeat;
  cursor: pointer;
}

.consent__box:checked {
  background-color: #e6c4fa;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235a127e' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2 8.5l4 4 8-9'/%3E%3C/svg%3E");
}

.consent__box[aria-invalid='true'] { border-color: #ff8ab0; box-shadow: 0 0 0 0.3rem rgba(255, 92, 140, 0.35); }

.consent__link {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 0.3rem;
  cursor: pointer;
}

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

.button {
  height: 6.3rem;
  padding: 0 3rem;
  border: 0;
  border-radius: 2.2rem;
  background: var(--button-idle);
  font-family: var(--text);
  font-weight: 700;
  font-size: 2.1rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #e6c8fa;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.12s ease;
}

/* Яркая кнопка — когда всё обязательное заполнено (макет «Регистрация заполнена») */
.button.is-ready { background: var(--pink); color: var(--white); }
.button:active { transform: scale(0.98); }
.button:disabled { cursor: wait; opacity: 0.7; }
.button:focus-visible { outline: 0.3rem solid var(--white); outline-offset: 0.4rem; }

.button--ghost {
  border: 0.2rem solid rgba(222, 170, 250, 0.5);
  background: rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(1rem);
  backdrop-filter: blur(1rem);
  color: var(--white);
}

.finish { margin-top: 2.6rem; min-width: 34rem; }
.finish [data-countdown] { margin-left: 0.8rem; font-variant-numeric: tabular-nums; opacity: 0.75; }

/* Ошибка — под панелью, чтобы не сдвигать вёрстку макета */
.notice {
  max-width: 95.8rem;
  margin: 2.2rem 0 0;
  padding: 1.4rem 2.6rem;
  border: 0.2rem solid rgba(255, 138, 176, 0.7);
  border-radius: 1.6rem;
  background: rgba(120, 10, 80, 0.55);
  -webkit-backdrop-filter: blur(1rem);
  backdrop-filter: blur(1rem);
  font-size: 2.1rem;
  line-height: 2.8rem;
  text-align: center;
}

/* ---------- Приветствие ---------- */

.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3.6rem;
  margin-top: 4.6rem;
}

.welcome__check {
  flex: none;
  width: 9.6rem;
  height: 7.6rem;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 96' fill='none' stroke='white' stroke-width='9' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 52l36 36L112 8'/%3E%3C/svg%3E") center / contain no-repeat;
}

.welcome__lead { margin: 0; font-weight: 700; font-size: 4.6rem; line-height: 5.4rem; }
.welcome__note { margin: 0.6rem 0 0; font-size: 2.4rem; line-height: 3rem; color: var(--soft); }

.panel__footer {
  margin: 6.4rem 0 0;
  font-weight: 700;
  font-size: 3.2rem;
  line-height: 4.2rem;
  text-align: center;
  text-wrap: balance;
}

/* ---------- Розыгрыш ---------- */

.draw__role {
  margin: 1.4rem 0 0;
  font-size: 2.2rem;
  line-height: 2.8rem;
  text-align: center;
  color: var(--soft);
}

/* ФИО крупно: по фото экрана сотрудник стойки выдаёт мерч */
.draw__name {
  margin: 0.6rem 0 0;
  font-weight: 700;
  font-size: 4.4rem;
  line-height: 5.2rem;
  text-align: center;
  overflow-wrap: anywhere;
}

.cards {
  display: flex;
  justify-content: center;
  gap: 6rem;
  margin-top: 2.8rem;
}

.card {
  position: relative;
  width: 28rem;
  height: 34rem;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  perspective: 140rem;
  cursor: pointer;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.card:focus-visible { outline: 0.3rem solid var(--white); outline-offset: 0.8rem; border-radius: 2.4rem; }

.card__inner {
  position: absolute;
  inset: 0;
  display: block;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
}

.card__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  border: 0.2rem solid var(--line);
  border-radius: 2.4rem;
  overflow: hidden;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Рубашка: кусочек той же платы и знак вопроса */
.card__face--back {
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120' fill='none' stroke='%23b070ff' stroke-opacity='.38' stroke-width='2'%3E%3Cpath d='M0 20h40l20 20v40l20 20h40M20 0v30l20 20h30M120 60H90L70 40V0M0 90h30l15-15'/%3E%3Ccircle cx='20' cy='30' r='4' fill='%23b070ff' fill-opacity='.4'/%3E%3Ccircle cx='90' cy='60' r='4' fill='%23b070ff' fill-opacity='.4'/%3E%3Ccircle cx='45' cy='75' r='4' fill='%23b070ff' fill-opacity='.4'/%3E%3C/svg%3E") center / 12rem,
    radial-gradient(circle at 50% 42%, rgba(255, 92, 196, 0.45), transparent 62%),
    linear-gradient(160deg, #3d0f8a 0%, #7a148f 100%);
  box-shadow: inset 0 0 3rem rgba(255, 120, 220, 0.25);
}

.card__mark {
  font-family: var(--display);
  font-weight: 500;
  font-size: 15rem;
  line-height: 1;
  text-shadow: 0 0 3rem rgba(255, 110, 215, 0.9), 0 0 1rem rgba(255, 255, 255, 0.6);
}

/*
 * Лицо: вещь целиком на подсвеченном фоне, подпись снизу. Мерч тёмный,
 * поэтому за ним светлое пятно — иначе силуэт теряется на тёмной карточке.
 */
.card__face--front {
  justify-content: flex-end;
  padding-bottom: 2.6rem;
  transform: rotateY(180deg);
  border-color: rgba(255, 150, 225, 0.9);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 178, 236, 0.75) 0%, rgba(190, 120, 255, 0.45) 32%, transparent 68%),
    linear-gradient(160deg, #3d0f8a 0%, #7a148f 100%);
  box-shadow: 0 0 4rem rgba(255, 92, 196, 0.6);
}

.card__photo {
  position: absolute;
  inset: 1.2rem 1.2rem 5.6rem;
  width: calc(100% - 2.4rem);
  height: calc(100% - 6.8rem);
  object-fit: contain;
  filter: drop-shadow(0 1.2rem 1.6rem rgba(10, 0, 40, 0.55));
}

.card__face--front::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 70%, rgba(20, 4, 60, 0.85) 100%);
}

/* Блик пробегает по лицу, когда карточка уже развернулась */
.card__face--front::after {
  content: '';
  position: absolute;
  inset: -10% -60%;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.45) 50%, transparent 60%);
  transform: translateX(-100%);
}

.card.is-open .card__face--front::after { animation: card-shine 0.9s ease-out 1s both; }

.card__label {
  position: relative;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.6rem; /* «ФУТБОЛКА» в Onder — почти во всю ширину карточки */
  line-height: 2.4rem;
  text-transform: uppercase;
  text-shadow: 0 0 1.6rem rgba(255, 92, 196, 0.9);
}

/*
 * Пока ждёт ответ сервера, карточка приподнимается и мерцает. Потом разворачивается
 * на 180° отдельной анимацией: переход transform здесь не годится — он не стартует,
 * если в том же кадре снимается анимация ожидания, и карточка просто подменялась.
 * В середине разворота карточка чуть увеличивается — как будто её подняли к глазам.
 */
.card.is-picking { transform: translateY(-1.4rem) scale(1.04); cursor: wait; }
.card.is-picking .card__face--back { animation: card-charge 0.7s ease-in-out infinite alternate; }
.card.is-picking .card__mark { animation: card-charge-mark 0.7s ease-in-out infinite alternate; }
.card.is-open .card__inner { animation: card-flip 1.1s both; }
.card.is-open { cursor: default; }
/* Вторая карточка гаснет, когда первая уже почти развернулась */
.card.is-dimmed { opacity: 0.3; transform: scale(0.92); cursor: default; transition-delay: 0.6s; }

/* Закрытые карточки слегка «дышат», чтобы их хотелось нажать */
.cards.is-waiting .card { animation: card-bob 2.6s ease-in-out infinite; }
.cards.is-waiting .card + .card { animation-delay: -1.3s; }

.draw__hint {
  min-height: 7.6rem; /* две строки: подсказка и «сфотографируй» одинаковой высоты */
  margin: 2.6rem auto 0;
  max-width: 82rem;
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 3.8rem;
  text-align: center;
  text-wrap: balance;
}

.draw__hint strong { color: #ffc2ee; }

/* ---------- Согласие ---------- */

.dialog {
  width: 96rem;
  max-height: 88rem;
  padding: 4.4rem 5rem 3.6rem;
  border: 0.2rem solid var(--panel-line);
  border-radius: 1.8rem;
  background: #3b0d7c;
  color: var(--white);
  font-size: 1.9rem;
  line-height: 2.8rem;
}

.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: rgba(10, 0, 30, 0.7); }
.dialog h2 { margin: 0 0 2rem; font-size: 3rem; line-height: 3.6rem; }
.dialog__text { overflow-y: auto; padding-right: 1.6rem; color: var(--soft); -webkit-user-select: text; user-select: text; }
.dialog__text p { margin: 0; }
.dialog__text p:empty { height: 1.4rem; }
.dialog form { margin-top: 2.4rem; text-align: center; }
.dialog .button { min-width: 30rem; background: var(--pink); color: var(--white); }

/* ---------- Отладка QR (?debug-qr=1) ---------- */

.debug {
  position: fixed;
  left: 2rem;
  bottom: 2rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.4rem;
  border-radius: 1rem;
  background: rgba(0, 0, 0, 0.55);
  font-size: 1.6rem;
}

.debug input { width: 28rem; font: inherit; }

.fallback { margin: 4rem; font-size: 2.4rem; }

@media (prefers-reduced-motion: reduce) {
  .screen, .cards.is-waiting .card, .card.is-picking .card__face--back, .card.is-picking .card__mark,
  .card.is-open .card__face--front::after { animation: none; }
  /* Без движения карточка не крутится, а сразу открыта */
  .card.is-open .card__inner { animation: none; transform: rotateY(180deg); }
  .frame, .keyboard, .keyboard.is-open { transition: none; }
}
