/* ============ Base ============ */
* { box-sizing: border-box; }

body {
  font-family: system-ui, "Segoe UI", sans-serif;
  margin: 0;
  line-height: 1.6;
  color: #1a1a1a;
  background: #f7f8fa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
  flex: 1; /* ← pousse le footer vers le bas de l'écran */
}

h1, h2, h3 { color: #0055A4; }

/* ============ En-tête ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(210, 213, 218, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1), 0 4px 16px rgba(0, 0, 0, 0.08);
}

.tricolore {
  height: 4px;
  background: linear-gradient(90deg,
    #0055A4 0%, #0055A4 33.33%,
    #FFFFFF 33.33%, #FFFFFF 66.66%,
    #EF4135 66.66%, #EF4135 100%);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-inner h1 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  padding: 0.85rem 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* ============ Navigation ============ */
.site-nav {
  display: flex;
  gap: 0.2rem;
  padding: 0.35rem;
  background: #f0f3f7;
  border-radius: 999px;
}

.nav-link {
  display: inline-block;
  padding: 0.4rem 0.95rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: #3a4a5c;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-link:hover {
  color: #0055A4;
  background: #e2ecf8;
}

.nav-link.active {
  background: #0055A4;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 85, 164, 0.3);
}

.nav-link:focus-visible {
  outline: 3px solid #0055A4;
  outline-offset: 2px;
}

/* Responsive : sur petit écran, la nav passe en bas */
@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    gap: 0.4rem;
    padding-bottom: 0.6rem;
  }
  .site-nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  .nav-link {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
  }
}

/* ============ Bulletin de vote ============ */
#ballot fieldset {
  border: 1px solid #c5cdd8;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin: 0 0 1rem;
  background: #ffffff;
}

#ballot legend {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0 0.4rem;
}

.grade {
  display: block;
  margin: 0.35rem 0;
}

.grade input {
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.55rem;
  accent-color: #0055A4;
}

.grade input:focus-visible {
  outline: 3px solid #0055A4;
  outline-offset: 2px;
}

/* ============ Boutons ============ */
button {
  font-size: 1rem;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  margin-top: 0.75rem;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  background: #0055A4;
  color: #ffffff;
}

button:hover:not(:disabled) { background: #003d75; }

button:disabled {
  background: #b6bdc6;
  cursor: not-allowed;
}

button:focus-visible {
  outline: 3px solid #0055A4;
  outline-offset: 2px;
}

#refresh-btn {
  background: #ffffff;
  color: #0055A4;
  border: 2px solid #0055A4;
}

#refresh-btn:hover { background: #e8f0fb; }

/* ============ Résultats ============ */
#results li {
  background: #ffffff;
  border-left: 6px solid #EF4135;
  border-radius: 6px;
  padding: 0.5rem 0.9rem;
  margin: 0.5rem 0;
}

/* ============ Pied de page ============ */
.site-footer {
  background: #1a1a1a;
  color: #f0f0f0;
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
}

.site-footer .tricolore {
  height: 5px;
  margin-bottom: 1rem;
}

.btn-link {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1.4rem;
  border-radius: 8px;
  background: #0055A4;
  color: #ffffff;
  font-weight: 600;
  text-decoration: none;
}
.btn-link:hover { background: #003d75; }

.site-footer {
  width: 100%;
}

.lock-box {
  text-align: center;
  max-width: 500px;
  margin: 3rem auto;
}
.lock-box .btn-link {
  display: inline-block; /* centré grâce au text-align du parent */
}

/* ============ Page Candidats ============ */
.candidat {
  background: #ffffff;
  border: 1px solid #c5cdd8;
  border-left: 6px solid #0055A4;
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin: 0 0 1rem;
}

.candidat h3 {
  margin: 0 0 0.4rem;
  font-size: 1.15rem;
}

.candidat h3 small {
  font-weight: 500;
  color: #555;
  font-size: 0.95rem;
}

.candidat p {
  margin: 0;
}

/* ============ Page Résultats — nouveau design ============ */

/* Grand compteur centré */
.participants-hero {
  display: flex;
  justify-content: center;
  margin: 2rem 0 2.5rem;
}

.participants-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0055A4, #EF4135);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(0, 85, 164, 0.35);
  border: 6px solid #ffffff;
}

.participants-number {
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
}

.participants-text {
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 0.3rem;
  opacity: 0.95;
}

.results-title {
  text-align: center;
  margin-bottom: 1.5rem;
}

.results-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-width: 560px;
  margin: 0 auto;
}

/* Cartes de résultats */
.result-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #ffffff;
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
  margin: 0.7rem 0;
  border: 2px solid transparent;
  transition: transform 0.15s ease;
}

.result-card:hover { transform: translateX(6px); }

.rank-badge {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  background: #eef1f5;
  color: #555;
}

.result-info {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.result-label {
  font-size: 0.95rem;
  color: #444;
}

/* Couleurs des 3 premiers */
/* ============ Rang 1 — Or ============ */
.rang-1 {
  border-color: #D4A017;
  background: linear-gradient(90deg, #FFF9E6, #ffffff);
  box-shadow: 0 4px 18px rgba(212, 160, 23, 0.40);
}
.rang-1 .rank-badge {
  background: linear-gradient(135deg, #F5C542, #D4A017);
  color: #5a3d00;
  box-shadow: 0 2px 8px rgba(212, 160, 23, 0.5);
}

.rang-2 {
  border-color: #C0C0C0;
  background: linear-gradient(90deg, #F4F6F8, #ffffff);
  box-shadow: 0 4px 14px rgba(150, 150, 150, 0.30);
}
.rang-2 .rank-badge { background: #C0C0C0; color: #3a3a3a; }
.rang-2 .result-label { font-weight: 600; }

.rang-3 {
  border-color: #CD7F32;
  background: linear-gradient(90deg, #FBEFE3, #ffffff);
  box-shadow: 0 4px 14px rgba(205, 127, 50, 0.30);
}
.rang-3 .rank-badge { background: #CD7F32; color: #4a2a05; }
.rang-3 .result-label { font-weight: 600; }

.rang-n {
  border-color: #dde3ea;
}

/* Lien candidat (voting + results) */
.cand-link {
  color: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  transition: color .2s;
}
.cand-link:hover {
  color: #1a3a6b;
  text-decoration: underline solid;
}

/* ============ Badges de mention (couleurs) ============ */
.result-label {
  display: inline-block;
  width: fit-content;
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  margin-top: 0.2rem;
}

/* Index 0 → 6 */
.grade-0 { background: #fde8e8; color: #b71c1c; }  /* À rejeter — rouge */
.grade-1 { background: #fff0e0; color: #e65100; }  /* Mauvais — orange */
.grade-2 { background: #fff8e1; color: #bf6900; }  /* Assez mauvais — ambre */
.grade-3 { background: #fffde7; color: #827717; }  /* Moyen — jaune */
.grade-4 { background: #e8f5e9; color: #33691e; }  /* Assez bien — vert clair */
.grade-5 { background: #dcedc8; color: #1b5e20; }  /* Bien — vert */
.grade-6 { background: #c8e6c9; color: #0d3d12; }  /* Excellent — vert foncé */

/* ============ Avatar candidat (résultats) ============ */
.avatar {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #e0e0e0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.rang-1 .avatar { border-color: #D4A017; }
.rang-2 .avatar { border-color: #C0C0C0; }
.rang-3 .avatar { border-color: #CD7F32; }

/* Fallback si l'image n'existe pas */
.rank-fallback {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: #eef1f5;
}

/* Numéro de rang à côté */
.rank-number {
  flex: 0 0 auto;
  font-size: 0.95rem;
  font-weight: 700;
  color: #555;
  min-width: 32px;
  text-align: center;
}

/* ============ Modal (popup) ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: #ffffff;
  border-radius: 16px;
  padding: 2rem 1.8rem 1.6rem;
  max-width: 420px;
  width: calc(100% - 2rem);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  transform: translateY(20px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.open .modal-box {
  transform: translateY(0) scale(1);
}

.modal-box h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: #1a1a1a;
}

.modal-box p {
  margin: 0 0 1.2rem;
  font-size: 0.95rem;
  color: #555;
  line-height: 1.5;
}

.modal-email {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid #dde3ea;
  border-radius: 10px;
  font-size: 1rem;
  margin-bottom: 0.8rem;
  transition: border-color 0.2s;
}

.modal-email:focus {
  outline: none;
  border-color: #0055A4;
  box-shadow: 0 0 0 3px rgba(0, 85, 164, 0.12);
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.modal-actions button {
  margin-top: 0;
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
}

.modal-skip {
  background: none;
  color: #777;
  font-weight: 500;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.modal-skip:hover {
  background: #f0f0f0;
  color: #333;
}

.modal-success {
  display: none;
  text-align: center;
  padding: 0.5rem 0;
}

.modal-success .check {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.modal-success p {
  margin-bottom: 1rem;
}