/* ==========================================================================
   ASTP — Page Exploits (exploits.html)
   1. En chiffres (bandeau de chiffres clés)
   2. Barre d'outils (filtres, statut, bascule Instagram)
   3. Grille des exploits (1 → 2 → 3 colonnes)
   4. Carte d'exploit (en-tête, lignes, pastilles de rang, pied)
   5. Publication Instagram (façade « cliquer pour charger » + intégration)
   6. Cible d'ancre (#exploit-…)
   7. Bandeau d'appel final
   8. Mouvement réduit
   ========================================================================== */


/* ==========================================================================
   1. En chiffres
   ========================================================================== */
.exploits-summary {
  padding: var(--space-md) var(--space-sm) var(--space-sm);
  background: var(--grad-soft);
  border: 1px solid var(--p-100);
  border-radius: var(--radius-box);
}

.exploits-summary__eyebrow {
  justify-content: center;
  margin-bottom: var(--space-2xs);
}

.exploits-summary .kpi__label {
  font-weight: 600;
}

@media (max-width: 479.98px) {
  .exploits-summary {
    padding-inline: var(--space-md);
  }

  .exploits-summary__eyebrow {
    justify-content: flex-start;
  }
}

/* La section suivante n'a pas de filet : le bandeau fait déjà la séparation */
.exploits-summary + .section {
  padding-top: clamp(2.5rem, 2rem + 2vw, 4rem);
}

.exploits-list:last-child {
  padding-bottom: 0;
}


/* ==========================================================================
   2. Barre d'outils (révélée par exploits.js)
   ========================================================================== */
.exploits-list .section-head {
  margin-bottom: var(--space-md);
}

.exploits-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs) var(--space-md);
  margin-bottom: var(--space-md);
}

.exploits-status {
  font-size: var(--fs-small);
  font-weight: 600;
  color: var(--c-muted);
}

.ig-toggle svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

@media (max-width: 599.98px) {
  .exploits-toolbar {
    display: block;
  }

  .exploits-status {
    margin-top: var(--space-2xs);
  }

  .ig-toggle {
    white-space: normal;
    text-align: left;
  }
}


/* ==========================================================================
   3. Grille des exploits
   Flexbox : la dernière rangée incomplète reste centrée ; les cartes d'une
   même rangée ont la même hauteur (pied de carte calé en bas).
   ========================================================================== */
.exploits-grid {
  --ex-gap: var(--space-md);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--ex-gap);
}

.exploits-grid > .exploit-card {
  flex: 0 0 100%;
}

@media (min-width: 640px) {
  .exploits-grid > .exploit-card {
    flex-basis: calc((100% - var(--ex-gap)) / 2);
  }
}

@media (min-width: 1200px) {
  .exploits-grid {
    --ex-gap: 1.75rem;
  }

  .exploits-grid > .exploit-card {
    flex-basis: calc((100% - 2 * var(--ex-gap)) / 3);
  }
}


/* ==========================================================================
   4. Carte d'exploit (.card.exploit-card)
   ========================================================================== */
.exploit-card {
  gap: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  container-type: inline-size;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

/* La carte n'est pas cliquable : pas de soulèvement au survol. Seul le lien
   du pied, lorsqu'il est survolé ou ciblé, met la carte légèrement en valeur. */
.exploit-card:has(.exploit-card__footer a:hover),
.exploit-card:has(.exploit-card__footer a:focus-visible) {
  box-shadow: var(--shadow-md);
  border-color: var(--p-200);
}

/* En-tête : logo sur pastille blanche + nom, sur fond violet très pâle */
.exploit-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--grad-soft);
  border-bottom: 1px solid var(--p-100);
}

.exploit-card__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 64px;
  height: 48px;
  padding: 0.3rem 0.4rem;
  background: var(--c-white);
  border: 1px solid var(--p-100);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.exploit-card__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: none;
}

/* Exocet : logo très pâle, on le ravive (comme sur la page Sociétés) */
[data-societe="exocet"] .exploit-card__logo img,
[data-societe="exocet"] .ig-fallback__logo img {
  filter: saturate(1.8) contrast(1.1);
}

.exploit-card__title {
  min-width: 0;
  -webkit-hyphens: auto;
  hyphens: auto;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--c-ink);
}

/* Ancre #exploit-… posée sur le titre : on garde tout l'en-tête de carte sous l'en-tête collant */
.exploit-card__title[id] {
  scroll-margin-top: calc(var(--header-height) + 2.5rem);
}

/* Lignes de réalisation
   (sélecteur d'attribut pour l'emporter sur le reset ul[role="list"]) */
.exploit-card__list[role="list"] {
  display: grid;
  gap: 0.375rem;
  padding: var(--space-sm) var(--space-sm) 0;
  font-size: 1rem;
  line-height: 1.5;
}

.exploit-line {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color var(--dur) var(--ease);
}

.exploit-line__text {
  min-width: 0;
  padding-top: 0.1rem;
}

.exploit-line strong {
  color: var(--c-ink);
}

/* Ligne correspondant au filtre actif */
.exploit-line.is-match {
  background: var(--p-50);
  box-shadow: inset 3px 0 0 var(--p-500);
}

/* Pastille de rang (28px) — le texte de la ligne énonce déjà le rang */
.rank-badge {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-family: var(--font-heading);
  font-size: 0.8125rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  background: var(--p-100);
  color: var(--p-700);
}

.rank-badge--1 {
  background: var(--c-tier-or);
  color: var(--p-900);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.rank-badge--2 {
  background: #d9d9de;
  color: var(--p-900);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.1);
}

.rank-badge--3 {
  background: var(--c-tier-bronze);
  color: var(--c-white);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

/* Lignes sans rang : étoile violette décorative */
.exploit-line__mark {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--p-400);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z'/%3E%3C/svg%3E") center / 20px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z'/%3E%3C/svg%3E") center / 20px no-repeat;
}

/* Précision commune à plusieurs lignes (ex. : nom de la compétition) */
.exploit-card__context {
  padding: var(--space-3xs) var(--space-sm) 0 calc(var(--space-sm) + 0.5rem + 28px + 0.625rem);
  font-size: var(--fs-small);
  color: var(--c-muted);
}

/* Pied : lien vers la fiche de la société */
.exploit-card__footer {
  margin-top: auto;     /* pieds alignés d'une carte à l'autre dans une même rangée */
  padding: var(--space-xs) var(--space-md) var(--space-sm);
  border-top: 1px solid var(--p-100);
}

.exploit-card__footer .link-arrow {
  display: inline;
  min-height: 2.75rem;
  line-height: 2.75rem;
}

.exploit-card__footer .link-arrow > [aria-hidden="true"] {
  white-space: nowrap;
  margin-left: 0.15em;
}

/* Cartes étroites (2 colonnes entre 640 et 1200px, petits mobiles) */
@container (max-width: 300px) {
  .exploit-card__header {
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
  }

  .exploit-card__title {
    font-size: 1.125rem;
  }

  .exploit-card__footer {
    padding-inline: var(--space-sm);
  }
}


/* ==========================================================================
   5. Publication Instagram
   ========================================================================== */
.exploit-card__post {
  position: relative;   /* contient l'iframe positionnée en absolu par embed.js pendant le chargement */
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  padding: var(--space-sm);
}

/* Hauteur réservée seulement pendant le chargement (évite le saut de mise en
   page à l'arrivée de l'iframe) ; exploits.js passe ensuite data-ig à
   « loaded » ou « error », ce qui libère la hauteur. */
.exploit-card__post[data-ig="loading"] {
  min-height: 540px;
}

/* Blockquote d'origine (avant/sans embed.js). embed.js remplace sa classe par
   « instagram-media-registered » pendant le chargement : on cible l'élément. */
.exploit-card__post blockquote {
  display: flex;
  margin: 0;
  padding: 0;
}

/* Iframe rendu par embed.js : on neutralise la largeur minimale de 326px
   imposée en style en ligne pour éviter tout débordement en colonnes étroites. */
.exploit-card__post iframe.instagram-media {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 0 !important;
  border-radius: var(--radius-md) !important;
}

/* Iframe encore en chargement (hauteur 0, position absolue) : invisible,
   la façade reste affichée dessous jusqu'au rendu. */
.exploit-card__post iframe.instagram-media:not(.instagram-media-rendered) {
  position: absolute !important;
  top: var(--space-sm);
  left: var(--space-sm);
  width: calc(100% - 2 * var(--space-sm)) !important;
  opacity: 0;
  visibility: hidden;           /* hors de l'ordre de tabulation tant qu'il charge */
  pointer-events: none;
}

/* ---- Façade : visible sans JS (lien direct), bouton de chargement ajouté par JS ----
   Encadré clair et discret (pas de grand aplat violet) : les réalisations
   restent l'élément dominant de la carte. Hauteur = contenu. */
.ig-fallback {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  width: 100%;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: var(--p-50);
  border: 1px dashed var(--p-300);
  color: var(--c-ink);
  text-align: center;
}

.ig-fallback__brand {
  position: static;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.7rem 0.3rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--p-100);
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--p-700);
}

.ig-fallback__glyph {
  width: 1.125rem;
  height: 1.125rem;
}

.ig-fallback__logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 5rem;
  height: 3.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 12px;
  background: var(--c-white);
  border: 1px solid var(--p-100);
  box-shadow: none;
}

.ig-fallback__logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: none;
}

.ig-fallback__text {
  max-width: 24ch;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--c-ink);
  text-wrap: balance;
}

.ig-fallback__load {
  margin-top: var(--space-2xs);
  white-space: nowrap;
}

.ig-fallback__load[aria-busy="true"] {
  cursor: progress;
  opacity: 0.85;
}

.ig-fallback__link {
  display: inline-block;
  max-width: 100%;
  padding: 0.65rem 0.25rem;
  line-height: 1.4;
  font-weight: 700;
  color: var(--p-700);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.ig-fallback__ext {
  margin-left: 0.15em;
}

.ig-fallback__link:hover {
  color: var(--p-700);
  text-decoration-thickness: 2px;
}

/* #4a5568 sur --p-50 (#f7f5fe) : contraste ≈ 7:1 (AA) */
.ig-fallback__note,
.ig-fallback__error {
  max-width: 30ch;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--c-muted);
}

.ig-fallback__error {
  font-weight: 700;
  color: var(--c-ink);
}

/* Façade étroite : plus compacte */
@container (max-width: 300px) {
  .ig-fallback {
    gap: var(--space-2xs);
    padding-inline: var(--space-sm);
  }

  .ig-fallback__logo {
    width: 4.5rem;
    height: 3.25rem;
  }
}

/* Lien direct conservé sous une publication chargée */
.ig-direct {
  display: flex;
  justify-content: flex-end;
  font-size: var(--fs-small);
}


/* ==========================================================================
   6. Cible d'ancre (exploits.html#exploit-…) : contour + halo lavande
   ========================================================================== */
.exploit-card:has(:target) {
  outline: 3px solid var(--p-700);
  outline-offset: 3px;
  animation: exploit-pulse 1.2s var(--ease-out) 2;
}

@keyframes exploit-pulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 192, 241, 0.9); }
  100% { box-shadow: 0 0 0 22px rgba(201, 192, 241, 0); }
}


/* ==========================================================================
   7. Bandeau d'appel final (après la boîte blanche)
   ========================================================================== */
.exploits-cta {
  margin-top: 3rem;
}


/* ==========================================================================
   8. Mouvement réduit
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .exploit-card:has(:target) {
    animation: none;
  }
}

/* ---- Impression ---- */
@media print {
  .exploits-toolbar,
  .exploits-ig-toggle {
    display: none !important;
  }
}
