/*
 * Catalogue: product and category cards.
 * Palette and typography follow the existing site: Montserrat, #09B1F6 accent,
 * #373F41 text, #F3F5F8 surfaces.
 */

.tk-cards {
    display: grid;
    /*
     * auto-fit, not auto-fill. Fill reserves a column for every card that would
     * fit, whether one exists or not: three categories in a fourteen hundred
     * pixel row were laid into three of five columns and stayed narrow, with the
     * last two standing empty. Fit drops the empty ones, so the cards that are
     * there share the row between them.
     */
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
    width: 100%;
    margin: 24px 0 40px;
}

.tk-card {
    /*
     * A ceiling on the width, because a section holding a single entry gets one
     * column the width of the whole row, and a card stretched across it reads as
     * a mistake.
     */
    box-sizing: border-box;
    max-width: 560px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #DDDEDD;
    border-radius: 6px;
    overflow: hidden;
    text-decoration: none;
    color: #373F41;
    transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}

/*
 * Grey, and the card stays where it is.
 *
 * A blue ring is the accent of the site and reads as a state rather than as a
 * pointer, and a card that jumps two pixels under the cursor makes a row of
 * them restless when the mouse crosses it.
 */
.tk-card:hover {
    border-color: #B4BCC2;
    box-shadow: 0 6px 18px rgba(53, 91, 100, .18);
}

.tk-card__image {
    position: relative;
    background: #F3F5F8;
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tk-card__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    box-sizing: border-box;
}

.tk-card__body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.tk-card__title {
    font-family: Montserrat, sans-serif;
    font-weight: 500;
    font-size: 17px;
    line-height: 24px;
    color: #373F41;
    overflow-wrap: break-word;
}

.tk-card__article {
    font-family: Montserrat, sans-serif;
    font-size: 13px;
    color: #7A8285;
}

.tk-card__price {
    margin-top: auto;
}

/* Price and availability, also used on the product page. */

.tk-price {
    font-family: Montserrat, sans-serif;
    font-weight: 500;
    font-size: 20px;
    color: #09B1F6;
    white-space: nowrap;
}

.tk-price__cur {
    font-size: 15px;
    font-weight: 400;
}

.tk-price--request {
    font-size: 16px;
    font-weight: 500;
    color: #355B64;
}

.tk-stock {
    position: absolute;
    top: 10px;
    left: 10px;
    font-family: Montserrat, sans-serif;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 3px;
    white-space: nowrap;
}

.tk-stock--in {
    background: #E4F7EC;
    color: #1D7A45;
}

.tk-stock--order {
    background: #FFF2DB;
    color: #8A5B00;
}

.tk-empty {
    font-family: Montserrat, sans-serif;
    font-size: 16px;
    color: #7A8285;
    padding: 24px 0;
}

/* The category page keeps its sidebar, so cards get less room there. */

@media (max-width: 1100px) {
    .tk-cards {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 600px) {
    .tk-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .tk-card__body {
        padding: 12px;
    }

    .tk-card__title {
        font-size: 15px;
        line-height: 20px;
    }

    .tk-price {
        font-size: 17px;
    }
}

/*
 * Services archive holds five cards. The shared auto-fit grid jumped
 * 5 / 4 / 3 columns as the window moved, and leftover cards stretched
 * so the photo changed size. Same width in a row, like the home block.
 */
.tk-cards--services {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 24px;
}

.tk-cards--services .tk-card {
    flex: 0 0 calc((100% - 48px) / 3);
    width: calc((100% - 48px) / 3);
    max-width: none;
    box-sizing: border-box;
}

@media (max-width: 1100px) {
    .tk-cards--services {
        gap: 16px;
    }

    .tk-cards--services .tk-card {
        flex-basis: calc((100% - 32px) / 3);
        width: calc((100% - 32px) / 3);
    }
}

@media (max-width: 900px) {
    .tk-cards--services {
        justify-content: flex-start;
        gap: 16px;
    }

    .tk-cards--services .tk-card {
        flex-basis: calc((100% - 16px) / 2);
        width: calc((100% - 16px) / 2);
    }
}

@media (max-width: 600px) {
    .tk-cards--services {
        gap: 12px;
    }

    .tk-cards--services .tk-card {
        flex: 0 0 100%;
        width: 100%;
    }
}

/* Placeholder for a product that has no image yet, so the grid keeps its rhythm. */

.tk-card__noimage {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #E3E8EE;
    position: relative;
}

.tk-card__noimage::after {
    content: "";
    position: absolute;
    left: 18px;
    top: 22px;
    width: 28px;
    height: 20px;
    border: 2px solid #B9C2CC;
    border-radius: 3px;
}

/*
 * Category banner on small screens.
 * The legacy rules pin the title with top: 32% inside a banner fixed at 85px,
 * so a three word category name overflowed upwards and was cut off by the
 * header. Centering it properly and letting the banner grow fixes that without
 * touching the desktop layout.
 */

@media (max-width: 600px) {
    .head-category {
        /*
         * The site header is position: fixed and 51px tall on phones, while the
         * banner starts at the very top of the document, so its upper half sat
         * behind the header and the centred title was cut in two. Offsetting the
         * banner by the header height is enough; everything below it follows.
         */
        margin-top: 52px;
        min-height: 96px;
        align-items: stretch;
    }

    .img-category img {
        height: 96px;
        object-fit: cover;
    }

    .head-text-category {
        position: absolute;
        inset: 0;
        top: 0;
        width: auto;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 8px 12px;
        box-sizing: border-box;
        font-size: 14px;
        line-height: 18px;
        text-shadow: 0 1px 4px rgba(0, 0, 0, .45);
    }
}

/*
 * At tablet width the title is still pinned at 40% of the banner, so a long
 * service name ran out of the picture. Stretch the title box over the banner
 * and center the words inside it.
 */
@media (min-width: 601px) and (max-width: 1024px) {
    .head-category {
        min-height: 200px;
    }

    .img-category img {
        min-height: 200px;
        object-fit: cover;
    }

    .head-text-category {
        top: 0;
        bottom: 0;
        width: 88%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        padding: 16px 12px;
        font-size: 22px;
        line-height: 1.25;
    }
}

/* Front page blocks reuse the catalogue card grid. */

.tk-home-block {
    padding: 48px 0 8px;
}

.tk-home-block--services {
    background: #F8FAFC;
    padding-bottom: 48px;
}

/*
 * Home services keep the same .tk-cards grid as the product tiles above
 * (photo + title). A separate 1/3 flex row wrapped to two giant cards:
 * .tk-card borders sat outside the flex basis.
 */

.tk-card__excerpt {
    font-family: Montserrat, sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 21px;
    color: #5A6367;
}

.tk-home-block__inner {
    /*
     * The same 96% the neighbouring sections of the front page use, and no
     * ceiling, so the left edge of the new blocks sits on the line of the
     * showcase and of the news below them. With 92% and a ceiling of 1400 the
     * blocks stood inset, and past 1522 pixels the step grew with the screen.
     */
    width: 96%;
    margin: 0 auto;
    font-family: Montserrat, sans-serif;
    color: #373F41;
}

.tk-home-block .tk-block__title {
    font-size: 26px;
    font-weight: 500;
    margin: 0 0 8px;
    padding-bottom: 10px;
    border-bottom: 2px solid #09B1F6;
    display: inline-block;
}

@media (max-width: 600px) {
    .tk-home-block {
        padding: 28px 0 4px;
    }

    .tk-home-block .tk-block__title {
        font-size: 20px;
    }
}

/* ------------------------------------------------------------- pagination */
/* Shown only when a category outgrows one page, which none does yet. */

.tk-cards + .page-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 34px 0 0;
    padding: 0;
    justify-content: center;
}

.tk-cards + .page-numbers a,
.tk-cards + .page-numbers span {
    display: block;
    min-width: 40px;
    padding: 9px 12px;
    border: 1px solid #DDDEDD;
    border-radius: 4px;
    font-family: Montserrat, sans-serif;
    font-size: 15px;
    line-height: 1;
    text-align: center;
    text-decoration: none;
    color: #373F41;
}

.tk-cards + .page-numbers a:hover {
    border-color: #09B1F6;
    color: #09B1F6;
}

.tk-cards + .page-numbers .current {
    background: #09B1F6;
    border-color: #09B1F6;
    color: #fff;
}

/*
 * Card captions and the height of the picture.
 *
 * The reset gives every div, p and span text-align: justify, which is fine for a
 * paragraph and wrong for a caption of two or three words: "Вироби за
 * кресленнями замовника" was stretched across the whole card with a hole between
 * the first two words.
 *
 * And the frame of the picture is declared four to three, but a grid item is
 * stretched to the height of the tallest in its row, so a portrait photograph
 * pushed its own card taller and left the captions of the row unaligned. The
 * minimum of a grid item is its content unless it is told otherwise.
 */
.tk-card__title,
.tk-card__article,
.tk-card__price,
.tk-empty {
    text-align: left;
}

.tk-card {
    min-height: 0;
}

.tk-card__image {
    min-height: 0;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

/*
 * Formatting inside the text an editor writes.
 *
 * The reset this theme starts from flattens everything: lists lose their
 * markers, headings lose their size and weight, and every paragraph is forced
 * to a 25px indent and justified, with !important. So a description written in
 * the admin with bold, a subheading and a list came out on the page as one
 * uniform block, and the specification asks for the description of a category
 * to keep its formatting.
 *
 * Scoped to the two containers that hold editor text, and !important only where
 * the reset uses it, so nothing else on the site is touched.
 */
.text-category-page,
.tk-richtext {
    line-height: 1.6;
}

.text-category-page p,
.tk-richtext p {
    text-indent: 0 !important;
    text-align: left;
    margin: 0 0 14px;
}

.text-category-page ul,
.text-category-page ol,
.tk-richtext ul,
.tk-richtext ol {
    margin: 0 0 16px;
    padding-left: 24px;
}

.text-category-page ul,
.tk-richtext ul {
    list-style: disc;
}

.text-category-page ol,
.tk-richtext ol {
    list-style: decimal;
}

.text-category-page li,
.tk-richtext li {
    margin: 0 0 6px;
    text-align: left;
}

.text-category-page h2, .tk-richtext h2 { font-size: 26px; line-height: 34px; }
.text-category-page h3, .tk-richtext h3 { font-size: 22px; line-height: 30px; }
.text-category-page h4, .tk-richtext h4 { font-size: 19px; line-height: 26px; }

.text-category-page h2,
.text-category-page h3,
.text-category-page h4,
.tk-richtext h2,
.tk-richtext h3,
.tk-richtext h4 {
    font-weight: 500;
    text-align: left;
    margin: 24px 0 12px;
}

.text-category-page strong, .text-category-page b,
.tk-richtext strong, .tk-richtext b {
    font-weight: 500;
}

.text-category-page em, .text-category-page i,
.tk-richtext em, .tk-richtext i {
    font-style: italic;
}

.text-category-page a,
.tk-richtext a {
    color: #0BA9EA;
    text-decoration: underline;
}

.text-category-page a:hover,
.tk-richtext a:hover {
    text-decoration: none;
}

.text-category-page img,
.tk-richtext img {
    max-width: 100%;
    height: auto;
    margin: 8px 0;
}

.text-category-page table,
.tk-richtext table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 16px;
}

.text-category-page th, .text-category-page td,
.tk-richtext th, .tk-richtext td {
    border: 1px solid #DDDEDD;
    padding: 8px 10px;
    text-align: left;
}

/*
 * A card whose picture has not been uploaded yet.
 *
 * The frame keeps the four to three of a real photograph, and on a wide card
 * that is a grey field half the height of the card with a small circle adrift in
 * the middle. A slot the height of the placeholder itself says the same thing —
 * a picture belongs here — without taking over the card.
 */
.tk-card__image--empty {
    aspect-ratio: auto;
    min-height: 132px;
    height: 132px;
}
