/*
 * maghzray-blog-ads.css — layout contract for the Yektanet slots inside the WordPress blog
 * (/home/maghzray/public_html/blog), enqueued by wp-content/mu-plugins/maghzray-blog-ads.php
 * at wp_enqueue_scripts priority 99, i.e. after the theme stylesheets.
 *
 * Why this file exists (every statement below is read from the live markup and from
 * wp-content/themes/writing/style.css + content.php/single.php/footer.php, not guessed):
 *
 * 1. The theme echoes six empty ad containers per article:
 *      content.php:208, 217, 221  -> <div id="pos-article-display-card-95791"></div>  (same id, three times)
 *      content.php:212, 227       -> <div class="yn-bnr" id="ynpos-20133"></div>
 *      single.php:38              -> <div id="pos-article-text-68342"></div>
 *      footer.php:9               -> <div id="pos-article-display-68343"></div>
 *    None of them has a single CSS rule anywhere in the theme (grep for pos-article /
 *    ynpos / yn-bnr in style.css and rtl.css returns nothing). The creative is injected
 *    into an unstyled, unbounded box in the middle of the article text.
 * 2. A duplicate id cannot be filled twice: Yektanet's loader resolves the slot by id, so
 *    at most the first container renders and the other two stay as dead gaps inside the
 *    post. The mu-plugin removes the extra occurrences; this file hides any slot that ends
 *    up empty so nothing is left as a hole.
 * 3. The theme's article typography leaks into native cards, because the cards are plain
 *    DOM inside .entry-content:
 *      style.css:1  .entry-content h1, ... h6 { margin-top:0; padding-top:35px; margin-bottom:10px }
 *      style.css:1  .title, h1, h2, h3, ...   { color:#000 }
 *      style.css:1  .blog_post_description p  { margin-top:10px/12px }
 *      style.css:1  .main_content.col-md-12 .blog_single .blog_post_text p { margin:21px 0 }
 *      style.css:1  body { font-family:'Lora',serif; word-break:break-word }
 *    A 35px gap above the ad headline and a mid-word break inside its title is exactly the
 *    "the ad images look terrible" symptom.
 * 4. Column geometry, measured from the theme stylesheet:
 *      .container { width:990px } at min-width:992px
 *      .main_content.col-md-9 { width:695px; padding-right:30px }  -> in-article width ~665px
 *      html, body { overflow-x:hidden }  -> an over-wide creative is silently clipped
 *
 * Nothing here hides or re-sizes the creative itself beyond max-width/height:auto, so no
 * ad revenue is suppressed; it only stops the layout from mangling it.
 */

/* ---------------------------------------------------------------------------
   1. The slot contract: block, full column width, vertical rhythm, centered.
      clear:both matters because the theme floats figures inside .entry-content.
   --------------------------------------------------------------------------- */
[id^="pos-article-"],
[id^="ynpos-"],
.yn-bnr {
  display: block;
  clear: both;
  width: 100%;
  max-width: 100%;
  margin-block: clamp(1.5rem, 3vw, 2.25rem);
  margin-inline: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  text-align: center;
  overflow-x: hidden;
  /* the theme's body{word-break:break-word} breaks Persian ad headlines mid-word */
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
}

/* ---------------------------------------------------------------------------
   2. An empty slot must never leave a hole in the article.
      :empty is true before Yektanet injects, and also forever if the slot has no
      fill (no bidding result, blocked script, duplicate id).
   --------------------------------------------------------------------------- */
[id^="pos-article-"]:empty,
[id^="ynpos-"]:empty,
.yn-bnr:empty {
  display: none !important;
}

/* ---------------------------------------------------------------------------
   3. Media inside a slot: proportional, never stretched, no inherited decorations.
      The theme already has img{max-width:100%;height:auto} but .blog_post_banner img
      and .entry-content img.alignleft/.alignright force width:100%;height:auto, which
      blows a small banner up to the full column and makes it blurry.
   --------------------------------------------------------------------------- */
[id^="pos-article-"] img,
[id^="ynpos-"] img,
.yn-bnr img {
  display: inline-block;
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  margin-inline: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

[id^="pos-article-"] iframe,
[id^="pos-article-"] video,
[id^="ynpos-"] iframe,
[id^="ynpos-"] video,
.yn-bnr iframe,
.yn-bnr video {
  display: block;
  max-width: 100%;
  margin-inline: auto;
  border: 0;
}

/* ---------------------------------------------------------------------------
   4. Stop the theme's article typography from leaking into native cards.
      Only the damaging inherited declarations are neutralised; Yektanet's own
      classes/sizes are left untouched.
   --------------------------------------------------------------------------- */
[id^="pos-article-"] :is(h1, h2, h3, h4, h5, h6, .title),
[id^="ynpos-"] :is(h1, h2, h3, h4, h5, h6, .title),
.yn-bnr :is(h1, h2, h3, h4, h5, h6, .title) {
  padding-top: 0;
  margin-top: 0;
  margin-bottom: 0.4em;
  color: inherit;
  line-height: 1.6;
}

[id^="pos-article-"] p,
[id^="ynpos-"] p,
.yn-bnr p {
  margin: 0 0 0.6em;
  line-height: 1.8;
  text-align: inherit;
}

[id^="pos-article-"] ul,
[id^="pos-article-"] ol,
[id^="ynpos-"] ul,
[id^="ynpos-"] ol,
.yn-bnr ul,
.yn-bnr ol {
  padding-inline-start: 1.4em;
  margin-block: 0.4em 0.8em;
}

/* a link inside a card must not inherit the site's orange hover transition */
[id^="pos-article-"] a,
[id^="ynpos-"] a,
.yn-bnr a {
  text-decoration: none;
}

/* ---------------------------------------------------------------------------
   5. Slots that sit outside the article column (single.php:38 text unit and the
      footer unit) get their own rhythm so they do not collide with the related
      posts block or the footer.

      The footer unit (footer.php:9) is a direct child of <footer class="site_footer">,
      i.e. it is NOT inside .container - that is why a native card there stretches to the
      whole viewport with the creative pushed to one side and empty space on the other.
      The theme container is 990px (style.css:1 .container{width:990px} at min-width:992px)
      with 15px gutters below it, so the slot is capped to the same box.
   --------------------------------------------------------------------------- */
#pos-article-text-68342,
#pos-article-display-68343 {
  margin-block: clamp(1.5rem, 3vw, 2rem) clamp(1rem, 2vw, 1.5rem);
}

#pos-article-display-68343 {
  width: min(100%, 990px);
  margin-inline: auto;
  padding-inline: 15px;
  padding-block: 0.5rem 1rem;
}

@media screen and (max-width: 992px) {
  #pos-article-display-68343 {
    width: 100%;
    padding-inline: clamp(1rem, 4vw, 1.5rem);
  }
}

/* ---------------------------------------------------------------------------
   5-b. Whatever Yektanet injects inside a slot, it must not be able to push the
      page wider than the slot: children are capped and allowed to shrink.
      min-width:0 is required because a flex/grid child with a fixed intrinsic
      width otherwise refuses to shrink.
   --------------------------------------------------------------------------- */
[id^="pos-article-"] > *,
[id^="ynpos-"] > *,
.yn-bnr > * {
  max-width: 100%;
  min-width: 0;
}

[id^="pos-article-"] > div,
[id^="ynpos-"] > div,
.yn-bnr > div {
  margin-inline: auto;
}


/* ---------------------------------------------------------------------------
   6. Small screens: keep the slot inside the viewport. The theme collapses the
      grid at max-width:992px and the container padding is 0 at that size, so an
      unbounded fixed-width banner would be clipped by html{overflow-x:hidden}.
   --------------------------------------------------------------------------- */
@media screen and (max-width: 600px) {
  [id^="pos-article-"],
  [id^="ynpos-"],
  .yn-bnr {
    margin-block: 1.25rem;
  }
}

@media print {
  [id^="pos-article-"],
  [id^="ynpos-"],
  .yn-bnr {
    display: none !important;
  }
}
