/* Partie de styles.css : projection, comparaison, rythme des sondages, boutons d'action, invitation au second tour.
   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. */

/* Projection de la tendance : même cadre que les vignettes de duels, une
   vignette par candidat, sans interaction. */
.projection-panel {
  margin-top: 64px;
  padding: 30px 28px 32px;
  border: 2px solid var(--frame);
  border-radius: 2px;
  background: var(--panel);
}

.projection-panel[hidden] {
  display: none;
}

.projection-panel .panel-lede {
  max-width: 820px;
}

.projection-intro {
  max-width: 820px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.projection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.projection-tile {
  border: 1px solid var(--line);
  border-bottom: 2px solid var(--line-strong);
  border-radius: 2px;
  background: var(--surface);
  padding: 12px 12px 10px;
}

.projection-tile-head {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 640;
}

.projection-tile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Ligne « Actuel » : séparée des deux projections par un filet. */
.projection-tile-horizons .is-current {
  margin-bottom: 2px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--line);
}

.projection-tile-chart {
  display: block;
  width: 100%;
  /* Comme les vignettes de duels : la règle globale `svg` imposerait la
     hauteur du grand graphique. */
  height: auto;
  min-height: 0;
  aspect-ratio: 300 / 132;
  margin-top: 6px;
}

.projection-tile-today {
  stroke: var(--line-strong);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}

.projection-fan.is-outer {
  opacity: 0.12;
}

.projection-fan.is-inner {
  opacity: 0.22;
}

.projection-history {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.projection-line {
  fill: none;
  stroke-width: 2;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
}

.projection-tile-horizons {
  display: grid;
  grid-template-columns: auto 1fr;
  /* Pas d'espace entre colonnes (remplacé par la marge des valeurs) : le filet
     sous « Actuel » reste ainsi d'un seul tenant. */
  gap: 2px 0;
  margin: 6px 0 0;
  font-size: 0.8rem;
}

.projection-tile-horizons dt {
  color: var(--muted);
}

.projection-tile-horizons dd {
  margin: 0;
  padding-left: 10px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.projection-tile-horizons strong {
  color: var(--ink);
  font-weight: 680;
}

/* Évolution en points depuis le score actuel, juste après la projection. */
.projection-tile-delta {
  color: var(--ink);
  font-weight: 560;
  white-space: nowrap;
}

.projection-legend {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.projection-panel .nowcast-head {
  align-items: flex-start;
}

.projection-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.projection-actions .chart-export-button[hidden] {
  display: none;
}

.projection-view {
  flex: 0 0 auto;
}

.projection-grid[hidden],
.projection-combined[hidden] {
  display: none;
}

/* Largeur plafonnée et centrée : en pleine largeur, 180 jours sur plus de
   1 000 px étiraient les courbes à plat. */
.projection-combined {
  max-width: 860px;
  margin: 22px auto 0;
}

.projection-combined svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 0;
}

.projection-combined-grid {
  pointer-events: none;
}

.projection-combined-grid line {
  stroke: var(--line);
  stroke-width: 1;
}

.projection-combined-grid .projection-tile-today {
  stroke: var(--line-strong);
  stroke-dasharray: 2 3;
}

.projection-combined-future {
  fill: rgba(var(--ink-rgb), 0.035);
}

.projection-combined-tick,
.projection-combined-date {
  fill: var(--muted);
  font-size: 11px;
  dominant-baseline: middle;
}

.projection-combined-label {
  font-size: 12.5px;
  font-weight: 680;
  dominant-baseline: middle;
}

.projection-combined-label.is-compact {
  font-size: 11px;
}

/* Évolution en points depuis le dernier sondage, après le score à J+60. */
.projection-combined-delta {
  font-weight: 520;
}

.projection-combined .projection-fan.is-outer {
  opacity: 0;
  transition: opacity 0.15s;
}

.projection-combined .projection-fan.is-inner {
  opacity: 0.13;
}

.projection-combined .projection-series {
  transition: opacity 0.15s;
}

/* Au toucher, le survol resterait collé après un tap : la mise en avant est
   réservée aux pointeurs qui survolent vraiment. */
@media (hover: hover) {
  .projection-combined svg:hover .projection-series:not(:hover) {
    opacity: 0.28;
  }
}

.projection-combined .projection-series:hover .projection-fan.is-outer {
  opacity: 0.12;
}

.projection-combined .projection-series:hover .projection-fan.is-inner {
  opacity: 0.24;
}

@media (max-width: 640px) {
  .projection-panel {
    padding: 20px 16px;
  }

  .projection-panel .nowcast-head {
    flex-direction: column;
    gap: 12px;
  }
}

.comparison-panel {
  margin-top: 64px;
  border: 2px solid var(--chestnut);
  border-radius: 2px;
  background: var(--panel);
}

.comparison-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 28px;
  padding: 30px 28px 0;
}

.comparison-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

/* Phrase de lecture : ce que montre le graphique, écrit en toutes lettres et
   recalculé à chaque rendu. Elle passe avant la note de méthode, qui reste en
   dessous, plus petite et en gris — l'ordre visuel suit l'ordre de lecture. */
p.panel-lede {
  margin-top: 12px;
  max-width: 74ch;
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.55;
  font-weight: 560;
}

p.panel-lede[hidden] {
  display: none;
}

p.panel-lede + p {
  margin-top: 8px;
  font-size: 0.86rem;
}

.action-button,
.icon-button {
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: var(--dark-slate);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 680;
}

.action-button {
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
}

.action-button:hover,
.icon-button:hover {
  background: var(--stormy-teal);
}

.nowcast-scenarios-cta {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  margin-bottom: 46px;
  padding: 0 28px;
}

/* L'invitation vers le détail hypothèse par hypothèse suit le bloc de
   synthèse, sans en faire partie. */
.nowcast-scenarios-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  grid-column: 2;
  justify-self: end;
  text-decoration: none;
}

.comparison-controls {
  display: grid;
  gap: 12px;
  padding: 22px 30px 0;
}

.comparison-row {
  display: grid;
  grid-template-columns: 13px minmax(126px, 0.42fr) minmax(210px, 1fr) 34px;
  gap: 12px;
  align-items: end;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(var(--ink-rgb), 0.12);
}

.comparison-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.comparison-swatch {
  width: 13px;
  height: 13px;
  margin-bottom: 14px;
  border-radius: 50%;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-width: 34px;
  max-width: 34px;
  height: 34px;
  min-height: 34px;
  max-height: 34px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.icon-button svg {
  display: block;
  width: 18px;
  height: 18px;
  margin: 0;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  pointer-events: none;
}

.danger-icon-button {
  position: relative;
  align-self: end;
  justify-self: end;
  border-color: rgba(196, 69, 54, 0.64);
  background: rgba(196, 69, 54, 0.12);
  color: var(--tomato-jam);
}

.danger-icon-button:hover {
  border-color: var(--tomato-jam);
  background: var(--tomato-jam);
  color: #ffffff;
}

.comparison-chart-wrap {
  min-height: 440px;
}

.comparison-chart-wrap svg {
  height: 460px;
  min-height: 440px;
}

.poll-pace-panel {
  margin-top: 32px;
}

.poll-pace-control {
  flex: 0 0 auto;
}

/* Le bouton d'export s'aligne sur le sélecteur de période, pas sur son libellé. */
.poll-pace-actions {
  align-items: flex-end;
}

.poll-pace-actions .comparison-export {
  margin-bottom: 7px;
}

.poll-pace-range {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-width: 250px;
}

/* Hauteur dictée par la viewBox : les hauteurs fixes des autres graphiques
   laisseraient un grand vide sous ce tracé plus bas. */
.chart-wrap.poll-pace-chart-wrap,
.chart-wrap.poll-pace-chart-wrap svg {
  min-height: 0;
  height: auto;
}

@media (max-width: 860px) {
  .poll-pace-actions {
    margin-top: 16px;
  }
}

.poll-pace-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  opacity: 0.85;
}

.poll-pace-line.is-target {
  stroke-width: 3.6;
  opacity: 1;
}

.poll-pace-line.is-pending {
  stroke-width: 2.4;
  stroke-dasharray: 2 5;
  stroke-linecap: round;
}

.poll-pace-today line {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.poll-pace-today text {
  fill: var(--muted);
  font-size: 0.72rem;
}

/* Menu intégré à la phrase : il se lit comme le texte, souligné en pointillé. */
.inline-select {
  appearance: none;
  -webkit-appearance: none;
  field-sizing: content;
  max-width: 100%;
  margin: 0;
  padding: 0 1.1em 0 0;
  border: 0;
  border-bottom: 1px dotted currentColor;
  border-radius: 0;
  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='%23197278' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 0.15em center / 0.65em;
  color: var(--stormy-teal, #197278);
  font: inherit;
  cursor: pointer;
}

.inline-select:focus-visible {
  outline: 2px solid var(--stormy-teal, #197278);
  outline-offset: 2px;
}

.end-label.is-target {
  font-weight: 800;
}

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

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

.comparison-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(40, 61, 59, 0.46);
}

.comparison-modal-card {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  border: 2px solid var(--frame);
  border-radius: 2px;
  background: var(--panel);
  padding: 24px;
}

.comparison-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 22px;
}

.comparison-modal-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.comparison-modal-head .icon-button {
  flex: 0 0 34px;
}

.comparison-modal-tools {
  margin-bottom: 22px;
}

.comparison-modal-tools .time-control {
  width: min(100%, 280px);
}

.comparison-modal-card .comparison-controls {
  padding: 0;
}

.comparison-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.comparison-modal-actions .action-button {
  margin-top: 0;
}

.nowcast-scenario-candidate {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border: 1px solid rgba(var(--ink-rgb), 0.18);
  border-radius: 99px;
  background: rgba(var(--panel-rgb), 0.78);
  padding: 2px 8px;
  color: var(--heading);
  font-size: 0.79rem;
  line-height: 1.2;
}

.nowcast-scenario-candidate::before {
  width: 7px;
  height: 7px;
  margin-right: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--scenario-candidate-color);
  content: "";
}

.secondary-action {
  background: var(--panel);
  color: var(--heading);
}

.secondary-action:hover {
  background: rgba(237, 221, 212, 0.42);
  color: var(--heading);
}

/* Invitation au second tour, en bas du premier tour : le second tour est un
   autre jeu de données, pas un filtre, donc il se propose explicitement. */
.second-round-cta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px 28px;
  flex-wrap: wrap;
  margin-top: 64px;
  padding: 30px 28px;
  border: 2px solid var(--tomato-jam);
  border-radius: 2px;
  background: var(--panel);
}

.second-round-cta[hidden] {
  display: none;
}

.second-round-cta p {
  margin-top: 6px;
  max-width: 60ch;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}
