/* Mobile layout for the PC Top Posts module reused on the homepage. */
/* Keep the automatic-ad exclusion narrowly scoped to Top Posts. */
#bodytop .toppostswrapper .google-auto-placed {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

#bodytop > .container {
  padding-left: 15px;
  padding-right: 15px;
}

/* Use semantic card variants instead of :nth-child(). Google may insert an
   auto-placement div before the cards, which must never change the layout. */
#bodytop .toppostgroup > .toppost-card--lead {
  width: 50%;
  display: inline-block;
  float: left;
  height: 100%;
}

#bodytop .toppostgroup > .toppost-card--lead .topposts-news__image {
  min-height: 300px;
  border: 1px solid #ededed;
  border-radius: 8px;
}

#bodytop .toppostgroup > .toppost-card--lead .topposts-news__news_title {
  font-size: 18px;
  font-weight: 700;
}

#bodytop .toppostgroup > .toppost-card--secondary {
  margin-bottom: 10px;
  padding-bottom: 10px;
  width: calc(50% - 20px);
  display: inline-block;
  float: left;
  margin-left: 20px;
}

#bodytop .toppostgroup > .toppost-card--secondary .inner {
  flex-wrap: nowrap;
  gap: 0 15px;
}

#bodytop .toppostgroup > .toppost-card--secondary .topposts-news__infowrapper {
  flex: 1;
}

#bodytop .toppostgroup > .toppost-card--secondary .topposts-news__news_description {
  display: none;
}

#bodytop .toppostgroup > .toppost-card--secondary .topposts-news__image {
  width: 40%;
  height: auto;
  border: 1px solid #ededed;
  border-radius: 8px;
}

#bodytop .toppostgroup > .toppost-card--secondary .topposts-news__news_title {
  font-size: 15px;
  font-weight: 600;
}

@media screen and (max-width: 767px) {
  #bodytop.bodytop-mobile {
    margin-top: 15px;
    overflow: hidden;
  }

  #bodytop.bodytop-mobile > .container {
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
  }

  #bodytop.bodytop-mobile .bodytopwrapper--mobile {
    display: block;
    width: 100%;
    min-width: 0;
    margin: 0;
    overflow: hidden;
  }

  #bodytop.bodytop-mobile .bodytopwrapper--mobile .toppostswrapper {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex: none;
    overflow: hidden;
    padding-bottom: 50px;
    position: relative;
  }

  /* Keep the lead story in the same full-width composition as the original
     mobile Top Posts layout. */
  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--lead {
    display: flex !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    float: none !important;
    margin: 0 0 15px !important;
    padding: 0 !important;
  }

  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--lead .inner {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
  }

  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--lead .topposts-news__image {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 1.38 / 1;
  }

  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--lead .topposts-news__infowrapper {
    width: 100% !important;
    padding: 0 !important;
  }

  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--lead .topposts-news__news_title {
    margin-top: 15px;
    font-size: 18px;
    font-weight: 700;
  }

  /* Secondary stories keep the compact horizontal card composition without
     relying on their position in the DOM. */
  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--secondary {
    display: flex !important;
    width: 100% !important;
    float: none !important;
    margin: 15px 0 !important;
    padding: 0 !important;
  }

  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--secondary .inner {
    width: 100%;
    display: flex;
    flex-wrap: nowrap;
    gap: 0 15px;
  }

  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--secondary .topposts-news__image {
    width: 40% !important;
    height: 150px !important;
    min-height: 0 !important;
    aspect-ratio: auto;
  }

  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--secondary .topposts-news__infowrapper {
    position: unset;
    width: calc(100% - 150px) !important;
    padding: 0 0 0 15px !important;
  }

  #bodytop.bodytop-mobile .toppostgroup > .toppost-card--secondary .topposts-news__news_description {
    display: none;
  }

  #bodytop.bodytop-mobile .bodytop-mobile__secondary {
    width: 100%;
    margin: 20px 0 0;
    overflow: hidden;
  }

  #bodytop.bodytop-mobile #mads_topposts_pc {
    width: 100%;
  }

  #bodytop.bodytop-mobile .toppostswrapper .flickity-prev-next-button {
    width: 44px;
    height: 36px;
    top: auto;
    bottom: 8px;
    transform: none;
    z-index: 3;
    color: #333;
    background: #fff;
    border: 1px solid #ededed;
    box-shadow: 0 5px 34px rgba(0, 0, 0, 0.07);
    border-radius: 0;
    opacity: 1;
  }

  #bodytop.bodytop-mobile .toppostswrapper .flickity-prev-next-button.previous {
    left: 0;
    right: auto;
    border-radius: 8px 0 0 8px;
  }

  #bodytop.bodytop-mobile .toppostswrapper .flickity-prev-next-button.next {
    left: 44px;
    right: auto;
    border-radius: 0 8px 8px 0;
  }

  #bodytop.bodytop-mobile .toppostswrapper .flickity-prev-next-button:disabled {
    opacity: 1;
  }

  #bodytop.bodytop-mobile .toppostswrapper .flickity-prev-next-button:disabled .flickity-button-icon {
    opacity: 0.3;
  }

  #bodytop.bodytop-mobile .toppostswrapper .flickity-button-icon {
    left: 25%;
    top: 25%;
    width: 50%;
    height: 50%;
  }
}
