/* ====== Overlay - Mobile-first, responsive & accessible ====== */

/* Couche overlay centrée, non bloquante pour les interactions */
.overlay {
  position: absolute !important;
  inset: 0;                          /* top/right/bottom/left: 0 */
  z-index: 1 !important;

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

  overflow: hidden;
  pointer-events: none;              /* laisse passer scroll/clics sous l'overlay */
}

/* Réactive les events uniquement sur le contenu cliquable */
.overlay .text,
.overlay a {
  pointer-events: auto;
}

/* Contrainte de largeur et padding réactif du bloc texte */
.overlay .text-wrap {
  display: inline-block;               /* pour que max-width s’applique proprement */
  box-sizing: border-box;
  max-width: min(92vw, 1100px);        /* borne la largeur à l’écran */
  padding-inline: clamp(12px, 4vw, 48px);
  white-space: normal;                  /* autorise le retour à la ligne */
  overflow-wrap: anywhere;              /* évite les débordements de mots longs */
}

/* Lien/texte principal : style, tailles fluides, transitions */
.overlay a.text {
  position: relative;
  display: block;

  color: #FFD700 !important;
  text-decoration: none;
  text-align: center;
  font-family: 'BalboaMedium', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  /* Taille fluide : min 1.4rem, évolue avec la largeur, plafonne à 7vh */
  /* Utilise vw pour la largeur, vh en plafond pour garder l'effet "plein écran" */
  font-size: clamp(1.4rem, 5.2vw, 7vh);
  line-height: 1.15;                   /* compact mais respirant */

  /* Stroke réduit sur mobile, renforcé sur grands écrans via MQ plus bas */
  -webkit-text-stroke: 0.5px rgb(66, 66, 66);
  text-rendering: optimizeLegibility;

  /* État de base : invisible (fade contrôlé par classes .is-visible/.is-hidden) */
  opacity: 0;
  transition:
    opacity 480ms cubic-bezier(.22,.61,.36,1),
    filter 480ms cubic-bezier(.22,.61,.36,1);
  filter: blur(0.001px);               /* hack pour lisser sur certains GPU */
  will-change: opacity, filter;
  background-clip: text;
}

/* Élément interne pour l'échelle continue (piloté par JS si présent) */
.overlay .text .scale {
  display: inline-block;
  transform: scale(1);
  transform-origin: center center;
  will-change: transform;
}

/* ====== États d’animation ====== */
.overlay .text.is-visible {
  opacity: 1;
  filter: blur(0);
}

.overlay .text.is-hidden {
  opacity: 0;
  filter: blur(0.6px);                 /* léger flou en sortie */
  pointer-events: none;                /* évite les clics pendant la disparition */
}

/* ====== Accessibilité : réduire les animations si demandé ====== */
@media (prefers-reduced-motion: reduce) {
  .overlay .text {
    transition: none !important;
    filter: none !important;
  }
  .overlay .text .scale {
    transition: none !important;
    transform: none !important;
  }
}

/* ====== Ajustements par points de rupture ====== */

/* Très petits téléphones */
@media (max-width: 360px) {
  .overlay a.text {
    font-size: clamp(1.2rem, 5.6vw, 6.5vh);
    line-height: 1.2;
    -webkit-text-stroke: 0.4px rgb(66, 66, 66);
  }
  .overlay .text-wrap {
    max-width: 94vw;
    padding-inline: 12px;
  }
}

/* Téléphones standards */
@media (min-width: 361px) and (max-width: 480px) {
  .overlay a.text {
    font-size: clamp(1.3rem, 5.2vw, 6.8vh);
    line-height: 1.18;
    -webkit-text-stroke: 0.45px rgb(66, 66, 66);
  }
  .overlay .text-wrap {
    max-width: 92vw;
  }
}

/* Tablettes portrait / petits laptops */
@media (min-width: 481px) and (max-width: 768px) {
  .overlay a.text {
    font-size: clamp(1.5rem, 4.4vw, 7vh);
    line-height: 1.14;
    -webkit-text-stroke: 0.6px rgb(66, 66, 66);
  }
  .overlay .text-wrap {
    max-width: min(84vw, 1000px);
  }
}

/* Tablettes paysage / desktop */
@media (min-width: 769px) and (max-width: 1200px) {
  .overlay a.text {
    font-size: clamp(1.6rem, 3.6vw, 7vh);
    line-height: 1.12;
    -webkit-text-stroke: 0.8px rgb(66, 66, 66);
  }
  .overlay .text-wrap {
    max-width: min(72vw, 1100px);
  }
}

/* Grands écrans */
@media (min-width: 1201px) {
  .overlay a.text {
    font-size: clamp(1.8rem, 3vw, 7vh);
    line-height: 1.1;
    -webkit-text-stroke: 1px rgb(66, 66, 66);
  }
  .overlay .text-wrap {
    max-width: min(60vw, 1100px);
  }
}

/* ====== Option : si .scale est piloté par JS, brider sur mobile ====== */
@media (max-width: 480px) {
  .overlay .text .scale {
    transform: scale(0.9);
  }
}

.overlayTitle {
  position: absolute;
  top: clamp(40px, 12vh, 120px);     /* équivalent de ton 100px → responsive */
  right: clamp(16px, 4vw, 60px);     /* équivalent de ton 50px → responsive */
  left: auto;
  bottom: auto;

  display: flex;
  justify-content: flex-end;
  align-items: flex-start;

  width: 100%;
  pointer-events: none;
  z-index: 10;
}

/* le texte */
.overlayTitle a.text {
  color: #FFD700 !important;
  -webkit-text-stroke: 1px rgb(66,66,66);

  font-family: 'BalboaMedium';
  line-height: 1.05;

  font-size: clamp(1.8rem, 6vw, 4rem); /* = ton 7vh → version responsive */
  text-align: right; /* important pour garder l’alignement à droite */
}

.overlayTitle .text-wrap {
  display: inline-block;
  max-width: min(70vw, 900px);
  overflow-wrap: anywhere;
}

/* scale interne */
.overlayTitle .scale {
  display: inline-block;
  transform-origin: right center; /* aligné avec l'alignement à droite */
}


/* --- VERSION MOBILE (≤ 600px) --- */
@media (max-width: 600px) {
  .overlayTitle {
    top: auto;
    right: clamp(16px, 4vw, 60px); 
    left: auto;
    left: auto;
    bottom: clamp(20px, 8vh, 60px);;
    padding-inline: 12px;
  }

  .overlayTitle a.text {
    font-size: clamp(1.8rem, 6vw, 4rem);
  }

  .overlayTitle .text-wrap {
    max-width: 90vw;                /* plus large pour éviter les sauts de ligne trop serrés */
    padding-inline: 0;
  }

  .overlayTitle .scale {
    transform-origin: center center; /* centre l'effet scale */
  }
}
