
/* ============ Mobile Post Layout Fixes (v1.0) ============ */
:root{
  --post-max: 720px;
  --gap: 16px;
  --gap-sm: 12px;
  --radius: 14px;
}

@media (max-width: 768px){
  .single-post .post-container,
  .single .entry-content,
  .single-post .content-area,
  .single-post .site-main,
  .single-post .post-inner,
  .single .hentry {
    width: 100% !important;
    max-width: var(--post-max);
    margin: 0 auto !important;
    padding-left: var(--gap) !important;
    padding-right: var(--gap) !important;
    box-sizing: border-box;
  }
  .single .entry-title{ 
    font-size: 1.4rem !important; 
    line-height: 1.3;
    margin: 12px 0 10px; 
  }
  .single .entry-content p{
    font-size: 0.98rem;
    line-height: 1.85;
    margin: 0 0 12px;
  }
  .single .entry-content h2{ font-size: 1.15rem; margin: 16px 0 10px; }
  .single .entry-content h3{ font-size: 1.05rem; margin: 14px 0 8px; }

  .single .entry-content img,
  .single .entry-content figure,
  .single .entry-content .wp-block-image img{
    max-width: 100% !important;
    height: auto !important;
    width: 100% !important;
    border-radius: var(--radius);
  }
  .single .entry-content iframe,
  .single .entry-content video{
    max-width: 100% !important;
    width: 100% !important;
    height: auto;
    aspect-ratio: 16/9;
    border: 0;
    border-radius: var(--radius);
  }

  .single .entry-content table{
    display: block;
    width: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin: 10px 0;
  }
  .single .entry-content table td,
  .single .entry-content table th{
    padding: 10px;
    border: 1px solid #e9ecef;
    font-size: 0.95rem;
    white-space: nowrap;
  }

  .single pre, .single code, .single .wp-block-code{
    max-width: 100%;
    overflow-x: auto;
    white-space: pre;
    font-size: 0.9rem;
    line-height: 1.6;
    border-radius: 10px;
  }

  .single .share, .single .post-share, .single .share-buttons{
    display: flex;
    gap: var(--gap-sm);
    flex-wrap: wrap;
    margin: 14px 0;
  }
  .single .share a, .single .post-share a, .single .share-buttons a{
    flex: 1 1 calc(33.33% - var(--gap-sm));
    text-align: center;
    padding: 10px 12px;
    border-radius: 10px;
  }

  .single .author-box, .single .post-author{
    display: grid;
    grid-template-columns: 56px 1fr;
    gap: var(--gap-sm);
    align-items: center;
    padding: 12px;
    border: 1px solid #f1f3f5;
    border-radius: var(--radius);
    background: #fff;
    margin: 16px 0;
  }
  .single .author-box img{ width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }

  .single .related-posts, .single .more-like-this{
    margin-top: 18px;
  }
  .single .related-posts .grid, .single .more-like-this .grid{
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: var(--gap-sm);
  }
  .single .related-posts .card, .single .more-like-this .card{
    display: flex; flex-direction: column; height: 100%;
    border: 1px solid #f1f3f5; border-radius: var(--radius); overflow: hidden;
  }
  .single .related-posts .card img, .single .more-like-this .card img{
    width: 100%; height: 120px; object-fit: cover;
  }
  .single .related-posts .card .meta, .single .more-like-this .card .meta{
    padding: 10px;
  }

  .single .sidebar, .single .post-sidebar{
    display: none !important;
  }

  .single .entry-content figure, 
  .single .entry-content .wp-block-image,
  .single .entry-content table,
  .single .entry-content .wp-block-embed{
    margin-bottom: 14px !important;
  }

  .single .post-meta{
    display: flex; flex-wrap: wrap; gap: 8px;
    font-size: 0.85rem;
    opacity: .85;
    margin: 8px 0 10px;
  }

  /* Common containers often used by themes */
  .container, .container-fluid, .site-content, .wrap, .content-area{
    max-width: 100% !important;
    padding-left: var(--gap);
    padding-right: var(--gap);
  }

  /* Fixed badge fallback on mobile */
  .fixed-badge{ position: static !important; margin: 8px 0 !important; }
  .glass, .glass-card{ backdrop-filter: blur(6px); background: rgba(255,255,255,.78); }
}


/* === Iteration 2: Typography & Float Button Fixes === */
@media (max-width: 768px){
  /* نص المقال: توازن السطور وتقليل التباعد */
  .single .entry-content p,
  .single .entry-content li{
    line-height: 1.8 !important;
    letter-spacing: 0 !important;
    word-spacing: 0 !important;
    text-align: start; /* اتركها start بدل justify لتفادي فجوات */
    text-wrap: pretty;
    overflow-wrap: break-word;
    word-break: normal; /* امنع break-all */
    margin-bottom: 12px !important;
  }

  /* العناوين: توازن الأسطر لتجنب كسور مزعجة */
  .single .entry-title,
  .single .entry-content h2,
  .single .entry-content h3{
    text-wrap: balance;
    line-height: 1.35 !important;
  }

  /* حواف الحاوية كانت بتضيّق العرض — قللناها */
  .single-post .post-container,
  .single .entry-content,
  .content-area,
  .site-content{
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* عناصر محتوى المنشور من WP Block غالباً تضيف max-width صغير — أزلناه */
  .single .entry-content > *{
    max-width: 100% !important;
  }

  /* منع إدراج كسور كلمات قاسية من بعض الثيمات */
  .single .entry-content p,
  .single .entry-content{
    -ms-word-break: normal;
    word-break: normal;
  }

  /* معالجة زر/بالون "تواصل معنا" العائم الذي يغطي النص */
  /* نحاول التقاط أغلب الإضافات الشائعة */
  [class*="chat"] [class*="float"],
  [class*="whatsapp"],
  .whatsapp-chat,
  .wc-chat,
  .contact-float,
  .floating-chat,
  .chaty-widget,
  .tiw-whatsapp,
  .callnow,
  .help-floating,
  .sticky-contact{
    z-index: 1000;
  }
  .single .entry-content,
  .single .site-main{
    /* مساحة سفلية إضافية عشان البالون ما يغطي آخر الفقرات */
    padding-bottom: 80px !important;
  }
  /* لو البالون ثابت في الأسفل: خلّيه أصغر على الموبايل */
  .floating-chat, .chaty-widget, .contact-float, .tiw-whatsapp, .sticky-contact{
    transform: scale(.92);
    bottom: 18px !important;
  }
}

/* === Iteration 3: Arabic Justify Fix === */
@media (max-width: 768px){
  .single .entry-content p,
  .single .entry-content li{
    text-align: justify !important;
    text-justify: inter-word !important;
    line-height: 1.9 !important;
    word-spacing: .2px;
    letter-spacing: 0;
    hyphens: auto;
    -webkit-hyphens: auto;
  }
}


/* === Iteration 4: Modern Mobile Look (card + clean typography) === */
@media (max-width: 768px){
  body.espw15pbf32-enhanced{
    background: #f7f8fa;
  }

  /* Main post wrapper as a card */
  .single .hentry, .single .post-inner, .single .entry-content{
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
  }

  /* Title more prominent */
  .single .entry-title{
    font-size: 1.5rem !important;
    font-weight: 800;
    margin: 14px 14px 8px !important;
    letter-spacing: 0;
  }

  /* Meta row compact */
  .single .post-meta{
    margin: 0 14px 8px !important;
    padding-bottom: 8px;
    border-bottom: 1px solid #eef0f3;
  }

  /* Paragraphs and lists inside the card */
  .single .entry-content{
    padding: 10px 14px 16px !important;
  }
  .single .entry-content p,
  .single .entry-content li{
    font-size: 1rem;
    line-height: 1.9;
    margin-bottom: 10px;
  }

  /* Accent rule under H2/H3 */
  .single .entry-content h2,
  .single .entry-content h3{
    position: relative;
    padding-bottom: 6px;
    margin: 16px 0 10px;
  }
  .single .entry-content h2:after,
  .single .entry-content h3:after{
    content:"";
    position:absolute; inset-inline-start:0; bottom:0;
    width: 56px; height: 3px; border-radius: 3px;
    background: linear-gradient(90deg,#2f80ed, #56ccf2);
  }

  /* Blockquote style */
  .single blockquote{
    margin: 12px 0;
    padding: 12px 14px;
    background: #f2f7ff;
    border-inline-start: 4px solid #2f80ed;
    border-radius: 12px;
    font-style: normal;
  }

  /* Images rounded + subtle border */
  .single .entry-content img{
    border-radius: 14px;
    border: 1px solid #eef0f3;
  }

  /* Code boxes */
  .single pre, .single code, .single .wp-block-code{
    background: #0a0f1a;
    color: #e6edf3;
  }

  /* Author box as pill */
  .single .author-box, .single .post-author{
    background: #fafbff;
    border: 1px solid #eef0f3;
    border-radius: 16px;
  }

  /* Related posts: horizontal scroll snaps (polished look) */
  .single .related-posts .grid, .single .more-like-this .grid{
    display: grid !important;
    grid-auto-flow: column;
    grid-auto-columns: 68%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    padding: 6px 2px 10px;
  }
  .single .related-posts .card, .single .more-like-this .card{
    scroll-snap-align: start;
    border: 1px solid #eef0f3;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,.05);
  }
  .single .related-posts .card img, .single .more-like-this .card img{
    height: 140px;
  }

  /* Share buttons as chips */
  .single .share a, .single .post-share a, .single .share-buttons a{
    border: 1px solid #e6e9ef;
    background: #fff;
  }

  /* Footer spacing so floating widgets do not overlap */
  .single .entry-content{ padding-bottom: 90px !important; }
}


/* === Iteration 5: Arabic Typography Rescue (fix broken lines) === */
@media (max-width: 768px){
  /* 1) تأكيد اتجاه RTL إن كانت العربية */
  html[dir="rtl"] body.espw15pbf32-enhanced{ direction: rtl; }

  /* 2) إعادة كل عناصر النص لحالتها الطبيعية لمنع "تكسيـر" الكلمات */
  .single .entry-content, 
  .single .entry-content *{
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word !important; /* يسمح بالكسر الصحيح عند الحاجة */
    -ms-word-break: normal !important;
    hyphens: none !important;
    -webkit-hyphens: none !important;
  }

  /* 3) بعض الثيمات بتحط display:block على span/strong فتعمل كل كلمة سطر */
  .single .entry-content p > span,
  .single .entry-content p > strong,
  .single .entry-content p > em,
  .single .entry-content p > a{
    display: inline !important;
  }

  /* 4) تفعيل/تعطيل الضبط حسب المطلوب: نجرب محاذاة start لتفادي الفجوات */
  .single .entry-content p,
  .single .entry-content li{
    text-align: start !important;      /* لو عايزها justify رجّع للسطر التالي */
    /* text-align: justify !important;
       text-justify: inter-word !important; */
    font-size: clamp(.98rem, 2.8vw, 1.05rem);
    line-height: 1.85 !important;
    margin: 0 0 10px !important;
    letter-spacing: 0 !important;
    word-spacing: 0 !important;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
  }

  /* 5) إزالة أي max-width صغير على عناصر داخلية يضيّق السطر */
  .single .entry-content > *{
    max-width: 100% !important;
  }

  /* 6) تقليل الحشو الجانبي لو النص لسه ضيّق */
  .single .entry-content, .content-area, .site-content, .post-inner{
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* 7) منع <br> المتكرر من توسيع الفراغات الأفقية */
  .single .entry-content br{
    line-height: 0;
  }
}
