/* mLog AdSense layout 2.2.0. Ad creatives must never be clipped. */
.mlog-ads-theme .mlog-ad { box-sizing: border-box; min-width: 0; }
.mlog-ads-theme .mlog-ad[hidden],
.mlog-ads-theme #mlog-ads-config { display: none !important; }
.mlog-ads-theme .mlog-ad:empty { display: none; }
.mlog-ads-theme .mlog-ad__label {
  display: block; margin: 0 0 8px; color: var(--secondary-foreground-color, #6b7280);
  font-size: 11px; font-weight: 400; line-height: 14px; text-align: center;
  letter-spacing: .04em;
}
.mlog-ads-theme .mlog-ad__body { min-width: 0; width: 100%; min-height: 250px; }
.mlog-ads-theme .mlog-ad ins { margin: 0; padding: 0; text-decoration: none; }
.mlog-ads-theme .mlog-ad--feed,
.mlog-ads-theme .mlog-ad--inline,
.mlog-ads-theme .mlog-ad--end {
  clear: both; width: 100%; max-width: 100%; margin: 40px 0;
}
.mlog-ads-theme .mlog-ad--feed { grid-column: 1 / -1; margin: 8px 0; }
.mlog-ads-theme .mlog-ad--rail { display: none; }
.mlog-ads-theme .mlog-ad__preview {
  display: flex; align-items: center; justify-content: center; min-height: 250px;
  box-sizing: border-box; padding: 16px; border: 1px dashed #5395df;
  background: #e9f3ff; color: #184677; font: 600 14px/1.6 sans-serif;
  text-align: center; white-space: pre-line;
}

/* Ten actual post cards stay in source order. Advertising is a complete row. */
.mlog-ads-theme #mlog-home-grid {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px;
  margin: 0; padding-bottom: 32px; justify-content: normal;
}
.mlog-ads-theme #mlog-home-grid > .m-article-card {
  margin: 0; width: auto; max-width: none; min-width: 0;
}
.mlog-ads-theme #mlog-home-grid > .m-featured-slider { grid-column: 1 / -1; min-width: 0; }
.mlog-ads-theme .mlog-article-body { min-width: 0; }
.mlog-ads-theme .mlog-article-body::after { display: block; clear: both; content: ''; }

/* Fixed-height sidebar ad lives OUTSIDE the internally scrolling TOC. */
@media (min-width: 1024px) {
  .mlog-ads-theme #mlog-home-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; }
  .mlog-ads-theme.post-template .l-wrapper.in-post.js-animation-wrapper {
    box-sizing: border-box; width: 100%; max-width: 1150px;
    padding-left: 24px; padding-right: 306px;
  }
  .mlog-ads-theme.post-template .m-share.mlog-post-sidebar {
    background: transparent; box-shadow: none; position: absolute; top: 0; bottom: 0;
    left: calc(100% + 32px); right: auto; width: 250px; height: auto;
  }
  .mlog-ads-theme.post-template .mlog-sidebar-dock {
    display: flex; flex-direction: column; align-items: stretch;
    position: sticky; top: 96px; height: auto;
  }
  .mlog-ads-theme.post-template .m-share .m-toc {
    --mlog-sidebar-ad-height: 280px;
    --mlog-toc-height: min(420px, max(96px, calc(100vh - 424px)));
    width: 100%; min-width: 0; margin-top: 0;
  }
  .mlog-ads-theme.post-template .m-share .m-toc__content {
    box-sizing: border-box; width: 100%; height: var(--mlog-toc-height);
    max-height: var(--mlog-toc-height); min-height: 0;
    overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain;
    scrollbar-gutter: stable; padding: 0 8px 8px 14px;
  }
  .mlog-ads-theme.post-template .m-share .mlog-sidebar-ad-reservation {
    min-height: 280px; margin-top: 24px; width: 250px;
  }
  .mlog-ads-theme.post-template .m-share .mlog-sidebar-ad-reservation .mlog-sidebar-ad-slot {
    display: block; width: 250px; min-height: 280px; height: auto;
    margin-top: 0; overflow: visible;
  }
  .mlog-ads-theme .mlog-ad--sidebar .mlog-ad__body { width: 250px; min-height: 250px; }
  .mlog-ads-theme.post-template .m-toc:has(.mlog-ad__preview),
  .mlog-ads-theme.post-template .m-toc:has(.adsbygoogle),
  .mlog-ads-theme.post-template .m-toc:has(.mlog-ad[data-mlog-prepared="true"]) { display: block !important; }
  .mlog-ads-theme.post-template .js-post-content .kg-width-wide,
  .mlog-ads-theme.post-template .js-post-content .kg-width-full {
    width: 100%; max-width: 100%; margin-left: 0; margin-right: 0;
    left: auto; right: auto; transform: none;
  }
}
@supports (height: 100dvh) {
  @media (min-width: 1024px) {
    .mlog-ads-theme.post-template .m-share .m-toc {
      --mlog-toc-height: min(420px, max(96px, calc(100dvh - 424px)));
    }
  }
}

/* Wide desktops only: rails occupy existing outer margins and scroll with the page. */
@media (min-width: 1600px) {
  .mlog-ads-theme .mlog-ad--rail:not(:empty):not([hidden]) {
    display: block; position: absolute; top: 0; width: 160px;
    min-height: 622px; z-index: 1;
  }
  .mlog-ads-theme .mlog-ad--home-left,
  .mlog-ads-theme .mlog-ad--post-left { left: -184px; }
  .mlog-ads-theme .mlog-ad--home-right { right: -184px; }
  .mlog-ads-theme .mlog-ad--rail .mlog-ad__body { width: 160px; min-height: 600px; }
  .mlog-ads-theme .mlog-ad--rail .mlog-ad__preview { height: 600px; }
}

/* A short viewport must not cut a 250px creative or create two sticky ads. */
@media (min-width: 1024px) and (max-height: 639px) {
  .mlog-ads-theme.post-template .mlog-sidebar-dock { position: static; }
}
@media (max-width: 1023px) {
  .mlog-ads-theme.post-template .mlog-sidebar-ad-reservation { display: none !important; }
  .mlog-ads-theme.post-template .mlog-sidebar-ad-slot { display: none !important; }
  .mlog-ads-theme .mlog-ad--inline,
  .mlog-ads-theme .mlog-ad--end { margin: 32px 0; }
}
@media print {
  .mlog-ads-theme .mlog-ad, .mlog-ads-theme .m-share { display: none !important; }
}
