/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */
#fp-app {
  --fp-bg:        #faf9f7;
  --fp-surface:   #ffffff;
  --fp-text:      #1a1a1a;
  --fp-muted:     #5e5e5e;
  --fp-accent:    #b45309;
  --fp-danger:    #b3261e;
  --fp-border:    #e5e2dc;
  --fp-grid:      #ebe8e2;
  --fp-war:       rgba(120,120,120,.16);
  --fp-radius:    8px;
  --fp-shadow:    0 2px 12px rgba(0,0,0,.08);
  --fp-transition: 0.2s ease;
  /* textes posés directement sur le fond clair du site (hors cartes) : jamais inversés en thème sombre */
  --fp-page-text:   #1a1a1a;
  --fp-page-muted:  #5e5e5e;
  --fp-page-accent: #b45309;
  /* séries : bleu, rouge, violet, ocre, vert-bleu (distinguables sans le seul usage de la teinte via tirets/marqueurs) */
  --fp-c-FRA: #2f5fb3;
  --fp-c-USA: #cf3f52;
  --fp-c-GBR: #7a4eb0;
  --fp-c-DEU: #b8730a;
  --fp-c-ITA: #138a7b;
  --fp-c-JPN: #7d8a14;
}

/* ============================================================
   2. THÈME SOMBRE (carte uniquement : le site reste clair)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  #fp-app:not([data-theme="light"]) {
    --fp-bg:      #1c1b19;
    --fp-surface: #262522;
    --fp-text:    #efece6;
    --fp-muted:   #b4afa5;
    --fp-accent:  #f0a04b;
    --fp-border:  #3a3935;
    --fp-grid:    #34332f;
    --fp-war:     rgba(200,200,200,.12);
    --fp-c-FRA: #7aa2ee;
    --fp-c-USA: #ff7d8e;
    --fp-c-GBR: #b896f0;
    --fp-c-DEU: #f0b350;
    --fp-c-ITA: #4fcfbe;
    --fp-c-JPN: #c4d34a;
  }
}
#fp-app[data-theme="dark"] {
  --fp-bg:#1c1b19; --fp-surface:#262522; --fp-text:#efece6; --fp-muted:#b4afa5;
  --fp-accent:#f0a04b; --fp-border:#3a3935; --fp-grid:#34332f; --fp-war:rgba(200,200,200,.12);
  --fp-c-FRA:#7aa2ee; --fp-c-USA:#ff7d8e; --fp-c-GBR:#b896f0; --fp-c-DEU:#f0b350; --fp-c-ITA:#4fcfbe; --fp-c-JPN:#c4d34a;
}

/* ============================================================
   3. LAYOUT PRINCIPAL
   ============================================================ */
#fp-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 0 3rem;
  color: var(--fp-text);
}
#fp-app *:focus-visible { outline: 2px solid var(--fp-accent); outline-offset: 2px; }

/* ============================================================
   4. EN-TÊTE
   ============================================================ */
.fp-head { margin-bottom: 1.5rem; }
.fp-kicker {
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .12em; color: var(--fp-page-accent); margin-bottom: .4rem;
}
.fp-head h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); letter-spacing: -.02em; margin-bottom: .6rem; color: var(--fp-page-text); }
.fp-lead { color: var(--fp-page-muted); max-width: 60ch; }

/* ============================================================
   5. CONTRÔLES
   ============================================================ */
.fp-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.fp-group {
  background: var(--fp-surface);
  border: 1px solid var(--fp-border);
  border-radius: var(--fp-radius);
  padding: .75rem 1rem 1rem;
  min-width: 0;
}
.fp-group legend {
  font-size: .75rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .1em; color: var(--fp-muted); padding: 0 .35rem; white-space: nowrap;
  background: var(--fp-surface); border-radius: 4px;
}
.fp-checks { display: flex; flex-direction: column; gap: .35rem; }
.fp-check {
  display: flex; align-items: center; gap: .55rem;
  font-size: .98rem; cursor: pointer; line-height: 1.3;
}
.fp-check input { width: 1.1rem; height: 1.1rem; accent-color: var(--fp-accent); flex: none; }
.fp-swatch {
  width: 1.5rem; height: 0; border-top: 3px solid currentColor; flex: none; border-radius: 2px;
}
.fp-period { grid-column: span 1; }
.fp-years { display: flex; align-items: center; gap: .35rem; margin-bottom: .6rem; flex-wrap: wrap; }
.fp-years input {
  width: 4.6rem; padding: .35rem .4rem; font: inherit;
  background: var(--fp-bg); color: var(--fp-text);
  border: 1px solid var(--fp-border); border-radius: 6px;
}
.fp-years input[aria-invalid="true"] { border-color: var(--fp-danger); }
.fp-presets { display: flex; flex-wrap: wrap; gap: .4rem; }
.fp-btn {
  font: inherit; font-size: .88rem; padding: .3rem .65rem; cursor: pointer;
  background: var(--fp-bg); color: var(--fp-text);
  border: 1px solid var(--fp-border); border-radius: 999px;
  transition: background var(--fp-transition), border-color var(--fp-transition);
}
.fp-btn:hover { border-color: var(--fp-accent); }
.fp-btn.active { background: var(--fp-accent); border-color: var(--fp-accent); color: #fff; }
.fp-msg { color: var(--fp-danger); font-size: .88rem; margin-top: .5rem; }

/* ============================================================
   6. GRAPHIQUE
   ============================================================ */
.fp-chart-card {
  background: var(--fp-surface);
  border: 1px solid var(--fp-border);
  border-radius: var(--fp-radius);
  box-shadow: var(--fp-shadow);
  padding: 1rem 1rem .75rem;
}
.fp-chart-title { font-size: 1.15rem; margin-bottom: .15rem; }
.fp-summary { color: var(--fp-muted); font-size: .9rem; margin-bottom: .5rem; min-height: 1.4em; }
.fp-chart { position: relative; width: 100%; }
#fp-svg { display: block; width: 100%; height: 520px; touch-action: pan-y; }
#fp-svg text { font-family: 'Source Sans 3', system-ui, sans-serif; fill: var(--fp-muted); }
.fp-grid line { stroke: var(--fp-grid); stroke-width: 1; }
.fp-axis line { stroke: var(--fp-border); }
.fp-axis text { font-size: 11.5px; }
.fp-war { fill: var(--fp-war); }
.fp-war-label { font-size: 10.5px; }
.fp-line { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.fp-line--est { stroke-dasharray: 6 4; opacity: .6; stroke-width: 2; }
.fp-line--alt { stroke-width: 1.9; stroke-dasharray: 10 3 2 3; }
.fp-line--est.fp-line--alt { stroke-dasharray: 3 3; }
.fp-line--sc { stroke-width: 1.2; opacity: .55; }
.fp-sc-dot { stroke: var(--fp-surface); stroke-width: 1; }
circle.fp-sc-dot--hollow { fill: var(--fp-surface); stroke-width: 1.6; }
.fp-grid line.fp-zero { stroke: var(--fp-muted); }
.fp-axis-title { font-size: 12px; font-weight: 600; }
#fp-svg text.fp-sc-label.fp-sc-label { font-size: 10.5px; stroke: var(--fp-surface); stroke-width: 2.5px; paint-order: stroke; }
.fp-line--fc  { stroke-dasharray: 2 3; }
.fp-line--gap { stroke-dasharray: 1 3; opacity: .5; stroke-width: 1.2; }
.fp-ev-line { stroke-width: 1; stroke-dasharray: 2 3; opacity: .75; }
.fp-ev-label { font-size: 10.5px; }
.fp-elec { stroke: var(--fp-surface); stroke-width: .8; }
.fp-cursor { stroke: var(--fp-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.fp-last-label { font-size: 11.5px; font-weight: 600; }
#fp-svg text.fp-last-label.fp-last-label { stroke: var(--fp-surface); stroke-width: 3px; paint-order: stroke; stroke-linejoin: round; }
.fp-dot { stroke: var(--fp-surface); stroke-width: 1.5; }
.fp-empty { font-size: 14px; }
.s-FRA { stroke: var(--fp-c-FRA); fill: var(--fp-c-FRA); }
.s-USA { stroke: var(--fp-c-USA); fill: var(--fp-c-USA); }
.s-GBR { stroke: var(--fp-c-GBR); fill: var(--fp-c-GBR); }
.s-DEU { stroke: var(--fp-c-DEU); fill: var(--fp-c-DEU); }
.s-ITA { stroke: var(--fp-c-ITA); fill: var(--fp-c-ITA); }
.s-JPN { stroke: var(--fp-c-JPN); fill: var(--fp-c-JPN); }
.fp-line.s-FRA, .fp-line.s-USA, .fp-line.s-GBR, .fp-line.s-DEU, .fp-line.s-ITA, .fp-line.s-JPN,
.fp-ev-line, .fp-cursor { fill: none; }
#fp-svg text.s-FRA { fill: var(--fp-c-FRA); stroke: none; }
#fp-svg text.s-USA { fill: var(--fp-c-USA); stroke: none; }
#fp-svg text.s-GBR { fill: var(--fp-c-GBR); stroke: none; }
#fp-svg text.s-DEU { fill: var(--fp-c-DEU); stroke: none; }
#fp-svg text.s-ITA { fill: var(--fp-c-ITA); stroke: none; }
#fp-svg text.s-JPN { fill: var(--fp-c-JPN); stroke: none; }
.fp-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--fp-surface); color: var(--fp-text);
  border: 1px solid var(--fp-border); border-radius: 6px;
  box-shadow: var(--fp-shadow); padding: .45rem .65rem;
  font-size: .88rem; line-height: 1.4; min-width: 9rem;
}
.fp-tip b { display: block; margin-bottom: .2rem; }
.fp-tip .row { display: flex; justify-content: space-between; gap: .8rem; }
.fp-tip .dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; }
.fp-tip .tag { color: var(--fp-muted); font-size: .78rem; }
.fp-tip .ev { margin-top: .3rem; padding-top: .3rem; border-top: 1px solid var(--fp-border); font-size: .82rem; color: var(--fp-muted); }

/* légende */
.fp-legend { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-top: .6rem; font-size: .88rem; color: var(--fp-muted); }
.fp-legend li { display: flex; align-items: center; gap: .4rem; }
.fp-legend svg { width: 28px; height: 10px; flex: none; }

/* ============================================================
   7. TABLEAU & NOTES
   ============================================================ */
.fp-table-box { margin-top: 1rem; background: var(--fp-surface); border: 1px solid var(--fp-border); border-radius: var(--fp-radius); padding: .6rem 1rem; }
.fp-table-box summary { cursor: pointer; font-weight: 600; }
.fp-table-wrap { max-height: 360px; overflow: auto; margin-top: .6rem; }
.fp-table-wrap table { border-collapse: collapse; width: 100%; font-size: .88rem; font-variant-numeric: tabular-nums; }
.fp-table-wrap th, .fp-table-wrap td { padding: .25rem .6rem; text-align: right; border-bottom: 1px solid var(--fp-border); }
.fp-table-wrap th:first-child, .fp-table-wrap td:first-child { text-align: left; }
.fp-table-wrap thead th { position: sticky; top: 0; background: var(--fp-surface); }
.fp-table-wrap td.est { color: var(--fp-muted); font-style: italic; }
.fp-notes { margin-top: 1.5rem; color: var(--fp-page-muted); font-size: .92rem; }
.fp-notes h2 { font-size: 1.1rem; color: var(--fp-page-text); margin-bottom: .5rem; }
.fp-notes ul { padding-left: 1.2rem; display: grid; gap: .4rem; }

/* ============================================================
   8. ÉTATS
   ============================================================ */
.fp-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   9. RESPONSIVE
   ============================================================ */
@media (max-width: 600px) {
  #fp-svg { height: 400px; }
  .fp-controls { grid-template-columns: 1fr; }
  .fp-chart-card { padding: .75rem .5rem .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  #fp-app * { transition: none !important; }
}
