/* ================================================================
   MOBILE OPTIMIZER PRO — mobile.css
   Breakpoint principal : ≤ 768px
   ================================================================ */

/* ---------- VARIABLES ---------- */
:root {
  --mop-primary: #E63946;
  --mop-accent:  #1D3557;
  --mop-white:   #ffffff;
  --mop-bg:      #f8f9fa;
  --mop-text:    #212529;
  --mop-muted:   #6c757d;
  --mop-radius:  12px;
  --mop-shadow:  0 4px 24px rgba(0,0,0,.12);
  --mop-transition: .3s cubic-bezier(.4,0,.2,1);
}

/* ---------- SMOOTH SCROLL ---------- */
html.mop-smooth { scroll-behavior: smooth; }

/* ================================================================
   BARRE DE PROGRESSION DE LECTURE
   ================================================================ */
#mop-progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--mop-primary), var(--mop-accent));
  z-index: 99999;
  transition: width .1s linear;
  border-radius: 0 3px 3px 0;
}

/* ================================================================
   EN-TÊTE MOBILE COLLANT
   ================================================================ */
@media (max-width: 768px) {
  #mop-sticky-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: var(--mop-accent);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 9990;
    box-shadow: 0 2px 12px rgba(0,0,0,.2);
    gap: 12px;
    transform: translateY(-100%);
    transition: transform var(--mop-transition);
  }
  #mop-sticky-header.mop-visible {
    transform: translateY(0);
  }
  #mop-sticky-header .mop-header-logo img {
    height: 34px;
    width: auto;
    border-radius: 6px;
  }
  #mop-sticky-header .mop-header-title {
    flex: 1;
    color: #fff;
    font-size: .92rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
  }
  #mop-hamburger {
    width: 36px; height: 36px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    border-radius: 8px;
    background: rgba(255,255,255,.12);
    flex-shrink: 0;
  }
  #mop-hamburger span {
    display: block;
    width: 20px; height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: var(--mop-transition);
    transform-origin: center;
  }
  #mop-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  #mop-hamburger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
  #mop-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Compenser la hauteur de l'en-tête */
  body.mop-has-sticky { padding-top: 0; }
  body.mop-header-shown { padding-top: 56px; }
}

/* ================================================================
   DRAWER NAVIGATION (SLIDE-IN)
   ================================================================ */
#mop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 9995;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--mop-transition);
}
#mop-overlay.visible { opacity: 1; }

#mop-drawer {
  position: fixed;
  top: 0; left: 0;
  width: min(300px, 85vw);
  height: 100vh;
  background: var(--mop-accent);
  z-index: 9999;
  transform: translateX(-100%);
  transition: transform var(--mop-transition);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#mop-drawer.open { transform: translateX(0); }

.mop-drawer-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  gap: 12px;
}
.mop-drawer-header img {
  height: 40px;
  border-radius: 8px;
}
.mop-drawer-header .mop-drawer-site {
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.2;
}
.mop-drawer-header .mop-drawer-tagline {
  color: rgba(255,255,255,.6);
  font-size: .75rem;
}

.mop-drawer-nav {
  flex: 1;
  padding: 12px 0;
}
.mop-drawer-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 20px;
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .95rem;
  font-weight: 500;
  transition: background var(--mop-transition), color var(--mop-transition);
  border-left: 3px solid transparent;
}
.mop-drawer-nav a:hover,
.mop-drawer-nav a:focus {
  background: rgba(255,255,255,.1);
  color: #fff;
  border-left-color: var(--mop-primary);
}
.mop-drawer-nav a .mop-nav-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,.1);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.mop-drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .75rem;
  color: rgba(255,255,255,.4);
  text-align: center;
}

/* ================================================================
   BARRE D'OUTILS DU BAS
   ================================================================ */
@media (max-width: 768px) {
  #mop-bottom-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 58px;
    background: var(--mop-accent);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 9980;
    box-shadow: 0 -2px 16px rgba(0,0,0,.2);
    border-top: 1px solid rgba(255,255,255,.08);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mop-bb-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: 1;
    padding: 6px 0;
    cursor: pointer;
    color: rgba(255,255,255,.6);
    font-size: .62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    text-decoration: none;
    transition: color var(--mop-transition), transform var(--mop-transition);
    -webkit-tap-highlight-color: transparent;
  }
  .mop-bb-item:active { transform: scale(.92); }
  .mop-bb-item.active { color: var(--mop-primary); }
  .mop-bb-item svg { width: 22px; height: 22px; }

  /* Compenser la barre du bas */
  body.mop-has-bottom { padding-bottom: calc(58px + env(safe-area-inset-bottom, 0)); }
}

/* ================================================================
   BOUTON RETOUR EN HAUT
   ================================================================ */
#mop-back-top {
  position: fixed;
  bottom: 80px; right: 16px;
  width: 46px; height: 46px;
  background: var(--mop-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  z-index: 9970;
  opacity: 0;
  transform: translateY(20px) scale(.8);
  transition: opacity var(--mop-transition), transform var(--mop-transition);
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
}
#mop-back-top.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}
#mop-back-top:active { transform: scale(.9); }
#mop-back-top svg { width: 20px; height: 20px; }

/* ================================================================
   AMÉLIORATIONS GLOBALES MOBILE
   ================================================================ */
@media (max-width: 768px) {

  /* Typographie */
  body.mop-font-boost {
    font-size: 16px !important;
    line-height: 1.7 !important;
    -webkit-text-size-adjust: 100%;
  }
  body.mop-font-boost h1 { font-size: clamp(1.5rem, 6vw, 2rem) !important; }
  body.mop-font-boost h2 { font-size: clamp(1.2rem, 5vw, 1.6rem) !important; }
  body.mop-font-boost h3 { font-size: clamp(1.05rem, 4vw, 1.3rem) !important; }
  body.mop-font-boost p,
  body.mop-font-boost li { font-size: 1rem !important; line-height: 1.75 !important; }

  /* Images fluides */
  img, video, iframe, embed, object {
    max-width: 100% !important;
    height: auto !important;
  }

  /* Tableaux défilables */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Boutons touchables */
  a, button, [role="button"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Anti-débordement */
  * { box-sizing: border-box; }
  body { overflow-x: hidden; }

  /* Cartes articles */
  .post, .entry, article.post, .blog-post {
    border-radius: var(--mop-radius) !important;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,.06) !important;
    margin-bottom: 20px !important;
  }

  /* Espacement contenu */
  .entry-content,
  .post-content,
  .article-content {
    padding: 16px !important;
  }
}

/* ================================================================
   MODE SOMBRE (prefers-color-scheme)
   ================================================================ */
@media (prefers-color-scheme: dark) {
  body.mop-dark {
    --mop-bg:   #121212;
    --mop-text: #e0e0e0;
    background-color: #121212 !important;
    color: #e0e0e0 !important;
  }
  body.mop-dark .post,
  body.mop-dark .entry,
  body.mop-dark article,
  body.mop-dark .card {
    background: #1e1e1e !important;
    border-color: #2a2a2a !important;
  }
  body.mop-dark a { color: var(--mop-primary) !important; }
  body.mop-dark input,
  body.mop-dark textarea,
  body.mop-dark select {
    background: #2a2a2a !important;
    color: #e0e0e0 !important;
    border-color: #444 !important;
  }
}

/* ================================================================
   ANIMATION CHARGEMENT DES ÉLÉMENTS
   ================================================================ */
@media (max-width: 768px) {
  @keyframes mop-fadein {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .mop-animate {
    animation: mop-fadein .4s ease both;
  }
}

/* ================================================================
   TOAST / NOTIFICATION
   ================================================================ */
#mop-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30,30,30,.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  backdrop-filter: blur(10px);
  white-space: nowrap;
}
#mop-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
