/* ========================================================================
   Генератор бейджа участника (/badge) — нейтральная, не завязанная на
   конкретный конкурс страница. Слева форма, справа настоящий предпросмотр:
   POST /badge/preview рендерит тот же PNG (site/src/badge/render.rs), что
   уйдёт в файл — никакой отдельной CSS-имитации, которая могла бы
   разойтись с реальным результатом.
   ======================================================================== */

:root {
  --bg-page: #07060d;
  --bg-soft: #0d0c18;
  --fg: #f4f2fb;
  --fg-dim: #a6a2bd;
  --line: rgba(255, 255, 255, .1);
  --accent: #22e3ff;
}

body {
  background: var(--bg-page);
  color: var(--fg);
  font-family: 'Inter', system-ui, sans-serif;
}

#pageContent {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.bgen-back {
  display: inline-block;
  color: var(--fg-dim);
  text-decoration: none;
  font-size: .9rem;
  margin-bottom: 24px;
}

.bgen-back:hover {
  color: var(--fg);
}

.bgen-page__title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.bgen-page__lead {
  color: var(--fg-dim);
  line-height: 1.6;
  margin-bottom: 28px;
  max-width: 60ch;
}

.bgen-page__lead strong {
  color: var(--fg);
}

/* ---------------------------------- LAYOUT: форма слева, превью справа ---------------------------------- */

.bgen-layout {
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
  gap: 40px;
  align-items: start;
}

@media (max-width: 860px) {
  .bgen-layout {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------- FORM ---------------------------------- */

.bgen-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
}

.bgen-banner {
  margin: 0 0 4px;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: .88rem;
  line-height: 1.5;
}

.bgen-banner--error {
  background: rgba(239, 68, 68, .12);
  border: 1px solid rgba(239, 68, 68, .35);
  color: #fca5a5;
}

.bgen-banner--success {
  background: rgba(34, 227, 255, .1);
  border: 1px solid rgba(34, 227, 255, .3);
  color: var(--fg);
}

.bgen-form__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: .9rem;
}

.bgen-form__field span {
  color: var(--fg-dim);
}

.bgen-form__field input[type="text"],
.bgen-form__field select {
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  color: var(--fg);
  font: inherit;
}

.bgen-form__field input[type="text"]:focus,
.bgen-form__field select:focus {
  outline: none;
  border-color: var(--accent);
}

.bgen-form__captcha-img {
  border-radius: 10px;
  width: 130px;
  height: 60px;
  align-self: flex-start;
}

.bgen-form__captcha-row {
  display: flex;
  gap: 10px;
}

.bgen-form__captcha-row input {
  flex: 1 1 auto;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  color: var(--fg);
  font: inherit;
}

.bgen-form__captcha-refresh {
  flex: 0 0 auto;
  width: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 1.1rem;
  cursor: pointer;
}

.bgen-form__captcha-refresh.is-spinning {
  animation: bgenSpin .6s linear;
}

@keyframes bgenSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.bgen-form__submit {
  margin-top: 6px;
  padding: 14px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(100deg, #22e3ff, #8b5cf6 55%, #f472d0);
  color: #07060d;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
}

.bgen-form__submit:hover {
  filter: brightness(1.08);
}

.bgen-form__submit:disabled {
  opacity: .6;
  cursor: wait;
}

/* ---------------------------------- PREVIEW (настоящий рендер с сервера) ---------------------------------- */
/* Раньше здесь была CSS-имитация бейджа — отличалась от настоящего PNG
   (разные мотивы, другая разметка), участник мог увидеть один дизайн, а
   скачать другой. Теперь тут просто <img>, которую подсовывает
   POST /badge/preview — ровно тот же render_png, что и настоящая
   генерация, так что превью физически не может разойтись с файлом. */

.bgen-preview-col {
  position: sticky;
  top: 32px;
  display: flex;
  justify-content: center;
}

.bgen-preview {
  width: 100%;
  max-width: 397px;
}

.bgen-preview__frame {
  position: relative;
  width: 100%;
  aspect-ratio: 105 / 148;
  border-radius: 22px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bgen-preview__frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bgen-preview__placeholder {
  max-width: 70%;
  text-align: center;
  font-size: .88rem;
  color: var(--fg-dim);
  line-height: 1.5;
}

.bgen-preview__spinner {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .15);
  border-top-color: var(--accent);
  animation: bgenPreviewSpin .7s linear infinite;
}

@keyframes bgenPreviewSpin {
  to { transform: rotate(360deg); }
}

.bgen-preview__hint {
  margin-top: 14px;
  font-size: .78rem;
  color: var(--fg-dim);
  text-align: center;
  line-height: 1.5;
}

/* ---------------------------------- ICON PICKER ---------------------------------- */

.bgen-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bgen-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 6px;
}

.bgen-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.bgen-icon--none {
  font-size: .78rem;
  font-weight: 700;
  color: var(--fg-dim);
}

.bgen-icon:hover {
  border-color: rgba(255, 255, 255, .3);
}

.bgen-icon.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(34, 227, 255, .3);
}

