/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: #e8ecf1;
  color: #1a1a2e;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a {
  text-decoration: none;
  color: inherit;
}

ul, ol {
  list-style: none;
}

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, #1a2744 0%, #2c3e6b 100%);
  color: #fff;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Logo France */
.logo-france {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: brightness(2.5) drop-shadow(0 0 6px rgba(255, 255, 255, 0.5));
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 4px;
}

/* Heartbeat animation (3 beats, repeats every 5s) */
.heartbeat {
  animation: heartbeat 5s ease-in-out infinite;
}

@keyframes heartbeat {
  0%   { transform: scale(1); }
  4%   { transform: scale(1.2); }
  8%   { transform: scale(1); }
  14%  { transform: scale(1.2); }
  18%  { transform: scale(1); }
  24%  { transform: scale(1.2); }
  28%  { transform: scale(1); }
  100% { transform: scale(1); }
}

.logo-text {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-dot {
  color: #f39c12;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
  color: #c5cde0;
}

.nav-link:hover,
.nav-link.active {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.nav-sep {
  color: #4a5a7a;
  font-size: 0.85rem;
}

/* ===== LAYOUT ===== */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 290px;
  gap: 24px;
  padding: 24px;
}

/* ===== TITRE ===== */
.title-section {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.title-section h1 {
  font-size: 1.55rem;
  font-weight: 800;
  color: #1a2744;
}

.last-update {
  font-size: 0.85rem;
  color: #6b7b95;
}

/* ===== GRILLE IA ===== */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* ===== CARTE IA ===== */
.ai-card {
  background: #fff;
  border: 1px solid #d0d7e2;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s, transform 0.2s;
}

.ai-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

.ai-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #f5f7fa;
  border-bottom: 1px solid #e2e7ef;
  border-radius: 10px 10px 0 0;
}

.ai-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}

.ai-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a2744;
  line-height: 1.2;
}

.ai-company {
  font-size: 0.75rem;
  color: #7a8ba3;
  font-weight: 500;
}

.flag-svg {
  width: 42px;
  height: 28px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  display: block;
  overflow: hidden;
}

/* Card body */
.ai-card-body {
  padding: 12px 14px;
  display: flex;
  gap: 10px;
}

.tour-section {
  flex: 1;
}

.tour-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #7a8ba3;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.candidates-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.candidates-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.candidate-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.candidate-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1a2744;
  min-width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* 2nd tour result */
.tour-2nd {
  min-width: 140px;
  flex-shrink: 0;
}

.second-tour-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.winner {
  text-align: center;
}

.winner-photo-wrap {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #27ae60;
  box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3);
  display: block;
  margin: 0 auto 4px;
}
.winner-photo {
  width: 118px;
  height: 118px;
  object-fit: cover;
  display: block;
  margin: -3px;
}

.winner-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1a2744;
  display: block;
  margin-bottom: 2px;
}

.winner-pct {
  font-size: 1rem;
  font-weight: 800;
  color: #27ae60;
  display: inline;
}

.winner-pct + .evo {
  display: inline;
  margin-left: 3px;
}

.winner-socials {
  display: flex;
  gap: 5px;
  margin-top: 2px;
  justify-content: center;
}
.winner-socials a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e2e7ef;
  transition: background 0.2s;
}
.winner-socials a:hover {
  background: #1a2744;
}
.winner-socials a svg {
  width: 12px;
  height: 12px;
  fill: #3d4f6b;
  transition: fill 0.2s;
}
.winner-socials a:hover svg {
  fill: #fff;
}

.loser {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 2px;
  border-top: 1px solid #e2e7ef;
  width: 100%;
  justify-content: center;
}

.loser-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: #7a8ba3;
}

.loser-pct {
  font-size: 0.72rem;
  font-weight: 700;
  color: #e74c3c;
  display: inline;
}

/* ===== BARRE ANALYSE COMPARATIVE ===== */
.comparative-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #f5f7fa;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 1px solid #d0d7e2;
  flex-wrap: wrap;
  gap: 12px;
}

.comparative-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a2744;
}

.next-update {
  font-size: 0.85rem;
  color: #6b7b95;
  background: #fff;
  padding: 6px 16px;
  border-radius: 20px;
  border: 1px solid #d0d7e2;
}

.cnil-logo {
  width: 80px;
  height: 36px;
  border-radius: 4px;
  background: #d0d7e2;
  border: 2px dashed #99a6b8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cnil-logo::after {
  content: attr(data-label);
  font-size: 0.55rem;
  color: #7a8ba3;
}

/* ===== BOTTOM GRID ===== */
.bottom-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.bottom-card {
  padding: 18px;
  border-radius: 10px;
  border: 1px solid #d0d7e2;
}

.bottom-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.bottom-card p,
.bottom-card li {
  font-size: 0.82rem;
  color: #3d4f6b;
  line-height: 1.55;
}

.bottom-card ol {
  list-style: decimal;
  padding-left: 16px;
}

.bottom-card ol li {
  margin-bottom: 8px;
}

/* Méthodologie */
.methodologie-card {
  background: linear-gradient(135deg, #1a2744 0%, #2c3e6b 100%);
  color: #fff;
}

.methodologie-card h3 {
  color: #f39c12;
}

.methodologie-card p {
  color: #c5cde0;
}

/* Actualités */
.actualites-card {
  background: #fff;
}

/* Commentaire expert */
.commentaire-card {
  background: #fff;
  position: relative;
}

.commentaire-card h3 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.commentaire-card blockquote {
  font-style: italic;
  font-size: 0.82rem;
  color: #3d4f6b;
  border-left: 3px solid #f39c12;
  padding-left: 12px;
  margin-bottom: 10px;
}

.expert-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: #1a2744;
}

.expert-role {
  font-weight: 400;
  color: #7a8ba3;
  font-size: 0.75rem;
}

.expert-photo-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #d0d7e2;
  border: 2px dashed #99a6b8;
  position: absolute;
  bottom: 16px;
  right: 16px;
}

.expert-photo-placeholder::after {
  content: attr(data-label);
  font-size: 0.35rem;
  text-align: center;
  color: #7a8ba3;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  line-height: 1;
}

/* ===== SIDEBAR - MILLION DOLLAR PIXELS ===== */
.sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.sidebar > * {
  width: 100%;
}

.sidebar-title {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  padding: 10px;
  background: linear-gradient(135deg, #1a2744 0%, #2c3e6b 100%);
  border-radius: 8px;
}

/* Pixel grid wrapper */
.pixel-grid-wrapper {
  background: #fff;
  border: 1px solid #d0d7e2;
  border-radius: 8px;
  padding: 6px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
}

/* Canvas pixel grid */
.pixel-canvas-container {
  position: relative;
  display: inline-block;
}

#pixelCanvas {
  display: block;
  border-radius: 0;
}

.pixel-tooltip {
  position: absolute;
  pointer-events: none;
  background: #1a2744;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.08s;
  z-index: 10;
}

/* Stats pixels */
.pixel-stats {
  display: flex;
  justify-content: space-around;
  background: #f5f7fa;
  border-radius: 8px;
  padding: 10px;
  border: 1px solid #d0d7e2;
}

.pixel-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pixel-stat-value {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1a2744;
}

.pixel-stat-label {
  font-size: 0.65rem;
  color: #7a8ba3;
  font-weight: 500;
}

/* CTA */
.action-cta {
  text-align: center;
}

.cta-button {
  width: 100%;
  padding: 12px 20px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 2px 8px rgba(231, 76, 60, 0.3);
}

.cta-button:hover {
  background: #c0392b;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
}

.cta-sub {
  font-size: 0.75rem;
  color: #7a8ba3;
  margin-top: 6px;
}

/* ===== FOOTER ===== */
.footer {
  background: #1a2744;
  color: #8899b3;
  text-align: center;
  padding: 16px 24px;
  font-size: 0.8rem;
  margin-top: 12px;
}

/* ===== PLACEHOLDER GENERIQUE ===== */
.placeholder-img {
  background: #d0d7e2;
  border: 2px dashed #99a6b8;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    align-items: center;
  }

  .pixel-grid-wrapper {
    max-width: 300px;
  }
}

@media (max-width: 900px) {
  .ai-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .ai-grid {
    grid-template-columns: 1fr;
  }

  .header {
    height: auto;
    padding: 10px 14px;
  }

  .header-inner {
    flex-wrap: wrap;
    gap: 4px 8px;
    align-items: center;
  }

  .logo {
    gap: 8px;
  }

  .logo-france {
    width: 32px;
    height: 32px;
  }

  .logo-text {
    font-size: 1.3rem;
  }

  .nav {
    flex-wrap: wrap;
    gap: 2px 0;
    justify-content: flex-end;
  }

  .nav-sep {
    display: none;
  }

  .nav-link {
    font-size: 0.75rem;
    padding: 4px 7px;
  }

  .layout {
    padding: 12px;
    overflow: hidden;
  }

  /* Centrage symétrique du canvas : sélecteur plus précis que .sidebar > * */
  .sidebar .pixel-grid-wrapper {
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }

  /* Empêche les cartes IA de dépasser */
  .ai-card-body {
    flex-wrap: wrap;
  }

  .tour-2nd {
    min-width: 0;
    width: 100%;
    flex-shrink: 1;
  }

  .title-section {
    flex-direction: column;
  }

  .comparative-bar {
    flex-direction: column;
    text-align: center;
  }

  .mentions-content {
    grid-template-columns: 1fr !important;
  }
}

/* ===== MENTIONS LEGALES ===== */
.mentions-legales {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px;
  background: #f5f7fa;
  border-top: 1px solid #d0d7e2;
}

.mentions-legales h2 {
  font-size: 1.2rem;
  font-weight: 800;
  color: #1a2744;
  margin-bottom: 20px;
}

.mentions-content {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.mentions-col h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a2744;
  margin-bottom: 6px;
}

.mentions-col p {
  font-size: 0.8rem;
  color: #3d4f6b;
  line-height: 1.6;
}

.footer-links {
  margin-top: 6px;
}

.footer-links a {
  color: #c5cde0;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.8rem;
}

.footer-links a:hover {
  color: #fff;
}

/* ===== EVOLUTION INDICATORS ===== */
.evo {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  margin-left: 4px;
  vertical-align: middle;
  flex-shrink: 0;
  white-space: nowrap;
  min-width: 28px;
  text-align: right;
}
.evo.up { color: #27ae60; }
.evo.down { color: #e74c3c; }
.evo.stable { color: #7a8ba3; }
.evo.new-entry { color: #f39c12; font-style: italic; }
