/**
 * Referendum Widget — Teal/Ambra
 * Desktop + Mobile responsive stylesheet
 * Plugin: IFQ Voting Widgets
 */

/* ========================= */
/* VARIABLES                 */
/* ========================= */

.ifq-ref-widget {
  --si:       #1f6f78;
  --no:       #d97706;
  --si-soft:  #eef7f8;
  --no-soft:  #fff6e8;
  --si-glow:  rgba(31,111,120,0.22);
  --no-glow:  rgba(217,119,6,0.20);
  --dark:     #eef1f6;
  --text:     #262424;
  --muted:    #5c5c5c;
  --rule:     #e5e7eb;
  --accent:   #e11d48;
}

.ifq-ref-widget *,
.ifq-ref-widget *::before,
.ifq-ref-widget *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ========================= */
/* WIDGET SHELL              */
/* ========================= */

.ifq-ref-widget {
  display: block;
  font-family: "TT Norms", system-ui, sans-serif;
  width: 100%;
  max-width: 1040px;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.ifq-ref-widget:hover {
  text-decoration: none;
}

/* ========================= */
/* HEADER                    */
/* ========================= */

.ifq-ref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--dark);
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.ifq-ref-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ifq-ref-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* live dot */
.ifq-ref-live-dot {
  position: relative;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  background: none;
  border-radius: 50%;
}
.ifq-ref-live-dot::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  z-index: 1;
}
.ifq-ref-live-dot::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(239,68,68,0.28);
  animation: ifq-ref-pulse-ring 2s ease-out infinite;
}
@keyframes ifq-ref-pulse-ring {
  0%   { transform: scale(0.5); opacity: 0.9; }
  70%  { transform: scale(1.7); opacity: 0;   }
  100% { transform: scale(1.7); opacity: 0;   }
}

.ifq-ref-header-title {
  font-family: "EB Garamond", serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
}

.ifq-ref-header-sub {
  font-size: 11px;
  color: var(--muted);
}

.ifq-ref-header-divider {
  width: 1px;
  height: 14px;
  background: #1f2937;
  flex-shrink: 0;
}

.ifq-ref-header-update {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ifq-ref-header-strillone {
  position: relative;
  width: 32px;
  height: 20px;
}
.ifq-ref-header-strillone img {
  position: absolute;
  right: -10px;
  bottom: -10px;
  display: block;
  width: 32px;
  height: auto;
}

/* ========================= */
/* DATA ROW (desktop)        */
/* ========================= */

.ifq-ref-data-row {
  display: flex;
  align-items: center;
  padding: 20px 6px;
}

/* VOTE BLOCK */
.ifq-ref-vote-block {
  width: 100%;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding: 18px 6px 6px;
  border-radius: 8px;
}
.ifq-ref-vote-block--si {
  background: var(--si-soft);
  border: 1px solid rgba(29,78,216,0.11);
}
.ifq-ref-vote-block--no {
  background: var(--no-soft);
  border: 1px solid rgba(220,38,38,0.11);
}

.ifq-ref-vote-block-top {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.ifq-ref-vote-word {
  font-family: "TT Norms", sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.ifq-ref-vote-word--si { color: var(--si); }
.ifq-ref-vote-word--no { color: var(--no); }

.ifq-ref-vote-perc {
  font-family: "TT Norms", sans-serif;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ifq-ref-vote-perc--si { color: var(--si); }
.ifq-ref-vote-perc--no { color: var(--no); }

.ifq-ref-vote-perc-unit {
  font-size: 16px;
  opacity: 0.48;
  font-weight: 400;
}

.ifq-ref-vote-count {
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin-top: 3px;
}
.ifq-ref-vote-count strong {
  color: var(--text);
}

/* ========================= */
/* VS BLOCK                  */
/* ========================= */

.ifq-ref-vs-block {
  flex: 1 0 0;
  padding: 0 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  min-width: 140px;
}

.ifq-ref-vs-end-labels {
  font-family: "TT Norms", sans-serif;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  position: relative;
  flex-wrap: wrap;
  row-gap: 10px;
  column-gap: 26px;
  justify-content: center;
}
.ifq-ref-vs-end-label--si { color: var(--si); }
.ifq-ref-vs-end-label--no { color: var(--no); }

.ifq-ref-vs-mid-label {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.ifq-ref-vs-track {
  height: 20px;
  background: #f0f2f7;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  position: relative;
}
.ifq-ref-vs-track::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.08);
  transform: translateX(-50%);
}

.ifq-ref-vs-bar-si {
  height: 100%;
  background: linear-gradient(90deg,#1f6f78 0%,#2da0ad 100%);
  box-shadow: inset 0 0 18px var(--si-glow);
  width: 0%;
  transition: width 1.4s cubic-bezier(0.4,0,0.2,1);
  border-radius: 999px 0 0 999px;
  flex-shrink: 0;
}
.ifq-ref-vs-bar-no {
  height: 100%;
  background: linear-gradient(270deg,#d97706 0%,#f59e0b 100%);
  box-shadow: inset 0 0 18px var(--no-glow);
  width: 0%;
  transition: width 1.4s cubic-bezier(0.4,0,0.2,1);
  border-radius: 0 999px 999px 0;
  margin-left: auto;
  flex-shrink: 0;
}

.ifq-ref-vs-diff-label {
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}

/* ========================= */
/* STATS BLOCK               */
/* ========================= */

.ifq-ref-stats-block {
  display: flex;
  gap: 6px;
  margin-left: 8px;
  flex-shrink: 0;
}

.ifq-ref-stat-item {
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0 8px 12px;
  width: calc(100% / 3);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.ifq-ref-stat-label {
  font-family: "TT Norms", sans-serif;
  font-size: 8.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  width: calc(100% + 16px);
  margin: 0 -8px;
  padding: 7px 8px;
  background: #eef1f6;
  border-radius: 7px 7px 0 0;
  text-align: center;
}

.ifq-ref-stat-value {
  font-family: "TT Norms", sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.ifq-ref-stat-sub {
  font-size: 9px;
  color: var(--muted);
  text-align: center;
  line-height: 1.3;
}

.ifq-ref-stat-flex1 {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* mini sezioni bar */
.ifq-ref-sez-mini-track {
  width: 46px;
  height: 3px;
  background: var(--rule);
  border-radius: 99px;
  overflow: hidden;
  margin: 2px auto 0;
}
.ifq-ref-sez-mini-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg,var(--accent),#fb5075);
  border-radius: 99px;
  transition: width 1.2s cubic-bezier(0.4,0,0.2,1);
}

/* vantaggio chip */
.ifq-ref-vantaggio-chip {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.ifq-ref-vantaggio-chip--si {
  background: var(--si-soft);
  color: var(--si);
  border-left: 3px solid var(--si);
}
.ifq-ref-vantaggio-chip--no {
  background: var(--no-soft);
  color: var(--no);
  border-left: 3px solid var(--no);
}

/* ========================= */
/* WINNER HIGHLIGHT          */
/* ========================= */

.ifq-ref-widget:has(.ifq-ref-vantaggio-chip--si) .ifq-ref-vote-block--si {
  border: 1px solid rgba(31,111,120,0.15);
}
.ifq-ref-widget:has(.ifq-ref-vantaggio-chip--no) .ifq-ref-vote-block--no {
  border: 1px solid rgba(217,119,6,0.15);
}
.ifq-ref-widget:has(.ifq-ref-vantaggio-chip--si) .ifq-ref-vs-bar-si { filter: brightness(1.08); }
.ifq-ref-widget:has(.ifq-ref-vantaggio-chip--no) .ifq-ref-vs-bar-no { filter: brightness(1.08); }

.ifq-ref-widget:has(.ifq-ref-vantaggio-chip--si) .ifq-ref-vote-block--si::before {
  content: "IN VANTAGGIO";
  position: absolute;
  top: 0;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--si);
  color: #fff;
  padding: 2px 8px;
  border-radius: 0 0 6px 6px;
}
.ifq-ref-widget:has(.ifq-ref-vantaggio-chip--no) .ifq-ref-vote-block--no::before {
  content: "IN VANTAGGIO";
  position: absolute;
  top: 0;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--no);
  color: #fff;
  padding: 2px 8px;
  border-radius: 0 0 6px 6px;
}

/* ========================= */
/* FOOTER                    */
/* ========================= */

.ifq-ref-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255,255,255,0.04);
  padding: 8px 20px;
  background: var(--dark);
  gap: 12px;
}

.ifq-ref-footer-left {
  font-family: "TT Norms", sans-serif;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

.ifq-ref-footer-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  max-width: 100%;
}

.ifq-ref-footer-source {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.ifq-ref-footer-link {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}
a.ifq-ref-widget:hover .ifq-ref-footer-link { opacity: 0.8; }

/* ========================= */
/* MOBILE LAYOUT             */
/* Scoped to data-layout     */
/* ========================= */

.ifq-ref-widget[data-layout="mobile"] {
  max-width: 380px;
}

.ifq-ref-widget[data-layout="mobile"] .ifq-ref-header {
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  padding: 10px 14px;
}
.ifq-ref-widget[data-layout="mobile"] .ifq-ref-header-left { display: contents; }
.ifq-ref-widget[data-layout="mobile"] .ifq-ref-live-dot { order: 1; flex: 0 0 auto; margin-right: 8px; }
.ifq-ref-widget[data-layout="mobile"] .ifq-ref-header-title { order: 2; flex: 1 1 calc(100% - 26px); }
.ifq-ref-widget[data-layout="mobile"] .ifq-ref-header-sub { order: 3; flex: 1 1 auto; font-size: 11px; margin-top: 4px; }
.ifq-ref-widget[data-layout="mobile"] .ifq-ref-header-right {
  order: 4; flex-shrink: 0;
  justify-content: space-between;
  align-items: flex-end; width: 100%;
}
.ifq-ref-widget[data-layout="mobile"] .ifq-ref-header-strillone img { right: 0; }

/* --- Mobile sezioni section --- */
.ifq-ref-sezioni-section {
  padding: 8px 14px;
  background: #fff;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 12px;
}
.ifq-ref-sezioni-label {
  font-size: 8.5px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); flex-shrink: 0;
}
.ifq-ref-sezioni-bar-wrap {
  flex: 1; height: 3px; background: var(--rule);
  border-radius: 99px; overflow: hidden;
}
.ifq-ref-sezioni-bar-fill {
  height: 100%;
  background: linear-gradient(90deg,var(--accent),#fb5075);
  border-radius: 99px;
  transition: width 1.2s cubic-bezier(0.4,0,0.2,1);
  width: 0%;
}
.ifq-ref-sezioni-count {
  font-size: 10px; font-weight: 600;
  color: var(--text); flex-shrink: 0;
  white-space: nowrap; font-variant-numeric: tabular-nums;
}

/* --- Mobile scheda block --- */
.ifq-ref-scheda-block { padding: 12px 14px 0; }
.ifq-ref-scheda-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.ifq-ref-scheda-num { font-size: 8.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.ifq-ref-scheda-update { font-size: 9px; color: var(--muted); font-variant-numeric: tabular-nums; }

.ifq-ref-m-vote-block { margin-bottom: 8px; }
.ifq-ref-m-vote-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.ifq-ref-m-vote-label { width: 24px; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.ifq-ref-m-vote-label--si { color: var(--si); }
.ifq-ref-m-vote-label--no { color: var(--no); }

.ifq-ref-m-bar-outer { flex: 1; height: 18px; background: #f0f2f7; border-radius: 4px; position: relative; overflow: hidden; }
.ifq-ref-m-bar-fill {
  height: 100%; position: absolute; left: 0; top: 0;
  transition: width 1.4s cubic-bezier(0.4,0,0.2,1);
  width: 0%; display: flex; align-items: center;
  padding-left: 8px; border-radius: 4px;
}
.ifq-ref-m-bar-fill--si { background: linear-gradient(90deg,#1f6f78 0%,#2da0ad 100%); box-shadow: inset 0 0 12px var(--si-glow); }
.ifq-ref-m-bar-fill--no { background: linear-gradient(90deg,#b45309 0%,#d97706 100%); box-shadow: inset 0 0 12px var(--no-glow); }
.ifq-ref-m-bar-inner-label { font-size: 9.5px; font-weight: 700; color: #fff; white-space: nowrap; opacity: 0; transition: opacity .3s ease 1s; }
.ifq-ref-m-bar-fill.active .ifq-ref-m-bar-inner-label { opacity: 1; }

.ifq-ref-m-vote-perc { width: 42px; text-align: right; font-size: 15px; font-weight: 700; flex-shrink: 0; line-height: 1; font-variant-numeric: tabular-nums; }
.ifq-ref-m-vote-perc--si { color: var(--si); }
.ifq-ref-m-vote-perc--no { color: var(--no); }
.ifq-ref-m-vote-count { font-size: 9px; color: var(--muted); padding-left: 30px; margin-top: -1px; margin-bottom: 6px; font-variant-numeric: tabular-nums; }

.ifq-ref-scheda-divider { height: 1px; background: var(--rule); margin: 10px 14px 0; }

.ifq-ref-m-vantaggio-wrap { padding: 8px 14px; display: flex; align-items: center; gap: 8px; }
.ifq-ref-m-vantaggio-label { font-size: 8.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.ifq-ref-m-vantaggio-value { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px; }
.ifq-ref-m-vantaggio-value--si { background: var(--si-soft); color: var(--si); border-left: 3px solid var(--si); }
.ifq-ref-m-vantaggio-value--no { background: var(--no-soft); color: var(--no); border-left: 3px solid var(--no); }

.ifq-ref-quorum-note { padding: 8px 14px; font-size: 9.5px; color: var(--muted); border-top: 1px solid var(--rule); line-height: 1.5; }

/* --- Mobile affluenza --- */
.ifq-ref-affluenza-block {
  padding: 10px 14px;
  background: var(--dark);
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ifq-ref-affluenza-label { font-size: 8.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.ifq-ref-affluenza-value { font-size: 16px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.ifq-ref-affluenza-detail { font-size: 9px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* --- Mobile footer --- */
.ifq-ref-widget[data-layout="mobile"] .ifq-ref-footer {
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
}
.ifq-ref-widget[data-layout="mobile"] .ifq-ref-footer-left {
  font-size: 12px;
  width: 100%;
}
