/* Trombinoscope Candidats – Front (2.4.3)
 * Stabilisé :
 * - grille responsive propre
 * - tuiles même hauteur
 * - champs textes à hauteur homogène (1 ou 2 lignes)
 * - portrait des tuiles PARFAITEMENT rond + ratio 1:1 garanti (quel que soit le zoom)
 * - numéro qui dépasse
 * - modale mobile : tout tient + boutons close/nav toujours visibles et cliquables
 * - modale desktop : cadre inchangé (photo en contain)
 */

.tcand{
  --tcand-border: rgba(0,0,0,.06);
  --tcand-overlay: rgba(0,0,0,.55);
  box-sizing:border-box;
}
.tcand *,
.tcand *::before,
.tcand *::after{box-sizing:inherit}

.tcand-wrap{width:100%}

/* =========================
   GRILLE responsive
   ========================= */
.tcand-grid{
  display:grid;
  gap:var(--tcand-gap,16px);
  grid-template-columns:repeat(var(--tcand-cols-d,4), minmax(0,1fr));
  align-items:stretch;
}
.tcand-col{display:block;min-width:0}

@media (max-width:980px){
  .tcand-grid{grid-template-columns:repeat(var(--tcand-cols-t,2), minmax(0,1fr))}
}
@media (max-width:680px){
  .tcand-grid{grid-template-columns:repeat(var(--tcand-cols-m,1), minmax(0,1fr))}
}

/* =========================
   CARD (hauteurs uniformes)
   ========================= */
.tcand-card{
  background:transparent;
  height:100%;
  min-width:0;
}

.tcand-open{
  width:100%;
  height:100%;
  min-width:0;

  border:1px solid var(--tcand-border);
  background:var(--tcand-card-bg,#fff);
  border-radius:var(--tcand-radius,18px);
  padding:16px 16px 14px;
  text-align:var(--tcand-align,center);

  display:flex;
  flex-direction:column;

  cursor:pointer;
  color:inherit;
  box-shadow:var(--tcand-shadow,none);
  transition:transform .12s ease, box-shadow .12s ease;
}

.tcand-open:focus{
  outline:3px solid color-mix(in srgb, var(--tcand-accent,#0b57d0) 45%, transparent);
  outline-offset:2px;
}
.tcand-open:hover{transform:translateY(-1px)}

/* =========================
   PHOTO (tuiles) : 1:1 GARANTI + rond parfait + numéro qui dépasse
   ========================= */

/* Carré 1:1 permanent via padding (robuste même si un thème touche à l'image) */
.tcand-photo{
  position:relative;
  margin:0 auto 12px;

  width:64%;
  max-width:12rem;

  border-radius:50%;
  overflow:visible;         /* badge peut dépasser */
  background:transparent;
}

/* carré 1:1 */
.tcand-photo::after{
  content:"";
  display:block;
  padding-top:100%;
}

/* fond rond */
.tcand-photo::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius:50%;
  background:rgba(0,0,0,.04);
  z-index:0;
}

/* image : toujours pleine, toujours ronde, zoom ignoré sur les tuiles */
.tcand-photo img{
  position:absolute;
  inset:0;
  z-index:1;

  width:100%;
  height:100%;
  display:block;

  object-fit:cover;
  object-position:var(--tcand-photo-pos,50% 50%);

  transform:none !important; /* garantit l'uniformité malgré un zoom stocké */
  border-radius:50%;
  clip-path:circle(50% at 50% 50%);
}

/* placeholder */
.tcand-photo-placeholder{
  position:absolute;
  inset:0;
  z-index:1;

  width:100%;
  height:100%;

  border-radius:50%;
  clip-path:circle(50% at 50% 50%);
  background:transparent;
}

/* Tu veux un portrait rond => on neutralise les variantes de forme sur les tuiles */
.tcand-photo-square .tcand-photo,
.tcand-photo-rounded .tcand-photo,
.tcand-photo-circle .tcand-photo{border-radius:50%}
.tcand-photo-square .tcand-photo::before,
.tcand-photo-rounded .tcand-photo::before,
.tcand-photo-circle .tcand-photo::before{border-radius:50%}
.tcand-photo-square .tcand-photo img,
.tcand-photo-rounded .tcand-photo img,
.tcand-photo-circle .tcand-photo img{border-radius:50%;clip-path:circle(50% at 50% 50%)}

/* Numéro */
.tcand-num-pill{
  position:absolute;
  left:50%;
  bottom:-0.65em;
  transform:translateX(-50%);
  z-index:20;
  pointer-events:none;

  min-width:1.9em;
  height:1.9em;
  padding:0 .45em;
  border-radius:999px;

  background:var(--tcand-num-bg,#111);
  color:var(--tcand-num-color,#fff);

  display:inline-flex;
  align-items:center;
  justify-content:center;

  font-weight:800;
  font-size:0.9rem;
  line-height:1;

  border:3px solid var(--tcand-card-bg,#fff);
  box-shadow:0 6px 16px rgba(0,0,0,.18);
}

/* =========================
   TEXT (hauteurs homogènes)
   ========================= */
.tcand-name,
.tcand-profession,
.tcand-age{line-height:1.25}

/* 2 lignes max + hauteur réservée */
.tcand-name{
  font-size:1.15rem;
  font-weight:var(--tcand-name-weight,700);
  margin:0 0 4px;

  min-height:2.5em;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

.tcand-profession{
  opacity:.7;
  font-size:.92rem;
  margin:0 0 6px;

  min-height:2.5em;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
  overflow:hidden;
}

/* 1 ligne, hauteur fixe */
.tcand-age{
  color:var(--tcand-accent,#0b57d0);
  font-weight:700;
  margin:0 0 10px;

  min-height:1.25em;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* Badges : hauteur uniforme */
.tcand-role,
.tcand-badge2{
  display:inline-flex;
  align-items:center;
  justify-content:center;

  padding:.55em 1em;
  border-radius:999px;
  font-weight:700;
  font-size:.92rem;
  line-height:1.15;
  margin:.35rem 0 0;
  width:100%;

  min-height:2.6em;
}

.tcand-role{
  background:var(--tcand-role-bg,var(--tcand-accent,#0b57d0));
  color:var(--tcand-role-color,#fff);
}

.tcand-badge2{
  background:var(--tcand-badge2-bg,#2e7d32);
  color:var(--tcand-badge2-color,#fff);
}

.tcand-badge2-outline .tcand-badge2{
  background:transparent;
  border:2px solid var(--tcand-badge2-bg,#2e7d32);
  color:var(--tcand-badge2-bg,#2e7d32);
}

/* =========================
   MODALE – base (desktop)
   ========================= */
.tcand-modal{position:fixed;inset:0;display:none;z-index:99999}
.tcand-modal.is-open{display:block}
.tcand-modal-overlay{position:absolute;inset:0;background:var(--tcand-overlay)}

.tcand-modal-panel{
  position:relative; /* contexte */
  width:min(var(--tcand-modal-max,980px), calc(100% - 32px));
  height:min(82vh, 780px);
  margin:6vh auto 0;
  border-radius:22px;
  overflow:hidden;
  background:#fff;
  box-shadow:0 22px 70px rgba(0,0,0,.35);
}

.tcand-modal-content{display:flex;height:100%}
.tcand-modal-photo{flex:1.2;background:#f4f4f4;position:relative}
.tcand-modal-photo-box{position:absolute;inset:0}

.tcand-modal-img{
  width:100%;
  height:100%;
  display:block;
  object-fit:contain; /* NE PAS TOUCHER */
  object-position:center;
}

.tcand-modal-text{
  flex:0.8;
  background:#fff;
  padding:32px 28px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  gap:10px;
}

/* Boutons ronds (fermer + nav) : toujours visibles, y compris mobile */
.tcand-modal-close,
.tcand-modal-nav{
  position:absolute;
  width:44px;
  height:44px;
  border-radius:999px;
  border:0;
  background:rgba(255,255,255,.85);
  display:flex !important;   /* sécurité contre thèmes */
  align-items:center;
  justify-content:center;
  cursor:pointer;
  box-shadow:0 10px 22px rgba(0,0,0,.18);
  color:#111;

  z-index:999999;            /* AU-DESSUS de tout */
  pointer-events:auto;
}

.tcand-modal-close{top:14px;right:14px;font-size:26px;line-height:1}
.tcand-modal-nav{top:50%;transform:translateY(-50%);font-size:30px;line-height:1}
.tcand-modal-nav:hover,.tcand-modal-close:hover{background:#fff}
.tcand-prev{left:14px}
.tcand-next{right:14px}

/* Numéro dans modale */
.tcand-modal-number{margin:0 0 10px}
.tcand-modal-number .tcand-num-pill{
  position:static;
  transform:none;
  border:0;
  box-shadow:0 10px 22px rgba(0,0,0,.22);
  min-width:2.0em;
  height:2.0em;
}

/* =========================
   MODALE – mobile : tout tient + boutons visibles
   ========================= */
@media (max-width:860px){
  /* panel quasi plein écran */
  .tcand-modal-panel{
    width:calc(100% - 16px);
    height:calc(100svh - 16px);
    margin:8px auto 0;
    border-radius:18px;
    overflow:hidden; /* garde propre; boutons sont au-dessus via z-index */
  }

  /* empilement */
  .tcand-modal-content{
    flex-direction:column;
    height:100%;
  }

  /* zone photo avec hauteur dédiée */
  .tcand-modal-photo{
    flex:none;
    height:44svh;
    min-height:240px;
  }

  /* texte scrollable */
  .tcand-modal-text{
    flex:1;
    padding:18px 16px 16px;
    overflow:auto;
    -webkit-overflow-scrolling:touch;
  }

  /* boutons un peu plus compacts */
  .tcand-modal-close,
  .tcand-modal-nav{
    width:40px;
    height:40px;
  }
  .tcand-modal-close{top:10px;right:10px;font-size:24px}

  /* nav sur la zone photo (donc toujours visibles) */
  .tcand-modal-nav{
    top:calc(22svh); /* milieu visuel de la zone photo */
    transform:translateY(-50%);
    font-size:28px;
  }
  .tcand-prev{left:10px}
  .tcand-next{right:10px}
}

.tcand-modal-disabled .tcand-open{cursor:default}
