/* ============================================================
   ENCUESTA ELECTORAL 2026 — Estilos
   Paleta: Azul institucional / Rojo / Blanco
   Tipografía: Sora (display) + Inter (texto) + JetBrains Mono (datos)
   ============================================================ */

:root {
  /* Paleta */
  --azul-950: #071A33;
  --azul-900: #0B2E5C;
  --azul-700: #173F7A;
  --azul-500: #2C5FA8;
  --azul-200: #C9DAF2;
  --rojo-700: #8F1420;
  --rojo-600: #C81E2C;
  --rojo-500: #E23A44;
  --blanco: #FFFFFF;
  --hueso: #F6F8FB;
  --gris-600: #5B6472;
  --gris-800: #232A35;

  /* Superficies */
  --bg: var(--hueso);
  --card-bg: rgba(255, 255, 255, 0.72);
  --card-border: rgba(11, 46, 92, 0.10);

  /* Tipografía */
  --f-display: 'Sora', 'Segoe UI', sans-serif;
  --f-body: 'Inter', 'Segoe UI', sans-serif;
  --f-mono: 'JetBrains Mono', monospace;

  /* Ritmo */
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --shadow-soft: 0 10px 40px -12px rgba(11, 46, 92, 0.25);
  --shadow-strong: 0 20px 60px -15px rgba(11, 46, 92, 0.35);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  margin: 0;
  font-family: var(--f-body);
  color: var(--gris-800);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { max-width: 100%; display: block; }

.container {
  width: min(1140px, 92%);
  margin-inline: auto;
}

/* ---------- Fondo animado del hero ---------- */
.hero {
  position: relative;
  min-height: 92vh;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: linear-gradient(160deg, var(--azul-950) 0%, var(--azul-900) 45%, var(--azul-700) 100%);
  isolation: isolate;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  z-index: -1;
  animation: drift 22s ease-in-out infinite alternate;
}
.hero::before {
  width: 620px; height: 620px;
  background: radial-gradient(circle at 30% 30%, rgba(200, 30, 44, 0.45), transparent 70%);
  top: -220px; right: -160px;
}
.hero::after {
  width: 520px; height: 520px;
  background: radial-gradient(circle at 60% 60%, rgba(44, 95, 168, 0.55), transparent 70%);
  bottom: -220px; left: -160px;
  animation-delay: -8s;
}

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, -30px) scale(1.12); }
}

.hero-grain {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.5;
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 120px 0 90px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-mono);
  font-size: 12.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--azul-200);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  padding: 8px 18px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  opacity: 0;
  animation: fadeUp 0.8s var(--ease) 0.1s forwards;
}
.eyebrow .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rojo-500);
  box-shadow: 0 0 0 0 rgba(226,58,68,0.7);
  animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
  0%   { box-shadow: 0 0 0 0 rgba(226,58,68,0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(226,58,68,0); }
  100% { box-shadow: 0 0 0 0 rgba(226,58,68,0); }
}

.hero h1 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(2.6rem, 6vw, 4.6rem);
  line-height: 1.04;
  color: var(--blanco);
  margin: 26px 0 18px;
  letter-spacing: -0.02em;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease) 0.25s forwards;
}
.hero h1 span {
  background: linear-gradient(100deg, var(--blanco) 30%, var(--azul-200) 55%, var(--rojo-500) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero .subtitle {
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  color: rgba(255,255,255,0.82);
  font-weight: 400;
  max-width: 640px;
  margin: 0 auto 40px;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease) 0.4s forwards;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: clamp(24px, 5vw, 64px);
  flex-wrap: wrap;
  opacity: 0;
  animation: fadeUp 0.8s var(--ease) 0.55s forwards;
}
.hero-stat { text-align: center; }
.hero-stat .num {
  font-family: var(--f-mono);
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--blanco);
}
.hero-stat .label {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.scroll-cue {
  position: absolute;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: rgba(255,255,255,0.55);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  animation: fadeUp 0.8s var(--ease) 0.8s forwards;
  opacity: 0;
}
.scroll-cue svg { animation: bob 1.8s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

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

/* ---------- Cinta institucional (motivo "boleta") ---------- */
.ribbon {
  height: 10px;
  background: linear-gradient(90deg, var(--azul-900) 0%, var(--azul-500) 35%, var(--blanco) 50%, var(--rojo-600) 65%, var(--rojo-700) 100%);
}

/* ---------- Secciones ---------- */
section { padding: 96px 0; }
.section-head {
  text-align: center;
  max-width: 640px;
  margin: 0 auto 56px;
}
.section-head .kicker {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--rojo-600);
  font-weight: 600;
}
.section-head h2 {
  font-family: var(--f-display);
  font-size: clamp(1.8rem, 3.4vw, 2.5rem);
  color: var(--azul-950);
  margin: 10px 0 12px;
  letter-spacing: -0.01em;
}
.section-head p {
  color: var(--gris-600);
  font-size: 1.02rem;
  line-height: 1.6;
}

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
.reveal.is-visible { opacity: 1; transform: translateY(0); }

/* ---------- Grid de candidatos ---------- */
.candidates {
  background: var(--bg);
}
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 26px;
}

.candidate-card {
  position: relative;
  background: var(--blanco);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--card-border);
  transition: transform 0.45s var(--ease), box-shadow 0.45s var(--ease);
}
.candidate-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-strong);
}

.candidate-photo-wrap {
  position: relative;
  aspect-ratio: 4 / 4.7;
  overflow: hidden;
  background: var(--azul-900);
}
.candidate-photo-wrap img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease);
}
.candidate-card:hover .candidate-photo-wrap img { transform: scale(1.05); }

.candidate-photo-wrap::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(7,26,51,0.85) 0%, rgba(7,26,51,0.05) 45%, transparent 70%);
}

.candidate-badge {
  position: absolute;
  top: 14px; left: 14px;
  z-index: 2;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--blanco);
  background: rgba(11,46,92,0.55);
  border: 1px solid rgba(255,255,255,0.25);
  backdrop-filter: blur(6px);
  padding: 5px 10px;
  border-radius: 999px;
}

.candidate-info {
  position: absolute;
  left: 18px; right: 18px; bottom: 16px;
  z-index: 2;
  color: var(--blanco);
}
.candidate-info h3 {
  font-family: var(--f-display);
  font-size: 1.18rem;
  margin: 0 0 3px;
  letter-spacing: -0.01em;
}
.candidate-info p {
  margin: 0;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.75);
}

.vote-panel { padding: 18px 20px 22px; }

.btn-vote {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--f-body);
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--blanco);
  background: linear-gradient(120deg, var(--azul-900), var(--azul-500));
  cursor: pointer;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), filter 0.25s var(--ease);
  box-shadow: 0 8px 20px -8px rgba(11,46,92,0.55);
}
.btn-vote:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.08); }
.btn-vote:active:not(:disabled) { transform: translateY(0); }
.btn-vote:focus-visible { outline: 3px solid var(--rojo-500); outline-offset: 2px; }
.btn-vote svg { width: 17px; height: 17px; }

.btn-vote:disabled {
  background: #E3E7EE;
  color: var(--gris-600);
  cursor: not-allowed;
  box-shadow: none;
}

.btn-vote.is-loading .btn-label { visibility: hidden; }
.btn-vote.is-loading::after {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: var(--blanco);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn-vote { position: relative; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Aviso de estado de voto ---------- */
.status-banner {
  display: none;
  align-items: center;
  gap: 12px;
  max-width: 640px;
  margin: -24px auto 56px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 500;
}
.status-banner.show { display: flex; animation: fadeUp 0.5s var(--ease); }
.status-banner.ok {
  background: rgba(44, 95, 168, 0.08);
  border: 1px solid rgba(44, 95, 168, 0.25);
  color: var(--azul-900);
}
.status-banner.warn {
  background: rgba(200, 30, 44, 0.08);
  border: 1px solid rgba(200, 30, 44, 0.25);
  color: var(--rojo-700);
}
.status-banner svg { flex-shrink: 0; width: 20px; height: 20px; }

/* ---------- Resultados / gráfico ---------- */
.results {
  background: linear-gradient(180deg, var(--azul-950) 0%, #0D2444 100%);
  color: var(--blanco);
  position: relative;
  overflow: hidden;
}
.results::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(600px circle at 15% 20%, rgba(200,30,44,0.12), transparent 60%),
    radial-gradient(600px circle at 85% 80%, rgba(44,95,168,0.25), transparent 60%);
  pointer-events: none;
}
.results .section-head p { color: rgba(255,255,255,0.65); }
.results .section-head .kicker { color: var(--rojo-500); }
.results .section-head h2 { color: var(--blanco); }

.results-panel {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 48px);
  backdrop-filter: blur(10px);
}

.results-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 34px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.results-total .n {
  font-family: var(--f-mono);
  font-size: 2.1rem;
  font-weight: 700;
}
.results-total .l {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--f-mono);
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(200,30,44,0.14);
  border: 1px solid rgba(200,30,44,0.35);
  color: #FF8A93;
}
.live-pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--rojo-500);
  animation: pulseDot 2s infinite;
}

.bars { display: flex; flex-direction: column; gap: 26px; }

.bar-row {
  display: grid;
  grid-template-columns: 190px 1fr 78px;
  align-items: center;
  gap: 18px;
}
@media (max-width: 640px) {
  .bar-row { grid-template-columns: 1fr; gap: 8px; }
  .bar-row .bar-pct { justify-self: end; }
}

.bar-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.25);
}
.bar-name {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-rank {
  font-family: var(--f-mono);
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
}

.bar-track {
  position: relative;
  height: 16px;
  background: rgba(255,255,255,0.08);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--azul-500), var(--azul-200));
  transition: width 1.1s var(--ease);
}
.bar-row.is-leader .bar-fill {
  background: linear-gradient(90deg, var(--rojo-700), var(--rojo-500) 60%, #FF8A93);
  box-shadow: 0 0 18px rgba(226,58,68,0.55);
}
.bar-fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255,255,255,0.35) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 2.4s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.bar-pct {
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 1rem;
  text-align: right;
}
.bar-votes {
  font-family: var(--f-mono);
  font-size: 0.68rem;
  color: rgba(255,255,255,0.45);
  text-align: right;
  display: block;
}

/* ---------- Franja de garantías / transparencia ---------- */
.trust {
  background: var(--hueso);
}
.trust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 22px;
}
.trust-card {
  background: var(--blanco);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 26px 22px;
  transition: transform 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.trust-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-soft); }
.trust-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--azul-900), var(--azul-500));
  color: var(--blanco);
  margin-bottom: 16px;
}
.trust-icon svg { width: 22px; height: 22px; }
.trust-card h3 {
  font-family: var(--f-display);
  font-size: 1.02rem;
  margin: 0 0 8px;
  color: var(--azul-950);
}
.trust-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--gris-600);
  line-height: 1.55;
}

/* ---------- Footer ---------- */
footer {
  background: var(--azul-950);
  color: rgba(255,255,255,0.55);
  padding: 40px 0;
  text-align: center;
  font-size: 0.82rem;
}
footer strong { color: rgba(255,255,255,0.85); }
.footer-ribbon-mini {
  width: 46px; height: 4px; margin: 0 auto 16px;
  background: linear-gradient(90deg, var(--azul-500), var(--blanco), var(--rojo-500));
  border-radius: 4px;
}

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translate(-50%, 20px);
  background: var(--azul-950);
  color: var(--blanco);
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-strong);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
  z-index: 100;
  border: 1px solid rgba(255,255,255,0.12);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast.warn { background: var(--rojo-700); }
#toast svg { width: 18px; height: 18px; flex-shrink: 0; }
