/* ============================================================================
   css/media.css — Galerie photo, revue de presse et visionneuse plein écran
   Composant partagé : page d'inscription d'un événement et page d'un salon.
   Mobile d'abord ; tokens propres (indépendants du style de la page hôte).
   ============================================================================ */
.mg-section {
  --mg-ink: #0E1A2E;
  --mg-text: #475467;
  --mg-muted: #667085;
  --mg-accent: #2B5A9E;
  --mg-gold: #E2D539;
  --mg-line: #E4E7EC;
  --mg-paper: #FFFFFF;
  --mg-radius: 14px;
  --mg-ease: cubic-bezier(.2, .7, .2, 1);
  padding: 56px 0;
  background: var(--mg-paper);
  border-top: 1px solid var(--mg-line);
  scroll-margin-top: 16px;
}

.mg-section--press { background: #F7F7F4; }

/* ---------- En-tête de section ---------- */
.mg-head { max-width: 640px; margin-bottom: 28px; }
.mg-kicker { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--mg-accent); }
.mg-title { margin: 0 0 8px; font-family: 'Playfair Display', Georgia, serif; font-size: clamp(26px, 3.4vw, 34px); font-weight: 600; line-height: 1.15; color: var(--mg-ink); }
.mg-lead { margin: 0; font-size: 15.5px; line-height: 1.6; color: var(--mg-text); }

/* ---------- Exposants des éditions passées (page d'un salon) ---------- */
.past-exh { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.past-exh__item { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 12px; border: 1px solid var(--mg-line); border-radius: var(--mg-radius); background: #FFFFFF; }
.past-exh__logo { flex-shrink: 0; width: 52px; height: 52px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; background: #F2F4F7; font-weight: 700; color: var(--mg-accent); }
.past-exh__logo img { width: 100%; height: 100%; object-fit: contain; }
.past-exh__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.past-exh__name { font-weight: 700; color: var(--mg-ink); text-decoration: none; overflow-wrap: anywhere; }
a.past-exh__name:hover { color: var(--mg-accent); text-decoration: underline; }
.past-exh__meta { font-size: 13px; color: var(--mg-muted); }

/* ---------- Galerie en rangées justifiées ----------
   Chaque photo garde ses proportions (--r = largeur / hauteur, calculé côté serveur) :
   largeur de base = proportion × hauteur de rangée, puis les photos d'une rangée
   s'élargissent ensemble, au prorata de leur proportion (hauteurs égales, bords alignés).
   La dernière rangée n'est pas étirée (::after). Hauteur de rangée selon l'écran. */
.mg-grid {
  --row: 132px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mg-grid::after { content: ''; flex-grow: 999999; }

.mg-grid__item {
  --r: 1.333;
  flex: var(--r) 1 calc(var(--r) * var(--row));
  min-width: 0;
}

.mg-grid__item[hidden] { display: none; }

.mg-grid__link {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 10px;
  background: #E9ECF1;
  width: 100%;
  aspect-ratio: var(--r);
  max-height: calc(var(--row) * 1.6);   /* photo seule sur sa rangée : pas démesurée */
}

.mg-grid__link img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s var(--mg-ease), filter .4s var(--mg-ease);
}

.mg-grid__link::after {            /* voile + loupe au survol */
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(14, 26, 46, 0) 50%, rgba(14, 26, 46, .55) 100%);
  opacity: 0;
  transition: opacity .35s var(--mg-ease);
}

.mg-grid__link:hover img, .mg-grid__link:focus-visible img { transform: scale(1.045); }
.mg-grid__link:hover::after, .mg-grid__link:focus-visible::after { opacity: 1; }
.mg-grid__link:focus-visible { outline: 3px solid var(--mg-gold); outline-offset: 3px; }

.mg-grid__play {                   /* vidéo : bouton de lecture sur la miniature */
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(14, 26, 46, .78);
  transform: translate(-50%, -50%);
  transition: background .25s var(--mg-ease);
}

.mg-grid__play::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  border-style: solid;
  border-width: 11px 0 11px 18px;
  border-color: transparent transparent transparent #FFFFFF;
  transform: translate(-35%, -50%);
}

.mg-grid__link:hover .mg-grid__play, .mg-grid__link:focus-visible .mg-grid__play { background: var(--mg-accent); }

.mg-grid__tag {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 1;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(14, 26, 46, .78);
  color: #FFFFFF;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .02em;
  backdrop-filter: blur(4px);
  max-width: calc(100% - 20px);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mg-actions { display: flex; justify-content: center; margin-top: 22px; }

.mg-more {
  min-height: 46px;
  padding: 0 24px;
  border: 1.5px solid var(--mg-ink);
  border-radius: 999px;
  background: transparent;
  color: var(--mg-ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background .25s var(--mg-ease), color .25s var(--mg-ease);
}

.mg-more:hover { background: var(--mg-ink); color: #FFFFFF; }
.mg-more:focus-visible { outline: 3px solid var(--mg-gold); outline-offset: 3px; }

/* ---------- Revue de presse ---------- */
.mg-press {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.mg-press__card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--mg-line);
  border-radius: var(--mg-radius);
  background: #FFFFFF;
  transition: box-shadow .3s var(--mg-ease), transform .3s var(--mg-ease);
}

.mg-press__card:hover { box-shadow: 0 18px 40px -22px rgba(14, 26, 46, .35); transform: translateY(-2px); }

.mg-press__img {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 8px;
  background: #ECEAE3;
  aspect-ratio: 3 / 4;
  box-shadow: 0 0 0 1px rgba(14, 26, 46, .06);
}

.mg-press__img img { width: 100%; height: 100%; object-fit: cover; object-position: top center; }
/* Coupure plus large que haute : affichée en entier sur fond papier */
.mg-press__img--wide img { object-fit: contain; object-position: center; padding: 6px; }

.mg-press__zoom {
  position: absolute;
  inset: auto 6px 6px auto;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(14, 26, 46, .82);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}

.mg-press__img:focus-visible { outline: 3px solid var(--mg-gold); outline-offset: 3px; }

.mg-press__body { display: flex; flex-direction: column; min-width: 0; }
.mg-press__media { margin: 0; font-family: 'Playfair Display', Georgia, serif; font-size: 19px; font-weight: 600; line-height: 1.2; color: var(--mg-ink); overflow-wrap: anywhere; }
.mg-press__meta { margin: 4px 0 0; font-size: 12.5px; font-weight: 600; letter-spacing: .03em; color: var(--mg-muted); }
.mg-press__meta:empty { display: none; }
.mg-press__title { margin: 10px 0 0; font-size: 14.5px; font-weight: 600; line-height: 1.45; color: var(--mg-text); overflow-wrap: anywhere; }

.mg-press__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  min-height: 40px;
  margin-top: auto;
  padding-top: 8px;
  color: var(--mg-accent);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.mg-press__link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Visionneuse plein écran ---------- */
.mg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: rgba(6, 9, 17, .95);
  color: #FFFFFF;
  opacity: 0;
  transition: opacity .25s ease;
}

.mg-lightbox.is-open { opacity: 1; }
.mg-lightbox[hidden] { display: none; }

.mg-lightbox__bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 14px; font-weight: 600; color: #C9D2E1; }

.mg-lightbox__stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 0 12px; touch-action: pan-y; }

.mg-lightbox__img {
  max-width: 100%;
  max-height: calc(100vh - 150px);    /* barre du haut + légende : la photo tient toujours dans l'écran */
  max-height: calc(100dvh - 150px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8);
  transition: opacity .2s ease, transform .3s var(--mg-ease, ease);
}

.mg-lightbox__img.is-loading { opacity: .25; transform: scale(.985); }

.mg-lightbox__video {
  display: block;
  width: min(100%, 1100px, calc((100vh - 150px) * 16 / 9));
  width: min(100%, 1100px, calc((100dvh - 150px) * 16 / 9));
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: 6px;
  background: #000000;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8);
}

.mg-lightbox__caption { min-height: 24px; margin: 0; padding: 14px 20px 22px; text-align: center; font-size: 14.5px; line-height: 1.5; color: #E2E7F0; }

.mg-lightbox__btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #FFFFFF;
  font: 600 22px/1 system-ui, sans-serif;
  cursor: pointer;
  transition: background .2s ease;
}

.mg-lightbox__btn:hover { background: rgba(255, 255, 255, .22); }
.mg-lightbox__btn:focus-visible { outline: 3px solid var(--mg-gold, #E2D539); outline-offset: 2px; }
.mg-lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); }
.mg-lightbox__nav--prev { left: 10px; }
.mg-lightbox__nav--next { right: 10px; }

/* Mobile : flèches sous la photo (ne masquent pas l'image, faciles à atteindre au pouce) */
@media (max-width: 767px) {
  .mg-lightbox__stage { padding-bottom: 64px; }
  .mg-lightbox__img { max-height: calc(100vh - 214px); max-height: calc(100dvh - 214px); }
  .mg-lightbox__video { width: min(100%, calc((100vh - 214px) * 16 / 9)); width: min(100%, calc((100dvh - 214px) * 16 / 9)); }
  .mg-lightbox__nav { top: auto; bottom: 6px; transform: none; }
  .mg-lightbox__nav--prev { left: calc(50% - 60px); }
  .mg-lightbox__nav--next { right: calc(50% - 60px); }
}

@media (prefers-reduced-motion: reduce) {
  .mg-grid__link img, .mg-press__card, .mg-lightbox, .mg-lightbox__img { transition: none; }
}

/* ---------- Tablette ---------- */
@media (min-width: 768px) {
  .mg-section { padding: 72px 0; }
  .mg-grid { --row: 190px; gap: 12px; }
  .mg-press { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .mg-press__card { grid-template-columns: 130px minmax(0, 1fr); padding: 16px; }
  .mg-lightbox__stage { padding: 0 80px; }
  .mg-lightbox__nav--prev { left: 18px; }
  .mg-lightbox__nav--next { right: 18px; }
}

/* ---------- Bureau ---------- */
@media (min-width: 1024px) {
  .mg-grid { --row: 240px; }
  .mg-press { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
