*, *:after, *:before { 
    -webkit-box-sizing: border-box; 
    box-sizing: border-box; 
}

*:focus {
    outline: 0px solid #aeb5ff;    
}

html {
    font-size: 18px;
}

figure {
    margin:0;
}

.gallery {
    width: 98%;
    margin-right: auto;
    margin-left: auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}

.gallery__item {
    background-color: #fff;
    min-width: 14rem;
    min-height: 8rem;
    max-height: 12rem;
    display: inline-block;
    position: relative;
    flex: 1;
    flex-basis: 10rem;
    margin-right: 8px;
    margin-bottom: 8px;
    width: auto;
    opacity: .99;
    box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.05);
}

.gallery__item:nth-child(5n) {
    min-width: 8rem;
}

.gallery__item:nth-child(2n+1) {
    min-width: 10rem;
}

.gallery__item:nth-child(7n+4) {
    min-width: 18rem;
}

.gallery__item:before {
    content: '';
    /*background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.7) 82%);*/
    width: 100%;
    height: 50%;
    opacity: 0;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 2;
    transition-property: top, opacity;
    transition-duration: 0.3s;
}

.gallery__item_link {
    display: block;
    width: 100%;
    height: 100%;
    max-width: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    object-fit: cover;
    border: 0;
    margin: 0;
    cursor: pointer;
}

.hover-down {
    position: absolute;
    width: 100%;
    bottom: 0;
    left: 0;
    z-index: 3;
}

.hover-up {
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 3;
}

.hover-down_content {
    opacity: 0;
    position: relative;
    top: 100px;
    transition-property: top, opacity;
    transition-duration: 0.3s;
    transition-delay: 0s;
}

.hover-up_content {
    opacity: 0;
    position: relative;
    top: 0;
    transition-property: top, opacity;
    transition-duration: 0.3s;
    transition-delay: 0s;
}

.hover-down_content {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-around;
    line-height: 0;
    font-size: 30px;
    margin: 0;
    padding: 0;
}

.hover-up_content {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    margin: 0;
    padding: 0;    
}

.content-text {
    display: inherit;
    flex-direction: row;
    flex-wrap: nowrap;
    color: #fff;
    font-size: 1.4rem;
    margin-left: 3px;
}

.hover-link {
    color: #666;
}

.content__circle {
    border: 0px solid #000;
    border-radius: 50%;
    background-color: #fff;
    box-shadow: 0 0 7px #666;
    display: inherit;
    justify-content: center;
    align-items: center;    
}

.content-item_up {    
    width: 30px;
    height: 30px;
    font-size: 1.4rem;
    margin: 5px;
}

.content-item_down {
     width: 40px;
     height: 40px;
     font-size: 1.5rem; 
     margin-bottom: 5px;
 }

.gallery__item:focus:before,
.gallery__item:focus .hover-up_content, .gallery__item:hover:before,
.gallery__item:hover .hover-up_content {
    opacity: 1;
}

.gallery__item:focus:before,
.gallery__item:focus  .hover-down_content, .gallery__item:hover:before,
.gallery__item:hover  .hover-down_content {
    opacity: 1;
}

.gallery__item:focus:before, .gallery__item:hover:before {
    top: 50%;
}

.gallery__item:focus .hover-up_content, .gallery__item:hover .hover-up_content {
    /*top: 0;*/
    /*background: linear-gradient(to top, rgba(72,76,97,0) 0%, rgba(72,76,97,0.8) 100%);*/
    background: linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.7) 79%);
}

.gallery__item:focus .hover-down_content, .gallery__item:hover  .hover-down_content {
    top: 0;
}

.gallery__item:focus .hover-down_content, .gallery__item:hover .hover-down_content {
    top: 0;
    transition-delay: 0.15s;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.7) 82%);
}
