/* ─────────────────────────────────────────────────────────────────────────────
   Акселератор такси 2026 — Будем внедрять!
   Общие стили для vote.html и results.html
───────────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Roboto+Condensed:wght@700&display=swap');

/* ── Переменные ────────────────────────────────────────────────────────────── */

:root {
  --red:          #EE4740;
  --red-dark:     #d63b34;
  --red-deeper:   #b52e28;
  --pink-light:   #FFE4E4;
  --pink-mid:     #fac8c8;
  --white:        #ffffff;
  --black:        #111111;

  --text-on-red:  rgba(255,255,255,0.92);
  --text-muted:   rgba(255,255,255,0.55);
  --surface:      rgba(255,255,255,0.10);
  --surface-hover:rgba(255,255,255,0.16);
  --border:       rgba(255,255,255,0.18);
  --border-hover: rgba(255,255,255,0.40);

  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  20px;
  --radius-xl:  32px;

  --font:       'Roboto', sans-serif;
  --font-cond:  'Roboto Condensed', sans-serif;

  --shadow:     0 4px 24px rgba(0,0,0,0.18);
  --shadow-sm:  0 2px 8px  rgba(0,0,0,0.12);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Body & layout ─────────────────────────────────────────────────────────── */

body {
  font-family: var(--font);
  background: var(--red);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 80px;
  color: var(--white);
  position: relative;
  overflow-x: hidden;
}

/* ── Brand corner decoration (bottom-right) ────────────────────────────────── */

body::after {
  content: '';
  position: fixed;
  bottom: 0;
  right: 0;
  width: clamp(200px, 35vw, 420px);
  aspect-ratio: 1;
  background: url('/static/brand.png') no-repeat bottom right / contain;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

/* ── Page wrapper ──────────────────────────────────────────────────────────── */

.page {
  width: 100%;
  max-width: 600px;
  position: relative;
  z-index: 1;
}

/* ── Top bar ───────────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 0 32px;
}

.topbar-logo {
  width: 40px;
  height: 40px;
  border: 2px solid var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-logo svg {
  width: 18px;
  height: 18px;
}

.topbar-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.topbar-title {
  font-family: var(--font-cond);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--white);
}

.topbar-sub {
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ── Page header ───────────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-family: var(--font-cond);
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--white);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.page-header p {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ── Nav link ──────────────────────────────────────────────────────────────── */

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-on-red);
  text-decoration: none;
  margin-bottom: 28px;
  opacity: 0.7;
  transition: opacity 0.2s;
  letter-spacing: 0.02em;
}

.nav-link:hover { opacity: 1; }

/* ── Glass card ────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(4px);
}

/* ── Topics list ───────────────────────────────────────────────────────────── */

.topics-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.topic-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.topic-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.topic-item.checked {
  background: rgba(255,255,255,0.20);
  border-color: rgba(255,255,255,0.60);
}

.topic-item input[type="checkbox"],
.topic-item input[type="radio"] { display: none; }

.custom-check {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.45);
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  background: transparent;
}

.topic-item.checked .custom-check {
  background: var(--white);
  border-color: var(--white);
}

.custom-check svg { display: none; width: 13px; height: 13px; }
.topic-item.checked .custom-check svg { display: block; }

.topic-label {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--white);
  flex: 1;
}

/* ── Selection counter ─────────────────────────────────────────────────────── */

.selection-info {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  height: 18px;
  font-weight: 400;
  transition: color 0.2s;
}

.selection-info.has-selection {
  color: var(--pink-light);
  font-weight: 500;
}

/* ── Primary button ────────────────────────────────────────────────────────── */

.btn-primary {
  width: 100%;
  padding: 16px 24px;
  background: var(--white);
  color: var(--red);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  text-transform: uppercase;
}

.btn-primary:hover {
  background: var(--pink-light);
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.btn-primary:active { transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Ghost button ──────────────────────────────────────────────────────────── */

.btn-ghost {
  padding: 12px 28px;
  background: transparent;
  color: var(--white);
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.03em;
}

.btn-ghost:hover {
  border-color: var(--white);
  background: rgba(255,255,255,0.10);
}

/* ── Success / Already-voted states ────────────────────────────────────────── */

.state-screen {
  display: none;
  text-align: center;
  padding: 20px 20px;
  animation: fadeUp 0.4s ease;
  /* Центрируем по высоте доступного пространства */
  flex: 1;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  min-height: 0;
}

.state-icon {
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 24px;
  border: 2px solid rgba(255,255,255,0.30);
}

.state-icon svg {
  width: 28px;
  height: 28px;
  color: var(--white);
}

.state-screen h2 {
  font-family: var(--font-cond);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.state-screen p {
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ── Error banner ──────────────────────────────────────────────────────────── */

.error-banner {
  background: rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.25);
  color: var(--pink-light);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: none;
}

/* ── Auth gate ─────────────────────────────────────────────────────────────── */

.auth-gate {
  padding: 48px 32px;
  text-align: center;
}

.auth-gate h2 {
  font-family: var(--font-cond);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 8px;
}

.auth-gate p {
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.input-row {
  display: flex;
  gap: 10px;
  max-width: 320px;
  margin: 0 auto;
}

.pass-input {
  flex: 1;
  padding: 13px 18px;
  background: rgba(255,255,255,0.12);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 1rem;
  color: var(--white);
  outline: none;
  text-align: center;
  letter-spacing: 0.15em;
  transition: border-color 0.15s, background 0.15s;
}

.pass-input::placeholder { color: rgba(255,255,255,0.35); letter-spacing: 0.05em; }
.pass-input:focus { border-color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.18); }

.auth-error {
  font-size: 0.83rem;
  color: var(--pink-light);
  margin-top: 14px;
  min-height: 20px;
  font-weight: 500;
}

/* ── Stats row ─────────────────────────────────────────────────────────────── */

.stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.stat-card {
  flex: 1;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

.stat-label {
  font-size: 0.70rem;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-cond);
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1;
}

.stat-value.stat-value--sm {
  font-size: 1rem;
  padding-top: 4px;
  line-height: 1.3;
  font-family: var(--font);
  font-weight: 500;
}

/* ── Results list ──────────────────────────────────────────────────────────── */

.results-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.results-list-header {
  display: flex;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 0.70rem;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.result-row {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  animation: fadeUp 0.3s ease;
}

.result-row:last-child { border-bottom: none; }

.result-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  gap: 12px;
}

.result-topic {
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--white);
  flex: 1;
}

.result-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.result-count {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--white);
  min-width: 20px;
  text-align: right;
  font-family: var(--font-cond);
}

.result-pct {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 36px;
  text-align: right;
}

.bar-track {
  height: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--white);
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Live indicator ────────────────────────────────────────────────────────── */

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 16px;
  font-weight: 400;
}

.live-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--pink-light);
  border-radius: 50%;
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

/* ── Footer ────────────────────────────────────────────────────────────────── */

.footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.footer-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}

.ws-status { font-size: 0.75rem; color: var(--text-muted); }

/* ── Animations ────────────────────────────────────────────────────────────── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  body { padding: 0 12px 80px; }
  .auth-gate { padding: 36px 20px; }
  .input-row { flex-direction: column; }
  .stat-value { font-size: 1.6rem; }
}

/* ── Mobile vote page ──────────────────────────────────────────────────────── */
/* Применяется только на странице голосования (body.vote-page) */

body.vote-page {
  padding-bottom: 0;
}

/* Отступ снизу для экранов без sticky-кнопки */
body.vote-page .state-screen,
body.vote-page .footer {
  margin-bottom: 32px;
}

/* Список тем скроллится, кнопка прибита снизу */
body.vote-page .page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* НЕ ставим overflow:hidden — иначе список тем не скроллится */
}

/* Экраны состояний: фиксируем на весь экран, центрируем, без скролла */
body.vote-page .state-screen {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
  /* Занимаем весь viewport, поверх остального контента */
  position: fixed;
  inset: 0;
  z-index: 5;
  background: var(--red);
  overflow: hidden;
}

body.vote-page #form-state {
  display: flex;
  flex-direction: column;
  flex: 1;
}

body.vote-page .topics-grid {
  flex: 1;
  margin-bottom: 0;
  /* Список скроллится если не влезает */
  overflow-y: auto;
}

/* Отступ под футером */
body.vote-page .footer {
  padding-bottom: 24px;
}

/* Кнопка — sticky внизу экрана */
body.vote-page .btn-primary {
  position: sticky;
  bottom: 0;
  border-radius: var(--radius-md);
  margin: 12px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 10;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

@media (max-width: 600px) {
  body.vote-page .topbar {
    padding: 20px 0 20px;
  }

  body.vote-page .page-header {
    margin-bottom: 20px;
  }

  body.vote-page .page-header h1 {
    font-size: 1.8rem;
  }

  body.vote-page .page-header p {
    font-size: 0.88rem;
  }

  /* Чуть крупнее для касания */
  body.vote-page .topic-item {
    padding: 16px 16px;
    min-height: 52px;
  }

  body.vote-page .topic-label {
    font-size: 0.97rem;
  }

  body.vote-page .custom-check {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
  }

  body.vote-page .topics-grid {
    gap: 6px;
  }

  body.vote-page .selection-info {
    margin-bottom: 12px;
  }

  body.vote-page .footer {
    margin-top: 24px;
  }

  /* Декоративный элемент меньше на мобильном чтоб не перекрывал */
  body.vote-page::after {
    width: 44vw;
    opacity: 0.12;
  }
}

/* ── Timer bar ─────────────────────────────────────────────────────────────── */

#timer-bar {
  margin-bottom: 20px;
}

.timer-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.timer-value {
  font-family: var(--font-cond);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.timer-track {
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 99px;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  background: var(--white);
  border-radius: 99px;
  transition: width 0.5s linear, background 0.3s;
}

.timer-fill--warning {
  background: var(--pink-light);
}
