/**
 * CMDC — correctifs responsive additifs (téléphone / tablette).
 * Ne s'applique qu'en dessous de 1024px pour préserver le rendu PC paysage.
 * Ne modifie pas les scripts, formulaires, menus ni la structure HTML.
 */

/* Flèche retour — dans le cadre noir (album vignettes) */
#vign_header {
  position: relative;
  /* place pour la pastille en haut à gauche, sans trou hors cadre */
  padding-top: 3.1rem !important;
}

/* Lecteur photo : fond noir (à la place du gris #222) */
#photo,
#photo figure {
  background-color: #000 !important;
}
a.back-nav {
  position: absolute;
  top: 0.55rem;
  left: 0.55rem;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.45rem;
  padding: 0.38rem 0.8rem 0.38rem 0.5rem;
  border-radius: 999px;
  text-decoration: none;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  background: linear-gradient(145deg, rgba(255, 150, 40, 0.95), rgba(210, 95, 15, 0.92));
  border: 1px solid rgba(255, 220, 170, 0.55);
  box-shadow:
    0 0.35rem 1rem rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
a.back-nav svg {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  fill: currentColor;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2));
}
a.back-nav span {
  line-height: 1;
  padding-right: 0.1rem;
}
a.back-nav:hover,
a.back-nav:focus-visible {
  transform: translateX(-2px) scale(1.03);
  filter: brightness(1.06);
  box-shadow:
    0 0.45rem 1.15rem rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  outline: none;
}
a.back-nav:active {
  transform: translateX(-1px) scale(0.98);
}
@media screen and (max-width: 1023px) {

  /* Garde-fou : éviter le scroll horizontal accidentel */
  html {
    overflow-x: clip;
  }
  body,
  #accueil,
  .bonjour,
  #nous,
  #listing,
  #profil {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  img:not(.logo_face),
  video,
  iframe {
    max-width: 100%;
    height: auto;
  }

  /* Icône Facebook : rester carrée (ne pas s'écraser) */
  .logo_f a {
    width: auto !important;
    max-width: 100%;
    display: inline-block;
  }
  img.logo_face,
  .logo_face {
    width: min(100px, 28vw) !important;
    height: min(100px, 28vw) !important;
    max-width: min(100px, 28vw) !important;
    max-height: min(100px, 28vw) !important;
    aspect-ratio: 1 / 1;
    object-fit: contain;
  }

  /* Présentation / Infos / Statuts : min-widths trop larges */
  #nous .texte,
  #nous .miroir {
    min-width: 0 !important;
    max-width: 100%;
  }
  .cadre {
    flex-wrap: wrap;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  /* Tableaux (agenda, comité…) : scroll interne plutôt que déborder la page */
  #calendrier,
  #next_table,
  #nous table,
  #comite table,
  #accueil table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Réservations : grille dates trop large (6 colonnes max-content) */
  #reserv_date {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    grid-gap: 0.5rem 0.6rem;
    overflow-x: auto;
  }
  #reserv_date > * {
    min-width: 0;
    word-break: break-word;
  }
  #reserv_date button,
  #reserv_date .span_c6 {
    grid-column: 1 / -1;
  }

  /* Accueil / pages shell : 1 colonne si étroit (évite 2 col. en paysage téléphone) */
  #accueil {
    height: auto !important;
    min-height: calc(98.6vh - 40px - 1.7vw);
  }
  #accueil #image {
    max-width: 100%;
    min-width: 0;
  }
  #accueil .bonjour {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Login header : rester dans le viewport */
  #log:checked ~ form,
  #login form {
    width: min(92vw, 22rem) !important;
    max-width: calc(100vw - 1.5rem);
    left: 0.5rem !important;
    right: auto;
    box-sizing: border-box;
  }

  /* Affiches / galeries événements */
  #affiches {
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
  }
  #affiches img {
    min-width: 0 !important;
    max-width: 42vw;
    width: auto;
  }
  .bton_affiche {
    min-width: 0 !important;
  }

  /* Distribution */
  #liste_role {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr)) !important;
  }

  /* Zone membre : listing / profil (si connecté) */
  #listing form {
    display: flex !important;
    flex-direction: column !important;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
  #listing form > * {
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
  }
  #profil {
    flex-wrap: wrap;
    max-width: 100%;
  }
  #general,
  #mesure {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* Téléphone réservation : autoriser le retour à la ligne */
  .nowrap {
    white-space: normal;
  }

  /* Photo viewer : hauteurs moins agressives */
  #vign_header img {
    height: auto !important;
    max-height: 14rem;
    width: auto;
    max-width: 100%;
  }

  /* Manifestation / soirée : lecteur audio ne doit pas sortir de la page */
  #vign_header {
    flex-wrap: wrap;
    max-width: 100%;
    box-sizing: border-box;
  }
  #vign_header h2,
  #vignettes h2,
  #affichet,
  #music,
  #vign_header > div {
    width: 100% !important;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  #affichet {
    text-align: center;
  }
  #music {
    display: flex;
    justify-content: center;
    padding: 0.6rem 0.4rem 0.8rem;
  }
  #music audio,
  #accueil audio,
  audio {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Presse / livre 3D : contenir #galerie dans le viewport */
  #livre {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  #galerie {
    left: 5vw !important;
    width: 90vw !important;
    max-width: 90vw;
  }
  #before,
  #after {
    max-width: 20vw;
  }
}

/* Portrait / très étroit : forcer colonne pour #accueil même en paysage étroit */
@media screen and (max-width: 900px) {
  #accueil {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
  }
  #accueil #image {
    width: 100% !important;
    height: auto !important;
    max-height: 42vh;
    overflow: hidden;
  }
  #accueil .bonjour {
    display: block;
    width: 100%;
    padding-left: 2vw;
    padding-right: 2vw;
  }
  #nous .cadre,
  .cadre {
    flex-direction: column !important;
  }
}

/* Téléphone très étroit */
@media screen and (max-width: 480px) {
  #reserv_date {
    grid-template-columns: 1fr !important;
  }
  #affiches img {
    max-width: 70vw;
  }
}
