/* ==========================================================================
   Fan Poll Component — HAMCO Sports News
   Supports both flat selectors (standalone polls) and BEM selectors (home.php)
   Uses global variables from variables.css
   ========================================================================== */

/* ---------- Poll Section (home.php wrapper) ---------- */
.hn-poll-section {
  padding: var(--hn-space-12) 0;
}

/* ---------- Poll Container ---------- */
.hn-poll {
  background: var(--hn-card-bg);
  border-radius: var(--hn-radius-md);
  box-shadow: var(--hn-shadow-card);
  overflow: hidden;
}

/* ---------- Poll Header ---------- */
.hn-poll-header {
  padding: var(--hn-space-4) var(--hn-space-5);
  border-bottom: 2px solid var(--hn-red);
}

.hn-poll-badge {
  display: inline-block;
  font-family: var(--hn-font-body);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--hn-white);
  background: var(--hn-red);
  padding: 3px var(--hn-space-2);
  border-radius: 3px;
  margin-bottom: var(--hn-space-2);
}

/* Question — flat selector */
.hn-poll-question {
  font-family: var(--hn-font-subheading);
  font-size: var(--hn-text-xl);
  font-weight: 700;
  color: var(--hn-black);
  line-height: 1.15;
  margin: 0;
  text-transform: uppercase;
}

/* Question — BEM selector (home.php uses .hn-poll__question) */
.hn-poll__question {
  font-family: var(--hn-font-subheading);
  font-size: var(--hn-text-xl);
  font-weight: 700;
  color: var(--hn-black);
  line-height: 1.15;
  margin: 0;
  text-transform: uppercase;
  padding: var(--hn-space-4) var(--hn-space-5);
  border-bottom: 2px solid var(--hn-red);
}

/* ---------- Poll Body ---------- */
.hn-poll-body {
  padding: var(--hn-space-4) var(--hn-space-5);
}

/* ---------- Option Buttons (voting state) ---------- */
/* Flat selectors */
.hn-poll-options {
  display: flex;
  flex-direction: column;
  gap: var(--hn-space-3);
}

.hn-poll-option {
  display: flex;
  align-items: center;
  gap: var(--hn-space-3);
  width: 100%;
  padding: var(--hn-space-3) var(--hn-space-4);
  font-family: var(--hn-font-body);
  font-size: var(--hn-text-sm);
  font-weight: 600;
  color: var(--hn-black);
  background: transparent;
  border: 2px solid var(--hn-gray-200);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all var(--hn-transition-base);
}

.hn-poll-option:hover {
  border-color: var(--hn-red);
  background: var(--hn-red-light);
  color: var(--hn-red);
}

.hn-poll-option:active {
  transform: scale(0.98);
}

.hn-poll-option:focus-visible {
  outline: 2px solid var(--hn-red);
  outline-offset: 2px;
}

/* Radio-style indicator */
.hn-poll-option::before {
  content: '';
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2px solid var(--hn-gray-200);
  border-radius: var(--hn-radius-full);
  transition: all var(--hn-transition-base);
}

.hn-poll-option:hover::before {
  border-color: var(--hn-red);
}

.hn-poll-option.is-selected::before {
  border-color: var(--hn-red);
  background: var(--hn-red);
  box-shadow: inset 0 0 0 3px var(--hn-white);
}

/* BEM selectors (home.php uses .hn-poll__options, .hn-poll__option) */
.hn-poll__options {
  display: flex;
  flex-direction: column;
  gap: var(--hn-space-3);
  padding: var(--hn-space-4) var(--hn-space-5);
}

.hn-poll__option {
  display: flex;
  align-items: center;
  gap: var(--hn-space-3);
  width: 100%;
  padding: var(--hn-space-3) var(--hn-space-4);
  font-family: var(--hn-font-body);
  font-size: var(--hn-text-sm);
  font-weight: 600;
  color: var(--hn-black);
  background: transparent;
  border: 2px solid var(--hn-gray-200);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all var(--hn-transition-base);
}

.hn-poll__option:hover {
  border-color: var(--hn-red);
  background: var(--hn-red-light);
  color: var(--hn-red);
}

.hn-poll__option:active {
  transform: scale(0.98);
}

.hn-poll__option:focus-visible {
  outline: 2px solid var(--hn-red);
  outline-offset: 2px;
}

/* Radio-style indicator for BEM */
.hn-poll__option::before {
  content: '';
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2px solid var(--hn-gray-200);
  border-radius: var(--hn-radius-full);
  transition: all var(--hn-transition-base);
}

.hn-poll__option:hover::before {
  border-color: var(--hn-red);
}

.hn-poll__option.is-selected::before {
  border-color: var(--hn-red);
  background: var(--hn-red);
  box-shadow: inset 0 0 0 3px var(--hn-white);
}

/* ==========================================================================
   Results State — Animated bar chart
   ========================================================================== */
/* Flat selector */
.hn-poll-results {
  display: flex;
  flex-direction: column;
  gap: var(--hn-space-3);
}

/* BEM selector (home.php uses .hn-poll__results) */
.hn-poll__results {
  display: flex;
  flex-direction: column;
  gap: var(--hn-space-3);
  padding: var(--hn-space-4) var(--hn-space-5);
}

.hn-poll-result-item {
  position: relative;
}

/* Label row */
.hn-poll-result-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--hn-space-1);
  font-family: var(--hn-font-body);
  font-size: 13px;
}

.hn-poll-result-name {
  font-weight: 600;
  color: var(--hn-black);
}

.hn-poll-result-pct {
  font-weight: 700;
  color: var(--hn-gray-600);
  font-family: var(--hn-font-subheading);
  font-size: var(--hn-text-md);
  line-height: 1;
}

/* Bar track */
.hn-poll-bar-track {
  width: 100%;
  height: 28px;
  background: var(--hn-gray-100);
  border-radius: var(--hn-radius-sm);
  overflow: hidden;
  position: relative;
}

/* Bar fill */
.hn-poll-bar-fill {
  height: 100%;
  background: var(--hn-gray-200);
  border-radius: var(--hn-radius-sm);
  width: 0;
  transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Winner bar */
.hn-poll-result-item.is-winner .hn-poll-bar-fill {
  background: var(--hn-red);
}

.hn-poll-result-item.is-winner .hn-poll-result-pct {
  color: var(--hn-red);
}

.hn-poll-result-item.is-winner .hn-poll-result-name {
  color: var(--hn-red);
  font-weight: 700;
}

/* User's choice marker */
.hn-poll-result-item.is-user-vote .hn-poll-result-name::after {
  content: 'Your vote';
  font-size: 10px;
  font-weight: 600;
  color: var(--hn-gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: var(--hn-space-2);
  vertical-align: middle;
}

/* ---------- Poll Footer ---------- */
.hn-poll-footer {
  padding: var(--hn-space-3) var(--hn-space-5);
  border-top: 1px solid var(--hn-gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hn-poll-total {
  font-family: var(--hn-font-body);
  font-size: var(--hn-text-xs);
  color: var(--hn-gray-400);
}

.hn-poll-total strong {
  color: var(--hn-gray-600);
}

.hn-poll-share {
  display: flex;
  align-items: center;
  gap: var(--hn-space-2);
}

.hn-poll-share-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--hn-radius-full);
  background: var(--hn-gray-100);
  color: var(--hn-gray-400);
  cursor: pointer;
  transition: all var(--hn-transition-base);
}

.hn-poll-share-btn:hover {
  background: var(--hn-red);
  color: var(--hn-white);
}

.hn-poll-share-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* ---------- Voted State ---------- */
.hn-poll.has-voted .hn-poll-options,
.hn-poll.has-voted .hn-poll__options {
  display: none;
}

.hn-poll:not(.has-voted) .hn-poll-results,
.hn-poll:not(.has-voted) .hn-poll__results {
  display: none;
}

/* ---------- Loading State ---------- */
.hn-poll.is-loading .hn-poll-body,
.hn-poll.is-loading .hn-poll__options {
  position: relative;
  pointer-events: none;
  opacity: 0.5;
}

.hn-poll.is-loading .hn-poll-body::after,
.hn-poll.is-loading .hn-poll__options::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid var(--hn-gray-200);
  border-top-color: var(--hn-red);
  border-radius: var(--hn-radius-full);
  animation: hn-poll-spin 0.6s linear infinite;
}

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

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 680px) {
  .hn-poll-header {
    padding: 14px var(--hn-space-4);
  }

  .hn-poll-question,
  .hn-poll__question {
    font-size: var(--hn-text-lg);
  }

  .hn-poll__question {
    padding: 14px var(--hn-space-4);
  }

  .hn-poll-body {
    padding: 14px var(--hn-space-4);
  }

  .hn-poll__options {
    padding: 14px var(--hn-space-4);
  }

  .hn-poll-option,
  .hn-poll__option {
    padding: 10px 14px;
    font-size: 13px;
  }

  .hn-poll-bar-track {
    height: 24px;
  }

  .hn-poll-footer {
    flex-direction: column;
    gap: var(--hn-space-2);
    align-items: flex-start;
    padding: 10px var(--hn-space-4);
  }

  .hn-poll-section {
    padding: var(--hn-space-8) 0;
  }
}
