/*
 * AdSense placements.
 *
 * Two rules govern everything here:
 *
 *  1. An ad must not move the page. Every non-fluid unit reserves its height
 *     inline before Google fills it, so the content below never jumps.
 *  2. An ad must not take space the design was using. The left rail lives in
 *     the browser margin beside a container the theme caps at 1210px, and only
 *     appears once the viewport is wide enough to hold it there; below that it
 *     is not rendered at all rather than squeezed in.
 *
 * The chrome is deliberately plain -- a small muted label and nothing else --
 * so a filled unit reads as an ad and an unfilled one reads as blank space
 * rather than a broken component.
 */

.ad-slot {
  position: relative;
  margin: 0 auto;
  text-align: center;
}

.ad-slot .adsbygoogle { display: block; width: 100%; }

/* Required by AdSense policy to distinguish ads from content, and it keeps an
   unfilled unit from looking like a rendering fault. */
.ad-label {
  display: block;
  font-size: 10px;
  line-height: 1;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #b3b9c0;
  margin-bottom: 4px;
  user-select: none;
}

/* ------------------------------------------------- horizontal strips */
.ad-header_bar,
.ad-footer_bar {
  max-width: 1210px;             /* the theme's container width */
  padding: 0 15px;
  margin-top: 18px;
  margin-bottom: 18px;
}
.ad-header_bar { margin-top: 20px; }
.ad-footer_bar { margin-bottom: 28px; }

/* ------------------------------------------------------- the sidebar */
.ad-sidebar_top { margin-bottom: 22px; }
.ad-sidebar_bottom { margin-top: 22px; }

/* The tall unit follows the reader down. The theme already runs a sticky
   sidebar script, so this only applies where that is not in charge. */
@media (min-width: 992px) {
  .ad-sidebar_bottom {
    position: sticky;
    top: 90px;
  }
}

/* ------------------------------------------------ in content and feed */
.ad-in_content { margin: 26px auto; max-width: 100%; }

/* Sits in the card grid as though it were a listing. */
.ad-in_feed {
  margin: 0 0 30px;
  width: 100%;
}
.listing-view .ad-in_feed { flex: 1 1 100%; }

/* ------------------------------------------------------- the left rail */
/*
 * Fixed in the left margin, outside the container. The width test is
 * deliberately generous: 1600px leaves (1600 - 1210) / 2 = 195px of margin,
 * so a 160px rail clears the content by 35px. Below that the rail is display:
 * none -- there is no narrow fallback, because every one of them would either
 * overlap the page or shove it sideways.
 */
.ad-rail_left { display: none; }

@media (min-width: 1600px) {
  .ad-rail_left {
    display: block;
    position: fixed;
    top: 120px;
    left: 16px;
    width: 160px;
    margin: 0;
    z-index: 2;
  }
  .ad-rail_left .adsbygoogle { width: 160px; }
}

/* Wider screens have room for a square or half-page unit instead. */
@media (min-width: 1900px) {
  .ad-rail_left { left: 28px; width: 300px; }
  .ad-rail_left .adsbygoogle { width: 300px; }
}

/* ---------------------------------------------------- mobile anchor */
.ad-mobile_anchor { display: none; }

@media (max-width: 991.98px) {
  .ad-mobile_anchor {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1140;
    margin: 0;
    padding: 2px 0 calc(2px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .12);
  }
  .ad-mobile_anchor .ad-label { margin: 0 0 2px; }

  .ad-anchor-close {
    position: absolute;
    top: -22px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 11px 11px 0 0;
    background: #fff;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, .12);
    color: #6b7280;
    font-size: 15px;
    line-height: 20px;
    cursor: pointer;
  }
  .ad-mobile_anchor[hidden] { display: none; }

  /* The listing page pins its "Filters" button to the same corner. When an
     anchor ad is on screen the button rides above it instead of under it. */
  body.has-anchor-ad .lf-trigger { bottom: calc(18px + var(--anchor-ad-height, 60px)); }
  body.has-anchor-ad { padding-bottom: var(--anchor-ad-height, 60px); }
}
