/* abstimmungsquiz v2 — form, averages widget, ranking. Form styling mirrors
   modules/ezpoll/assets/css/ezpoll-frontend.css. */

.abstimmungsquiz {
  --abstimmungsquiz-accent: rgb(1, 62, 131);
  background-color: rgb(228, 239, 249);
  background-color: var(--color-popular-comments-bg, rgb(228, 239, 249));
  margin: 1em 0;
}

.abstimmungsquiz .widget-title {
  margin-bottom: 0;
}

.abstimmungsquiz-content-wrap {
  padding: 10px 1em;
}

.abstimmungsquiz-content-wrap p {
  margin: 0;
}

.abstimmungsquiz-description {
  margin: 0 0 1em;
  font-size: 0.95em;
  color: #444;
}

/* ─── Yes/No radio cards (ezpoll pattern) ─── */

.abstimmungsquiz-choices {
  display: grid;
  gap: 8px;
  margin-bottom: 1em;
}

.abstimmungsquiz-choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

.abstimmungsquiz-choice input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.abstimmungsquiz-choice span {
  position: relative;
  display: block;
  padding-left: 30px;
  line-height: 1.25;
}

.abstimmungsquiz-choice span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #8c8f94;
  background: #fff;
  box-sizing: border-box;
  transition: border-color 150ms ease;
}

.abstimmungsquiz-choice span::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%) scale(0);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--abstimmungsquiz-accent);
  transition: transform 150ms ease;
}

.abstimmungsquiz-choice input[type="radio"]:checked + span::before {
  border-color: var(--abstimmungsquiz-accent);
}

.abstimmungsquiz-choice input[type="radio"]:checked + span::after {
  transform: translateY(-50%) scale(1);
}

/* ─── Prediction group (slider + number) ─── */

.abstimmungsquiz-prediction-group {
  margin-bottom: 1em;
}

.abstimmungsquiz-prediction-label {
  display: block;
  margin-bottom: 0.4em;
  font-weight: 600;
}

.abstimmungsquiz-prediction-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Slider takes more of the row; the number+unit readout hugs together
   so the percent sign sits flush against the number. */
.abstimmungsquiz-prediction-readout {
  display: flex;
  align-items: baseline;
  flex: 0 0 auto;
}

.abstimmungsquiz-prediction-range {
  flex: 1 1 auto;
  min-width: 0;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--abstimmungsquiz-accent) 0,
    var(--abstimmungsquiz-accent) var(--abstimmungsquiz-fill, 50%),
    #d4d6da var(--abstimmungsquiz-fill, 50%),
    #d4d6da 100%
  );
}

.abstimmungsquiz-prediction-range::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--abstimmungsquiz-accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.abstimmungsquiz-prediction-range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--abstimmungsquiz-accent);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* Bumped specificity to win over the theme's input[type="number"] rule
   (style.css:1008 sets border, background, padding). */
.abstimmungsquiz .abstimmungsquiz-prediction-number {
  width: 4em;
  padding: 0;
  background: transparent;
  border: none;
  text-align: right;
  font: inherit;
  font-weight: 600;
  color: var(--abstimmungsquiz-accent);
  font-variant-numeric: tabular-nums;
}

.abstimmungsquiz .abstimmungsquiz-prediction-number:focus {
  outline: none;
}

.abstimmungsquiz-prediction-unit {
  font-weight: 600;
  color: var(--abstimmungsquiz-accent);
}

/* ─── Nickname identity ─── */

.abstimmungsquiz-identity {
  margin-bottom: 1em;
}

.abstimmungsquiz-identity-label {
  display: block;
  margin-bottom: 0.3em;
  font-weight: 600;
}

.abstimmungsquiz-nickname {
  width: 100%;
  max-width: 24em;
  box-sizing: border-box;
}

/* ─── Submit + spinner + message ─── */

.abstimmungsquiz-submit {
  margin-top: .5em;
  margin-bottom: .5em;
}

.abstimmungsquiz-submit:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.abstimmungsquiz-message {
  margin-top: 0.6em;
  min-height: 1.2em;
}

.abstimmungsquiz-message:empty {
  display: none;
}

.abstimmungsquiz-message-error {
  color: #b91c1c;
}

.abstimmungsquiz-spinner {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px 0;
}

.abstimmungsquiz-spinner::after {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--abstimmungsquiz-accent);
  animation: abstimmungsquiz-spin 0.9s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .abstimmungsquiz-spinner::after { animation: none; }
}

/* ─── After-vote view: shares the sidebar averages layout ─── */

.abstimmungsquiz-results {
  margin-top: 0.5em;
}

.abstimmungsquiz-results-title {
  font-weight: 600;
  margin-bottom: 0.6em;
}

.abstimmungsquiz-bars {
  display: grid;
  gap: 10px;
}

.abstimmungsquiz-bar-row {
  display: grid;
  grid-template-columns: 160px 1fr 50px;
  gap: 10px;
  align-items: center;
}

.abstimmungsquiz-bar-label,
.abstimmungsquiz-vote-count,
.abstimmungsquiz-bar-pct {
  font-size: .875em;
  font-weight: bold;
  line-height: 1.2;
}

.abstimmungsquiz-bar-pct {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.abstimmungsquiz-bar-track {
  background: rgba(1, 62, 131, .1);
  border-radius: 999px;
  height: 24px;
  overflow: hidden;
  position: relative;
}

.abstimmungsquiz-bar-fill {
  box-sizing: content-box;
  height: 100%;
  width: 0%;
  max-width: calc(100% - 10px);
  min-width: fit-content;
  padding: 0 10px;
  background: var(--abstimmungsquiz-accent);
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: flex-end;

  /* allow count text to remain readable even on small percentages */
  overflow: visible;
  white-space: nowrap;

  transition: width 900ms ease;
}

.abstimmungsquiz-bar-count {
  color: rgba(255, 255, 255, .75);
  font-weight: 600;
  font-size: 13px;
}

.is-winner .abstimmungsquiz-bar-count {
  color: #fff;
}

.abstimmungsquiz-bar-fill.is-winner {
  background-color: var(--abstimmungsquiz-accent);
  background-image: linear-gradient(
    120deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.22) 45%,
    rgba(255,255,255,0) 60%
  );
  background-repeat: no-repeat;
  background-size: 260% 100%;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
  animation: abstimmungsquiz-winner-sheen 4.5s ease-in-out infinite;
}

.abstimmungsquiz-bar-row.abstimmungsquiz-winner .abstimmungsquiz-bar-label {
  font-weight: 600;
}

@keyframes abstimmungsquiz-winner-sheen {
  0%   { background-position: 220% 0; }
  55%  { background-position: -220% 0; }
  100% { background-position: -220% 0; }
}

.abstimmungsquiz-vote-count {
  margin-top: 0.8em;
  text-align: right;
  font-size: .875em;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .abstimmungsquiz-bar-fill { transition: none; }
}

/* Mobile: label above bar (mirrors ezpoll responsive rule) */
@media (max-width: 959px) {
  .abstimmungsquiz-bar-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "label pct"
      "track track";
    gap: 6px 10px;
  }
  .abstimmungsquiz-bar-label { grid-area: label; }
  .abstimmungsquiz-bar-pct   { grid-area: pct; }
  .abstimmungsquiz-bar-track { grid-area: track; }
}

/* ─── Closed / resolved states (anonymous visitor) ─── */

.abstimmungsquiz-closed-pending,
.abstimmungsquiz-resolved {
  font-style: italic;
}

.abstimmungsquiz-results-link {
  display: inline-block;
  margin-top: 0.4em;
  font-weight: 600;
}

/* ─── Averages sidebar widget — three stacked bars (reuses .bar-row) ─── */

.abstimmungsquiz-averages-subtitle {
  margin: 0 0 0.8em;
  font-size: 0.9em;
  color: #666;
}

.abstimmungsquiz-averages-footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 0.8em;
  font-size: 0.875em;
}

.abstimmungsquiz-averages-footer .abstimmungsquiz-vote-count {
  margin-top: 0;       /* override the default top margin from the bar layout */
  text-align: right;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

/* ─── Ranking ─── */

.abstimmungsquiz-ranking-wrap {
  margin: 1em 0;
}

.abstimmungsquiz-ranking-title {
  margin: 0 0 0.5em;
}

.abstimmungsquiz-ranking {
  list-style: none;
  padding: 0;
  margin: 0;
}

.abstimmungsquiz-ranking-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 0.4em;
  border-bottom: 1px solid #e5e7eb;
}

.abstimmungsquiz-ranking-row:last-child {
  border-bottom: none;
}

/* "Resultat: X% JA-Stimmen" line at the very top of the resolved view.
   Scoped to .abstimmungsquiz so this (0,2,0) wins over the generic
   .abstimmungsquiz-content-wrap p (0,1,1) rule above. */
.abstimmungsquiz .abstimmungsquiz-actual {
  margin: .75em 0;
}

.abstimmungsquiz-actual strong {
  font-weight: 700;
}

.abstimmungsquiz-actual-value {
  color: var(--abstimmungsquiz-accent);
  font-variant-numeric: tabular-nums;
}

.abstimmungsquiz-community-intro {
  margin: 0 0 0.4em;
}

.abstimmungsquiz-ranking-title {
  margin-top: 1em;
}

/* Compact 3-column winners grid — no borders, no left chrome.
   Caps at ~10 rows; the overflow scrolls vertically. */
.abstimmungsquiz-ranking-winners {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.25em 1em;
  max-height: 18em;
  overflow-y: auto;
}

.abstimmungsquiz-ranking-winners > li {
  display: flex;
  align-items: center;
  gap: 0.35em;
  padding: 0;
  border: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.abstimmungsquiz-ranking-trophy {
  font-size: 1.1em;
  line-height: 1;
}

.abstimmungsquiz-ranking-author {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 599px) {
  .abstimmungsquiz-ranking-winners {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.abstimmungsquiz-author-verified img,
.abstimmungsquiz-author-identicon img {
  vertical-align: -3px;
}

/* ─── Pending / empty states ─── */

.abstimmungsquiz-ranking-pending,
.abstimmungsquiz-ranking-empty {
  color: #666;
  font-style: italic;
}

/* ─── Logged-in subscriber affordance (mirrors comment-form pattern) ─── */

.abstimmungsquiz-nickname.logged-in-user-email {
  padding-right: 2.2em !important;
  background-position: right 0.6em center !important;
  background-repeat: no-repeat !important;
  background-size: 1.1em 1.1em !important;
  border-color: #2e7d32 !important;
  background-color: #F0FDF4 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0%200%2016%2016'%3E%3Cpath fill='none' stroke='%232e7d32' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M3%209l3%203%207-8'/%3E%3C/svg%3E") !important;
}

/* ─── Error placeholder ─── */

.abstimmungsquiz-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 0.5em 1em;
}
