/* Sobre, fond blanc, sans dépendance externe — même parti pris que budgetetatfrancais.fr. */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --rule: #dcdcdc;
  --rule-2: #ededed;
  --ink: #111111;
  --ink-2: #4a4a4a;
  --ink-3: #767676;
  --s1: #2a78d6;   /* France */
  --s2: #eb6834;   /* pays comparé */
  --barre: #c4c8ce;
  --hover: #eef3fb;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121212;
    --rule: #343434;
    --rule-2: #262626;
    --ink: #f5f5f5;
    --ink-2: #b8b8b8;
    --ink-3: #8a8a8a;
    --s1: #3987e5;
    --s2: #d95926;
    --barre: #4b4f55;
    --hover: #1c2a3d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0; min-height: 100dvh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
header, footer { flex: none; }
main { flex: 1 0 auto; padding-bottom: clamp(3rem, 7vw, 4.5rem); }

.wrap { width: min(100% - 2.5rem, 78rem); margin-inline: auto; }
@media (min-width: 1200px) { .wrap { width: min(100% - 4rem, 78rem); } }

h1, h2 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
a { color: inherit; text-underline-offset: .18em; text-decoration-color: var(--rule); }
a:hover { text-decoration-color: currentColor; }
.emo { font-family: var(--emoji); }

header { padding: clamp(2.5rem, 7vw, 4.5rem) 0 0; }
h1 { font-size: clamp(1.875rem, 5.5vw, 3rem); }
.sub { font-size: .9375rem; color: var(--ink-3); max-width: 62ch; margin: .9rem 0 0; }

/* ---------- unité ---------- */

.unites { border: 0; padding: 0; margin: clamp(2rem, 5vw, 3rem) 0 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; }
.unites legend { float: left; padding: 0; margin-right: .5rem; font-size: .8125rem; color: var(--ink-3); }
.unites label { cursor: pointer; }
.unites input { position: absolute; opacity: 0; pointer-events: none; }
.unites span { display: block; font-size: .875rem; padding: .3rem .7rem;
  border: 1px solid var(--rule); border-radius: 3px; color: var(--ink-2);
  font-variant-numeric: tabular-nums; }
.unites label:hover span { background: var(--hover); }
.unites input:checked + span { border-color: var(--ink); color: var(--ink); font-weight: 600; }
.unites input:focus-visible + span { outline: 2px solid var(--s1); outline-offset: 1px; }

/* ---------- deux colonnes ---------- */

.deux { margin-top: clamp(1.5rem, 3vw, 2.25rem); display: grid; gap: 2.5rem clamp(2rem, 4vw, 3.5rem); }
@media (min-width: 920px) {
  .deux { grid-template-columns: minmax(19rem, 24rem) minmax(0, 1fr); align-items: start; }
  .metiers { position: sticky; top: 1rem; max-height: calc(100dvh - 2rem); overflow-y: auto; }
}

/* ---------- liste des métiers ---------- */

.metiers h3 { font: 600 .75rem/1.4 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); margin: 1.4rem 0 .4rem; display: flex; justify-content: space-between; gap: 1rem; }
.metiers h3:first-child { margin-top: 0; }
.metiers h3 small { font: inherit; text-transform: none; letter-spacing: 0; font-weight: 400; }
.metiers ul { list-style: none; margin: 0; padding: 0; }
.metiers li { border-bottom: 1px solid var(--rule-2); }
.metiers li:first-child { border-top: 1px solid var(--rule-2); }
.metiers button {
  font: inherit; width: 100%; background: none; border: 0; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 1.6em 1fr auto 3.6rem; align-items: baseline;
  gap: .3rem .5rem; padding: .5rem .3rem; color: var(--ink);
}
.metiers button:hover, .metiers button[aria-current="true"] { background: var(--hover); }
.metiers button[aria-current="true"] { box-shadow: inset 2px 0 0 var(--s1); }
.metiers .nom { font-size: .9rem; }
.metiers .val { font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metiers .ecart { font-size: .8125rem; color: var(--ink-3); text-align: right;
  font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- fiche ---------- */

.fiche h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.fiche h3 { font: 600 .9375rem/1.4 var(--sans); margin: 2.25rem 0 .75rem; }
.resume { font-size: 1.0625rem; max-width: 62ch; margin: .8rem 0 0; color: var(--ink-2); }
.resume b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* Barres : une ligne par pays, valeur toujours écrite — le graphique sert aussi de tableau. */
.barres { list-style: none; margin: 0; padding: 0; max-width: 46rem; }
.barres button {
  font: inherit; width: 100%; background: none; border: 0; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 7.2rem minmax(0, 1fr) 5.6rem 2.4rem; align-items: center;
  gap: 0 .6rem; padding: 2px .25rem; color: var(--ink-2); font-size: .8125rem; line-height: 1.5;
}
.barres button:hover, .barres button:focus-visible { background: var(--hover); outline: none; }
.barres .piste { height: .8rem; }
.barres .piste i { display: block; height: 100%; min-width: 2px; background: var(--barre); border-radius: 0 3px 3px 0; }
.barres .v { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.barres .an { color: var(--ink-3); font-size: .75rem; font-variant-numeric: tabular-nums; }
.barres .hors .p { font-style: italic; }
.barres .fr, .barres .ue, .barres .cmp { color: var(--ink); font-weight: 600; }
.barres .fr .piste i { background: var(--s1); }
.barres .cmp .piste i { background: var(--s2); }
.barres .ue .piste i { background: var(--ink); }
.barres li.ue { border-block: 1px dashed var(--rule); margin-block: 2px; }
.barres li.ue button { cursor: default; }
@media (max-width: 480px) {
  .barres .hu { display: none; }
  .barres button { grid-template-columns: 5.6rem minmax(0, 1fr) 4.9rem 2.2rem; gap: 0 .4rem; }
}

.cellule { font-size: .8125rem; color: var(--ink-2); max-width: 46rem; min-height: 3.2em;
  margin: .6rem 0 0; padding: .5rem .7rem; background: var(--hover); border-radius: 3px;
  font-variant-numeric: tabular-nums; }
.cellule b { color: var(--ink); font-weight: 600; }

/* ---------- évolution ---------- */

.legende { list-style: none; display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; margin: 0 0 .4rem; padding: 0;
  font-size: .8125rem; color: var(--ink-2); }
.legende i { display: inline-block; width: 1.1rem; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: .4rem; }
.evol { position: relative; max-width: 46rem; }
.evol svg { display: block; width: 100%; height: auto; overflow: visible; }
.evol text { font: 12px var(--sans); fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.evol .grille { stroke: var(--rule-2); stroke-width: 1; }
.evol .base { stroke: var(--rule); stroke-width: 1; }
.evol path { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.evol circle { stroke: var(--bg); stroke-width: 2; }
.evol .fin { fill: var(--ink); font-weight: 600; }
.evol .curseur { stroke: var(--ink-3); stroke-width: 1; }
.evol .bulle { position: absolute; top: 0; pointer-events: none; background: var(--bg);
  border: 1px solid var(--rule); border-radius: 3px; padding: .4rem .6rem; font-size: .8125rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .08); white-space: nowrap; font-variant-numeric: tabular-nums; }
.evol .bulle b { display: block; }
.evol .bulle i { display: inline-block; width: .8rem; border-top: 2px solid; vertical-align: middle; margin-right: .35rem; }
.evol .vide { font-size: .875rem; color: var(--ink-3); margin: 0; }

/* ---------- définitions et sources ---------- */

.caption { font-size: .8125rem; color: var(--ink-2); margin: clamp(2rem, 4vw, 3rem) 0 0;
  padding-top: 1.25rem; border-top: 1px solid var(--rule-2); }
.caption p, .caption li { max-width: 72ch; }
.caption p { margin: 0 0 .5rem; }
.caption ul { margin: 0 0 .6rem; padding-left: 1.1rem; }
.caption li { margin-bottom: .3rem; }
.caption b { color: var(--ink); font-weight: 600; }
.caption code { font-size: .78rem; overflow-wrap: anywhere; }

footer { padding: 2rem 0 2.5rem; border-top: 1px solid var(--rule); }
footer.wrap { display: grid; gap: 1.25rem 2.5rem; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
footer p { font-size: .8125rem; color: var(--ink-3); max-width: 62ch; margin: 0; }

/* ---------- choix de la source, chiffres nationaux ---------- */

.sources { margin-top: 1rem; }
.national { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--rule-2); }
.national h3 { margin-top: 0; }
.national table { border-collapse: collapse; width: 100%; max-width: 46rem; font-size: .8125rem;
  font-variant-numeric: tabular-nums; }
.national th, .national td { text-align: left; padding: .45rem .6rem .45rem 0; vertical-align: top;
  border-bottom: 1px solid var(--rule-2); font-weight: 400; color: var(--ink-2); }
.national thead th { color: var(--ink-3); font-size: .75rem; border-bottom-color: var(--rule); }
.national tbody th { color: var(--ink); }
.national .num { text-align: right; white-space: nowrap; padding-right: 0; padding-left: .6rem; }
.national td.num { color: var(--ink); font-weight: 600; }
.national small { display: block; color: var(--ink-3); font-size: .75rem; }
.national .note { font-size: .8125rem; color: var(--ink-3); max-width: 72ch; margin: .6rem 0 0; }

/* ---------- arborescence ---------- */

.metiers ul.sous { border-left: 0; }
.metiers ul.sous li:first-child { border-top: 1px solid var(--rule-2); }
.metiers ul.sous li:last-child { border-bottom: 0; }
.metiers ul.sous .nom { font-size: .85rem; color: var(--ink-2); }
.metiers ul.sous button[aria-current="true"] .nom { color: var(--ink); }
.metiers .chev { color: var(--ink-3); font-size: .75rem; }
.crumb { font-size: .8125rem; color: var(--ink-3); margin: 0 0 .4rem; }
.crumb button, .detail tbody button { font: inherit; color: inherit; background: none; border: 0; padding: 0;
  cursor: pointer; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: .18em; }
.crumb button:hover, .detail tbody button:hover { text-decoration-color: currentColor; }
.crumb b { color: var(--ink-2); font-weight: 600; }
.detail { border-top: 0; padding-top: 0; margin-top: 1.5rem; }
.detail h3 { margin-top: 0; }
.detail tbody button { text-align: left; color: var(--ink); }


/* ---------- poignée de redimensionnement entre la liste et la fiche ---------- */

.poignee { display: none; }
@media (min-width: 920px) {
  .deux { grid-template-columns: var(--liste, 22rem) 13px minmax(0, 1fr); column-gap: clamp(.75rem, 1.5vw, 1.25rem); }
  .poignee { display: block; position: sticky; top: 1rem; height: calc(100dvh - 2rem); cursor: col-resize;
    touch-action: none; border-radius: 3px; }
  .poignee::before { content: ""; position: absolute; top: 0; bottom: 0; left: 6px; width: 1px; background: var(--rule); }
  .poignee::after { content: ""; position: absolute; top: 50%; left: 3px; width: 7px; height: 2.25rem; margin-top: -1.125rem;
    border-radius: 4px; background: var(--bg); border: 1px solid var(--rule); }
  .poignee:hover::before, .poignee.glisse::before { background: var(--s1); width: 2px; left: 5.5px; }
  .poignee:hover::after, .poignee.glisse::after { border-color: var(--s1); }
  .poignee:focus-visible { outline: 2px solid var(--s1); outline-offset: 1px; }
  body.redimensionne { cursor: col-resize; user-select: none; }
}

/* ---------- petit écran : la liste est au-dessus de la fiche ---------- */

.retour { font-size: .8125rem; margin: 0 0 .9rem; }
.fiche { scroll-margin-top: .75rem; }
.metiers { scroll-margin-top: .75rem; }
@media (min-width: 920px) { .retour { display: none; } }
@media (max-width: 560px) {
  /* Tableaux : l'année passe sous le libellé pour laisser la place au texte. */
  .national table, .national tbody, .national tr { display: block; }
  .national thead { display: none; }
  .national tr { display: grid; grid-template-columns: 1fr auto auto; gap: .1rem .9rem;
    padding: .5rem 0; border-bottom: 1px solid var(--rule-2); }
  .national th, .national td { border: 0; padding: 0; }
  .national tbody th { grid-column: 1 / -1; }
  .national tbody td:first-of-type { color: var(--ink-3); }
  .national .num { padding-left: 0; }
  .national td[data-u]::after { content: " " attr(data-u); color: var(--ink-3); font-weight: 400; }
  .detail tr { grid-template-columns: 1fr auto auto; }
  .detail tbody td:first-of-type { color: var(--ink); }
  .detail tbody td:first-of-type::before { content: "France "; color: var(--ink-3); font-weight: 400; }
  .detail tbody td:nth-of-type(2)::before { content: "UE "; color: var(--ink-3); font-weight: 400; }
}

/* ---------- colonnes facultatives de la liste (cases à cocher) ---------- */

.reglages { display: flex; flex-wrap: wrap; gap: .6rem 2.5rem; margin-top: clamp(2rem, 5vw, 3rem); }
.reglages .unites { margin: 0; }
.coches span::before { content: ""; display: inline-block; width: .7em; height: .7em; margin-right: .45em;
  border: 1px solid var(--ink-3); border-radius: 2px; vertical-align: -.02em; }
.coches input:checked + span::before { background: var(--ink); border-color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--bg); }
.metiers button { grid-template-columns: 1.6em 1fr auto; }
.metiers.avec-ecart button, .metiers.avec-rang button { grid-template-columns: 1.6em 1fr auto 3.6rem; }
.metiers.avec-ecart.avec-rang button { grid-template-columns: 1.6em 1fr auto 3.6rem 4rem; }
.metiers .rang { font-size: .8125rem; color: var(--ink-3); text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums; }
.metiers.avec-rang:not(.avec-ecart) button { grid-template-columns: 1.6em 1fr auto 4rem; }
.metiers .rang sup { font-size: .65em; }
@media (min-width: 920px) {
  /* Les deux colonnes cochées : la liste s'élargit d'elle-même, sauf réglage à la poignée. */
  .deux:has(.metiers.avec-ecart.avec-rang) { grid-template-columns: var(--liste, 26rem) 13px minmax(0, 1fr); }
}

/* ---------- détail : axes et somme ---------- */

.detail tr.axe th { font-size: .72rem; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3);
  padding-top: .9rem; border-bottom-color: var(--rule); }
.detail tr.somme th, .detail tr.somme td { color: var(--ink-3); font-weight: 400; font-style: italic; }
.detail tr.somme td:first-of-type { color: var(--ink-2); }
@media (max-width: 560px) {
  .detail tr.axe, .detail tr.somme { display: block; }
  .detail tr.somme td { display: inline; }
  .detail tr.somme td::before { content: " " !important; }
}

/* ---------- liens vers la source, près des chiffres ---------- */

.src { font-size: .8125rem; color: var(--ink-3); max-width: 72ch; margin: .6rem 0 0; }
.src b { color: var(--ink-2); font-weight: 600; }
.src a { color: var(--ink-2); text-decoration-color: var(--ink-3); }
.src a:hover { color: var(--ink); }
.src code { font-size: .75rem; }
.src-graphe { font-size: .75rem; margin-top: .4rem; }
.src-graphe:empty { display: none; }

/* ---------- ordre de la liste ---------- */

.tri { display: flex; align-items: center; gap: .5rem; font-size: .8125rem; color: var(--ink-3); }
.tri select { font: inherit; font-size: .875rem; color: var(--ink); background: var(--bg);
  border: 1px solid var(--rule); border-radius: 3px; padding: .3rem .5rem; cursor: pointer; }
.tri select:focus-visible { outline: 2px solid var(--s1); outline-offset: 1px; }
.metiers .de { display: block; font-size: .72rem; color: var(--ink-3); line-height: 1.3; }
.metiers.plat h3 { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: .8125rem; }

.metiers h3 #sens { display: inline; width: auto; padding: .15rem .3rem; margin-left: -.3rem; font: inherit;
  color: var(--ink-2); border-radius: 3px; text-align: left; }
.metiers h3 #sens:hover { background: var(--hover); color: var(--ink); }
.metiers h3 #sens span { color: var(--s1); font-weight: 600; }

/* Icône d'inversion du tri : deux flèches, celle du sens en cours est en bleu. */
.ico-tri { vertical-align: -2px; margin-right: .3rem; fill: none; stroke-width: 1.6; stroke-linecap: round;
  stroke-linejoin: round; }
.ico-tri .bas { stroke: var(--s1); }
.ico-tri .haut { stroke: var(--ink-3); }
.ico-tri.inverse .bas { stroke: var(--ink-3); }
.ico-tri.inverse .haut { stroke: var(--s1); }
