:root {
  --paper: #fbf8ef;
  --paper-tint: #eef2f8;
  --ink: #1b1d22;
  --ink-soft: #4a4f5a;
  --line: #2b2f38;
  --rule: #c9c3b2;
  --pen: #1f3fbf;
  --ru-blue: #0039a6;
  --ru-red: #d52b1e;
  --stamp: #b3261e;
  --shadow: 0 20px 60px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: #20283a;
  color: var(--ink);
  font-family: "PT Sans", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

/* Фон: американский флаг в цветах российского триколора */
.flag-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-size: cover;
  background-position: center;
}
.flag-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(15, 20, 35, .35);
}

.joke-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 16px;
  background: #fff3c4;
  border-bottom: 2px solid #e2b800;
  text-align: center;
  font-size: 15px;
}
.joke-banner a { color: inherit; margin-left: 6px; }

.ballot {
  position: relative;
  max-width: 860px;
  margin: 32px auto 48px;
  padding: 32px 40px 40px;
  /* Тангирная сетка, как на защищённых бланках */
  background: url("assets/guilloche.svg") repeat center top / 120px 60px, var(--paper);
  border: 1px solid #000;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.ballot-stamp {
  position: absolute;
  top: 210px;
  right: -40px;
  transform: rotate(-18deg);
  padding: 6px 28px;
  border: 5px double var(--stamp);
  border-radius: 8px;
  color: var(--stamp);
  font: 700 46px/1 "PT Serif", serif;
  letter-spacing: .12em;
  opacity: .22;
  pointer-events: none;
}

/* Шапка бюллетеня */
.ballot-head {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
  padding-bottom: 18px;
  border-bottom: 3px double var(--line);
}
.sign-box {
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.3;
  color: var(--ink-soft);
}
.sign-box { position: relative; }
.sign-lines span {
  display: block;
  height: 34px;
  border-bottom: 1px solid var(--ink-soft);
}
.sign-art {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}
.sign-art .ink { fill: none; stroke: var(--pen); stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.sign-art .stamp { fill: none; stroke: #4b3fc4; opacity: .62; }
.sign-art .stamp text { fill: #4b3fc4; stroke: none; font: 700 6.2px "PT Sans", sans-serif; letter-spacing: .4px; }
h1 {
  margin: 0;
  text-align: center;
  font-family: "PT Serif", serif;
  font-weight: 400;
}
h1 span { display: block; }
.h-main {
  font-weight: 700;
  font-size: 30px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.h-sub { font-size: 16px; margin-top: 4px; }
.h-date { margin-top: 10px; font-weight: 700; font-size: 17px; }


/* Ряды партий */
.parties { border-top: 2px solid var(--line); }

.party {
  display: grid;
  grid-template-columns: 44px 1fr 84px;
  border-bottom: 2px solid var(--line);
  cursor: pointer;
  transition: background .15s;
}
.party:hover { background: rgba(0, 57, 166, .04); }
.party.is-locked { cursor: default; }
.party.is-locked:hover { background: none; }

.party-num {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 14px;
  border-right: 1px solid var(--line);
  font: 700 22px/1 "PT Serif", serif;
}
.party-main { padding: 12px 16px 14px; }
.party-name {
  margin: 0;
  font: 700 21px/1.2 "PT Serif", serif;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.party-note { margin: 2px 0 10px; font-size: 13px; color: var(--ink-soft); }

.people {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.person {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  margin: 0;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: zoom-in;
}
.person:hover { border-color: var(--rule); background: rgba(255, 255, 255, .7); }
.person:focus-visible { outline: 3px solid var(--ru-blue); outline-offset: 1px; }
.person-more { display: inline-block; margin-top: 3px; font-size: 12px; color: var(--ru-blue); text-decoration: underline; }
.person img, .person .no-photo {
  width: 64px;
  height: 80px;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--line);
  background: #ddd;
  filter: grayscale(.25);
}
.person .no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 20px "PT Serif", serif;
  color: var(--ink-soft);
  background: #e6e2d6;
}
.person-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.person-bio { font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; margin-top: 2px; }

.party-check {
  display: flex;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--line);
}
.party-check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.box {
  position: relative;
  width: 52px;
  height: 52px;
  border: 2px solid var(--line);
  background: #fff;
}
.box svg {
  position: absolute;
  inset: -6px;
  width: calc(100% + 12px);
  height: calc(100% + 12px);
  stroke: var(--pen);
  stroke-width: 5;
  stroke-linecap: round;
  fill: none;
  opacity: 0;
}
.box svg path { stroke-dasharray: 70; stroke-dashoffset: 70; }
.party-check input:checked + .box svg { opacity: 1; }
.party-check input:checked + .box svg path { animation: draw .25s ease-out forwards; }
.party-check input:checked + .box svg path + path { animation-delay: .18s; }
.party-check input:focus-visible + .box { outline: 3px solid var(--ru-blue); outline-offset: 3px; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Кнопки и статусы */
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-top: 22px;
}
.status { margin: 0; font-size: 15px; }
.status.ok { color: #186a2e; font-weight: 700; }
.status.err { color: var(--stamp); }

.btn {
  font: 700 16px "PT Sans", sans-serif;
  padding: 12px 22px;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid var(--ru-blue);
}
.btn-primary { background: var(--ru-blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #002d85; }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--ru-blue); }
.btn-ghost:hover { background: #eef2fb; }

/* Отсчёт */
.countdown-box {
  margin-top: 28px;
  padding: 20px;
  text-align: center;
  border: 2px dashed var(--line);
  background: #fff;
}
.countdown-box h2 { margin: 0 0 12px; font: 700 18px "PT Serif", serif; text-transform: uppercase; letter-spacing: .05em; }
.countdown {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.countdown div {
  min-width: 72px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  background: var(--paper);
}
.countdown span { display: block; font: 700 32px/1.1 "PT Serif", serif; font-variant-numeric: tabular-nums; }
.countdown small { font-size: 12px; color: var(--ink-soft); }
.reveal-note { max-width: 600px; margin: 14px auto 16px; font-size: 14px; }
.reveal-note p { margin: 6px 0; }
.return-at { font-size: 17px; line-height: 1.35; }
.return-at strong { font: 700 20px "PT Serif", serif; }

.subscribe {
  margin-top: 20px;
  padding: 16px 20px;
  border: 2px dashed var(--line);
  background: #fff;
}
.share-row { margin-top: 20px; text-align: center; }

/* Подсветка формы подписки после голосования */
.subscribe.attention { animation: attention .8s ease-in-out 3; }
@keyframes attention {
  0%, 100% { border-color: var(--line); background: #fff; box-shadow: 0 0 0 0 rgba(0, 57, 166, 0); }
  50% { border-color: var(--ru-blue); background: #eef2fb; box-shadow: 0 0 0 6px rgba(0, 57, 166, .22); }
}

/* Якоря не прячутся под закреплённой плашкой-дисклеймером (её высоту пишет app.js) */
#status, #disclaimer, #results { scroll-margin-top: calc(var(--banner-h, 44px) + 16px); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .subscribe.attention { animation: none; border-color: var(--ru-blue); background: #eef2fb; }
}
.subscribe label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 700; }
.subscribe-row { display: flex; gap: 8px; flex-wrap: wrap; }
.subscribe-row input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: 16px "PT Sans", sans-serif;
  background: #fff;
  color: var(--ink);
}
.subscribe-row input:focus-visible { outline: 3px solid var(--ru-blue); outline-offset: 1px; }
.subscribe-note { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-soft); }
.subscribe .status { margin-top: 6px; }

/* Итоги */
.results {
  margin-top: 28px;
  padding: 20px;
  border: 2px solid var(--line);
  background: #fff;
}
.results h2 { margin: 0 0 14px; font: 700 20px "PT Serif", serif; text-align: center; text-transform: uppercase; }
.result-row { margin: 10px 0; }
.result-label { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; font-size: 15px; }
.result-bar { height: 14px; margin-top: 4px; background: #eceae3; border: 1px solid var(--rule); }
.result-bar span { display: block; height: 100%; background: var(--ru-blue); }
.result-row.leader .result-bar span { background: var(--ru-red); }
.result-total { margin-top: 14px; text-align: center; color: var(--ink-soft); font-size: 14px; }

/* Дисклеймер */
.disclaimer {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 3px double var(--line);
  font-size: 13.5px;
  color: var(--ink-soft);
}
.disclaimer h2 { margin: 0 0 6px; font: 700 15px "PT Sans", sans-serif; color: var(--ink); text-transform: uppercase; }
.disclaimer p { margin: 6px 0; }
.credits { margin-top: 10px; }
.credits summary { cursor: pointer; }
.credits ul { padding-left: 18px; }
.credits a { color: var(--ru-blue); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 10px 18px;
  background: #1b1d22;
  color: #fff;
  border-radius: 6px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .ballot { margin: 16px; padding: 20px 16px 28px; }
  .ballot-head { grid-template-columns: 1fr; gap: 12px; }
  .sign-box { order: 2; justify-self: center; width: 100%; max-width: 240px; }
  .h-main { font-size: 22px; }
  .party { grid-template-columns: 32px 1fr 64px; }
  .party-main { padding: 10px; }
  .party-name { font-size: 17px; }
  .box { width: 42px; height: 42px; }
  .people { grid-template-columns: 1fr; }
  .countdown div { min-width: 60px; }
  .countdown span { font-size: 26px; }
  .ballot-stamp { font-size: 32px; top: 300px; }
}

/* Попап с кандидатом */
.person-dialog {
  width: min(640px, calc(100% - 32px));
  max-height: calc(100vh - 48px);
  padding: 28px 28px 20px;
  border: 1px solid #000;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.person-dialog::backdrop { background: rgba(10, 14, 25, .6); }
.pd-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
}
.pd-close:hover { color: var(--ink); }
.pd-head {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 18px;
  align-items: start;
  padding-bottom: 14px;
  border-bottom: 3px double var(--line);
}
.pd-head img, .pd-head .no-photo {
  width: 120px;
  height: 150px;
  object-fit: cover;
  object-position: top;
  border: 1px solid var(--line);
}
.pd-head .no-photo {
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 34px "PT Serif", serif;
  color: var(--ink-soft);
  background: #e6e2d6;
}
.pd-party { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.person-dialog h2 { margin: 4px 0 6px; font: 700 26px/1.15 "PT Serif", serif; }
.pd-role { margin: 0; font-size: 15px; }
.person-dialog h3 { margin: 16px 0 6px; font: 700 15px "PT Sans", sans-serif; text-transform: uppercase; letter-spacing: .04em; }
.person-dialog ul { margin: 0; padding-left: 20px; font-size: 15px; }
.person-dialog li { margin: 4px 0; }
.pd-source { margin: 18px 0 0; font-size: 13px; color: var(--ink-soft); }
.pd-source a { color: var(--ru-blue); }

/* Рекламный баннер */
.promo-wrap {
  max-width: 860px;
  margin: -16px auto 48px;
}
.promo {
  display: grid;
  grid-template-columns: 1fr 300px;
  overflow: hidden;
  border-radius: 20px;
  background: #0e1120;
  color: rgba(255, 255, 255, .72);
  text-decoration: none;
  box-shadow: var(--shadow);
  font-family: "PT Sans", system-ui, sans-serif;
}
.promo-text { padding: 26px 28px; }
.promo-label { display: block; margin-bottom: 12px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255, 255, 255, .45); }
.promo-logo { display: block; width: 180px; height: auto; }
.promo-title { margin: 16px 0 6px; font: 700 28px/1.15 "PT Sans", sans-serif; color: #fff; }
.promo-sub { margin: 0 0 18px; font-size: 15px; }
.promo-cta {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, #5b4cf5, #8e4ff0);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(110, 80, 245, .45);
  transition: transform .15s;
}
.promo:hover .promo-cta { transform: translateY(-1px); }
.promo:focus-visible { outline: 3px solid #8e4ff0; outline-offset: 3px; }
.promo-img { width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 640px) {
  .person-dialog { padding: 22px 16px 16px; }
  .pd-head { grid-template-columns: 84px 1fr; gap: 12px; }
  .pd-head img, .pd-head .no-photo { width: 84px; height: 105px; }
  .person-dialog h2 { font-size: 21px; }
  .promo-wrap { margin: -8px 16px 32px; }
  .promo { grid-template-columns: 1fr; }
  .promo-img { order: -1; height: 180px; }
  .promo-text { padding: 20px; }
  .promo-title { font-size: 24px; }
}

/* Шапка «РоссияГолосует» */
.masthead {
  max-width: 860px;
  margin: 28px auto 0;
  padding: 22px 20px 18px;
  text-align: center;
  background: var(--paper);
  border: 1px solid #000;
  box-shadow: var(--shadow);
}
.masthead + .ballot { margin-top: 16px; }
.wordmark {
  margin: 0;
  font: 400 clamp(26px, 8.6vw, 72px)/1 "Russo One", "PT Sans", sans-serif;
  text-transform: uppercase;
  letter-spacing: .02em;
  white-space: nowrap;
}
.wm-red { color: var(--ru-red); }
.wm-blue { color: var(--ru-blue); }
.masthead-sub {
  margin: 10px 0 0;
  font: 700 clamp(15px, 3.4vw, 22px)/1.2 "PT Serif", serif;
  letter-spacing: .04em;
  color: var(--ink);
}

@media (max-width: 640px) {
  .masthead { margin: 16px 16px 0; padding: 16px 10px 14px; }
  .masthead + .ballot { margin-top: 12px; }
}
