/**
 * Homepage grid cards — title above poster, fixed height, readable text.
 * Selectors target .shortstory_item.grid (grid_view class is added by JS later).
 */

#dle-content .shortstory_item.grid,
.shortstory_item.grid {
    display: flex;
    flex-direction: column;
}

#dle-content .shortstory_item.grid .shortstory_item_content,
.shortstory_item.grid .shortstory_item_content {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    background: #004845 !important;
    border-radius: 12px !important;
    overflow: hidden;
    padding: 0 !important;
    position: relative;
}

/* Fixed-height title bar — keeps grid rows aligned */
#dle-content .shortstory_item.grid .title,
.shortstory_item.grid .title {
    order: 0;
    flex: 0 0 54px;
    height: 54px;
    min-height: 54px;
    max-height: 54px;
    padding: 8px 10px !important;
    margin: 0;
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: #004845 !important;
    border-bottom: 2px solid #accb51;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

#dle-content .shortstory_item.grid .title h3,
.shortstory_item.grid .title h3 {
    margin: 0 !important;
    padding: 0;
    width: 100%;
    line-height: 1.3 !important;
    text-align: center;
}

#dle-content .shortstory_item.grid .title h3 a,
.shortstory_item.grid .title h3 a {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3 !important;
    max-height: calc(1.3em * 2);
    word-break: break-word;
}

#dle-content .shortstory_item.grid .title h3 a:hover,
.shortstory_item.grid .title h3 a:hover {
    color: #accb51 !important;
}

#dle-content .shortstory_item.grid .shortstory_item_img,
.shortstory_item.grid .shortstory_item_img {
    order: 1;
    flex: 0 0 270px;
    height: 270px !important;
    border-radius: 0 !important;
    margin: 0;
    position: relative;
}

#dle-content .shortstory_item.grid .shortstory_item_img img,
.shortstory_item.grid .shortstory_item_img img {
    border-radius: 0 !important;
}

/* Category badge — on poster, not on title bar */
#dle-content .shortstory_item.grid .year,
.shortstory_item.grid .year {
    top: calc(54px + 7px) !important;
    z-index: 3;
}

#dle-content .shortstory_item.grid .rating,
.shortstory_item.grid .rating {
    top: calc(54px + 7px) !important;
    z-index: 3;
}

#dle-content .shortstory_item.grid .ratingg,
.shortstory_item.grid .ratingg {
    z-index: 2;
    bottom: 10px !important;
    left: 10px !important;
}

#dle-content .shortstory_item.grid .perevodx,
.shortstory_item.grid .perevodx {
    z-index: 2;
    bottom: 10px !important;
    right: 10px !important;
}

@media only screen and (max-width: 1024px) {
    #dle-content .shortstory_item.grid .shortstory_item_img,
    .shortstory_item.grid .shortstory_item_img {
        flex-basis: 295px;
        height: 295px !important;
    }

    #dle-content .shortstory_item.grid .year,
    .shortstory_item.grid .year,
    #dle-content .shortstory_item.grid .rating,
    .shortstory_item.grid .rating {
        top: calc(54px + 7px) !important;
    }
}

@media only screen and (max-width: 800px) {
    #dle-content .shortstory_item.grid .shortstory_item_img,
    .shortstory_item.grid .shortstory_item_img {
        flex-basis: 335px;
        height: 335px !important;
    }
}

@media only screen and (max-width: 640px) {
    #dle-content .shortstory_item.grid .title h3 a,
    .shortstory_item.grid .title h3 a {
        font-size: 12px !important;
    }

    #dle-content .shortstory_item.grid .shortstory_item_img,
    .shortstory_item.grid .shortstory_item_img {
        flex-basis: 265px;
        height: 265px !important;
    }
}

@media only screen and (max-width: 480px) {
    #dle-content .shortstory_item.grid .shortstory_item_img,
    .shortstory_item.grid .shortstory_item_img {
        flex-basis: 290px;
        height: 290px !important;
    }
}

@media only screen and (max-width: 360px) {
    #dle-content .shortstory_item.grid .shortstory_item_img,
    .shortstory_item.grid .shortstory_item_img {
        flex-basis: 450px;
        height: 450px !important;
    }
}
