/* ═══════════════════════════════════════════
   VoteFlow — Styles
   Aesthetic: Dark observatory / neon data
   ═══════════════════════════════════════════ */

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

:root {
  --bg-deep: #06060e;
  --bg-surface: #0b0b1a;
  --bg-card: #10102a;
  --border: rgba(120, 100, 255, 0.1);
  --border-hover: rgba(120, 100, 255, 0.28);
  --text: #e4e4f0;
  --text-muted: #6a6a8c;
  --primary: #7c5cfc;
  --primary-glow: rgba(124, 92, 252, 0.3);
  --radius: 14px;
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

html { height: 100%; }

body {
  min-height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ── Atmospheric background ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 12% 45%, rgba(124,92,252,0.07), transparent),
    radial-gradient(ellipse 50% 40% at 88% 18%, rgba(0,212,170,0.05), transparent),
    radial-gradient(ellipse 55% 45% at 50% 90%, rgba(255,107,107,0.04), transparent);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(120,100,255,0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ── Screen container ── */
.screen {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 24px;
  animation: fadeUp 0.45s var(--ease-out-expo);
}

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

/* ═══ HOME ═══ */
.hero {
  text-align: center;
  padding-top: 72px;
  margin-bottom: 56px;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: rgba(124, 92, 252, 0.08);
  border: 1px solid rgba(124, 92, 252, 0.15);
  margin-bottom: 20px;
}

.hero-title {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(2.6rem, 7vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #7c5cfc 0%, #c084fc 40%, #ff6b6b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 10px;
  line-height: 1.1;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 1.15rem;
  font-weight: 300;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  max-width: 640px;
  margin: 0 auto;
}

.home-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
  transition: all 0.35s var(--ease-out-expo);
}

.card-create {
  cursor: pointer;
}
.card-create:hover {
  border-color: var(--border-hover);
  transform: translateY(-6px);
  box-shadow: 0 16px 48px rgba(124,92,252,0.12);
}

.home-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(124,92,252,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 16px;
}

.home-card h2 {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.home-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.join-form {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.join-form input {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  text-align: center;
  text-transform: uppercase;
}

#btn-join {
  padding: 12px 20px;
  background: var(--primary);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  white-space: nowrap;
}
#btn-join:hover {
  background: #6b4ae8;
  transform: translateY(-1px);
}

/* ═══ FORMS ═══ */
.form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.25s;
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,92,252,0.1);
}
.form-input::placeholder { color: var(--text-muted); }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 28px 0 10px;
}

/* ═══ CREATE ═══ */
.screen-create { max-width: 580px; }

.create-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.option-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  animation: fadeUp 0.3s var(--ease-out-expo);
}

.option-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(124, 92, 252, 0.2);
}

.option-input-row .form-input { flex: 1; }

.btn-remove-option {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-remove-option:hover {
  background: rgba(255,107,107,0.12);
  color: #ff6b6b;
  border-color: rgba(255,107,107,0.3);
}

.btn-add-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: 1px dashed rgba(120,100,255,0.15);
  border-radius: 10px;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: all 0.25s;
  margin-top: 4px;
}
.btn-add-option:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(124,92,252,0.04);
}

.btn-launch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px;
  margin-top: 36px;
  background: linear-gradient(135deg, #7c5cfc, #9b7dfc);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s var(--ease-out-expo);
}
.btn-launch:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 36px rgba(124,92,252,0.35);
}
.btn-launch:active { transform: translateY(0) scale(0.98); }
.btn-launch:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none !important;
  box-shadow: none !important;
}

/* ═══ BACK BUTTON ═══ */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 24px;
  flex-shrink: 0;
}
.back-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

/* ═══ POLL PAGE ═══ */
.poll-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.poll-topbar .back-btn { margin-bottom: 0; }

.poll-badges {
  display: flex;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.badge-code {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.2s;
  user-select: all;
}
.badge-code:hover {
  border-color: var(--primary);
  color: var(--text);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #00d4aa;
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.35; transform: scale(0.8); }
}

.btn-share {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(124,92,252,0.08);
  border: 1px solid rgba(124,92,252,0.18);
  border-radius: 8px;
  color: var(--primary);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: auto;
  white-space: nowrap;
}
.btn-share:hover {
  background: rgba(124,92,252,0.15);
  border-color: rgba(124,92,252,0.3);
}

.poll-question {
  font-family: 'Unbounded', sans-serif;
  font-size: clamp(1.35rem, 3.5vw, 2rem);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 6px;
}

.poll-total {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 36px;
}

.poll-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 36px;
  align-items: start;
}

/* ═══ VOTE OPTIONS (interactive bar chart) ═══ */
.poll-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.vote-option {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  color: var(--text);
  text-align: left;
  font-size: 1rem;
  transition: border-color 0.35s, transform 0.25s var(--ease-out-expo), box-shadow 0.35s;
}

.vote-option:not(.disabled):hover {
  border-color: var(--option-color, var(--primary));
  transform: translateX(6px);
}

.vote-option:not(.disabled):active {
  transform: scale(0.98);
  transition-duration: 0.1s;
}

.vote-option.disabled {
  cursor: default;
}

.vote-option.voted {
  border-color: var(--option-color, var(--primary));
  box-shadow:
    inset 0 0 40px rgba(124,92,252,0.06),
    0 0 24px color-mix(in srgb, var(--option-color, var(--primary)) 20%, transparent);
}

.vote-option.just-voted {
  animation: voteSlam 0.45s var(--ease-out-expo);
}

@keyframes voteSlam {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.025) translateX(4px); }
  100% { transform: scale(1) translateX(0); }
}

/* Fill bar (animated percentage background) */
.vote-option-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0;
  background: var(--option-color, var(--primary));
  opacity: 0.09;
  border-radius: 12px;
  transition: width 0.85s cubic-bezier(0.22, 1, 0.36, 1);
}

.vote-option.voted .vote-option-fill,
.vote-option.disabled .vote-option-fill {
  opacity: 0.13;
}

.vote-option-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  position: relative;
  z-index: 1;
  min-width: 0;
}

.vote-option-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--option-color, var(--primary));
  flex-shrink: 0;
  box-shadow: 0 0 6px color-mix(in srgb, var(--option-color, var(--primary)) 40%, transparent);
}

.vote-option-text {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vote-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--option-color, var(--primary));
  color: #fff;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
  from { transform: scale(0) rotate(-90deg); }
  to   { transform: scale(1) rotate(0); }
}

.vote-option-stats {
  position: relative;
  z-index: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 56px;
  text-align: right;
  flex-shrink: 0;
  transition: color 0.3s;
}

.vote-option.voted .vote-option-stats,
.vote-option.disabled .vote-option-stats {
  color: var(--text);
}

/* ═══ DONUT CHART ═══ */
.poll-chart {
  position: sticky;
  top: 32px;
  display: flex;
  justify-content: center;
}

#donut-canvas {
  width: 100%;
  aspect-ratio: 1;
  max-width: 260px;
}

/* ═══ PARTICLES ═══ */
.particle {
  position: fixed;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  animation: particleFly 0.65s ease-out forwards;
}

@keyframes particleFly {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

/* ═══ TOAST ═══ */
#toast-container {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--text);
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: all 0.3s var(--ease-out-expo);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ═══ LOADING ═══ */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 140px;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(120,100,255,0.12);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* ═══ ERROR SCREEN ═══ */
.screen-error {
  text-align: center;
  padding-top: 140px;
}

.screen-error h2 {
  font-family: 'Unbounded', sans-serif;
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.screen-error p {
  color: var(--text-muted);
  margin-bottom: 28px;
}

.screen-error .btn-launch {
  max-width: 220px;
  margin: 0 auto;
}

/* ═══ LIVE PULSE INDICATOR ═══ */
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(255, 59, 48, 0.1);
  border: 1px solid rgba(255, 59, 48, 0.2);
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #ff3b30;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff3b30;
  animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,59,48,0.4); }
  50%      { opacity: 0.7; box-shadow: 0 0 0 4px rgba(255,59,48,0); }
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 720px) {
  .poll-layout {
    grid-template-columns: 1fr;
  }
  .poll-chart {
    position: static;
    order: -1;
    margin-bottom: 8px;
  }
  #donut-canvas {
    max-width: 180px;
  }
  .screen {
    padding: 24px 16px;
  }
  .hero {
    padding-top: 40px;
    margin-bottom: 40px;
  }
  .poll-topbar {
    gap: 8px;
  }
  .btn-share {
    margin-left: 0;
  }
}

@media (max-width: 400px) {
  .home-cards {
    grid-template-columns: 1fr;
  }
  .hero-title {
    font-size: 2.2rem;
  }
}
