/* ==========================================================================
   Services v2 : rangées « Mes services » (19/11/2026)
   Se charge APRES signature.css. Remplace la disposition des rangées
   (.services-grid) : grille stable à 3 colonnes (titre / texte / image),
   texte immobile au survol, l'image grandit dans son propre espace
   (clip-path sur le cadre + léger zoom sur la photo), aucun reflow.
   Aucune couleur nouvelle : variables existantes (--ink, --ink2, --vin).
   ========================================================================== */

.services-grid {
  container-type: inline-size;              /* cqi = largeur de la liste, base de la taille des titres */
  --svc-gap: clamp(20px, 3cqi, 44px);
  --svc-vis-h: clamp(190px, 17vw, 250px);
  --svc-ease: cubic-bezier(0.4, 0.1, 0.2, 1);  /* départ doux, arrivée douce */
  --svc-dur: 0.65s;
}

/* ---------- Disposition de base (sans survol) : 3 colonnes fixes ---------- */
.services-grid .card-shell .card-inner,
.services-grid .card-shell:hover .card-inner,
.services-grid .card-shell:focus-within .card-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.5fr);
  grid-template-rows: auto auto 1fr;
  column-gap: var(--svc-gap);
  row-gap: 0;
  align-items: start;
  padding: clamp(22px, 2.6vw, 36px) 0;
  transition: none;
}

/* Titre : colonne 1, haut de rangée. Taille calée sur la colonne : le mot le plus long
   (Adoucisseur, environ 5 em de large) y tient toujours, avec une marge de sécurité. */
.services-grid .card-shell .card-body h3 {
  grid-column: 1; grid-row: 1 / 4; align-self: start; justify-self: start;
  margin: 0; max-width: 100%;
  font-size: clamp(1.8rem, calc((1.2 / 3.7) * (100cqi - 2 * var(--svc-gap)) / 5.3), 4.3rem);
  line-height: 0.94; color: var(--ink);
  overflow-wrap: normal; word-break: normal; hyphens: none;
  transition: color calc(var(--svc-dur) * 0.8) var(--svc-ease);
}

/* Texte : colonne 2, empilé depuis le haut, aligné avec le haut du titre */
.services-grid .card-shell .card-body p {
  grid-column: 2; grid-row: 1; align-self: start; margin: 0 0 14px; padding-top: 0.2em;
  color: var(--ink2); font-size: 1rem; line-height: 1.6;
}
.services-grid .card-shell .tags { grid-column: 2; grid-row: 2; align-self: start; }
.services-grid .card-shell .card-more { grid-column: 2; grid-row: 3; align-self: start; justify-self: start; margin-top: 14px; color: var(--vin); font-weight: 650; }

/* Image : colonne 3, pleine hauteur de rangée, cadre qui rogne */
.services-grid .card-shell .card-visual {
  grid-column: 3; grid-row: 1 / 4; align-self: start; justify-self: stretch;
  width: 100%; height: var(--svc-vis-h);
  position: relative; overflow: hidden; background: var(--marine);
}

/* ---------- Souris seulement : l'image grandit dans son propre espace ---------- */
@media (hover: hover) and (pointer: fine) and (min-width: 960px) and (prefers-reduced-motion: no-preference) {
  /* Repos : photo plus petite, calée à droite. Le cadre garde sa taille, seul le clip change :
     rien ne bouge autour, pas de reflow. */
  .services-grid .card-shell .card-visual {
    clip-path: inset(9% 0 9% 36%);
    transition: clip-path var(--svc-dur) var(--svc-ease);
    will-change: clip-path;
  }
  .services-grid .card-shell .card-visual img {
    scale: 1.14 !important;               /* propriété indépendante de transform (celle de GSAP) */
    transition: scale var(--svc-dur) var(--svc-ease), transform 0.5s var(--ease, ease);
  }
  /* Survol : petite tolérance d'entrée (80 ms) pour ne pas clignoter entre deux rangées ;
     la sortie est immédiate et se fond avec l'entrée de la rangée voisine. */
  .services-grid .card-shell .card-visual:hover,
  .services-grid .card-shell:has(:focus-visible) .card-visual {
    clip-path: inset(0);
    transition-delay: 0.08s;
  }
  .services-grid .card-shell .card-visual:hover img,
  .services-grid .card-shell:has(:focus-visible) .card-visual img {
    scale: 1 !important;
    transition-delay: 0.08s, 0s;
  }
  .services-grid .card-shell:has(.card-visual:hover) .card-body h3,
  .services-grid .card-shell:has(:focus-visible) .card-body h3 {
    color: var(--vin);
    transition-delay: 0.08s;
  }
}

/* Appareils tactiles ou grand écran sans souris fine : pas de survol, titre en couleur normale */
@media (hover: none), (pointer: coarse) {
  .services-grid .card-shell:hover .card-body h3 { color: var(--ink); }
}

/* ---------- Mobile et petites tablettes : disposition empilée ---------- */
@media (max-width: 959px) {
  .services-grid .card-shell .card-inner,
  .services-grid .card-shell:hover .card-inner,
  .services-grid .card-shell:focus-within .card-inner {
    grid-template-columns: minmax(0, 1fr); grid-template-rows: none; padding: 22px 0 30px;
  }
  .services-grid .card-shell .card-visual { grid-column: 1; grid-row: 1; height: clamp(180px, 46vw, 300px); margin-bottom: 18px; clip-path: none; }
  .services-grid .card-shell .card-body h3 { grid-column: 1; grid-row: 2; margin-bottom: 10px; font-size: clamp(2.2rem, 11cqi, 3.6rem); }
  .services-grid .card-shell .card-body p { grid-column: 1; grid-row: 3; padding-top: 0; }
  .services-grid .card-shell .tags { grid-column: 1; grid-row: 4; }
  .services-grid .card-shell .card-more { grid-column: 1; grid-row: 5; }
  .services-grid .card-shell .card-visual img { scale: 1 !important; }
}

/* ---------- Mouvement réduit : pas d'agrandissement animé, tout reste en place ---------- */
@media (prefers-reduced-motion: reduce) {
  .services-grid .card-shell .card-visual,
  .services-grid .card-shell .card-visual img,
  .services-grid .card-shell .card-body h3 { transition: none !important; }
  .services-grid .card-shell .card-visual { clip-path: none !important; }
  .services-grid .card-shell .card-visual img { scale: 1 !important; }
}

/* Gab 19/11 : mieux cadrer la photo pompe à chaleur au repos (la PAC est à gauche de l'image,
   la fenêtre visible est à droite) : on décale la photo, elle revient en place quand elle s'agrandit. */
@media (hover: hover) and (pointer: fine) and (min-width: 960px) and (prefers-reduced-motion: no-preference) {
  .services-grid .card-shell .card-visual img[src*="02-carte-pac"] {
    translate: 40% 0;
    transition: scale var(--svc-dur) var(--svc-ease), translate var(--svc-dur) var(--svc-ease), transform 0.5s var(--ease, ease);
  }
  .services-grid .card-shell .card-visual:hover img[src*="02-carte-pac"],
  .services-grid .card-shell:has(:focus-visible) .card-visual img[src*="02-carte-pac"] { translate: 0 0; }
}

/* Gab 19/11 : la photo passe au-dessus du lien qui couvre la rangée, pour que seul son survol l'agrandisse.
   Un clic sur la photo suit le même lien (services-v2.js). */
.services-grid .card-shell .card-visual { position: relative; z-index: 5; cursor: pointer; }
