/*
 * voter2027.fr — /immigration hub page. New file, loaded after public.css and scorecard.css
 * (scripts/immigration-page.php's public_vars() 'styles' array), so it only adds what those two
 * don't already give: the facts strip, the axis mini-track (own markup — NOT fiche.css's .fi-track,
 * which is templates/public/fiche.php's own file, mid-redesign by another agent), the candidates ×
 * axes grid (two layouts, same 44rem breakpoint as the rest of the site: comparer.php's
 * .comparer-cards/.comparer-table-wrap, candidats.css's .hemi-scores/.sheet), and the measures list.
 * Every colour/spacing value is a base.css token; badges/chips/icons are scorecard.css's shared
 * vocabulary (reused, not reforked) via .badge/.metric-chip/.flag-chip/.icon.
 */

.imm-sec { margin-top: var(--space-6); }
.imm-sec > h2 { margin-top: 0; }
.imm-sec:first-of-type { margin-top: var(--space-3); }
.imm-hero { margin-bottom: var(--space-3); }
.imm-lead { color: var(--color-text-muted); font-size: 1rem; max-width: var(--measure); }

/* ---------------------------------------------------------------- Les chiffres */

.imm-facts-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 calc(var(--gutter, 1rem) * -1);
  padding: 0 var(--gutter, 1rem);
}
.imm-facts {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0 0 var(--space-2);
}
.imm-fact {
  flex: 0 0 auto;
  width: 9rem;
  background: transparent;
  border: 0;
  border-top: 2px solid var(--color-rule);
  border-radius: 0;
  padding: var(--space-2) 0 0;
}
.imm-fact-value { margin: 0; font-size: 1.75rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.imm-fact-year { margin-left: 4px; font-size: 0.75rem; font-weight: 400; color: var(--color-text-muted); vertical-align: super; }
.imm-fact-unit { margin: 1px 0 0; font-size: 0.75rem; color: var(--color-text-muted); }
.imm-fact-label { margin: 4px 0 0; font-size: 0.875rem; line-height: 1.3; }
.imm-fact-src { margin: 4px 0 0; font-size: 0.75rem; }
.imm-fact-src a { color: var(--color-text-muted); }

/* ---------------------------------------------------------------- Qui décide quoi */

.imm-decides { margin: 0 0 var(--space-3); padding-left: 1.1em; }
.imm-decides li { margin-bottom: var(--space-2); line-height: 1.4; }

/* ---------------------------------------------------------------- axis mini-track (own component, not fiche.css's) */

.imm-axis-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 7px 0;
  border-top: 1px solid var(--color-border);
  min-height: 44px;
}
.imm-pos-card .imm-axis-row:first-of-type { border-top: none; }
.imm-axis-label { font-size: 0.86rem; line-height: 1.25; }

.imm-track { position: relative; display: inline-block; width: 54px; height: 16px; vertical-align: middle; flex-shrink: 0; }
.imm-track::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; border-top: 2px solid var(--color-border); }
.imm-track.is-unknown::before { border-top-style: dotted; }
.imm-ticks { position: absolute; inset: 3px 0; display: flex; justify-content: space-between; }
.imm-ticks i { width: 2px; height: 8px; background: var(--color-border); }
.imm-ticks i:nth-child(3) { background: var(--color-text-muted); opacity: .6; }
.imm-dot {
  position: absolute; top: 2px; width: 12px; height: 12px; border-radius: 50%;
  transform: translateX(-50%); border: 2px solid var(--color-accent); background: var(--color-accent);
}
.imm-dot.is-ded { background: var(--color-surface); }
.imm-dot.mini { position: static; display: inline-block; transform: none; width: 10px; height: 10px; margin-right: 3px; vertical-align: -1px; }
.imm-track-mini { display: inline-block; width: 20px; height: 0; border-top: 2px dotted var(--color-border); margin: 0 3px 0 8px; vertical-align: middle; }

.imm-pole { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; justify-self: end; }
.imm-pole-unknown { color: var(--color-text-muted); font-weight: 400; }
.imm-ded-tag { font-size: 0.75rem; font-weight: 400; color: var(--color-text-muted); }

/* each candidate's positions sit on a board (.panneau in the markup) */
.imm-pos-card { padding: 10px 12px; margin-bottom: var(--space-3); }
.imm-pos-card-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-weight: 700; margin: 0 0 2px; }
.imm-pos-legend { margin-top: var(--space-2); }

/* ---------------------------------------------------------------- positions: layout switch (same 44rem breakpoint site-wide) */

.imm-pos-table-wrap { display: none; }

@media (min-width: 44rem) {
  .imm-pos-cards { display: none; }

  /* The only horizontally-scrolling element on this table — overflow-x lives here only, same
     pattern as comparer.php's .comparer-table-wrap, so a 7-axis-wide table never scrolls the page. */
  .imm-pos-table-wrap {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-top: 1px solid var(--color-rule);
    border-bottom: 1px solid var(--color-rule);
    margin-bottom: var(--space-2);
  }
  .imm-pos-table { table-layout: fixed; border-collapse: separate; border-spacing: 0; width: auto; }
  col.imm-pos-col-name { width: 12rem; }
  col.imm-pos-col-axis { width: 7.5rem; }
  .imm-pos-table th, .imm-pos-table td { padding: var(--space-2); border-bottom: 1px solid var(--color-border); vertical-align: middle; text-align: left; }
  .imm-pos-table tbody tr:last-child th, .imm-pos-table tbody tr:last-child td { border-bottom: none; }
  .imm-pos-table thead th { font-size: 0.8125rem; font-weight: 600; border-bottom: 1px solid var(--color-rule); }
  /*
   * The cell stays a normal table-cell (removing that keeps row heights consistent so the sticky
   * first column lines up with its row) — only the track and pole word inside it stack vertically,
   * via block-level spans, not by changing the <td>'s own display (found 2026-09-27: `display:
   * block` on the <td> itself broke row alignment, the sticky name column no longer matched its
   * row's cells).
   */
  .imm-pos-table td .imm-track { display: block; margin-bottom: 3px; }
  .imm-pos-table td .imm-pole { display: block; }
  .imm-pos-th-name {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--color-bg);
    font-weight: 600;
    font-size: 0.9375rem;
  }
  .imm-pos-th-party { display: block; font-weight: 400; font-size: 0.72rem; color: var(--color-text-muted); margin-top: 2px; }
}

/* ---------------------------------------------------------------- measures */

.imm-measure summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-height: 44px;
}
.imm-measure summary::-webkit-details-marker { display: none; }
.imm-measure-label { font-weight: 600; font-size: 1.0625rem; flex: 1 1 100%; }
.imm-measure-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.imm-measure-count { margin-left: auto; color: var(--color-text-muted); font-size: 0.8rem; }
.imm-measure-body { padding-top: var(--space-2); border-top: 1px solid var(--color-border); margin-top: var(--space-2); }
.imm-measure-params-h, .imm-measure-proposers-h { font-size: var(--fs-1); font-weight: 400; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); margin: var(--space-3) 0 4px; }
.imm-measure-params { margin: 0; padding-left: 1.1em; font-size: 0.88rem; }
.imm-measure-params li { margin-bottom: 4px; }
.imm-measure-proposers { list-style: none; margin: 0; padding: 0; }
.imm-measure-proposers li { padding: 7px 0; border-top: 1px solid var(--color-border); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.imm-measure-proposers li:first-child { border-top: none; }
.imm-measure-proposer-text { flex: 1 1 100%; font-size: 0.88rem; color: var(--color-text-muted); }

/* ---------------------------------------------------------------- pledges by candidate: one line each, open in place */

.imm-cand-group { border-bottom: 1px solid var(--color-border); }
.imm-cand-group:first-of-type { border-top: 1px solid var(--color-rule); }
.imm-cand-group-h { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-height: 48px; padding: 10px 28px 10px 0; cursor: pointer; list-style: none; position: relative; }
.imm-cand-group-h::-webkit-details-marker { display: none; }
.imm-cand-group-h::after { content: "+"; position: absolute; right: 2px; top: 10px; font-size: 1.5rem; line-height: 1; color: var(--color-accent); transition: transform .2s; }
.imm-cand-group[open] > .imm-cand-group-h::after { transform: rotate(45deg); }
.imm-cand-name { font-weight: 600; font-size: 1.0625rem; }
.imm-cand-count { margin-left: auto; font-size: var(--fs-1); color: var(--color-text-muted); }
.imm-cand-group[open] { padding-bottom: var(--space-3); }
.imm-cand-sheet { margin: 0 0 var(--space-2); font-size: 0.9375rem; }
.imm-obstacle { display: block; margin-top: 4px; }

/* phone: the candidates' position boards are one horizontal snap row, not 15 stacked cards */
@media (max-width: 43.99rem) {
  .imm-pos-cards {
    display: grid; grid-auto-flow: column; grid-auto-columns: min(84%, 20rem); gap: 10px;
    overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
    margin: 0 calc(-1 * var(--gutter, 1rem)); padding: 0 var(--gutter, 1rem) 10px; scroll-padding-inline: var(--gutter, 1rem);
  }
  .imm-pos-cards > .imm-pos-card { scroll-snap-align: start; margin-bottom: 0; }
}

/* section index, sticky under the header on long pages */
.page-index {
  position: sticky; top: var(--sticky-top, 0px); z-index: 6;
  display: flex; gap: 18px; overflow-x: auto; scrollbar-width: none;
  margin: var(--space-2) calc(-1 * var(--gutter, 1rem)) 0; padding: 0 var(--gutter, 1rem);
  background: var(--color-bg); border-bottom: 1px solid var(--color-divider);
}
.page-index::-webkit-scrollbar { display: none; }
.page-index a { flex: 0 0 auto; display: flex; align-items: center; min-height: 44px; font-size: 0.8125rem; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 400; color: var(--color-text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.page-index a:hover { color: var(--color-accent); border-bottom-color: var(--color-accent); }
.imm-sec { scroll-margin-top: calc(var(--sticky-top, 0px) + 52px); }
@media (min-width: 44rem) { .page-index { margin-left: 0; margin-right: 0; padding: 0; gap: 24px; } }

/* ---------------------------------------------------------------- vérifications rows */

.imm-rows { list-style: none; margin: 0 0 var(--space-3); padding: 0; }
.imm-rows li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--color-divider); }
.imm-rows li:first-child { border-top: 1px solid var(--color-rule); }
.imm-row-text { flex: 1 1 100%; font-size: 0.9375rem; }

/* ---------------------------------------------------------------- aller plus loin */

.imm-links ul { padding-left: 1.1em; }
.imm-links li { margin-bottom: var(--space-2); }
