/* bercy-theme.css : charte concours-bercy.fr, surcharge des variables de styles.css.
   Charge APRES styles.css dans Layout.astro.

   Direction artistique reprise de la maquette : inspiration DSFR (bleu France #000091,
   rouge Marianne #E1000F), avec l'or des douanes pour distinguer les deux administrations.

   Typographie : la maquette appelait Spectral et Inter chez Google Fonts. Le reseau
   auto-heberge ses polices (perf + RGPD, aucun appel runtime a fonts.gstatic). On sert donc
   Newsreader, deja auto-hebergee et tres proche de Spectral, et la pile systeme pour le sans.
   Pour retrouver exactement Spectral et Inter, il faudra les auto-heberger dans public/fonts. */

:root {
  /* --- palette Republique --- */
  --bleu-france: #000091;
  --bleu-france-survol: #1212ff;
  --bleu-nuit: #0a0a2e;
  --rouge-marianne: #e1000f;
  --or-douanes: #c3992b;
  --vert-succes: #18753c;
  --ocre-alerte: #b34000;

  /* --- variables du design system partage --- */
  --accent: #000091;
  --accent2: #c3992b;
  --ink: #0a0a2e;
  --encre: #0a0a2e;
  --bg: #f6f6f6;
  --card: #ffffff;
  --card2: #f0f0f7;
  --text: #1e1e1e;
  --heading: #0a0a2e;
  --muted: #666666;
  --line: #e5e5e5;
  --ok: #18753c;
  --okbg: #e3f5ea;
  --warn: #b34000;
  --warnbg: #fbeee4;
  --bad: #e1000f;
  --badbg: #fdeaea;
  --shadow: 0 1px 3px rgba(10, 10, 46, .07), 0 10px 30px rgba(10, 10, 46, .06);
  --shadow-strong: 0 18px 50px rgba(10, 10, 46, .18);
  --radius: 8px;
  --radius-lg: 12px;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

:root[data-theme='dark'] {
  --accent: #8b8bff;
  --accent2: #e0b955;
  --ink: #06061a;
  --encre: #ececf7;
  --bg: #06061a;
  --card: #12123a;
  --card2: #1a1a4a;
  --text: #dcdcec;
  --heading: #f2f2fb;
  --muted: #9a9ab4;
  --line: #262658;
  --ok: #4cc47a;
  --okbg: #0f2f1c;
  --bad: #ff6b6b;
  --badbg: #3a1414;
  --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-strong: 0 18px 50px rgba(0, 0, 0, .55);
}

/* Angles francs plutot qu'arrondis : c'est la signature visuelle du DSFR. */
.card, .tuile, .btn { border-radius: var(--radius); }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  letter-spacing: -.02em;
  color: var(--heading);
}

/* Le texte courant est justifie sur tout le reseau. */
.prose, .prose p, .prose li { text-align: justify; }
@media (max-width: 640px) {
  .prose, .prose p, .prose li { text-align: left; }
}

/* ---------- atomes de la charte ---------- */

/* Filet tricolore : bleu / blanc / rouge, pose sous l'en-tete et au-dessus du pied. */
.filet-tricolore {
  height: 3px;
  background: linear-gradient(to right,
    var(--bleu-france) 0 33.33%,
    #ffffff 33.33% 66.66%,
    var(--rouge-marianne) 66.66% 100%);
}

.badge-categorie {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid currentColor;
  border-radius: 3px;
}
.badge-categorie[data-cat='A'] { color: var(--rouge-marianne); }
.badge-categorie[data-cat='B'] { color: var(--bleu-france); }
.badge-categorie[data-cat='C'] { color: var(--vert-succes); }
:root[data-theme='dark'] .badge-categorie[data-cat='B'] { color: #8b8bff; }

.puce-direction {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.puce-direction img { width: 18px; height: 18px; }

/* Tuile de concours : le motif de navigation principal du site. */
.tuile {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--bleu-france);
  padding: 18px 20px;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
  height: 100%;
}
.tuile:hover {
  border-color: var(--bleu-france);
  border-left-color: var(--bleu-france);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.tuile[data-direction='DGDDI'] { border-left-color: var(--or-douanes); }
.tuile[data-direction='DGDDI']:hover { border-color: var(--or-douanes); }
.tuile h3 { margin: 0; font-size: 1.06rem; line-height: 1.35; }
.tuile .tuile-meta {
  font-family: var(--font-mono);
  font-size: .76rem;
  color: var(--muted);
}
.tuile .tuile-lien {
  margin-top: auto;
  font-weight: 600;
  font-size: .9rem;
  color: var(--bleu-france);
}
:root[data-theme='dark'] .tuile .tuile-lien { color: #8b8bff; }

/* Grilles : minmax(min(Xpx,100%),1fr) et jamais minmax(Xpx,1fr), sinon la piste garde son
   minimum sous 280 px et le contenu sort de l'encart sur mobile. */
.grille-tuiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 16px;
}
.grille-large {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: 20px;
}

/* Tableau des epreuves. Il deborde sur mobile : on le fait defiler dans son propre cadre
   plutot que de laisser la page defiler horizontalement. */
.cadre-defilant { overflow-x: auto; }
.table-epreuves {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: .93rem;
}
.table-epreuves th,
.table-epreuves td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table-epreuves th {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.table-epreuves td.num { font-family: var(--font-mono); white-space: nowrap; }
.table-epreuves tr.facultative td { color: var(--muted); }
.table-epreuves .eliminatoire {
  display: block;
  margin-top: 4px;
  font-size: .8rem;
  color: var(--ocre-alerte);
}
:root[data-theme='dark'] .table-epreuves .eliminatoire { color: #f0a97a; }

.bandeau-phase {
  font-family: var(--font-mono);
  font-size: .74rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--bleu-france);
  background: var(--card2);
  padding: 7px 12px;
  border-left: 3px solid var(--bleu-france);
}
:root[data-theme='dark'] .bandeau-phase { color: #8b8bff; border-left-color: #8b8bff; }

.encart-source {
  font-size: .82rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 18px;
}
.encart-source a { color: var(--bleu-france); text-decoration: underline; }
:root[data-theme='dark'] .encart-source a { color: #8b8bff; }

.avis-session-close {
  background: var(--warnbg);
  border-left: 3px solid var(--ocre-alerte);
  padding: 12px 14px;
  font-size: .9rem;
}
:root[data-theme='dark'] .avis-session-close { background: #33220f; }

.fil-ariane {
  font-size: .84rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.fil-ariane a { color: var(--muted); text-decoration: underline; }
.fil-ariane a:hover { color: var(--bleu-france); }
.fil-ariane span[aria-hidden] { opacity: .5; }

.chiffre-cle {
  font-family: var(--font-mono);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 600;
  color: var(--bleu-france);
  line-height: 1;
}
:root[data-theme='dark'] .chiffre-cle { color: #8b8bff; }
