/*
 * Cross-Browser Compatibility Pro — CSS Fixes
 * Couvre : Chrome, Firefox, Safari, Edge
 * ============================================
 */

/* --------------------------------------------------------
   1. BOX MODEL & RESET UNIVERSEL
   -------------------------------------------------------- */
*, *::before, *::after {
  -webkit-box-sizing: border-box;
          box-sizing: border-box;
}

/* --------------------------------------------------------
   2. FLEXBOX — correctifs Safari & anciens Edge
   -------------------------------------------------------- */

/* Safari < 14 : gap non supporté dans Flexbox */
.wp-block-group,
.wp-block-columns,
.wp-block-buttons,
[class*="flex"] {
  /* Fallback margin quand gap n'est pas supporté */
}

/* Flexbox préfixes complets */
.flex-container {
  display: -webkit-box;
  display: -webkit-flex;
  display:    -ms-flexbox;
  display:         flex;
  -webkit-flex-wrap: wrap;
      -ms-flex-wrap: wrap;
          flex-wrap: wrap;
}

/* --------------------------------------------------------
   3. CSS GRID — préfixes IE/Edge legacy
   -------------------------------------------------------- */
@supports not (display: grid) {
  .wp-block-columns {
    display: -webkit-box;
    display: -webkit-flex;
    display:     -ms-flexbox;
    display:          flex;
    -webkit-flex-wrap: wrap;
        -ms-flex-wrap: wrap;
            flex-wrap: wrap;
  }
  .wp-block-column {
    -webkit-box-flex: 1;
    -webkit-flex: 1 1 300px;
        -ms-flex: 1 1 300px;
            flex: 1 1 300px;
  }
}

/* --------------------------------------------------------
   4. TRANSITIONS & ANIMATIONS — préfixes webkit
   -------------------------------------------------------- */
a, button, input, select, textarea,
[class*="btn"], [class*="button"] {
  -webkit-transition: all 0.3s ease;
       -o-transition: all 0.3s ease;
          transition: all 0.3s ease;
}

/* --------------------------------------------------------
   5. POSITION STICKY — Safari (-webkit-)
   -------------------------------------------------------- */
.sticky,
[class*="sticky"],
.site-header,
.admin-bar .site-header {
  position: -webkit-sticky;
  position:          sticky;
}

/* --------------------------------------------------------
   6. ASPECT-RATIO FALLBACK
   Safari < 15, Firefox < 89 ne supportent pas aspect-ratio
   -------------------------------------------------------- */
@supports not (aspect-ratio: 16/9) {
  .wp-block-embed__wrapper,
  .responsive-embed,
  iframe[src*="youtube"],
  iframe[src*="vimeo"] {
    position: relative;
    padding-top: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
  }
  .wp-block-embed__wrapper > *,
  .responsive-embed > iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
  }
}

/* --------------------------------------------------------
   7. iOS / SAFARI : fix 100vh avec la barre d'adresse
   -------------------------------------------------------- */
.full-height,
.hero,
[class*="hero"],
[class*="fullscreen"] {
  min-height: 100vh; /* fallback */
  min-height: -webkit-fill-available;
  min-height: 100dvh; /* dynamic viewport height — Chrome 108+, Safari 15.4+, Firefox 101+ */
}

/* --------------------------------------------------------
   8. SMOOTH SCROLL — Firefox et Safari
   -------------------------------------------------------- */
html {
  scroll-behavior: smooth;
}

/* Firefox : désactive si l'utilisateur préfère pas d'animation */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    -webkit-animation-duration: 0.01ms !important;
            animation-duration: 0.01ms !important;
    -webkit-transition-duration: 0.01ms !important;
         -o-transition-duration: 0.01ms !important;
            transition-duration: 0.01ms !important;
  }
}

/* --------------------------------------------------------
   9. SCROLLBAR — homogénéisation Chrome / Firefox / Safari
   -------------------------------------------------------- */
/* Chrome, Edge, Safari */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: #c1c1c1 #f1f1f1; }

/* --------------------------------------------------------
   10. BACKDROP-FILTER — Firefox (support limité avant FF 103)
   -------------------------------------------------------- */
.has-backdrop-filter,
[class*="blur"],
[class*="glass"] {
  -webkit-backdrop-filter: blur(10px);
          backdrop-filter: blur(10px);
}

/* Fallback Firefox < 103 */
@supports not (backdrop-filter: blur(1px)) {
  .has-backdrop-filter,
  [class*="blur"],
  [class*="glass"] {
    background-color: rgba(255,255,255,0.85) !important;
  }
}

/* --------------------------------------------------------
   11. APPEARANCE — normalisation des inputs
   -------------------------------------------------------- */
input, button, select, textarea {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
}

/* Remettre l'apparence native pour les checkboxes/radios */
input[type="checkbox"],
input[type="radio"] {
  -webkit-appearance: auto;
     -moz-appearance: auto;
          appearance: auto;
}

/* --------------------------------------------------------
   12. INPUT DATE — Safari (ne supporte pas input[type=date])
   -------------------------------------------------------- */
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  -webkit-appearance: none;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  font-size: inherit;
}

/* --------------------------------------------------------
   13. OBJECT-FIT — fix Edge legacy via JS (voir main.js)
   -------------------------------------------------------- */
img.object-fit-cover,
.wp-block-image img {
  -o-object-fit: cover;
     object-fit: cover;
  width: 100%;
  height: 100%;
}

/* --------------------------------------------------------
   14. PRINT STYLES — cross-browser
   -------------------------------------------------------- */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    -webkit-box-shadow: none !important;
            box-shadow: none !important;
    text-shadow: none !important;
  }
  a, a:visited { text-decoration: underline; }
  a[href]::after { content: " (" attr(href) ")"; }
  img { page-break-inside: avoid; }
  p, h2, h3 { orphans: 3; widows: 3; }
  h2, h3 { page-break-after: avoid; }
}

/* --------------------------------------------------------
   15. BARRE DE DEBUG (affichée si option activée)
   -------------------------------------------------------- */
#cbc-debug-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.85);
  color: #fff;
  font-size: 12px;
  font-family: monospace;
  padding: 6px 16px;
  z-index: 999999;
  display: -webkit-box;
  display: -webkit-flex;
  display:     -ms-flexbox;
  display:          flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
      -ms-flex-align: center;
          align-items: center;
  gap: 16px;
}
#cbc-debug-bar span { opacity: 0.7; }
#cbc-debug-bar strong { color: #7ec8e3; }
