/* Partie de styles.css : fiche de sondage, balayage tactile du graphique, graphique intégré.
   Chargée après les parties précédentes, dans l'ordre de scripts/app_sources.js
   (STYLESHEETS) : l'ordre de la cascade est celui de l'ancien fichier unique. */

/* The two independent disclosures keep each nowcast chart's display controls out of the way. */
.nowcast-candidate-toolbar { display: flex; justify-content: flex-end; margin: 12px 0; }
.nowcast-candidate-picker { position: relative; }
.nowcast-candidate-picker summary { cursor: pointer; border: 1px solid var(--line); padding: 9px 12px; font-size: 0.85rem; font-weight: 650; }
.nowcast-candidate-picker[open] summary { background: #edddd4; }
.nowcast-candidate-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: min(320px, calc(100vw - 64px)); padding: 12px; border: 1px solid var(--muted); background: var(--panel); }
.nowcast-candidate-menu p { margin: 0 0 8px; font-size: 0.78rem; color: var(--muted); }
.nowcast-candidate-menu [role="group"] { max-height: 300px; overflow-y: auto; }
.nowcast-candidate-option { display: flex; align-items: center; gap: 9px; min-height: 42px; cursor: pointer; font-size: 0.85rem; }
.nowcast-candidate-option:hover { background: var(--hover); }
.nowcast-candidate-option input { width: 17px; height: 17px; accent-color: #197278; flex-shrink: 0; }
.nowcast-candidate-dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; }
.nowcast-candidate-reset { margin-top: 10px; padding: 9px 0; border: 0; background: transparent; color: #197278; text-decoration: underline; cursor: pointer; font: inherit; font-size: 0.8rem; }

/* Fiche détaillée d'un sondage : ouverte depuis une ligne du tableau ou un
   point du graphique. Une carte par hypothèse (ou par duel), les candidats en
   liste avec une barre fine à l'échelle du meilleur score du sondage, pour que
   les hypothèses se comparent d'un coup d'œil. */
.polls-table tbody tr[data-poll-id] {
  cursor: pointer;
}

.polls-table tbody tr[data-poll-id]:focus-visible {
  outline: 2px solid var(--da-accent, var(--accent));
  outline-offset: -2px;
}

.chart-wrap.is-over-point {
  cursor: pointer;
}

/* Au doigt, glisser horizontalement déplace la barre de lecture ; le
   défilement vertical de la page reste libre. */
#chart {
  touch-action: pan-y;
}

.chart-scrub {
  pointer-events: none;
}

.chart-scrub-rule {
  stroke: var(--ink, #222);
  stroke-width: 1;
  opacity: 0.45;
}

.tooltip.is-scrub {
  min-width: 150px;
}

.tooltip.is-scrub ol {
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.tooltip.is-scrub li {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 7px;
  line-height: 1.5;
}

.tooltip.is-scrub li i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.tooltip.is-scrub li span {
  display: inline;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tooltip.is-scrub li b {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.poll-modal[hidden] {
  display: none;
}

.poll-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
}

.poll-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 61, 59, 0.36);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.poll-modal-card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(840px, calc(100vh - 48px));
  overflow: hidden;
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(var(--ink-rgb), 0.28);
  animation: poll-modal-in 0.2s ease-out;
}

.poll-modal-card.is-multi {
  width: min(940px, 100%);
}

.poll-modal-head {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 26px 28px 18px;
  border-bottom: 1px solid rgba(46, 107, 98, 0.10);
}

.poll-modal-eyebrow {
  margin: 0 0 4px;
  color: var(--da-accent, var(--accent));
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.poll-modal-head h2 {
  margin: 0;
  color: var(--da-green, var(--ink));
  font-family: var(--da-heading-font, inherit);
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.poll-modal-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.poll-modal-head-actions {
  display: flex;
  flex: none;
  gap: 8px;
}

.poll-modal-head .icon-button {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--da-pill-bg, var(--soft));
  color: var(--da-green, var(--ink));
  font-size: 1.3rem;
  line-height: 1;
}

.poll-modal-head .icon-button:hover {
  background: var(--da-pill-bg-hover, var(--surface));
}

.poll-modal-head .icon-button[hidden] {
  display: none;
}

.poll-modal-head .icon-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.poll-modal-export svg {
  width: 17px;
  height: 17px;
  min-height: 0;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.poll-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: 14px;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 20px 28px 22px;
}

.poll-modal-card.is-multi .poll-modal-body {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 400px), 1fr));
  align-items: start;
}

.poll-scenario {
  margin: 0;
}

.poll-modal-card.is-multi .poll-scenario {
  padding: 16px 18px 14px;
  border-radius: 18px;
  background: rgba(46, 107, 98, 0.05);
}

.poll-scenario h3 {
  margin: 0 0 10px;
  color: var(--da-green, var(--ink));
  font-family: var(--da-heading-font, inherit);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
}

.poll-scenario-variant {
  font-weight: 400;
}

.poll-scenario-meta {
  margin: -6px 0 10px;
  color: var(--muted);
  font-size: 0.76rem;
}

.poll-scenario-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.poll-candidate {
  display: grid;
  grid-template-columns: 20px minmax(0, 12.5rem) minmax(40px, 1fr) 3.1rem;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  margin: 0 -8px;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.86rem;
}

/* Les deux qualifiés (le vainqueur au second tour) sur fond vert, avec une
   coche ; une égalité à cheval sur la dernière place, sur fond orange avec un
   point d'interrogation. */
.poll-candidate.is-qualified {
  background: rgba(47, 138, 93, 0.13);
}

.poll-candidate.is-tied {
  background: rgba(229, 132, 38, 0.16);
}

.poll-candidate-mark {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}

/* La règle globale `svg` des graphiques impose une hauteur minimale. */
.poll-candidate-mark svg {
  display: block;
  flex: none;
  width: 11px;
  height: 11px;
  min-height: 0;
}

.poll-candidate.is-qualified .poll-candidate-mark {
  background: #2f8a5d;
}

.poll-candidate.is-tied .poll-candidate-mark {
  background: #d9771e;
}

.poll-candidate-name {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--ink);
  white-space: nowrap;
}

.poll-candidate-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.poll-candidate-name small {
  flex: none;
  color: var(--muted);
  font-size: 0.7rem;
}

.poll-candidate-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--track);
}

.poll-candidate-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--candidate-color);
  opacity: 0.45;
  transform-origin: left center;
  animation: poll-bar-in 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.poll-candidate-score {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.poll-candidate.is-qualified .poll-candidate-bar span,
.poll-candidate.is-tied .poll-candidate-bar span {
  opacity: 1;
}

.poll-candidate.is-qualified .poll-candidate-label,
.poll-candidate.is-qualified .poll-candidate-score,
.poll-candidate.is-tied .poll-candidate-label {
  color: var(--da-green, var(--ink));
  font-weight: 600;
}

.poll-candidate.is-tied .poll-candidate-score {
  color: #a4520f;
  font-weight: 600;
}

.poll-modal-foot[hidden] {
  display: none;
}

.poll-modal-foot {
  flex: none;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 14px 28px 20px;
  border-top: 1px solid rgba(46, 107, 98, 0.10);
}

.poll-modal-document {
  flex: none;
  display: inline-flex;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--da-accent, var(--accent));
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease;
}

.poll-modal-document:hover {
  background: var(--da-green, var(--ink));
}

.poll-modal-document:focus-visible {
  outline: 2px solid var(--da-accent, var(--accent));
  outline-offset: 3px;
}

/* La règle globale `svg` des graphiques impose une hauteur minimale. */
.poll-modal-document svg {
  display: block;
  flex: none;
  width: 15px;
  height: 15px;
  min-height: 0;
}

/* Onglets Sondage / Évolution : le contrôle segmenté du site, à deux choix. */
.segmented.poll-modal-tabs {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 250px);
  min-height: 38px;
  margin-top: 14px;
}

/* Colonne d'écart de l'onglet Sondage, quand l'institut avait déjà testé la
   même liste : « vs 8 juil. » en tête, « +1,5 » sur chaque ligne. */
.poll-scenario.has-delta .poll-candidate {
  grid-template-columns: 20px minmax(0, 12.5rem) minmax(40px, 1fr) 3.1rem 2.6rem;
}

.poll-candidate-delta {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.poll-delta-head {
  margin: -6px 0 4px;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: right;
  white-space: nowrap;
}

/* Choix de la vague comparée : un lien discret avec chevron plutôt qu'un champ. */
.poll-delta-select {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  padding: 0 12px 0 1px;
  border: 0;
  border-radius: 4px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%232c5f57' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right center / 8px 5px;
  color: var(--da-accent, var(--accent));
  font: inherit;
  font-weight: 600;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
  cursor: pointer;
}

.poll-delta-select:hover {
  color: var(--da-green, var(--ink));
}

.poll-delta-select:focus-visible {
  outline: 2px solid var(--da-accent, var(--accent));
  outline-offset: 2px;
}

/* Onglet Évolution : un mini-graphique par hypothèse, toutes les courbes
   ensemble. Survoler une courbe l'isole. */
/* Bouton d'export en haut à droite de chaque graphique, comme sur le
   graphique principal ; le titre lui laisse la place. */
.poll-evolution.has-export {
  position: relative;
}

.poll-evolution.has-export > h3,
.poll-evolution.has-export > .poll-scenario-meta {
  padding-right: 36px;
}

.poll-evolution .poll-evo-export {
  top: 0;
  right: 0;
}

.poll-modal-card.is-multi .poll-evolution .poll-evo-export {
  top: 14px;
  right: 16px;
}

.poll-evo-chart {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
  overflow: visible;
  margin-top: 2px;
}

.poll-evo-grid {
  stroke: var(--grid-line);
  stroke-width: 1;
}

.poll-evo-tick {
  fill: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.poll-evo-current {
  stroke: rgba(var(--ink-rgb), 0.3);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.poll-evo-series {
  transition: opacity 0.15s ease;
}

.poll-evo-chart:hover .poll-evo-series {
  opacity: 0.25;
}

.poll-evo-chart .poll-evo-series:hover {
  opacity: 1;
}

.poll-evo-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 9;
  pointer-events: stroke;
}

.poll-evo-line {
  fill: none;
  stroke: var(--candidate-color);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.poll-evo-line.is-strong {
  stroke-width: 2.8;
  opacity: 1;
}

.poll-evo-series circle {
  fill: var(--candidate-color);
  stroke: var(--panel);
  stroke-width: 0.8;
  opacity: 0.75;
}

.poll-evo-series circle.is-current {
  stroke-width: 1.2;
  opacity: 1;
}

.poll-evo-leader {
  fill: none;
  stroke: var(--candidate-color);
  stroke-width: 0.8;
  opacity: 0.45;
}

.poll-evo-label {
  fill: color-mix(in srgb, var(--candidate-color) 72%, #283d3b);
  font-size: 10.5px;
  font-weight: 500;
}

.poll-evo-label.is-strong {
  font-weight: 700;
}

.poll-evolution-empty {
  margin: 2px 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

@keyframes poll-modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}

@keyframes poll-bar-in {
  from {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .poll-modal-card,
  .poll-candidate-bar span {
    animation: none;
  }
}

@media (max-width: 560px) {
  .poll-modal {
    padding: 10px;
  }

  .poll-modal-card {
    max-height: calc(100vh - 20px);
    border-radius: 24px;
  }

  .poll-modal-head {
    padding: 20px 20px 14px;
  }

  .poll-modal-head h2 {
    font-size: 1.25rem;
  }

  .poll-modal-body {
    padding: 16px 20px 18px;
  }

  .poll-modal-foot {
    padding: 12px 20px 16px;
  }

  .poll-candidate {
    grid-template-columns: 20px minmax(0, 1fr) 3.2rem;
    row-gap: 4px;
    padding-block: 5px;
  }

  .poll-candidate-bar {
    grid-column: 2 / -1;
    grid-row: 2;
  }

  .poll-modal-document {
    width: 100%;
  }

  .poll-scenario.has-delta .poll-candidate {
    grid-template-columns: 20px minmax(0, 1fr) 3.2rem 2.4rem;
  }
}

/* Graphique intégré à un article (?integration=1) : le panneau du graphique
   seul, sans en-tête ni commandes. La période, les candidats et le duel sont
   fixés par l'URL ; la légende et les infobulles restent actives. */
.is-embed body {
  background: transparent;
}

.is-embed .shell {
  width: 100%;
  padding: 0;
}

.is-embed .shell > :not(.chart-panel),
.is-embed .chart-actions,
.is-embed .filters-card,
.is-embed .time-range-editor,
.is-embed .chart-settings,
.is-embed .chart-export-button {
  display: none !important;
}

.is-embed .chart-panel {
  margin: 0;
}
