*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bleu:   #1a4a7a;
  --bleu2:  #2563a8;
  --eau:    #4a90c4;
  --ciel:   #e8f2fb;
  --alerte: #c0392b;
  --or:     #e67e22;
  --vert:   #27ae60;
  --jaune:  #f39c12;
  --gris:   #f5f7fa;
  --texte:  #1a2a3a;
  --doux:   #556070;
}

html { scroll-behavior: smooth; }
body { font-family: Georgia, serif; background: var(--gris); color: var(--texte); line-height: 1.7; }

/* ── HEADER ── */
header {
  background: linear-gradient(160deg, #0d2d4d 0%, var(--bleu) 60%, var(--eau) 100%);
  color: white; padding: 3.5rem 1.5rem 3rem; text-align: center;
  position: relative; overflow: hidden;
}
header::after {
  content: ''; position: absolute; bottom: -2px; left: 0; right: 0;
  height: 40px; background: var(--gris);
  clip-path: ellipse(55% 100% at 50% 100%);
}
header h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); margin-bottom: .5rem; letter-spacing: -.02em; }
header .subtitle {
  font-size: 1.05rem;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.55);
  max-width: 620px; margin: 0 auto; font-style: italic;
}
.badge-alerte {
  display: inline-block; background: var(--alerte); color: white; font-size: .78rem;
  padding: .3rem .8rem; border-radius: 20px; margin-top: 1rem; font-style: normal;
  letter-spacing: .04em; text-transform: uppercase; font-family: sans-serif;
}

/* ── NAV ── */
nav {
  background: white; border-bottom: 1px solid #d0dce8;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
nav ul { list-style: none; display: flex; justify-content: center; flex-wrap: wrap; gap: .2rem; padding: .6rem 1rem; }
nav a { display: block; padding: .4rem .9rem; text-decoration: none; color: var(--bleu); font-family: sans-serif; font-size: .82rem; border-radius: 4px; transition: background .15s; }
nav a:hover { background: var(--ciel); }

/* ── LAYOUT ── */
main { max-width: 960px; margin: 0 auto; padding: 2.5rem 1.5rem 3rem; }
section { margin-bottom: 3.5rem; }
h2 { font-size: 1.5rem; color: var(--bleu); margin-bottom: 1.2rem; padding-bottom: .5rem; border-bottom: 3px solid var(--eau); display: flex; align-items: center; gap: .5rem; }
h2 .icon { font-size: 1.2rem; }
h3 { font-size: 1.05rem; color: var(--bleu2); margin: 1.4rem 0 .5rem; }
p { margin-bottom: .9rem; color: var(--texte); }

/* ── INTRO ── */
.intro-card {
  background: white; border-left: 5px solid var(--bleu);
  padding: 1.4rem 1.8rem; border-radius: 0 8px 8px 0;
  box-shadow: 0 2px 10px rgba(0,0,0,.06); font-size: 1.05rem;
}

/* ── STATS ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.stat { background: white; border-radius: 8px; padding: 1.2rem; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.07); border-top: 3px solid var(--eau); }
.stat .val { font-size: 1.9rem; font-weight: bold; color: var(--bleu); line-height: 1.2; }
.stat .lbl { font-size: .8rem; color: var(--doux); font-family: sans-serif; margin-top: .3rem; }

/* ── ONGLETS GRAPHIQUES ── */
.chart-section { background: white; border-radius: 12px; box-shadow: 0 3px 16px rgba(0,0,0,.09); overflow: hidden; }
.tabs-header {
  display: flex; border-bottom: 2px solid #e5ecf3;
  background: #f0f5fa;
}
.tab-btn {
  flex: 1; padding: 1rem 1.5rem; border: none; background: transparent;
  font-family: sans-serif; font-size: .95rem; color: var(--doux);
  cursor: pointer; transition: all .2s; font-weight: 500;
  border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tab-btn:hover { color: var(--bleu); background: var(--ciel); }
.tab-btn.active { color: var(--bleu); border-bottom-color: var(--bleu); background: white; }
.tab-content { display: none; padding: 1.5rem; }
.tab-content.active { display: block; }

/* ── NIVEAU COURANT ── */
.live-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.2rem;
}
.niveau-badge {
  display: flex; align-items: baseline; gap: .4rem;
  background: var(--ciel); border-radius: 8px; padding: .7rem 1.2rem;
}
.niveau-val { font-size: 2.2rem; font-weight: bold; color: var(--bleu); font-family: sans-serif; }
.niveau-val.alerte  { color: var(--alerte); }
.niveau-val.orange  { color: var(--or); }
.niveau-unit { font-size: 1rem; color: var(--doux); font-family: sans-serif; }
.niveau-label { font-family: sans-serif; font-size: .8rem; color: var(--doux); margin-top: .1rem; }
.range-btns { display: flex; gap: .4rem; }
.range-btn {
  padding: .35rem .8rem; border: 1px solid #c5d8ec; background: white;
  border-radius: 4px; font-family: sans-serif; font-size: .8rem;
  color: var(--bleu); cursor: pointer; transition: all .15s;
}
.range-btn:hover, .range-btn.active { background: var(--bleu); color: white; border-color: var(--bleu); }

.chart-container { position: relative; height: 340px; }
.chart-loading {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 340px; gap: 1rem; color: var(--doux); font-family: sans-serif; font-size: .9rem;
}
.spinner {
  width: 36px; height: 36px; border: 3px solid #d0dce8;
  border-top-color: var(--bleu); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.chart-error {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 200px; gap: .8rem; color: var(--doux); font-family: sans-serif; text-align: center;
}
.chart-error a { color: var(--bleu); }

.live-footer {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: .5rem; margin-top: .8rem;
}
.legende-seuils { display: flex; gap: 1rem; flex-wrap: wrap; font-family: sans-serif; font-size: .78rem; }
.leg-item { display: flex; align-items: center; gap: .4rem; color: var(--doux); }
.leg-dot { width: 14px; height: 3px; border-radius: 2px; }

/* ── GRAPHIQUE HISTO ── */
.histo-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.histo-note { font-family: sans-serif; font-size: .8rem; color: var(--doux); max-width: 480px; }

/* ── RIVIERES ── */
.river-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.river-card {
  background: white; border-radius: 8px; padding: 1.2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.07); border-top: 4px solid var(--eau);
  transition: transform .15s, box-shadow .15s;
}
.river-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.river-card h3 { margin: 0 0 .7rem; font-size: 1rem; }
.river-card p { font-size: .88rem; color: var(--doux); margin-bottom: 0; }
.river-card .data { font-size: .82rem; margin-top: .6rem; }
.river-card .data span { display: block; color: var(--bleu); font-weight: bold; }
.river-card .data small { color: var(--doux); font-size: .78rem; }

/* ── TIMELINE ── */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before { content: ''; position: absolute; left: .45rem; top: 0; bottom: 0; width: 3px; background: linear-gradient(to bottom, var(--bleu), var(--eau)); }
.tl-item { position: relative; margin-bottom: 2rem; background: white; border-radius: 8px; padding: 1.2rem 1.4rem; box-shadow: 0 2px 8px rgba(0,0,0,.07); }
.tl-item::before { content: ''; position: absolute; left: -1.7rem; top: 1.1rem; width: 14px; height: 14px; background: var(--bleu); border: 3px solid var(--gris); border-radius: 50%; }
.tl-item.majeur::before { background: var(--alerte); }
.tl-year { font-family: sans-serif; font-weight: bold; font-size: 1.1rem; color: var(--bleu); margin-bottom: .3rem; }
.tl-item.majeur .tl-year { color: var(--alerte); }
.tl-badge { display: inline-block; font-family: sans-serif; font-size: .72rem; padding: .15rem .6rem; border-radius: 10px; background: var(--ciel); color: var(--bleu2); margin-left: .5rem; vertical-align: middle; }
.tl-item.majeur .tl-badge { background: #fdecea; color: var(--alerte); }
.tl-item p { font-size: .9rem; color: var(--doux); margin-bottom: .4rem; }
.tl-item p:last-child { margin-bottom: 0; }
.tl-cote { display: inline-block; background: var(--bleu); color: white; font-family: sans-serif; font-size: .85rem; padding: .2rem .7rem; border-radius: 4px; margin-bottom: .5rem; }
.tl-item.majeur .tl-cote { background: var(--alerte); }

/* ── LEVEES ── */
.info-box { background: var(--ciel); border: 1px solid #b3d4ee; border-radius: 8px; padding: 1.2rem 1.5rem; margin: 1.5rem 0; }
.info-box p { font-size: .9rem; margin-bottom: .4rem; color: var(--texte); }
.alerte-box { background: #fdecea; border: 2px solid #e74c3c; border-radius: 8px; padding: 1.2rem 1.5rem; margin: 1.5rem 0; }
.alerte-box p { margin-bottom: .4rem; color: var(--texte); font-size: .93rem; }

/* ── PREVENTION ── */
.prev-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.prev-card { background: white; border-radius: 8px; padding: 1.3rem; box-shadow: 0 2px 8px rgba(0,0,0,.07); }
.prev-card h3 { margin: 0 0 .6rem; font-size: .95rem; color: var(--bleu); }
.prev-card p { font-size: .86rem; color: var(--doux); margin-bottom: 0; }
.prev-icon { font-size: 1.5rem; margin-bottom: .5rem; display: block; }

/* ── ANECDOTES ── */
.anecdote { background: white; border-radius: 8px; padding: 1.2rem 1.5rem; box-shadow: 0 2px 8px rgba(0,0,0,.07); margin-bottom: 1rem; border-left: 4px solid var(--or); }
.anecdote h3 { color: var(--or); margin: 0 0 .5rem; font-size: .95rem; }
.anecdote p { font-size: .88rem; color: var(--doux); margin-bottom: 0; }

/* ── RESSOURCES ── */
.ressources-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; }
.res-link { display: flex; align-items: center; gap: .8rem; background: white; border-radius: 8px; padding: .9rem 1rem; text-decoration: none; color: var(--texte); box-shadow: 0 2px 6px rgba(0,0,0,.06); border-left: 4px solid var(--eau); font-size: .88rem; transition: transform .15s, box-shadow .15s; }
.res-link:hover { transform: translateX(3px); box-shadow: 0 3px 12px rgba(0,0,0,.1); }
.res-link .res-title { font-weight: bold; color: var(--bleu2); }
.res-link .res-desc { color: var(--doux); font-size: .8rem; }
.sources { font-family: sans-serif; font-size: .8rem; color: var(--doux); }
.sources li { margin-bottom: .3rem; }
.sources a { color: var(--bleu2); text-decoration: none; }
.sources a:hover { text-decoration: underline; }

.vigicrues-btn { display: inline-flex; align-items: center; gap: .5rem; background: var(--bleu); color: white; text-decoration: none; padding: .7rem 1.4rem; border-radius: 6px; font-family: sans-serif; font-size: .9rem; transition: background .15s; margin: .5rem .3rem 0 0; }
.vigicrues-btn:hover { background: var(--bleu2); }
.vigicrues-btn.danger { background: var(--alerte); }

footer { text-align: center; padding: 1.8rem; font-family: sans-serif; font-size: .8rem; color: #999; border-top: 1px solid #d0dce8; background: white; }

@media (max-width: 600px) {
  nav a { font-size: .75rem; padding: .35rem .6rem; }
  .niveau-val { font-size: 1.7rem; }
  .tab-btn { font-size: .82rem; padding: .8rem .8rem; }
}
