/* =========================
   OPTO HUB - CLEAN CSS
   ========================= */

/* Layout desktop */
.opto-hub{
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  box-sizing: border-box;

  display: grid;
  grid-template-columns: 320px minmax(0,1fr);
  gap: 16px;
  align-items: start;
}

.opto-menu{
  background: #f7f7f7;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.06);

  max-height: 80vh;
  overflow: auto;
}

.opto-content{
  width: 100%;
  min-width: 0;       /* IMPORTANT pour grid */
  min-height: 70vh;
}

/* Panels (✅ ne pas utiliser display:none pour DFlip/H5P) */
.opto-panel{
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.opto-panel.is-visible{
  max-height: 200000px; /* valeur volontairement grande */
  overflow: visible;
  opacity: 1;
  pointer-events: auto;
}
 }

/* Boutons */
.opto-btn{
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.10);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.opto-btn.is-active{
  border-color: rgba(0,0,0,0.25);
  font-weight: 700;
}

/* Iframes H5P + DFlip full width */
.opto-content iframe,
.h5p-iframe-wrapper iframe,
.opto-content .dflip,
.dflip,
.dflip-container,
.dflip-wrapper,
.dflip-embed,
.dflip-book{
  width: 100% !important;
  max-width: 100% !important;
}

/* Mobile */
@media (max-width: 900px){
  .opto-hub{
    display: block;
  }

  .opto-menu,
  .opto-content{
    width: 100%;
    max-width: 100%;
  }

  .opto-menu{
    max-height: none;
  }

  .opto-btn{
    white-space: normal;
    word-break: break-word;
  }

  .opto-content iframe,
  .h5p-iframe-wrapper iframe{
    min-height: 75vh !important;
  }
}
.opto-submenu {
  margin-top: 10px;
  padding-left: 10px;
  border-left: 2px solid rgba(0,0,0,0.08);
}

.opto-submenu > summary {
  cursor: pointer;
  font-weight: 600;
  margin: 8px 0;
}
/* Si le flipbook s'affiche (donc membre), on cache l'encart */
.opto-hub .opto-noaccess { margin-top: 16px; }
.opto-hub .opto-content .opto-panel.is-visible .dflip ~ .opto-noaccess { display:none; }

.opto-access-until{
  margin: 12px 0 20px;
  padding: 10px 14px;
  border-left: 5px solid #b3d9b3;
  background:#f9fdf9;
  border-radius:10px;
}
.opto-access-until.opto-expired{ border-left-color:#e57373; }

/* Layout de base */
.opto-hub{
  display:flex;
  gap:20px;
}

/* Menu */
.opto-menu{
  width:320px;
  flex:0 0 320px;
  max-height:85vh;
  overflow:auto;
  position:sticky;
  top:80px;
}

/* Contenu */
.opto-content{
  flex:1;
  min-width:0;
}

/* ✅ Mobile : menu au-dessus, mais on le cache après clic */
@media (max-width: 900px){
  .opto-hub{
    display:block;
  }

  .opto-menu{
    width:auto;
    max-height:none;
    position:relative;
    top:auto;
    overflow:visible;
  }

  /* Quand on a choisi une activité → on cache le menu */
  .opto-hub.is-menu-hidden .opto-menu{
    display:none;
  }

  /* Bouton "Retour menu" */
  .opto-back-menu{
    display:inline-block;
    margin:0 0 12px;
    padding:10px 14px;
    border-radius:10px;
    background:#1b5e20;
    color:#fff;
    text-decoration:none;
    font-weight:600;
  }
}
/* ✅ Menu matières : scroll fluide sur mobile */
.opto-menu{
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* iOS */
  overscroll-behavior: contain;
}

/* ✅ Sur mobile, on limite la hauteur pour que ça puisse scroller */
@media (max-width: 900px){
  .opto-menu{
    max-height: 70vh;      /* ajuste si besoin : 60-80vh */
    position: relative;    /* IMPORTANT : évite le bug sticky sur mobile */
    top: auto;
  }
}
@media (max-width: 900px){
  .opto-hub{
    overflow: visible !important;
  }
}

/* ✅ MENU MOBILE (hamburger) : rendre la liste scrollable sur iPhone */
@media (max-width: 980px){

  /* WordPress Navigation Block (très fréquent) */
  .wp-block-navigation__responsive-container.is-menu-open,
  .wp-block-navigation__responsive-container-content,
  .wp-block-navigation__responsive-dialog{
    max-height: 100vh !important;
    height: 100vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Fallback thèmes classiques */
  .main-navigation.toggled,
  .main-navigation.toggled .nav-menu,
  #site-navigation.toggled,
  #site-navigation.toggled .nav-menu,
  .menu-toggle + .nav-menu{
    max-height: 100vh !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}
/* iOS: aide le scroll dans les overlays */
.is-menu-open, .is-open, .toggled, .open, [aria-modal="true"]{
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}