/* ============================================
   Hub API UI — Vote cards + Lead magnets + Modal + Toast
   Design tokens from style.css (dark theme + gold accent)
   Mobile-first responsive | Touch targets ≥ 48px
   ============================================ */

/* --- Hero section (common) --- */
.hub-hero {
  padding: var(--space-3xl) var(--space-md);
  text-align: center;
  background: radial-gradient(ellipse at top, rgba(245,197,24,0.06), transparent 60%);
}
.hub-hero__title {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 5vw, 3rem);
  font-weight: 700;
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
}
.hub-hero__sub {
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 auto;
  line-height: 1.6;
}

/* --- Language switcher --- */
.hub-lang-bar {
  display: flex;
  justify-content: center;
  gap: var(--space-xs);
  margin: var(--space-lg) auto 0;
  flex-wrap: wrap;
}
.hub-lang-btn {
  padding: 0.5rem 0.9rem;
  min-height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-body);
}
.hub-lang-btn:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.hub-lang-btn.is-active {
  background: var(--accent-gold);
  color: var(--bg-primary);
  border-color: var(--accent-gold);
}

/* --- Candidate grid --- */
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-xl) var(--space-md);
  max-width: var(--max-width);
  margin: 0 auto;
}

.vote-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  transition: all var(--transition-normal);
  position: relative;
}
.vote-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.vote-card--voted {
  border-color: var(--success);
  background: color-mix(in srgb, var(--success) 6%, var(--bg-card));
}

.vote-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}
.vote-card__category {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: color-mix(in srgb, var(--accent-gold) 12%, transparent);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
}
.vote-card__count {
  font-size: 0.9rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}
.vote-card__count strong {
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 700;
}
.vote-card__title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}
.vote-card__desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.55;
  flex-grow: 1;
}
.vote-card__btn {
  min-height: 48px;
  width: 100%;
  background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-gold-hover) 100%);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.vote-card__btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}
.vote-card__btn:active { transform: translateY(0); }
.vote-card--voted .vote-card__btn {
  background: var(--success);
  color: #fff;
  pointer-events: none;
}

/* --- Loading / Empty state --- */
.hub-loading, .hub-empty {
  text-align: center;
  padding: var(--space-3xl) var(--space-md);
  color: var(--text-secondary);
}
.hub-loading__spinner {
  display: inline-block;
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-gold);
  border-radius: 50%;
  animation: hub-spin 0.9s linear infinite;
  margin-bottom: var(--space-md);
}
@keyframes hub-spin { to { transform: rotate(360deg); } }
.hub-empty__icon {
  font-size: 3rem;
  opacity: 0.4;
  margin-bottom: var(--space-md);
}
.hub-empty__title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

/* --- Lead magnet cards --- */
.magnets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-lg);
  padding: var(--space-xl) var(--space-md);
  max-width: var(--max-width);
  margin: 0 auto;
}
.magnet-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all var(--transition-normal);
}
.magnet-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-gold);
}
.magnet-card__visual {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
}
.magnet-card__body {
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  flex-grow: 1;
}
.magnet-card__meta {
  display: flex;
  gap: var(--space-sm);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.magnet-card__title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
}
.magnet-card__desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.55;
  flex-grow: 1;
}
.magnet-card__btn {
  min-height: 48px;
  background: var(--accent-gold);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.magnet-card__btn:hover {
  background: var(--accent-gold-hover);
  box-shadow: var(--shadow-glow);
}

/* --- Modal --- */
.hub-modal {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  z-index: 9000;
}
.hub-modal.is-open { opacity: 1; pointer-events: auto; }
.hub-modal__inner {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  transform: scale(0.96);
  transition: transform var(--transition-normal);
  box-shadow: var(--shadow-lg);
}
.hub-modal.is-open .hub-modal__inner { transform: scale(1); }
.hub-modal__title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}
.hub-modal__sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.5;
}
.hub-modal__input {
  min-height: 48px;
  width: 100%;
  background: var(--bg-primary);
  border: 1.5px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color var(--transition-fast);
}
.hub-modal__input:focus {
  outline: none;
  border-color: var(--accent-gold);
}
.hub-modal__actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
.hub-modal__btn {
  min-height: 48px;
  flex-grow: 1;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.hub-modal__btn--primary {
  background: var(--accent-gold);
  color: var(--bg-primary);
}
.hub-modal__btn--primary:hover:not(:disabled) {
  background: var(--accent-gold-hover);
  box-shadow: var(--shadow-glow);
}
.hub-modal__btn--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.hub-modal__btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.hub-modal__btn--ghost:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}
.hub-modal__note {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-xs);
}

/* --- Toast --- */
.hub-toast {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translate(-50%, 30px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 0.9rem 1.4rem;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all var(--transition-normal);
  z-index: 9500;
  max-width: 90vw;
  text-align: center;
  border: 1px solid var(--border-color);
}
.hub-toast--show { opacity: 1; transform: translate(-50%, 0); }
.hub-toast--success { border-color: var(--success); }
.hub-toast--error { border-color: var(--error); }
.hub-toast--warn { border-color: var(--warning); }

/* --- Top voted widget (homepage) --- */
.top-voted-widget {
  padding: var(--space-2xl) var(--space-md);
  max-width: var(--max-width);
  margin: 0 auto;
  opacity: 0;
  transition: opacity var(--transition-slow);
}
.top-voted-widget.is-loaded { opacity: 1; }
.top-voted-widget__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}
.top-voted-widget__title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
}
.top-voted-widget__link {
  color: var(--accent-gold);
  font-weight: 500;
  font-size: 0.95rem;
}
.top-voted-widget__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}
.top-voted__item {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  color: inherit;
  text-decoration: none;
  transition: all var(--transition-fast);
  min-height: 56px;
}
.top-voted__item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-gold);
  transform: translateX(2px);
}
.top-voted__rank {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-align: center;
}
.top-voted__title {
  color: var(--text-primary);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-voted__votes {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* --- Mobile tuning --- */
@media (max-width: 640px) {
  .hub-modal__inner { padding: var(--space-lg); max-width: 100%; }
  .hub-modal__actions { flex-direction: column-reverse; }
  .candidates-grid, .magnets-grid { padding: var(--space-lg) var(--space-md); gap: var(--space-md); }
  .vote-card, .magnet-card__body { padding: var(--space-md); }
  .top-voted__item { grid-template-columns: 32px 1fr; }
  .top-voted__votes { grid-column: 2; font-size: 0.8rem; }
}

/* --- Accessibility --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
