/* =====================================================================
   ENGINE.CSS
   Styles pilotés par responsive.js : structure des sections, états
   actif/mobile, animations de swipe, bouton fermer dynamique.
   Ne pas modifier sans vérifier l'impact sur responsive.js.
   ===================================================================== */

/* ---- Variables de layout ---- */
:root {
  --section-width: 25vw;
}

/* ---- Conteneurs principaux ---- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: stretch;
  height: 100vh;
  flex-wrap: nowrap;
}

/* ---- Section (état par défaut : masquée) ---- */
.section {
  position: relative;          /* ancrage du .btn-fermer-dynamique */
  width: var(--section-width);
  height: 100vh;
  display: none;
  flex: 0 0 auto;
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  touch-action: pan-y;
  min-width: 0;
  box-sizing: border-box;
  background-color:white;
  color: black;
  border: thin #000080 solid;
}

/* ---- Section active (desktop) ---- */
.section.active {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
  padding: 0;
}

/* ---- Zone de contenu AJAX ---- */
.section .contenu {
  width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
  padding: 0 0 6em 0;
}

/* ---- Contraintes internes des sections ---- */
.section img {
  max-width: 100%;
  height: auto;
  display: block;
}

.section * {
  max-width: 100%;
  box-sizing: border-box;
}

/* ---- Media query mobile (≤ 768px) ---- */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
    align-items: stretch;
  }

  .section {
    width: 100vw;
    height: 100vh;
  }

  /* Sur mobile, .active seul ne suffit pas : il faut aussi .mobile-only */
  .section.active {
    display: none;
  }

  .section.active.mobile-only {
    display: flex !important;
  }

  /* Plein écran empilé, géré par JS */
  .section.mobile-only {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: white;
    z-index: 100;
  }
}

/* ---- Animations de swipe (classes appliquées par JS) ---- */
@keyframes swipeOutLeft {
  from { transform: translateX(0);     opacity: 1; }
  to   { transform: translateX(-100%); opacity: 0; }
}

@keyframes swipeOutRight {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100%); opacity: 0; }
}

@keyframes slideInMobile {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.section.swipe-out-left  { animation: swipeOutLeft  0.3s ease-out forwards; }
.section.swipe-out-right { animation: swipeOutRight 0.3s ease-out forwards; }

/* NOTE : .animate-in référençait slideInRight (non défini) — corrigé ici */
.section.animate-in      { animation: slideInMobile 0.4s ease-out; }

/* ---- Bouton fermer injecté par JS ---- */
.btn-fermer-dynamique {
  position: absolute;
  top: 0.2em;
  right: 0.2em;
  z-index: 1000;
  width: 2em;
  height: 2em;
  background: rgba(255, 255, 255, 0.6);
  border: 0.04em solid #555555;
  border-radius: 50%;
  color: #555555;
  font-size: 1.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0;
}

.btn-fermer-dynamique:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #000000;
  border-color: #000000;
}
