/*
 * E94 — Réalisations 1.1 — Masonry fluide, formats d'images respectés.
 * CSS columns : pas de gabarit imposé, pas de recadrage, aucun JS de calcul de hauteur.
 * Styles volontairement encapsulés pour Divi 5.
 */
.e94-projects {
  --e94-p-ink: var(--color-text-primary, #1c1b18);
  --e94-p-stone: var(--color-text-secondary, #5c564c);
  --e94-p-green: var(--color-surface-inverse, #0f3a21);
  --e94-p-line: var(--color-border-default, #c2b9a8);
  --e94-p-gap: clamp(14px, 1.6vw, 24px);
  width: 100%;
  min-width: 0;
  font-family: inherit;
}
.e94-projects *, .e94-projects *::before, .e94-projects *::after {
  box-sizing: border-box;
}

/* Catégories : fonctionnement inchangé. Sans JS, les photos restent visibles. */
.e94-projects__filters {
  display: none;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 20px;
}
.e94-projects--ready .e94-projects__filters { display: flex; }
.e94-projects__filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  appearance: none;
  border: 1px solid var(--e94-p-line);
  border-radius: 2px;
  background: transparent;
  color: var(--e94-p-ink);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.35;
  padding: 12px 18px;
  min-height: 44px;
  text-align: center;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.e94-projects__filter:hover { border-color: var(--e94-p-green); }
.e94-projects__filter:focus-visible { outline: 2px solid #007a35; outline-offset: 3px; }
.e94-projects__filter.is-active {
  background: var(--e94-p-green);
  color: #fff;
  border-color: var(--e94-p-green);
}
.e94-projects__check { display: none; font-size: 15px; }
.e94-projects__filter.is-active .e94-projects__check { display: inline; }
.e94-projects__count {
  color: var(--e94-p-stone);
  margin: 0 0 30px;
  font-size: 14px;
  line-height: 1.5;
}

/*
 * Véritable composition masonry : le navigateur équilibre des colonnes,
 * la hauteur de chaque carte suit automatiquement le ratio de sa photographie.
 * Les cartes sont lues de haut en bas dans une colonne, puis dans la suivante.
 */
.e94-projects__grid {
  display: block;
  column-count: 3;
  column-gap: var(--e94-p-gap);
  width: 100%;
}
.e94-project-card {
  display: inline-block;
  vertical-align: top;
  position: relative;
  width: 100%;
  margin: 0 0 var(--e94-p-gap);
  padding: 0;
  border-radius: 0;
  background: #dad3c5;
  overflow: hidden;
  isolation: isolate;
  break-inside: avoid;
  page-break-inside: avoid;
  cursor: default;
}
.e94-project-card[hidden] { display: none !important; }
.e94-project-card__media { position: relative; width: 100%; }
.e94-project-card__image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  position: relative;
  object-fit: contain;
  /* Agrandissement doux au hover, sans déformation du format original. */
  transition: transform 420ms cubic-bezier(.2,.7,.2,1);
}
.e94-project-card__placeholder { aspect-ratio: 4 / 3; background: #dad3c5; }
.e94-project-card__media::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(10,39,23,0) 16%, rgba(10,39,23,.12) 43%, rgba(10,39,23,.90) 100%);
}

/* Cartouches : toujours visibles pour catégorie/titre ; description au hover/focus. */
.e94-project-card__caption {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: 0;
  padding: clamp(15px, 1.7vw, 26px);
  color: #fff;
  transform: translateY(0);
  transition: transform 220ms ease;
}
.e94-project-card__category {
  margin: 0 0 6px !important;
  padding: 0 !important;
  color: #d4eadb !important;
  text-transform: uppercase;
  font-size: clamp(10px, .7vw, 12px) !important;
  letter-spacing: .14em;
  line-height: 1.35 !important;
  font-weight: 600;
}
.e94-project-card__title {
  margin: 0 !important;
  padding: 0 !important;
  color: #fff !important;
  font-size: clamp(17px, 1.35vw, 24px) !important;
  font-weight: 600 !important;
  line-height: 1.22 !important;
  letter-spacing: -.015em;
}
.e94-project-card__detail-wrap {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 220ms ease, opacity 180ms ease;
}
.e94-project-card__description {
  overflow: hidden;
  min-height: 0;
  margin: 0 !important;
  padding: 0 !important;
  color: #fff !important;
  font-size: clamp(12px, 1vw, 15px) !important;
  line-height: 1.5 !important;
  font-weight: 400;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.e94-project-card__description::before { content: ''; display: block; height: 8px; }

@media (hover: hover) and (pointer: fine) {
  .e94-project-card:hover .e94-project-card__image { transform: scale(1.025); }
  .e94-project-card:hover .e94-project-card__caption { transform: translateY(-3px); }
  .e94-project-card:hover .e94-project-card__detail-wrap {
    grid-template-rows: 1fr;
    opacity: 1;
  }
}
.e94-project-card:focus-visible { outline: 3px solid #a6d3b3; outline-offset: -3px; }
.e94-project-card:focus-visible .e94-project-card__caption { transform: translateY(-3px); }
.e94-project-card:focus-visible .e94-project-card__detail-wrap {
  grid-template-rows: 1fr;
  opacity: 1;
}

/* Pour 1 ou 2 photos après filtrage, éviter une galerie aux colonnes vides. */
.e94-projects--few-1 .e94-projects__grid { column-count: 1; max-width: 620px; }
.e94-projects--few-2 .e94-projects__grid { column-count: 2; }
.e94-projects__empty, .e94-projects-empty { color: var(--e94-p-stone); margin: 20px 0; }
.e94-projects__empty[hidden] { display: none !important; }

@media (max-width: 1050px) {
  .e94-projects__grid { column-count: 2; }
  .e94-projects--few-1 .e94-projects__grid { column-count: 1; }
  .e94-projects--few-2 .e94-projects__grid { column-count: 2; }
}
@media (max-width: 700px) {
  .e94-projects__filters { gap: 8px; margin-bottom: 14px; }
  .e94-projects__filter { font-size: 13px; padding: 10px 12px; }
  .e94-projects__count { margin-bottom: 22px; }
  .e94-projects__grid,
  .e94-projects--few-1 .e94-projects__grid,
  .e94-projects--few-2 .e94-projects__grid {
    column-count: 1;
  }
  .e94-project-card { margin-bottom: 14px; }
  .e94-project-card__caption { padding: 20px; }
  .e94-project-card__title { font-size: clamp(18px, 5vw, 23px) !important; }
}

/* Sur écran tactile, la description est accessible sans survol. */
@media (hover: none) {
  .e94-project-card__detail-wrap { grid-template-rows: 1fr; opacity: 1; }
  .e94-project-card__media::after {
    background: linear-gradient(180deg, rgba(10,39,23,0) 9%, rgba(10,39,23,.15) 37%, rgba(10,39,23,.93) 100%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .e94-projects *, .e94-projects *::before, .e94-projects *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ========================================================================
   E94 — V1.2 : présentations éditoriales pour les sélections courtes.
   La grille .e94-projects--portfolio reste strictement en masonry V1.1.
   Home : mosaïque maîtrisée, services : cartes égales et pleine largeur.
   ======================================================================== */

/* Les modes éditoriaux sortent explicitement de CSS columns. */
.e94-projects--home .e94-projects__grid,
.e94-projects--services .e94-projects__grid {
  display: grid;
  column-count: auto;
  grid-auto-flow: row;
  gap: var(--e94-p-gap);
  width: 100%;
  align-items: stretch;
  min-width: 0;
}

.e94-projects--home .e94-project-card,
.e94-projects--services .e94-project-card {
  display: block;
  width: 100%;
  margin: 0;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  aspect-ratio: 3 / 2;
}

/* Ratio et cadrage pilotés par les cartes, pas par la photo originale.
   Les originaux ne sont jamais déformés : object-fit: cover recadre. */
.e94-projects--home .e94-project-card__media,
.e94-projects--services .e94-project-card__media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.e94-projects--home .e94-project-card__image,
.e94-projects--services .e94-project-card__image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}
.e94-projects--home .e94-project-card__placeholder,
.e94-projects--services .e94-project-card__placeholder {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

/* --- ACCUEIL : 5 projets = vedette + deux vignettes + deux cartes --- */
.e94-projects--home .e94-projects__grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.e94-projects--home.e94-projects--count-5 .e94-projects__grid,
.e94-projects--home.e94-projects--count-3 .e94-projects__grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: auto auto auto;
}
.e94-projects--home.e94-projects--count-3 .e94-projects__grid {
  grid-template-rows: auto auto;
}
.e94-projects--home.e94-projects--count-5 .e94-project-card:first-child,
.e94-projects--home.e94-projects--count-3 .e94-project-card:first-child {
  grid-column: span 4;
  grid-row: span 2;
  aspect-ratio: auto;
}
.e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(2),
.e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(3),
.e94-projects--home.e94-projects--count-3 .e94-project-card:nth-child(2),
.e94-projects--home.e94-projects--count-3 .e94-project-card:nth-child(3) {
  grid-column: span 2;
  aspect-ratio: 1.48 / 1;
}
.e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(4),
.e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(5) {
  grid-column: span 3;
  aspect-ratio: 1.52 / 1;
}
.e94-projects--home.e94-projects--count-4 .e94-projects__grid,
.e94-projects--home.e94-projects--count-2 .e94-projects__grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.e94-projects--home.e94-projects--count-1 .e94-projects__grid {
  grid-template-columns: minmax(0, 1fr);
  max-width: 780px;
}

/* --- SERVICES : 3 colonnes équivalentes, 2 cartes = moitié chacune --- */
.e94-projects--services .e94-projects__grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.e94-projects--services.e94-projects--count-2 .e94-projects__grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.e94-projects--services.e94-projects--count-1 .e94-projects__grid {
  grid-template-columns: minmax(0, 1fr);
  max-width: 760px;
}
.e94-projects--services .e94-project-card {
  aspect-ratio: 4 / 3;
}

/* Les très petites cartes éditoriales nécessitent un titre compact. */
.e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(2) .e94-project-card__caption,
.e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(3) .e94-project-card__caption,
.e94-projects--home.e94-projects--count-3 .e94-project-card:not(:first-child) .e94-project-card__caption {
  padding: clamp(13px, 1.25vw, 20px);
}
.e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(2) .e94-project-card__title,
.e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(3) .e94-project-card__title,
.e94-projects--home.e94-projects--count-3 .e94-project-card:not(:first-child) .e94-project-card__title {
  font-size: clamp(16px, 1.05vw, 20px) !important;
}

/* Breakpoint tablette : on privilégie des cartes suffisamment larges pour
   les titres, au lieu de conserver une mini-vignette trop basse. */
@media (max-width: 1100px) {
  .e94-projects--home .e94-projects__grid,
  .e94-projects--home.e94-projects--count-3 .e94-projects__grid,
  .e94-projects--home.e94-projects--count-5 .e94-projects__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
  }
  .e94-projects--home .e94-project-card,
  .e94-projects--home.e94-projects--count-5 .e94-project-card,
  .e94-projects--home.e94-projects--count-3 .e94-project-card {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: 3 / 2;
  }
  /* Remettre aussi les positions spécifiques du motif 6-colonnes à auto. */
  .e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(2),
  .e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(3),
  .e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(4),
  .e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(5),
  .e94-projects--home.e94-projects--count-3 .e94-project-card:nth-child(2),
  .e94-projects--home.e94-projects--count-3 .e94-project-card:nth-child(3) {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: 3 / 2;
  }
  .e94-projects--home.e94-projects--count-3 .e94-project-card:first-child,
  .e94-projects--home.e94-projects--count-5 .e94-project-card:first-child {
    grid-column: 1 / -1;
    grid-row: auto;
    aspect-ratio: 2.05 / 1;
  }
  .e94-projects--home.e94-projects--count-1 .e94-projects__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 1050px) {
  .e94-projects--services .e94-projects__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .e94-projects--services.e94-projects--count-3 .e94-project-card:last-child {
    grid-column: 1 / -1;
    aspect-ratio: 2 / 1;
  }
  .e94-projects--services.e94-projects--count-1 .e94-projects__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 700px) {
  .e94-projects--home .e94-projects__grid,
  .e94-projects--home.e94-projects--count-1 .e94-projects__grid,
  .e94-projects--home.e94-projects--count-2 .e94-projects__grid,
  .e94-projects--home.e94-projects--count-3 .e94-projects__grid,
  .e94-projects--home.e94-projects--count-4 .e94-projects__grid,
  .e94-projects--home.e94-projects--count-5 .e94-projects__grid,
  .e94-projects--services .e94-projects__grid,
  .e94-projects--services.e94-projects--count-1 .e94-projects__grid,
  .e94-projects--services.e94-projects--count-2 .e94-projects__grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .e94-projects--home .e94-project-card,
  .e94-projects--home.e94-projects--count-3 .e94-project-card:first-child,
  .e94-projects--home.e94-projects--count-5 .e94-project-card:first-child,
  .e94-projects--services .e94-project-card,
  .e94-projects--services.e94-projects--count-3 .e94-project-card:last-child {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: 4 / 3;
  }
  .e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(2),
  .e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(3),
  .e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(4),
  .e94-projects--home.e94-projects--count-5 .e94-project-card:nth-child(5),
  .e94-projects--home.e94-projects--count-3 .e94-project-card:not(:first-child) {
    grid-column: auto;
    aspect-ratio: 4 / 3;
  }
}
