/*
  Muawiyah Magazine — Mobile Optimized Styles
  Inspiré des best practices Reuters, BBC Arabic, Al Jazeera

  Features:
  - Navigation hamburger fluide
  - Cartes optimisées tactiles
  - Typographie lisible (18-20px)
  - Espacement généreux
  - Touches minimales 44x44px
  - Animations performantes
  - RTL support complet
*/

/* ═══════════════════════════════════════════════════════
   HIDE MOBILE ELEMENTS ON DESKTOP (DEFAULT)
   ═══════════════════════════════════════════════════════ */
.mobile-menu-toggle,
.mobile-nav-drawer,
.mobile-nav-overlay,
.mobile-bottom-nav,
.mobile-fab,
.mobile-ptr-indicator {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════
   MOBILE RESET & BASE
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* Show mobile elements on mobile only */
  .mobile-menu-toggle {
    display: flex !important;
  }

  .mobile-nav-drawer,
  .mobile-nav-overlay,
  .mobile-fab,
  .mobile-ptr-indicator {
    display: block !important;
  }

  .mobile-bottom-nav {
    display: flex !important;
  }

  /* Scroll fluide */
  html {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }

  /* Éviter les zooms non désirés */
  input, textarea, select {
    font-size: 16px !important;
  }

  /* Optimisation des fonts */
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }

  /* ═══════════════════════════════════════════════════════
     HEADER MOBILE STICKY
     ═══════════════════════════════════════════════════════ */
  .header {
    position: sticky;
    top: 0;
    z-index: 9999;
    background: var(--mu-paper, #fff);
    border-bottom: 1px solid rgba(0,0,0,.08);
    padding: 12px 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
    transition: transform 0.3s ease;
  }

  /* Header scroll up/down */
  .header.header-hidden {
    transform: translateY(-100%);
  }

  .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 100%;
  }

  /* Logo mobile compact */
  .header-logo {
    height: 36px;
    width: auto;
  }

  /* Cacher le logo brand sur mobile */
  .brand {
    display: none !important;
  }

  /* ═══════════════════════════════════════════════════════
     HAMBURGER MENU BUTTON
     ═══════════════════════════════════════════════════════ */
  .mobile-menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 10000;
    position: relative;
  }

  .mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--mu-green, #0b4f40);
    border-radius: 2px;
    transition: all 0.3s ease;
    transform-origin: center;
  }

  /* Animation hamburger → X */
  .mobile-menu-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-20px);
  }

  .mobile-menu-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* ═══════════════════════════════════════════════════════
     MOBILE NAVIGATION DRAWER
     ═══════════════════════════════════════════════════════ */
  .mobile-nav-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: var(--mu-paper, #fff);
    box-shadow: -4px 0 20px rgba(0,0,0,.2);
    z-index: 9998;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 16px 0 24px 0;
  }

  .mobile-nav-drawer.active {
    right: 0;
  }

  /* Overlay backdrop */
  .mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0,0,0,.5);
    z-index: 9997;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
  }

  .mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
  }

  /* Mobile nav header (logo centered) */
  .mobile-nav-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 16px 10px;
    border-bottom: 1px solid rgba(0,0,0,.06);
  }

  .mobile-nav-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    background: #fff;
    border-radius: 50%;
    padding: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
  }

  .mobile-nav-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--mu-muted, #555);
  }

  /* Navigation links */
  .mobile-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  .mobile-nav-item {
    border-bottom: 1px solid rgba(0,0,0,.06);
  }

  .mobile-nav-link {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    color: var(--mu-text, #1a1a1a);
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--mu-font, 'Noto Naskh Arabic', serif);
    transition: all 0.2s ease;
    min-height: 48px;
    gap: 10px;
  }

  .mobile-nav-link:active {
    background: rgba(11,79,64,.05);
  }

  .mobile-nav-link--cta {
    font-weight: 700;
  }

  .mobile-nav-arrow {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--mu-green, #0b4f40);
    flex: 0 0 auto;
  }

  .mobile-nav-arrow svg {
    width: 18px;
    height: 18px;
  }

  .mobile-nav-text {
    flex: 1 1 auto;
  }

  .mobile-nav-divider {
    height: 10px;
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,.08);
  }

  .mobile-nav-cta {
    padding: 8px 0 6px;
  }
  }

  /* ═══════════════════════════════════════════════════════
     CONTENT CARDS (Reuters-style)
     ═══════════════════════════════════════════════════════ */
  .mobile-card {
    background: var(--mu-paper, #fff);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .mobile-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 6px rgba(0,0,0,.1);
  }

  .mobile-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
  }

  .mobile-card-content {
    padding: 20px;
  }

  .mobile-card-title {
    font-size: 20px;
    font-weight: 900;
    line-height: 1.4;
    color: var(--mu-green, #0b4f40);
    margin: 0 0 12px 0;
    font-family: 'Amiri', serif;
  }

  .mobile-card-excerpt {
    font-size: 16px;
    line-height: 1.7;
    color: var(--mu-muted, #555);
    margin: 0 0 16px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .mobile-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--mu-muted, #555);
    font-family: 'Tajawal', sans-serif;
  }

  .mobile-card-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  /* ═══════════════════════════════════════════════════════
     TOUCH-OPTIMIZED BUTTONS
     ═══════════════════════════════════════════════════════ */
  .mobile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 12px 24px;
    font-size: 17px;
    font-weight: 700;
    border-radius: 8px;
    border: none;
    font-family: 'Tajawal', sans-serif;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    gap: 8px;
  }

  .mobile-btn-primary {
    background: var(--mu-green, #0b4f40);
    color: #fff;
  }

  .mobile-btn-primary:active {
    background: #094032;
    transform: scale(0.97);
  }

  .mobile-btn-secondary {
    background: transparent;
    color: var(--mu-green, #0b4f40);
    border: 2px solid var(--mu-green, #0b4f40);
  }

  .mobile-btn-secondary:active {
    background: rgba(11,79,64,.05);
  }

  .mobile-btn-full {
    width: 100%;
  }

  /* ═══════════════════════════════════════════════════════
     ARTICLE MOBILE LAYOUT
     ═══════════════════════════════════════════════════════ */
  .article-mobile {
    padding: 0 16px 40px 16px;
  }

  .article-mobile-header {
    padding: 24px 0;
  }

  .article-mobile-title {
    font-size: 28px;
    line-height: 1.3;
    font-weight: 900;
    color: var(--mu-green, #0b4f40);
    margin: 0 0 16px 0;
    font-family: 'Amiri', serif;
  }

  .article-mobile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 14px;
    color: var(--mu-muted, #555);
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0,0,0,.08);
  }

  .article-mobile-body {
    padding-top: 24px;
  }

  .article-mobile-body p {
    font-size: 18px;
    line-height: 2;
    margin: 0 0 20px 0;
    color: var(--mu-text, #1a1a1a);
  }

  .article-mobile-body h2 {
    font-size: 24px;
    font-weight: 900;
    color: var(--mu-green, #0b4f40);
    margin: 36px 0 16px 0;
    padding-right: 12px;
    border-right: 4px solid var(--mu-gold, #d4af37);
  }

  .article-mobile-body h3 {
    font-size: 20px;
    font-weight: 800;
    color: var(--mu-green, #0b4f40);
    margin: 28px 0 12px 0;
  }

  /* ═══════════════════════════════════════════════════════
     FLOATING ACTION BUTTONS
     ═══════════════════════════════════════════════════════ */
  .mobile-fab-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 1000;
  }

  .mobile-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--mu-green, #0b4f40);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-fab:active {
    transform: scale(0.9);
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
  }

  .mobile-fab-share {
    background: var(--mu-gold, #d4af37);
  }

  /* ═══════════════════════════════════════════════════════
     CAROUSEL DOTS (Reuters-style)
     ═══════════════════════════════════════════════════════ */
  .mobile-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 20px 0;
  }

  .mobile-carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0,0,0,.2);
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .mobile-carousel-dot.active {
    width: 24px;
    border-radius: 4px;
    background: var(--mu-green, #0b4f40);
  }

  /* ═══════════════════════════════════════════════════════
     BOTTOM NAVIGATION (App-like)
     ═══════════════════════════════════════════════════════ */
  .mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--mu-paper, #fff);
    border-top: 1px solid rgba(0,0,0,.08);
    display: flex;
    flex-direction: row-reverse;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 999;
    box-shadow: 0 -2px 10px rgba(0,0,0,.05);
  }

  .mobile-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 8px;
    text-decoration: none;
    color: var(--mu-muted, #555);
    font-size: 11px;
    font-weight: 600;
    font-family: 'Tajawal', sans-serif;
    transition: color 0.2s ease;
    min-height: 56px;
  }

  .mobile-bottom-nav-item.active {
    color: var(--mu-green, #0b4f40);
  }

  .mobile-bottom-nav-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    fill: currentColor;
  }

  /* ═══════════════════════════════════════════════════════
     SWIPEABLE SECTIONS
     ═══════════════════════════════════════════════════════ */
  .mobile-swipe-container {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    display: flex;
    gap: 16px;
    padding: 0 16px 16px 16px;
    scrollbar-width: none;
  }

  .mobile-swipe-container::-webkit-scrollbar {
    display: none;
  }

  .mobile-swipe-item {
    flex: 0 0 85%;
    scroll-snap-align: start;
  }

  /* ═══════════════════════════════════════════════════════
     PULL TO REFRESH INDICATOR
     ═══════════════════════════════════════════════════════ */
  .mobile-ptr-indicator {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--mu-paper, #fff);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 9999;
  }

  .mobile-ptr-indicator.visible {
    opacity: 1;
  }

  .mobile-ptr-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(11,79,64,.2);
    border-top-color: var(--mu-green, #0b4f40);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }

  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  /* ═══════════════════════════════════════════════════════
     RESPONSIVE IMAGES & MEDIA
     ═══════════════════════════════════════════════════════ */
  img, video {
    max-width: 100%;
    height: auto;
    display: block;
  }

  figure {
    margin: 24px -16px;
  }

  figcaption {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--mu-muted, #555);
    background: rgba(0,0,0,.02);
  }

  /* ═══════════════════════════════════════════════════════
     MOBILE TYPOGRAPHY SCALE
     ═══════════════════════════════════════════════════════ */
  h1 { font-size: 28px; line-height: 1.3; }
  h2 { font-size: 24px; line-height: 1.3; }
  h3 { font-size: 20px; line-height: 1.4; }
  h4 { font-size: 18px; line-height: 1.4; }
  p, li { font-size: 18px; line-height: 2; }
  small { font-size: 14px; }

  /* ═══════════════════════════════════════════════════════
     MOBILE SPACING UTILITIES
     ═══════════════════════════════════════════════════════ */
  .mobile-container {
    padding: 0 16px;
    max-width: 100%;
  }

  .mobile-section {
    padding: 32px 16px;
  }

  .mobile-mb-small { margin-bottom: 12px; }
  .mobile-mb-medium { margin-bottom: 20px; }
  .mobile-mb-large { margin-bottom: 32px; }

  .mobile-mt-small { margin-top: 12px; }
  .mobile-mt-medium { margin-top: 20px; }
  .mobile-mt-large { margin-top: 32px; }

  /* ═══════════════════════════════════════════════════════
     LOADING SKELETON
     ═══════════════════════════════════════════════════════ */
  .mobile-skeleton {
    background: linear-gradient(
      90deg,
      rgba(0,0,0,.05) 25%,
      rgba(0,0,0,.1) 50%,
      rgba(0,0,0,.05) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
  }

  @keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }

  .mobile-skeleton-title {
    height: 28px;
    margin-bottom: 12px;
  }

  .mobile-skeleton-text {
    height: 18px;
    margin-bottom: 8px;
  }

  .mobile-skeleton-image {
    height: 200px;
    margin-bottom: 16px;
  }

  /* ═══════════════════════════════════════════════════════
     DARK MODE MOBILE
     ═══════════════════════════════════════════════════════ */
  @media (prefers-color-scheme: dark) {
    .header {
      background: #1a1a1a;
      border-bottom-color: rgba(255,255,255,.1);
    }

    .mobile-nav-drawer {
      background: #1a1a1a;
    }

    .mobile-nav-link {
      color: #e8e8e8;
    }

    .mobile-nav-item {
      border-bottom-color: rgba(255,255,255,.05);
    }

    .mobile-card {
      background: #2a2a2a;
    }

    .mobile-card-title {
      color: var(--mu-gold, #d4af37);
    }

    .mobile-bottom-nav {
      background: #1a1a1a;
      border-top-color: rgba(255,255,255,.1);
    }

    .mobile-skeleton {
      background: linear-gradient(
        90deg,
        rgba(255,255,255,.05) 25%,
        rgba(255,255,255,.1) 50%,
        rgba(255,255,255,.05) 75%
      );
    }
  }

  /* ═══════════════════════════════════════════════════════
     ACCESSIBILITY (A11Y)
     ═══════════════════════════════════════════════════════ */

  /* Focus visible pour navigation clavier */
  *:focus-visible {
    outline: 2px solid var(--mu-gold, #d4af37);
    outline-offset: 2px;
  }

  /* Textes sélectionnables */
  ::selection {
    background: rgba(212,175,55,.3);
    color: var(--mu-text, #1a1a1a);
  }

  /* Reduce motion pour accessibilité */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }

}

/* ═══════════════════════════════════════════════════════
   SMALL MOBILE (< 375px)
   ═══════════════════════════════════════════════════════ */
@media (max-width: 374px) {
  .article-mobile-title { font-size: 24px; }
  .mobile-card-title { font-size: 18px; }
  .article-mobile-body p { font-size: 17px; }
  .mobile-nav-drawer { width: 90%; }
}
