/* ACTE3 - Mosaique responsive : tous les styles de cette page sont autonomes.
   Seuils EXACTS en largeur de viewport : 5 / 4 / 3 / 2 / 1 colonnes.
   Les largeurs et hauteurs des modules sont des multiples d'une unite + gap. */

:root { color-scheme: light; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: #fff;
  color: #171717;
  font-family: 'Abel', 'Arial Narrow', Arial, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

/* Le meme retrait aligne EXACTEMENT les bords de la navigation et de la grille. */
:root { --gallery-gutter: clamp(10px, 1.2vw, 22px); }
#wrap { min-height: 100vh; display: flex; flex-direction: column; }

/* Le bandeau complet reste fixe en haut via sticky : les cartes defilent dessous.
   Une enveloppe commune evite les decalages entre les deux navigations sur mobile.
   La barre blanche de 20px sous le nav rend visible son border-bottom. */
.site-sticky {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #fff;
  /* Marge blanche protegeant la bordure basse du menu des photographies. */
  padding-bottom: 20px;
}
.site-header {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  min-height: 80px;
  padding: 0 var(--gallery-gutter);
  gap: 25px;
  background: #fff;
  color: #111;
}
.site-logo,
.site-nav a {
  display: flex;
  align-items: center;
  min-height: 80px;
  padding: 0 2px 6px;
  border-top: 6px solid transparent; /* Trait rose en HAUT au hover */
  color: #111;
  text-decoration: none;
  text-transform: uppercase;
  transition: border-top-color .6s ease-out;
}
.site-logo {
  flex-shrink: 0;
  font-size: clamp(19px, 1.7vw, 25px);
  letter-spacing: .015em;
  color: #cf0564; /* Logo ACTE3 : rose en permanence. */
}
.site-nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: clamp(15px, 3vw, 46px);
}
.site-nav a { font-size: 16px; }
.site-nav a[aria-current='page'] { color: #cf0564; } /* Projets actif sans barre permanente. */
.site-nav a:hover,
.site-nav a:focus-visible { color: #cf0564; }
.site-logo:hover,
.site-logo:focus-visible,
.site-nav a:hover,
.site-nav a:focus-visible { border-top-color: #cf0564; }
.site-logo:focus-visible,
.site-nav a:focus-visible { outline: 2px solid #cf0564; outline-offset: -2px; }

#main-flat { width: 100%; flex: 1; }
.project-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px 24px;
  min-height: 55px;
  margin: 0 var(--gallery-gutter);
  padding: 12px 0;
  border-top: 1px solid #dedede;
  border-bottom: 1px solid #dedede;
  background: #fff;
}
.project-menu a {
  color: #555;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 14px;
  letter-spacing: .015em;
  border-bottom: 2px solid transparent;
}
.project-menu a:hover,
.project-menu a:focus-visible,
.project-menu a[aria-current='page'] { color: #cf0564; border-bottom-color: #cf0564; }

/* Galerie et sous-navigation ont le meme retrait de chaque cote. */
.portfolio-gallery { padding: 0 var(--gallery-gutter) 36px; }
.mosaic-frame { width: 100%; container-type: inline-size; }
.mosaic {
  --gap: 12px;
  --cols: 5;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  /* Formule CSS sans JS : u = (W + gap) / N - gap */
  grid-auto-rows: var(--unit, calc((100cqw + var(--gap)) / 5 - var(--gap)));
  gap: var(--gap);
  width: 100%;
  padding: 0;
  margin: 0;
  align-items: stretch;
}
.mosaic__card {
  position: relative;
  display: block;
  grid-column: span 1;
  grid-row: span 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;
  /* Fond blanc sous les PNG transparents (pas de gris visible). */
  background: #fff;
  color: white;
  text-decoration: none;
  outline: 0;
}
.mosaic__card[data-format='2x1'] { grid-column: span 2; }
.mosaic__card[data-format='1x2'] { grid-row: span 2; }
.mosaic__card[data-format='2x2'] { grid-column: span 2; grid-row: span 2; }
/* Deux calques independants : image N&B par defaut et image couleur au hover.
   --focus conserve le meme cadrage pour les deux fichiers. */
.mosaic__image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus, 50% 50%);
  /* Chaque calque a son propre blanc : les zones transparentes du PNG
     couleur ne montrent pas le dessin N&B en dessous au survol. */
  background-color: #fff;
  transition: transform .55s cubic-bezier(.18,.7,.2,1);
}
.mosaic__image--default {
  filter: grayscale(1); /* Garantie N&B si le fichier source est en couleur. */
}
.mosaic__image--hover {
  opacity: 0;
  transition: opacity .35s ease, transform .55s cubic-bezier(.18,.7,.2,1);
}
.mosaic__overlay {
  position: absolute;
  inset: auto 0 0; /* Le bandeau occupe seulement le bas de la vignette. */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 13px clamp(12px, 1.7vw, 24px);
  background: rgba(0,0,0,.60);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
  z-index: 2;
}
.mosaic__title {
  color: #fff;
  width: 100%;
  font-size: clamp(15px, 1.4vw, 23px);
  text-align: center;
  line-height: 1.2;
  text-transform: uppercase;
  font-weight: 400;
  overflow-wrap: anywhere;
}
.mosaic__card:hover .mosaic__image,
.mosaic__card:focus-visible .mosaic__image { transform: scale(1.035); }
.mosaic__card:hover .mosaic__image--hover,
.mosaic__card:focus-visible .mosaic__image--hover { opacity: 1; }
.mosaic__card:hover .mosaic__overlay,
.mosaic__card:focus-visible .mosaic__overlay { opacity: 1; visibility: visible; }
.mosaic__card:focus-visible { outline: 3px solid #cf0564; outline-offset: -3px; z-index: 10; }
/* Une image de survol absente ne masque jamais la vignette N&B. */
.mosaic__card.is-hover-missing .mosaic__image--hover { display: none; }
/* Image absente : conserver un fond blanc et un titre lisible.
   Une image introuvable doit aussi etre signalee par le generateur. */
.mosaic__card.is-missing { background: #fff; }
.mosaic__card.is-missing .mosaic__image { display: none; }
.mosaic__card.is-missing .mosaic__overlay {
  inset: 0;
  background: transparent;
  opacity: 1;
  visibility: visible;
}
.mosaic__card.is-missing .mosaic__title { color: #555; }
/* Footer : reseaux sociaux a gauche et mentions legales a droite.
   Les SVG sont integres dans le HTML : aucune bibliotheque externe. */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  margin: 0 auto;
  padding: 22px var(--gallery-gutter) 28px;
  background: #fff;
  color: #666;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
}
.site-footer__socials {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 8px;
}
.site-footer__social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  color: #242424;
  text-decoration: none;
  transition: color .2s ease;
}
.site-footer__icon {
  display: block;
  width: 21px;
  height: 21px;
}
.site-footer__social:hover,
.site-footer__social:focus-visible { color: #cf0564; }
.site-footer__social:focus-visible {
  outline: 2px solid #cf0564;
  outline-offset: 2px;
}
.site-footer__legal {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}
.site-footer__legal a { text-decoration: none; }
.site-footer__legal a:hover,
.site-footer__legal a:focus-visible { text-decoration: underline; }
@media (max-width: 470px) {
  .site-footer { gap: 10px; font-size: 12px; }
  .site-footer__socials { gap: 4px; }
}

/* Breakpoints en largeur de viewport, selon les seuils demandes. */
@media (max-width:1600px) {
  .mosaic { --cols: 4; grid-auto-rows: var(--unit, calc((100cqw + var(--gap)) / 4 - var(--gap))); }
}
@media (max-width:1300px) {
  .mosaic { --cols: 3; grid-auto-rows: var(--unit, calc((100cqw + var(--gap)) / 3 - var(--gap))); }
}
@media (max-width:990px) {
  .mosaic { --cols: 2; grid-auto-rows: var(--unit, calc((100cqw + var(--gap)) / 2 - var(--gap))); }
  .mosaic__title { font-size: clamp(16px, 2.6vw, 27px); }
}
@media (max-width:650px) {
  .site-header { min-height: 58px; gap: 10px; }
  .site-logo, .site-nav a { min-height: 58px; border-top-width: 4px; padding-bottom: 4px; }
  .site-logo { font-size: 17px; }
  .site-nav { gap: 10px; }
  .site-nav a { font-size: 13px; }
  .project-menu { gap: 8px 15px; min-height: 0; padding: 10px 0; }
  .project-menu a { font-size: 13px; }
}
@media (max-width:440px) {
  /* Aux tres petites largeurs, le header peut prendre deux lignes.
     L'enveloppe sticky suit automatiquement sa hauteur reelle. */
  .site-header { flex-wrap: wrap; gap: 0 12px; padding-bottom: 4px; }
  .site-logo { min-height: 38px; }
  .site-nav { width: 100%; justify-content: flex-start; gap: 19px; }
  .site-nav a { min-height: 32px; }
}
@media (max-width:470px) {
  /* Une colonne : pas de sous-grille. Les rapports sont EXACTS. */
  .mosaic { --cols: 1; display: flex; flex-direction: column; gap: var(--gap); }
  .mosaic__card { flex: none; width: 100%; height: auto; aspect-ratio: 1 / 1; }
  .mosaic__card[data-format='2x1'] { aspect-ratio: 2 / 1; }
  .mosaic__card[data-format='1x2'] { aspect-ratio: 1 / 2; }
  .mosaic__card[data-format='2x2'] { aspect-ratio: 1 / 1; }
  /* Surclassement editorial facultatif du format mobile. */
  .mosaic__card[data-mobile='1x1'] { aspect-ratio: 1 / 1; }
  .mosaic__card[data-mobile='2x1'] { aspect-ratio: 2 / 1; }
  .mosaic__card[data-mobile='1x2'] { aspect-ratio: 1 / 2; }
}

/* Ecran tactile : pas de survol. La vignette reste N&B, et son titre est
   visible dans le MEME bandeau sombre, afin de garder l'acces aux titres. */
@media (hover: none) {
  .mosaic__overlay {
    padding: 11px 12px;
    opacity: 1;
    visibility: visible;
    background: rgba(0,0,0,.60);
  }
  .mosaic__title { font-size: clamp(14px, 3.7vw, 22px); }
  /* Un tap ne doit pas provoquer le passage a la photo couleur. */
  .mosaic__card:hover .mosaic__image--hover { opacity: 0; }
  .mosaic__card:focus-visible .mosaic__image--hover { opacity: 1; }
  .mosaic__card.is-missing .mosaic__overlay { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Panneau de diagnostic, visible UNIQUEMENT avec ?debug=1 */
.mosaic-debug { margin: 28px 0 0; padding: 18px; border: 1px solid #d4d4d4; background: #f6f6f6; font-family: Arial, sans-serif; }
.mosaic-debug h2 { margin: 0 0 8px; font-size: 17px; font-weight: 600; }
.mosaic-debug p { margin: 0 0 14px; font-size: 12px; color: #555; }
.mosaic-debug__samples { display: flex; align-items: flex-start; gap: 18px; flex-wrap: wrap; }
.mosaic-debug__sample { width: min(100%, 270px); padding: 12px; background: white; border: 1px solid #ddd; }
.mosaic-debug__sample h3 { margin: 0 0 9px; font-size: 12px; font-weight: 600; }
.mosaic-debug__sample p { margin: 8px 0 0; line-height: 1.45; overflow-wrap: anywhere; }
.mosaic-debug__grid { display: grid; gap: 2px; grid-auto-rows: 22px; }
.mosaic-debug__cell { display: grid; place-items: center; min-width: 0; overflow: hidden; color: white; font-size: 10px; font-weight: bold; }
.mosaic-debug__hole { background: #fff; border: 1px dashed #c97070; }
.mosaic-debug__mobile { display: flex; flex-direction: column; gap: 2px; width: 70px; }
.mosaic-debug__mobile .mosaic-debug__cell { width: 100%; }
