/*
 * voter2027.fr — /candidats showcase: the hemicycle, the scorecard sheet, the comparison grid, the
 * polls chart. Loaded after base.css, public.css and scorecard.css; every colour is a base.css token
 * (light and dark), every chip/badge/bar class comes from scorecard.css or base.css. Nothing here is
 * a party colour: seats and poll lines are ink and grey, the selected one is the site accent.
 *
 * Motion: only transform and opacity are animated (60 fps on an iPhone). The settled state is what
 * the server renders; candidats.js adds the `is-armed` classes that hide things before they play,
 * and never adds them when prefers-reduced-motion is set, so the page lands settled.
 *
 * CSP is default-src 'self' with no style-src 'unsafe-inline': no inline style attributes anywhere.
 * Bar widths are SVG attributes; anything dynamic is set from JS through element.style.
 */

.cand-page { --hemi-ink: var(--color-text); }
.cand-hero h1 { margin-bottom: var(--space-1); }
.cand-lede { color: var(--color-text-muted); max-width: 62ch; margin-bottom: var(--space-3); }
.scene { margin-top: var(--space-5); }
.scene-hemicycle { margin-top: var(--space-2); }
.cmp-note { color: var(--color-text-muted); font-size: 0.85rem; margin: var(--space-2) 0 var(--space-3); }

/* ---------------------------------------------------------------- scene 1: hemicycle */

.hemi-figure { margin: 0; }
.hemi { display: block; width: 100%; height: auto; overflow: visible; }
.hemi .bench { fill: none; stroke: var(--color-border); stroke-width: 12; stroke-dasharray: 9 9; stroke-linecap: butt; opacity: 0.85; }
.hemi .hemi-desk { fill: var(--color-border); }
.hemi-pole { fill: var(--color-text-muted); font-size: 24px; font-weight: 600; letter-spacing: 0.02em; }

.seat { transform-box: fill-box; transform-origin: center; }
.seat-link { cursor: pointer; outline: none; }
.seat-disc { fill: var(--color-surface); stroke: var(--hemi-ink); stroke-width: 3; transition: stroke-width .15s, fill .15s; }
.seat-init { fill: var(--hemi-ink); font-size: 22px; font-weight: 700; pointer-events: none; }
.seat-link:hover .seat-disc { stroke-width: 5; }
.seat-link:focus-visible .seat-disc { stroke: var(--color-focus); stroke-width: 7; }
.seat.is-active .seat-disc { fill: var(--color-accent); stroke: var(--color-accent); }
.seat.is-active .seat-init { fill: var(--color-accent-contrast); }
.hemi-seats.is-dim .seat:not(.is-active) { opacity: 0.55; }
.hemi-seats.is-dim .seat { transition: opacity .2s; }

/* pre-animation state (only ever set by JS, never on a reduced-motion or no-JS page) */
.hemi.is-armed .seat, .hemi.is-armed .hemi-pole, .hemi.is-armed .hemi-benches { opacity: 0; }

.hemi-caption { text-align: center; color: var(--color-text-muted); font-size: 0.85rem; min-height: 2.6em; margin: var(--space-2) 0 0; padding: 0 var(--space-2); }
.hemi-caption strong { color: var(--color-text); }
.hemi-caption-text { display: inline-block; }

/* the ribbon: every name in seat order, left to right — the labels the SVG cannot fit on a phone */
.hemi-ribbon { list-style: none; margin: var(--space-2) 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; }
.ribbon-item {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 34px; padding: 2px 10px 2px 4px;
  border: 1px solid var(--color-border); border-radius: 999px;
  background: var(--color-surface); color: var(--color-text);
  text-decoration: none; font-size: 0.8rem; font-weight: 600; white-space: nowrap;
}
.ribbon-init { width: 24px; height: 24px; border-radius: 50%; background: var(--color-surface-2); color: var(--color-text); font-size: 0.62rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.ribbon-item:hover { border-color: var(--hemi-ink); }
.ribbon-item.is-active { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-contrast); }
.ribbon-item.is-active .ribbon-init { background: var(--color-accent-contrast); color: var(--color-accent); }
.hemi.is-armed ~ .hemi-ribbon .ribbon-item, .hemi-figure.is-armed + .hemi-ribbon .ribbon-item { opacity: 0; }

.hemi-method { margin-top: var(--space-3); border-top: 1px solid var(--color-border); padding-top: var(--space-2); }
.hemi-method summary { cursor: pointer; color: var(--color-link); font-size: 0.9rem; font-weight: 600; min-height: 40px; display: inline-flex; align-items: center; }
.hemi-method-body { font-size: 0.9rem; color: var(--color-text-muted); }
.hemi-method-body p { max-width: 70ch; }
.hemi-scores { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: grid; gap: 2px 18px; grid-template-columns: 1fr; font-size: 0.85rem; }
@media (min-width: 44rem) { .hemi-scores { grid-template-columns: 1fr 1fr 1fr; } }
.hemi-scores li { display: flex; gap: 8px; align-items: baseline; min-height: 28px; }
.hemi-score-val { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--color-text); min-width: 3.2em; text-align: right; }
.hemi-score-n { color: var(--color-text-muted); font-size: 0.78rem; }

/* ---------------------------------------------------------------- scene 2: the sheet (bottom sheet on iPhone, side panel on desktop) */

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 18px 18px 0 0;
  background: var(--color-surface);
  color: var(--color-text);
  max-height: 88dvh;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.sheet::backdrop { background: rgba(10, 14, 20, 0.38); }
.sheet-inner { display: flex; flex-direction: column; max-height: 88dvh; }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--color-border); margin: 8px auto 0; flex: 0 0 auto; }
.sheet-close {
  position: absolute; top: 4px; right: 6px;
  width: 44px; height: 44px;
  border: 0; background: none; color: var(--color-text-muted);
  font-size: 1.7rem; line-height: 1; cursor: pointer; border-radius: 50%;
}
.sheet-close:hover { background: var(--color-surface-2); }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px var(--space-3) var(--space-3); overscroll-behavior: contain; }
.sheet-nav { display: flex; gap: 8px; padding: 8px var(--space-3) calc(8px + var(--safe-bottom, 0px)); border-top: 1px solid var(--color-border); flex: 0 0 auto; background: var(--color-surface); }
.sheet-nav-btn { flex: 1 1 0; min-height: 44px; padding: 0.4em 0.6em; font-size: 0.9rem; }
@media (min-width: 44rem) {
  .sheet { inset: 0 0 0 auto; width: min(460px, 100%); height: 100dvh; max-height: 100dvh; border-radius: 0; box-shadow: -12px 0 40px rgba(0, 0, 0, 0.22); }
  .sheet-inner { height: 100dvh; max-height: 100dvh; }
  .sheet-grip { display: none; }
  .sheet-body { padding-top: var(--space-3); }
}

.sheet-head { display: flex; align-items: center; gap: var(--space-2); padding-right: 44px; margin-bottom: var(--space-2); }
.sheet-head h2 { font-size: 1.2rem; margin: 0 0 2px; line-height: 1.2; }
.sheet-head .candidate-party { margin: 0; font-size: 0.85rem; color: var(--color-text-muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sheet-place { font-size: 0.8rem; color: var(--color-text-muted); margin: 0 0 var(--space-2); }
.sheet-place b { color: var(--color-text); font-variant-numeric: tabular-nums; }

.sheet-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: var(--space-3); }
.sheet-tile {
  background: color-mix(in srgb, var(--lvl, var(--color-text-muted)) 10%, var(--color-surface));
  border: 1px solid color-mix(in srgb, var(--lvl, var(--color-border)) 40%, var(--color-border));
  border-radius: var(--radius);
  padding: 8px 10px;
  min-height: 62px;
  display: flex; flex-direction: column; gap: 2px;
}
.sheet-tile .icon { color: var(--lvl, var(--color-text-muted)); }
.sheet .tile-label { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--color-text-muted); text-transform: none; letter-spacing: 0; }
.tile-value { font-size: 0.95rem; font-weight: 700; line-height: 1.2; }
.tile-value-muted { color: var(--color-text-muted); font-weight: 600; font-size: 0.85rem; }
.tile-sub { font-size: 0.75rem; color: var(--color-text-muted); }

/* the animated feasibility distribution: a div bar, segments sized from JS, the whole bar reveals with scaleX */
.dist-bar { display: flex; width: 100%; height: 8px; border-radius: 4px; overflow: hidden; background: var(--color-border); margin-top: 4px; transform-origin: left center; }
.dist-bar span { height: 100%; flex: 0 0 auto; }
.dist-bar .seg-4 { background: var(--color-badge-4); }
.dist-bar .seg-3 { background: var(--color-badge-3); }
.dist-bar .seg-2 { background: var(--color-badge-2); }
.dist-bar .seg-1 { background: var(--color-badge-1); }
.dist-legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: 0.7rem; color: var(--color-text-muted); margin-top: 3px; }
.dist-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 3px; vertical-align: middle; }

.sheet h3 { font-size: 0.95rem; margin: var(--space-3) 0 var(--space-2); }
.reel { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--space-3)); padding: 4px var(--space-3) 10px; scrollbar-width: thin; }
.reel-card {
  flex: 0 0 min(78%, 280px);
  scroll-snap-align: start;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 132px;
}
.reel-theme { font-size: 0.72rem; font-weight: 700; color: var(--color-text-muted); letter-spacing: 0.01em; }
.reel-text { font-size: 0.86rem; line-height: 1.4; margin: 0; flex: 1 1 auto; }
.reel-foot { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.reel-foot .badge { font-size: 0.68rem; padding: 0.15em 0.55em; }
.reel-foot .flag-chip-row { margin-top: 0; }
.reel-empty { color: var(--color-text-muted); font-size: 0.85rem; }
.sheet-cta { margin: var(--space-2) 0 0; }
.sheet-cta .btn { width: 100%; }

/* ---------------------------------------------------------------- scene 3: compare at a glance */

.cmp-sort { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0; }
.cmp-sort-label { font-size: 0.85rem; color: var(--color-text-muted); margin-right: 2px; }
.segbtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 4px 12px;
  border-radius: 999px; border: 1px solid var(--color-border);
  background: var(--color-surface); color: var(--color-text);
  font: inherit; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.segbtn:hover { background: var(--color-surface-2); }
.segbtn[aria-pressed="true"] { background: var(--color-accent); color: var(--color-accent-contrast); border-color: var(--color-accent); }

.cmp-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cmp-row {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid; grid-template-columns: 1fr; gap: 8px;
}
.cmp-row.is-hot { border-color: var(--color-accent); }
@media (min-width: 44rem) { .cmp-row { grid-template-columns: 230px 1fr; align-items: center; gap: 16px; } }
.cmp-name { display: flex; gap: 8px; align-items: center; text-decoration: none; color: inherit; min-width: 0; }
.cmp-name-text { display: flex; flex-direction: column; min-width: 0; }
.cmp-name-text strong { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-name-text .candidate-party { font-size: 0.78rem; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
@media (min-width: 44rem) { .cmp-bars { grid-template-columns: repeat(4, 1fr); } }
.cmp-bar { display: grid; gap: 3px; font-size: 0.72rem; min-width: 0; }
.cmp-bar-label { display: inline-flex; align-items: center; gap: 4px; color: var(--color-text-muted); }
.cmp-bar-label .icon { width: 13px; height: 13px; color: var(--lvl, var(--color-text-muted)); }
.cmp-bar-svg { display: block; width: 100%; height: 8px; border-radius: 4px; overflow: hidden; }
.bar-track { fill: var(--color-border); }
.bar-fill { fill: var(--lvl, var(--color-text-muted)); transform-box: fill-box; transform-origin: left center; }
.cmp-bar-val { font-weight: 600; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-compare.is-armed .cmp-row:not(.is-in) .bar-fill { transform: scaleX(0); }
.cmp-row.is-in .bar-fill { transform: scaleX(1); transition: transform .9s cubic-bezier(.2, .7, .2, 1); }

/* ---------------------------------------------------------------- scene 4: polls */

.poll-controls { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: var(--space-2); }
.poll-toggle { display: none; flex-wrap: wrap; gap: 6px; }
.js .poll-toggle { display: flex; }
.poll-family .segbtn { font-weight: 500; }
.poll-family-n { color: inherit; opacity: 0.7; font-weight: 400; margin-left: 4px; }
.poll-tip { font-size: 0.8rem; color: var(--color-text-muted); min-height: 2.4em; margin: var(--space-2) 0 0; }
.poll-tip strong { color: var(--color-text); }
.pc-dot-partial { fill: var(--color-surface); stroke-dasharray: 2 2; }
.pc-dot:hover { r: 5; }
.poll-bar-other .poll-bar-name { color: var(--color-text-muted); }
.poll-bar-note { font-size: 0.72rem; }
.poll-hyps { margin: 4px 0 0; padding-left: 1.1em; }
.poll-hyps li { margin-bottom: 2px; }
.poll-hyp-main { color: var(--color-text); font-weight: 600; }
.poll-view[hidden] { display: none; }
.poll-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 calc(-1 * var(--space-3)); padding: 0 var(--space-3); }
.poll-scroll[hidden] { display: none; }
.poll-chart { display: block; min-width: 640px; width: 100%; height: auto; }
.pc-grid { stroke: var(--color-border); stroke-width: 1; }
.pc-axis { fill: var(--color-text-muted); font-size: 14px; }
.pc-series { transition: opacity .2s; }
.pc-line { fill: none; stroke: var(--color-text-muted); stroke-width: 2; opacity: 0.6; stroke-linejoin: round; stroke-linecap: round; transition: opacity .2s; }
.pc-dot { fill: var(--color-surface); stroke: var(--color-text-muted); stroke-width: 1.5; opacity: 0.6; }
.pc-leader { stroke: var(--color-border); stroke-width: 1; }
.pc-label { fill: var(--color-text); font-size: 13px; font-weight: 600; cursor: default; }
.pc-label-val { fill: var(--color-text-muted); font-weight: 400; }
.poll-chart-note { margin-top: var(--space-2); }
.poll-notices-more { margin-top: var(--space-2); }
.poll-notices-more summary { cursor: pointer; font-size: 0.85rem; color: var(--color-link); min-height: 36px; display: inline-flex; align-items: center; }
.poll-notices-more .poll-notices { margin-top: var(--space-2); }
.pc-series.is-hot .pc-line { stroke: var(--color-accent); opacity: 1; stroke-width: 3; }
.pc-series.is-hot .pc-dot { stroke: var(--color-accent); opacity: 1; }
.pc-series.is-hot .pc-label, .pc-series.is-hot .pc-label-val { fill: var(--color-accent); }
.pc-series.is-hot .pc-leader { stroke: var(--color-accent); }
.poll-chart.has-hot .pc-series:not(.is-hot) { opacity: 0.3; }
.poll-last-title { font-size: 0.85rem; color: var(--color-text-muted); margin-bottom: var(--space-2); }
.poll-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.poll-bar { display: grid; grid-template-columns: minmax(96px, 1fr) 2fr 3.6em; gap: 8px; align-items: center; font-size: 0.85rem; }
.poll-bar.is-hot .poll-bar-name { color: var(--color-accent); font-weight: 700; }
.poll-bar.is-hot .bar-fill { fill: var(--color-accent); }
.poll-bar-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.poll-bar-svg { display: block; width: 100%; height: 10px; border-radius: 5px; overflow: hidden; }
.poll-bar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.poll-notices-title { font-size: 0.9rem; margin-top: var(--space-4); }
.poll-notices { margin: 0; padding-left: 1.1em; font-size: 0.8rem; color: var(--color-text-muted); }
.poll-notices li { margin-bottom: 6px; }
.poll-notice, .poll-empty { background: var(--color-surface-2); border: 1px solid var(--color-border); border-radius: var(--radius); padding: var(--space-3); font-size: 0.9rem; }
.poll-empty p:last-child { margin-bottom: 0; }
.poll-blackout { font-weight: 600; }

/* ---------------------------------------------------------------- scene 5: dense list — CSP-safe stacked bar */

svg.stacked-bar { display: inline-block; width: 44px; height: 6px; border-radius: 3px; overflow: hidden; flex-shrink: 0; }
svg.stacked-bar rect.seg-4 { fill: var(--color-badge-4); }
svg.stacked-bar rect.seg-3 { fill: var(--color-badge-3); }
svg.stacked-bar rect.seg-2 { fill: var(--color-badge-2); }
svg.stacked-bar rect.seg-1 { fill: var(--color-badge-1); }

@media (prefers-reduced-motion: reduce) {
  .cmp-row.is-in .bar-fill, .scene-compare.is-armed .cmp-row:not(.is-in) .bar-fill { transform: none; transition: none; }
  .hemi.is-armed .seat, .hemi.is-armed .hemi-pole, .hemi.is-armed .hemi-benches { opacity: 1; }
  .hemi-figure.is-armed + .hemi-ribbon .ribbon-item { opacity: 1; }
}
