/* ============================================================
   APC — Mobile Responsive Overrides
   Loaded LAST on all pages to fix mobile layout
   Targets: max-width 767px (below desktop breakpoint)
   ============================================================ */

/* ======================
   1. BASE — Make page scrollable
   ====================== */
@media (max-width: 767px) {

  html, html.page-groupe, html.page-realisations {
    overflow: visible !important;
    overflow-x: hidden !important;
    height: auto !important;
  }

  body,
  html.page-groupe body,
  html.page-realisations body {
    overflow: visible !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100vh;
    min-height: 100dvh;
    font-size: 14px;
  }


  /* ======================
     2. HAMBURGER BUTTON
     ====================== */
  .menubtn {
    position: fixed !important;
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    z-index: 1000 !important;
    width: 44px !important;
    height: 44px !important;
    border: 0 !important;
    border-left: 0 !important;
    background-color: rgba(0,0,0,.65) !important;
    opacity: 1 !important;
  }

  .menubtn:hover,
  .menubtn:active {
    background-color: rgba(0,0,0,.9) !important;
  }

  .menubtn .mt {
    display: none !important;
  }

  .menubtn .mn {
    position: absolute !important;
    left: 10px !important;
    width: 24px !important;
    height: 2px !important;
    background-color: #fff !important;
    transform: none !important;
  }

  .menubtn .mn1 {
    top: 14px !important;
    transform: none !important;
  }

  .menubtn .mn2 {
    top: 28px !important;
    transform: none !important;
  }

  .menubtn .mn3 {
    top: 21px !important;
    transform: none !important;
  }

  /* Open state: X */
  .menubtn.open {
    background-color: rgba(0,0,0,.9) !important;
  }

  .menubtn.open .mn1 {
    top: 21px !important;
    transform: rotate(45deg) !important;
  }

  .menubtn.open .mn2 {
    top: 21px !important;
    transform: rotate(-45deg) !important;
  }

  .menubtn.open .mn3 {
    left: 100% !important;
    opacity: 0 !important;
  }


  /* ======================
     3. MENU DRAWER
     ====================== */
  .menubox {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    max-height: 0 !important;
    margin-top: 0 !important;
    overflow: hidden !important;
    background: #fff !important;
    z-index: 999 !important;
    box-shadow: 0 4px 15px rgba(0,0,0,.15) !important;
    transition: max-height .35s ease !important;
  }

  .menubox.menushow {
    max-height: 100vh !important;
    max-height: 100dvh !important;
    overflow-y: auto !important;
  }

  .nav-menu {
    margin-top: 60px !important;
    padding: 0 !important;
  }

  .nav-menu li a {
    padding: 0 20px !important;
    font-size: 14px !important;
    line-height: 3em !important;
    height: 3em !important;
  }

  .nav-menu .submenu li a {
    padding-left: 36px !important;
    font-size: 13px !important;
  }

  .socmed {
    left: 15px !important;
    padding-bottom: 10px !important;
  }

  .socmed li {
    margin: 1em 10px 1em 0 !important;
  }


  /* ======================
     4. LOGO
     ====================== */
  #logo {
    position: fixed !important;
    top: 8px !important;
    left: 12px !important;
    width: 44px !important;
    height: 44px !important;
    z-index: 998 !important;
    opacity: 1 !important;
  }

  #logo.menuopen {
    top: 8px !important;
  }

  /* Full-width page logos */
  .page-groupe #logo,
  .page-realisations #logo {
    width: 44px !important;
    height: 44px !important;
    top: 8px !important;
    left: 12px !important;
  }


  /* ======================
     5. BACKGROUND SLIDESHOW — Classic panel pages
     ====================== */
  .panes {
    position: relative !important;
    width: 100% !important;
    height: 55vw !important;
    min-height: 200px !important;
    max-height: 350px !important;
    top: 0 !important;
    left: 0 !important;
    overflow: hidden !important;
    opacity: 1 !important;
    touch-action: pan-y pinch-zoom !important;
  }

  /* Slides: fill container, show first by default, JS uses .active */
  .panes div.bgImage {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background-size: cover !important;
    background-position: center !important;
    opacity: 0 !important;
    z-index: 0 !important;
    transition: opacity .4s ease !important;
  }

  /* First slide always visible as fallback */
  .panes div.bgImage:first-child {
    opacity: 1 !important;
    z-index: 1 !important;
  }

  /* Active slide (set by JS) shows on top */
  .panes div.bgImage.active {
    opacity: 1 !important;
    z-index: 2 !important;
  }

  /* Also handle jQuery Tools display toggling (legacy pages) */
  .panes div.bgImage[style*="display: block"],
  .panes div.bgImage[style*="display:block"] {
    opacity: 1 !important;
    z-index: 2 !important;
  }

  /* Shade overlay — when NESTED inside .panes (project pages) */
  .panes > #slideshd {
    position: absolute !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: auto !important;
    top: auto !important;
    z-index: 4 !important;
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
  }

  /* Shade overlay — when SIBLING of .panes (homepage, category)
     Cover exact same area as .panes so dots sit inside the image */
  .panes + #slideshd {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 55vw !important;
    min-height: 200px !important;
    max-height: 350px !important;
    overflow: visible !important;
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
    pointer-events: none !important;
    z-index: 3 !important;
  }

  #slideshd.menuopen {
    top: 0 !important;
  }

  #slideshd::after {
    display: none !important;
  }

  /* Slide navigation: dots overlay on image */
  a.backward,
  a.forward {
    display: none !important;
  }

  /* Dots: absolute at the bottom of the image area */
  #slidenav,
  .panes #slidenav,
  .panes + #slideshd #slidenav {
    position: absolute !important;
    bottom: 10px !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 10 !important;
    text-align: center !important;
    overflow: visible !important;
    pointer-events: auto !important;
    background: none !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  #slidenav.gallery {
    bottom: 10px !important;
  }

  .slidetabs {
    display: block !important;
    visibility: visible !important;
    text-align: center !important;
    height: auto !important;
    overflow: visible !important;
  }

  .slidetabs a {
    float: none !important;
    display: inline-block !important;
    width: 9px !important;
    height: 9px !important;
    margin: 0 5px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    border: 1.5px solid #fff !important;
    background: transparent !important;
    vertical-align: middle !important;
    cursor: pointer !important;
    line-height: normal !important;
    text-indent: -9999px !important;
    position: static !important;
    box-shadow: 0 0 2px rgba(0,0,0,.3) !important;
  }

  .slidetabs a.current {
    background: #fff !important;
    border-color: #fff !important;
    box-shadow: 0 0 2px rgba(0,0,0,.3) !important;
  }

  /* Category pages: hide slideshow dots */
  html.no-slideshow #slidenav,
  html.no-slideshow .slidetabs,
  html.no-slideshow a.forward,
  html.no-slideshow a.backward {
    display: none !important;
    visibility: hidden !important;
  }


  /* ======================
     6. CONTENT PANEL — Stacked layout
     ====================== */
  #container {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    width: 100% !important;
    height: auto !important;
    background: #fff !important;
    box-shadow: none !important;
    overflow: visible !important;
    opacity: 1 !important;
  }

  #container.conhid {
    right: auto !important;
    opacity: 1 !important;
  }

  #content {
    position: relative !important;
    height: auto !important;
    overflow: visible !important;
    padding: 25px 18px 30px !important;
    line-height: 1.6 !important;
  }

  #textcon {
    height: auto !important;
    overflow: visible !important;
    padding-right: 0 !important;
  }

  #textcon.noscroll {
    margin-right: 0 !important;
  }

  /* Hide panel toggle button on mobile */
  #hidecon {
    display: none !important;
  }


  /* ======================
     7. FORMS
     ====================== */
  .inpString,
  textarea {
    width: 100% !important;
    max-width: 100% !important;
  }

  .inpShort {
    width: 100% !important;
    max-width: 200px !important;
  }

  input.button {
    float: none !important;
    display: block !important;
    width: 100% !important;
    padding: 12px !important;
    font-size: 13px !important;
    margin-top: 8px !important;
  }

  input, textarea {
    padding: 8px !important;
    font-size: 14px !important;
  }

  label {
    margin-top: 10px !important;
    margin-bottom: 4px !important;
    font-size: 11px !important;
  }


  /* ======================
     8. TYPOGRAPHY
     ====================== */
  h1 {
    font-size: 1.5em !important;
    line-height: 1.3 !important;
  }

  h3 {
    font-size: 1.15em !important;
  }

  p {
    font-size: 14px;
    line-height: 1.6;
  }


  /* ======================
     9. PHOTO GALLERY (project pages)
     ====================== */
  .photoGallery {
    list-style: none !important;
    padding: 0 !important;
  }

  .photoGallery li {
    width: 48% !important;
    margin: 0 4% 4% 0 !important;
    aspect-ratio: 4/3 !important;
    line-height: 0 !important;
  }

  .photoGallery li:nth-child(3n) {
    margin-right: 4% !important;
    clear: none !important;
  }

  .photoGallery li:nth-child(2n) {
    margin-right: 0 !important;
  }

  .photoGallery li img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    opacity: 0 !important;
  }

  .photoGallery li a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
  }


  /* ======================
     10. FULL-WIDTH PAGES — Le Groupe
     ====================== */
  .groupe-header {
    padding: 65px 18px 35px !important;
  }

  .groupe-header h1 {
    font-size: 1.6em !important;
  }

  .groupe-header .sous-titre {
    font-size: .72em !important;
  }

  .groupe-content {
    padding: 25px 18px 40px !important;
    font-size: 14px !important;
  }

  .groupe-intro {
    font-size: .95em !important;
    padding-left: 14px !important;
  }

  .profil h2 {
    font-size: 1.25em !important;
  }

  .profil-photo {
    max-width: 100% !important;
  }


  /* ======================
     11. FULL-WIDTH PAGES — Nos Réalisations
     ====================== */
  .realisations-header {
    padding: 65px 18px 35px !important;
  }

  .realisations-header h1 {
    font-size: 1.6em !important;
  }

  .realisations-header .sous-titre {
    font-size: .72em !important;
  }

  .realisations-cards {
    padding: 20px 14px 40px !important;
    gap: 16px !important;
    flex-direction: column !important;
  }

  .realisation-card {
    height: 220px !important;
  }

  .realisation-card h2 {
    font-size: 1.3em !important;
  }

  .realisation-card .card-overlay {
    padding: 18px !important;
  }


  /* ======================
     12. LOADER — Faster fade on mobile
     ====================== */
  .loader {
    transition: opacity .3s ease !important;
  }


  /* ======================
     13. MISC OVERRIDES
     ====================== */

  /* Prevent body shift when menu opens */
  body.menuopen,
  .menuopen {
    left: 0 !important;
  }

  #slideshd.menuopen {
    top: 0 !important;
  }

  /* Remove desktop shadow on mobile */
  .shadow {
    box-shadow: none !important;
  }

  /* Video */
  .video-wrapper video {
    width: 100% !important;
  }

  /* Description float */
  span.desc {
    float: none !important;
    display: block !important;
    margin-top: 4px !important;
  }

}


/* ======================
   SMALL SCREENS (< 360px)
   ====================== */
@media (max-width: 359px) {

  .menubtn {
    width: 40px !important;
    height: 40px !important;
  }

  .menubtn .mn {
    left: 9px !important;
    width: 22px !important;
  }

  .menubtn .mn1 { top: 12px !important; }
  .menubtn .mn3 { top: 19px !important; }
  .menubtn .mn2 { top: 26px !important; }

  .menubtn.open .mn1,
  .menubtn.open .mn2 {
    top: 19px !important;
  }

  #logo {
    width: 38px !important;
    height: 38px !important;
    top: 9px !important;
    left: 8px !important;
  }

  #content {
    padding: 18px 12px 25px !important;
  }

  .groupe-header,
  .realisations-header {
    padding: 55px 12px 28px !important;
  }

  .groupe-content {
    padding: 18px 12px 30px !important;
  }
}
