/* ---------------------------------------------------------
   Habillage de la page autonome "Recherche commune".
   Le système de design (tokens, typographie, composants
   .tool-panel / .result-panel / .ring / .metric-bar…) vient
   entièrement de ../styles.css : cette page ne redéfinit rien,
   elle réutilise les mêmes classes que le simulateur du site.
--------------------------------------------------------- */

.intro-tool .lede { margin-top: 2px; margin-bottom: 0; }

.intro-tool .tool-panel { max-width: none; margin: 22px 0 0; }
.intro-tool .result-panel { max-width: none; margin: 24px 0 0; }

.intro-tool code,
.file-fallback code {
  padding: 2px 6px;
  background: var(--blue-soft);
  border-radius: 4px;
  font-size: .88em;
}

/* ---------------------------------------------------------
   Comparaison avec les autres communes de l'intercommunalité
   et du département
--------------------------------------------------------- */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 26px;
}

.compare-block {
  padding: 16px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.compare-title { margin: 0 0 12px; color: var(--ink); font-size: .92rem; font-weight: 700; }

.compare-rows { display: grid; gap: 4px; }

.compare-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 6px;
  margin: 0 -6px;
  border-radius: 4px;
  font-size: .86rem;
}

.compare-row.is-clickable {
  cursor: pointer;
  border: 0;
  background: none;
  width: calc(100% + 12px);
  font-family: inherit;
  font-size: .86rem;
  font-weight: inherit;
  line-height: inherit;
  text-align: left;
}

.compare-row.is-clickable:hover,
.compare-row.is-clickable:focus-visible { background: var(--white); }
.compare-row.is-clickable:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.compare-row .compare-tag { flex-shrink: 0; color: var(--muted); font-weight: 600; }
.compare-row .compare-name { flex: 1; min-width: 0; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compare-row .compare-figure { flex-shrink: 0; font-weight: 700; }
.compare-row .compare-figure.is-best { color: var(--green-deep); }
.compare-row .compare-figure.is-worst { color: var(--red); }

.compare-caveat { margin: 14px 0 0; color: var(--muted); font-size: .78rem; }

/* ---------------------------------------------------------
   Repère "pouvoir d'achat" coloré (rouge / vert / neutre)
   dans les tableaux de classement
--------------------------------------------------------- */
.cv-tier {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  font-size: .82rem;
  white-space: nowrap;
}

.cv-tier::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
}

.cv-tier--favorable { color: var(--green-deep); background: var(--green-soft); }
.cv-tier--neutral { color: var(--muted); background: var(--paper); }
.cv-tier--unfavorable { color: #fff; background: var(--red); }

/* ---------------------------------------------------------
   Tableaux (classement des régions, classement des communes)
--------------------------------------------------------- */
.cv-table-wrap {
  overflow-x: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cv-table-wrap--tall { max-height: 560px; overflow-y: auto; }

.cv-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: .88rem;
}

.cv-table th,
.cv-table td {
  padding: 10px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.cv-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--paper);
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.cv-table tbody tr:last-child td { border-bottom: 0; }
.cv-table tbody tr:hover { background: var(--blue-soft); }
.cv-table td.is-name { white-space: normal; font-weight: 600; color: var(--ink); }

.cv-table thead th:first-child,
.cv-table tbody td:first-child { width: 34px; color: var(--muted); text-align: right; }

.cv-table tbody tr.is-clickable { cursor: pointer; }
.cv-table tbody tr.is-clickable:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.cv-table tbody tr.is-clickable td.is-name { color: var(--blue); text-decoration: underline; text-decoration-color: transparent; }
.cv-table tbody tr.is-clickable:hover td.is-name,
.cv-table tbody tr.is-clickable:focus-visible td.is-name { text-decoration-color: currentColor; }

.cv-table--regions .cv-region-caret {
  width: 28px;
  padding-right: 0;
  color: var(--muted);
  text-align: center;
  transition: transform .15s ease;
}

.cv-table--regions tr.is-open .cv-region-caret { transform: rotate(90deg); color: var(--blue); }

.cv-region-detail-cell { padding: 0 !important; background: var(--paper); }
.cv-region-detail { padding: 12px 14px 16px 42px; }
.cv-region-detail p { margin: 0 0 10px; color: var(--muted); font-size: .82rem; }

.cv-dept-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.cv-dept-table th,
.cv-dept-table td { padding: 8px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.cv-dept-table thead th { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.cv-dept-table thead th:first-child,
.cv-dept-table tbody td:first-child { width: 30px; color: var(--muted); text-align: right; }
.cv-dept-table tbody tr:last-child td { border-bottom: 0; }
.cv-dept-table tbody tr:hover { background: var(--white); }
.cv-dept-table tbody tr.is-clickable { cursor: pointer; }
.cv-dept-table tbody tr.is-clickable td.is-name { color: var(--blue); }

.cv-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; margin-bottom: 16px; }

.cv-select-label { display: flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; color: var(--ink); font-size: .88rem; font-weight: 600; }

.cv-select-label select {
  min-width: 0;
  max-width: 100%;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  font-size: .88rem;
}

.cv-select-label select:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.cv-reverse-label { cursor: pointer; }
.cv-reverse-label input { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }

.cv-ranking-truncate { margin-top: 12px; color: var(--muted); font-size: .84rem; }

/* ---------------------------------------------------------
   Bandeau des totaux nationaux
--------------------------------------------------------- */
.cv-national { padding-top: clamp(28px, 5vw, 48px); padding-bottom: clamp(28px, 5vw, 48px); }

.cv-national-kicker {
  margin: 0 0 18px;
  color: rgba(242, 242, 246, .7);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cv-stat-label {
  display: block;
  margin-bottom: 10px;
  color: rgba(242, 242, 246, .68);
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cv-national .stats-grid strong { font-size: clamp(1.8rem, 3.4vw, 2.6rem); }

@media (max-width: 640px) {
  .cv-table--regions .cv-col-optional,
  .cv-dept-table .cv-col-optional { display: none; }

  .cv-table--regions,
  .cv-dept-table { min-width: 0; table-layout: fixed; }

  .cv-table--regions td.is-name,
  .cv-dept-table td.is-name { overflow-wrap: break-word; }

  .cv-region-detail { padding-left: 20px; }
}

@media (max-width: 780px) {
  .compare-grid { grid-template-columns: 1fr; }
}
