/* Prevent content overlap with fixed footer (قصيدة بتصميم فني template) */
body.post-template-wp-custom-template-4 .entry-content {
    padding-bottom: 90px;
}

/* Fix negative margin from theme full-bleed rule on the Claude template header sidebar */
body.post-template-a .wp-site-blocks > aside.wp-block-group.has-background {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

/* Force black paragraph text only within كلود قصيدة template */
body.post-template-a .entry-content p {
    color: #000000 !important;
}

/* Slightly bolder text within قصيدة paper content */
body.post-template-a .entry-content p {
    font-weight: 600 !important;
}

/* Hide Jetpack sharing/likes from inside the قصيدة paper content (still active elsewhere) */
body.post-template-a .entry-content .sharedaddy {
    display: none !important;
}

/* Themed scrollbar for قصيدة paper content (warm tone matching paper) */
body.post-template-a .entry-content {
    scrollbar-width: thin;
    scrollbar-color: #9c7a35 rgba(0,0,0,0.08);
}
body.post-template-a .entry-content::-webkit-scrollbar {
    width: 8px;
}
body.post-template-a .entry-content::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.08);
    border-radius: 4px;
}
body.post-template-a .entry-content::-webkit-scrollbar-thumb {
    background-color: #9c7a35;
    border-radius: 4px;
}
body.post-template-a .entry-content::-webkit-scrollbar-thumb:hover {
    background-color: #7a5f28;
}

/* ===== Mobile/Tablet FIXED layout for قصيدة template (v2, does not affect desktop) ===== */
@media (max-width: 768px) {
  html.post-template-a, body.post-template-a {
    height: 100% !important;
    overflow: hidden !important;
  }

  /* Top header: title + smaller image, category hidden */
  body.post-template-a .poem-right-sidebar {
    position: fixed !important;
    top: 26px !important;
    left: 12px !important;
    right: 12px !important;
    bottom: auto !important;
    width: auto !important;
    height: auto !important;
    max-height: 100px !important;
    margin: 0 !important;
    z-index: 999 !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 12px !important;
    overflow: hidden !important;
  }
  body.post-template-a .poem-right-sidebar .wp-block-post-featured-image {
    width: 60px !important;
    height: 60px !important;
    flex-shrink: 0 !important;
  }
  body.post-template-a .poem-right-sidebar .wp-block-post-featured-image img {
    width: 60px !important;
    height: 60px !important;
    object-fit: cover !important;
  }
  body.post-template-a .poem-right-sidebar .wp-block-post-terms {
    position: fixed !important;
    bottom: 150px !important;
    right: 30% !important;
    left: auto !important;
    top: auto !important;
    z-index: 999 !important;
  }
  body.post-template-a .poem-right-sidebar h1,
  body.post-template-a .poem-right-sidebar .wp-block-post-title {
    font-size: 20px !important;
    margin: 0 !important;
  }

  /* Paper: fill remaining space between header and footer, internal scroll for poem text */
  body.post-template-a .poem-paper-outer {
    position: fixed !important;
    top: 118px !important;
    bottom: 128px !important;
    left: 8px !important;
    right: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
  }
  body.post-template-a .poem-paper-square {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    aspect-ratio: auto !important;
    margin: 0 !important;
  }
  body.post-template-a .poem-content {
    position: absolute !important;
    top: 12% !important;
    bottom: 23% !important;
    left: 15% !important;
    right: 11% !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Left sidebar (extra components) temporarily hidden on mobile until a spot is decided */
  body.post-template-a .poem-left-sidebar {
    display: none !important;
  }

  /* Slightly larger title + image in mobile header */
  body.post-template-a .poem-right-sidebar .wp-block-post-featured-image,
  body.post-template-a .poem-right-sidebar .wp-block-post-featured-image img {
    width: 80px !important;
    height: 80px !important;
  }
  body.post-template-a .poem-right-sidebar h1,
  body.post-template-a .poem-right-sidebar .wp-block-post-title {
    font-size: 24px !important;
  }

  /* Smaller site logo in footer on mobile only */
  body.post-template-a .wp-block-site-logo img {
    width: 90px !important;
    height: auto !important;
  }

  /* Prevent poem text from overflowing paper edges on mobile */
  body.post-template-a .poem-content,
  body.post-template-a .poem-content * {
    box-sizing: border-box !important;
  }
  body.post-template-a .poem-content {
    max-width: 100% !important;
  }
  body.post-template-a .poem-content p {
    max-width: 100% !important;
  }

  /* Tighten line/paragraph spacing on mobile */
  body.post-template-a .poem-content p {
    line-height: 1.5 !important;
    margin-top: 0 !important;
    margin-bottom: 8px !important;
  }

  /* Footer: logo on top, navigation menu below, centered (mobile only) */
  body.post-template-a footer.wp-block-group.is-position-sticky {
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 6px !important;
    height: auto !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }
}

/* ===== Site-wide mobile footer: logo on top, nav menu below (all pages except homepage) ===== */
@media (max-width: 768px) {
  body:not(.home) footer.wp-block-group.is-position-sticky {
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 6px !important;
    height: auto !important;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
  }
  body:not(.home) footer.wp-block-group.is-position-sticky .wp-block-site-logo img {
    width: 90px !important;
    height: auto !important;
  }
}

/* ===== Site-wide mobile fix: force Columns blocks to stack (overrides fixed px flex-basis) ===== */
@media (max-width: 768px) {
  .wp-block-columns {
    flex-wrap: wrap !important;
  }
  .wp-block-columns > .wp-block-column {
    flex-basis: 100% !important;
    width: 100% !important;
  }
}

/* ===== Site-wide mobile fix: Query Loop grids (e.g. مقالات page) collapse to single column ===== */
@media (max-width: 768px) {
  .wp-block-post-template.is-layout-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ===== Site-wide mobile header: logo on top (smaller), nav menu below, centered ===== */
@media (max-width: 768px) {
  header.wp-block-template-part .is-content-justification-space-between.is-nowrap {
    flex-direction: column !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: center !important;
    row-gap: 8px !important;
  }
  header.wp-block-template-part .wp-block-site-logo img {
    width: 140px !important;
    height: auto !important;
  }
}

/* ===== Site-wide mobile fix: opaque, properly layered mobile nav menu overlay ===== */
@media (max-width: 768px) {
  .wp-block-navigation__responsive-container.is-menu-open {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 99999 !important;
    background-color: #0b0f14 !important;
    overflow-y: auto !important;
  }
  .wp-block-navigation__responsive-container.is-menu-open,
  .wp-block-navigation__responsive-container.is-menu-open * {
    color: #ffffff !important;
  }
  .wp-block-navigation__responsive-container.is-menu-open .wp-block-navigation-item a {
    background-color: transparent !important;
  }
}

/* ===== Robust nav menu overlay background fix (no media query gate, always applies when opened) ===== */
html body .wp-block-navigation__responsive-container.is-menu-open {
    background-color: #0b0f14 !important;
    position: fixed !important;
    inset: 0 !important;
    z-index: 999999 !important;
}
html body .wp-block-navigation__responsive-container.is-menu-open,
html body .wp-block-navigation__responsive-container.is-menu-open * {
    color: #ffffff !important;
}

/* ===== Mobile/Tablet layout for كلود مقالة template (does not affect desktop) ===== */
@media (max-width: 768px) {
  body.post-template-wp-custom-template-5 .article-right-sidebar,
  body.post-template-wp-custom-template-5 .article-left-sidebar {
    position: static !important;
    top: auto !important; right: auto !important; left: auto !important; bottom: auto !important;
    width: 92% !important;
    max-width: 92% !important;
    height: auto !important;
    margin: 20px auto !important;
    z-index: auto !important;
    border-radius: 0 !important;
  }
  body.post-template-wp-custom-template-5 .article-right-sidebar .wp-block-post-featured-image,
  body.post-template-wp-custom-template-5 .article-right-sidebar .wp-block-post-featured-image img {
    width: 140px !important;
    height: 140px !important;
  }
  body.post-template-wp-custom-template-5 .article-content {
    margin: 20px 4% 140px 4% !important;
  }
}

/* ===== Mobile only: unpin the footer on the كلود مقالة template so it stops floating over the text ===== */
@media (max-width: 768px) {
  body.post-template-wp-custom-template-5 footer.wp-block-group.is-position-sticky {
    position: static !important;
    margin-top: 24px !important;
    margin-bottom: 0 !important;
  }
}

/* Mobile only: hanging indent so a wrapped verse reads as a continuation, not a new line */
@media (max-width: 768px) {
  body.post-template-a .poem-content p {
    padding-right: 1.4em !important;
    text-indent: -1.4em !important;
    text-align: start !important;
  }
}

/* Mobile only: align the article sidebars to the same column as the text (theme full-bleed rule pulls them flush to the edge) */
@media (max-width: 768px) {
  body.post-template-wp-custom-template-5 .wp-site-blocks > aside.article-right-sidebar,
  body.post-template-wp-custom-template-5 .wp-site-blocks > aside.article-left-sidebar {
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

/* Mobile only: stack the مرئيّات grid into one column and trim its desktop-sized padding */
@media (max-width: 768px) {
  body.page-template-wp-custom-template-4 .wp-block-group.is-layout-grid {
    grid-template-columns: 1fr !important;
    padding: 16px !important;
    row-gap: 28px !important;
  }
}

/* Mobile only: widen the touch area around small controls without changing how they look */
@media (max-width: 768px) {
  .wp-block-navigation__responsive-container-open,
  .wp-block-navigation__responsive-container-close {
    padding: 10px !important;
    margin: -10px !important;
    box-sizing: content-box !important;
  }
  .wp-block-social-links .wp-social-link > .wp-block-social-link-anchor {
    padding: 10px !important;
    box-sizing: content-box !important;
  }
  body.post-template-a .poem-right-sidebar .wp-block-post-terms a {
    display: inline-block !important;
    padding: 9px 10px !important;
  }
  body.post-template-wp-custom-template-5 .wp-block-post-navigation-link a {
    display: inline-block !important;
    padding: 10px 4px !important;
  }
}

/* All screens: keep the article sidebars in one column. Column wrapping pushed the comments block into a second column, which lands off-screen in RTL */
body.post-template-wp-custom-template-5 .article-left-sidebar,
body.post-template-wp-custom-template-5 .article-right-sidebar {
  flex-wrap: nowrap !important;
  justify-content: flex-start !important;
}

/* All screens: comments stay quieter than the article body; reply form first; no avatar; plain heading */
.wp-block-comments {
  display: flex !important;
  flex-direction: column !important;
  padding-left: 28px !important;
  padding-right: 28px !important;
  box-sizing: border-box !important;
}
.wp-block-comments .comment-respond { order: 1 !important; }
.wp-block-comments .wp-block-comments-title { order: 2 !important; }
.wp-block-comments .wp-block-comment-template { order: 3 !important; }
.wp-block-comments .wp-block-comments-title {
  font-size: 17px !important;
  line-height: 1.45 !important;
  color: rgba(255, 255, 255, 0.82) !important;
  margin-top: 24px !important;
  margin-bottom: 12px !important;
}
.wp-block-comments #reply-title,
.wp-block-comments .comment-reply-title {
  font-size: 17px !important;
  line-height: 1.45 !important;
  color: rgba(255, 255, 255, 0.82) !important;
}
.wp-block-comments .wp-block-comment-content,
.wp-block-comments .wp-block-comment-content p {
  font-size: 13px !important;
  line-height: 1.8 !important;
  color: rgba(255, 255, 255, 0.72) !important;
}
.wp-block-comments .wp-block-comment-author-name,
.wp-block-comments .wp-block-comment-author-name a {
  font-size: 13px !important;
  line-height: 1.4 !important;
  color: rgba(255, 255, 255, 0.88) !important;
}
.wp-block-comments .wp-block-comment-date,
.wp-block-comments .wp-block-comment-date a,
.wp-block-comments .wp-block-comment-reply-link,
.wp-block-comments .wp-block-comment-reply-link a {
  font-size: 12px !important;
  line-height: 1.4 !important;
  color: rgba(255, 255, 255, 0.55) !important;
}
.wp-block-comments #respond label,
.wp-block-comments #respond input,
.wp-block-comments #respond textarea,
.wp-block-comments #respond .comment-notes,
.wp-block-comments #respond .form-submit {
  font-size: 14px !important;
}

/* زرّ فتح التعليق المطويّ */
.claude-comment-toggle {
  display: inline-block;
  margin: 6px 0 14px;
  padding: 6px 14px;
  background: transparent;
  border: 1px solid rgba(200, 160, 80, 0.45);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
}
.claude-comment-toggle:hover,
.claude-comment-toggle:focus {
  border-color: rgba(200, 160, 80, 0.85);
  color: #ffffff;
}

/* حتّى يقع الطيّ عند نهاية السطر الثاني تمامًا */
.wp-block-comments .wp-block-comment-content > *:first-child {
  margin-top: 0 !important;
}
