/* FreshOffice (ru) — site-specific styles.
 *
 * Loaded after shared/style/custom.css (see the sync-style script and the
 * resources list in docs/.yfm), so rules here override the shared ones.
 * Only what differs between the two sites lives here — the landing banner
 * and the landing layout. Colors are common to both and stay in the shared file.
 */

/* Landing hero: the artwork carries the wording, so the gradient and the
 * h1 padding from the shared file give way to the banner image. The source
 * is trimmed to the artwork itself (2200x880, transparent corners), so the
 * box repeats its 2.5:1 proportions and nothing gets cropped or letterboxed. */
.dc-doc-leading-page__title {
    padding: 0;
    /* a narrow strip like the Yandex docs hero: the 2.5:1 artwork is cropped
     * top and bottom, which only eats empty gradient — the pill and the logo
     * sit well inside the visible band */
    aspect-ratio: 4 / 1;
    /* vector artwork drawn at the display proportions, so nothing is cropped
     * and the strip stays crisp at any zoom */
    background: url('../_assets/banner.svg') center / cover no-repeat;
    /* the heading text lives on inside the artwork — keep the h1 for search
     * engines and screen readers, but stop it painting over the picture */
    font-size: 0;
    color: transparent;
}

/* ------------------------------------------------------------------ */
/* Landing layout below the banner.
 *
 * Diplodoc gives a leading page one flat list of links, so the grouping
 * lives in the order of items in index.yaml — change one, change the other:
 *   1-4   tiles right under the banner
 *   5     item without href, rendered as plain text — the section heading
 *   6-14  nine services, three per row, on a blue plate
 *
 * The plate itself is the ::after pseudo-element: a leading page has no
 * wrapper around a group of links, so the background is a grid item placed
 * under the tiles and inflated by a negative margin to look like padding. */

.dc-doc-leading-page__links_root {
    grid-template-columns: repeat(12, 1fr);
    margin-bottom: 32px;
}

.dc-doc-leading-page__links-item_root {
    position: relative;
    grid-column: span 3;
}

/* The markup makes only the title a link. Stretching it over the whole tile
 * turns the plate into a single click target: title, description and the
 * padding around them. */
.dc-doc-leading-page__links-link::after {
    content: '';
    position: absolute;
    inset: 0;
}

/* Items without href carry no <a>, and those are the section headings. */
.dc-doc-leading-page__links-item_root:not(:has(a)) {
    grid-column: 1 / -1;
    margin: 36px 0 52px;
    padding: 0;
    background: none;
    text-align: center;
}

/* The blue plate reaches 32px below its last tile, which eats into the gap
 * above the next heading — give it that much back so both headings sit the
 * same 56px away from whatever is above them. */
.dc-doc-leading-page__links-item_root:nth-child(18) {
    margin-top: 68px;
}

.dc-doc-leading-page__links-item_root:not(:has(a)):hover {
    transform: none;
    box-shadow: none;
}

.dc-doc-leading-page__links-item_root:not(:has(a)) .dc-doc-leading-page__links-title_root {
    margin: 0;
    color: var(--g-color-text-primary);
    font-size: clamp(26px, 3vw, 34px);
    font-weight: 500;
}

/* "Скоро" badge for tiles whose section is still being written. Keyed to the
 * page the tile leads to, not to its position, so reordering the grid keeps
 * the badge on the right tile. Add a selector here when a section ships. */
.dc-doc-leading-page__links-item_root:has(a[href$="attachment/project.html"]) {
    position: relative;
}

.dc-doc-leading-page__links-item_root:has(a[href$="attachment/project.html"])::after {
    content: 'Скоро';
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 3px 12px;
    border-radius: 999px;
    background: var(--wz-accent);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 18px;
}

/* The plate is a grid item too, so it would push the tiles out of its rows
 * unless they are placed there explicitly — hence the row/column numbers
 * below. The first four tiles and the heading still place themselves. */
.dc-doc-leading-page__links-item_root:nth-child(n + 6) {
    z-index: 1;
}

.dc-doc-leading-page__links-item_root:nth-child(6) { grid-area: 3 / 1 / 4 / 5; }
.dc-doc-leading-page__links-item_root:nth-child(7) { grid-area: 3 / 5 / 4 / 9; }
.dc-doc-leading-page__links-item_root:nth-child(8) { grid-area: 3 / 9 / 4 / 13; }
.dc-doc-leading-page__links-item_root:nth-child(9) { grid-area: 4 / 1 / 5 / 5; }
.dc-doc-leading-page__links-item_root:nth-child(10) { grid-area: 4 / 5 / 5 / 9; }
.dc-doc-leading-page__links-item_root:nth-child(11) { grid-area: 4 / 9 / 5 / 13; }
.dc-doc-leading-page__links-item_root:nth-child(12) { grid-area: 5 / 1 / 6 / 5; }
.dc-doc-leading-page__links-item_root:nth-child(13) { grid-area: 5 / 5 / 6 / 9; }
.dc-doc-leading-page__links-item_root:nth-child(14) { grid-area: 5 / 9 / 6 / 13; }
.dc-doc-leading-page__links-item_root:nth-child(15) { grid-area: 6 / 1 / 7 / 5; }
.dc-doc-leading-page__links-item_root:nth-child(16) { grid-area: 6 / 5 / 7 / 9; }
.dc-doc-leading-page__links-item_root:nth-child(17) { grid-area: 6 / 9 / 7 / 13; }

/* Item 18 is the "Решения на базе AI" heading (row 7); item 19 is the AI
 * banner. Here the roles are swapped on purpose: description holds the
 * headline, title holds the button — so only the button is a link, while the
 * rest of the plate stays unclickable. */
.dc-doc-leading-page__links-item_root:nth-child(19) {
    position: relative;
    grid-area: 8 / 1 / 9 / 13;
    display: flex;
    align-items: center;
    aspect-ratio: 4 / 1;
    padding: 0;
    /* same corner as the hero above: rx 33 in the artwork, 24px on the box */
    border-radius: 24px;
    background: url('../_assets/AIbaner.svg') center / cover no-repeat;
}

.dc-doc-leading-page__links-item_root:nth-child(19) .dc-doc-leading-page__links-right {
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 28px;
    max-width: 52%;
    padding-left: 7%;
}

/* the description is the headline of the banner */
.dc-doc-leading-page__links-item_root:nth-child(19) .dc-doc-leading-page__links-description {
    margin: 0;
    color: var(--g-color-text-primary);
    font-size: clamp(18px, 2.1vw, 30px);
    line-height: 1.25;
    font-weight: 500;
}

/* …and the title is the button */
.dc-doc-leading-page__links-item_root:nth-child(19) .dc-doc-leading-page__links-title_root {
    margin: 0;
}

.dc-doc-leading-page__links-item_root:nth-child(19) .dc-doc-leading-page__links-link,
.dc-doc-leading-page__links-item_root:nth-child(19) .dc-doc-leading-page__links-link:hover {
    display: inline-block;
    padding: 12px 32px;
    border-radius: 999px;
    background: var(--wz-accent);
    color: #fff;
    font-size: 15px;
    font-weight: 500;
}

.dc-doc-leading-page__links-item_root:nth-child(19) .dc-doc-leading-page__links-link:hover {
    background: #2749c9;
}

/* the plate itself is not a link: cancel the stretched overlay and the lift */
.dc-doc-leading-page__links-item_root:nth-child(19) .dc-doc-leading-page__links-link::after {
    content: none;
}

.dc-doc-leading-page__links-item_root:nth-child(19):hover {
    transform: none;
    box-shadow: none;
}

/* Each tile inside the plate gives up 32px of width to horizontal margins —
 * split differently per column, so the three stay equal while the plate ends
 * up with even 32px padding on both sides. */
.dc-doc-leading-page__links-item_root:nth-child(3n) { margin-left: 32px; }
.dc-doc-leading-page__links-item_root:nth-child(3n + 1) { margin-inline: 16px; }
.dc-doc-leading-page__links-item_root:nth-child(3n + 2) { margin-right: 32px; }

/* …the padding is the plate's alone: tiles above it and below it keep the
 * full content width. */
.dc-doc-leading-page__links-item_root:nth-child(-n + 5),
.dc-doc-leading-page__links-item_root:nth-child(n + 18) {
    margin-inline: 0;
}

.dc-doc-leading-page__links_root::after {
    content: '';
    grid-area: 3 / 1 / 7 / 13;
    margin: -32px 0;
    border-radius: 24px;
    background: #315EFB;
    z-index: 0;
}

/* Two tiles per row: the top four take rows 1-2, so everything shifts down. */
@media (max-width: 1100px) {
    .dc-doc-leading-page__links-item_root {
        grid-column: span 6;
    }

    .dc-doc-leading-page__links-item_root:nth-child(6) { grid-area: 4 / 1 / 5 / 7; }
    .dc-doc-leading-page__links-item_root:nth-child(7) { grid-area: 4 / 7 / 5 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(8) { grid-area: 5 / 1 / 6 / 7; }
    .dc-doc-leading-page__links-item_root:nth-child(9) { grid-area: 5 / 7 / 6 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(10) { grid-area: 6 / 1 / 7 / 7; }
    .dc-doc-leading-page__links-item_root:nth-child(11) { grid-area: 6 / 7 / 7 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(12) { grid-area: 7 / 1 / 8 / 7; }
    .dc-doc-leading-page__links-item_root:nth-child(13) { grid-area: 7 / 7 / 8 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(14) { grid-area: 8 / 1 / 9 / 7; }
    .dc-doc-leading-page__links-item_root:nth-child(15) { grid-area: 8 / 7 / 9 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(16) { grid-area: 9 / 1 / 10 / 7; }
    .dc-doc-leading-page__links-item_root:nth-child(17) { grid-area: 9 / 7 / 10 / 13; }

    /* the banner is too short for its text at this width — let the content
     * set the height instead of the 4:1 ratio */
    .dc-doc-leading-page__links-item_root:nth-child(19) {
        grid-area: 11 / 1 / 12 / 13;
        aspect-ratio: auto;
        padding: 40px 0;
        border-radius: 32px;
    }

    .dc-doc-leading-page__links-item_root:nth-child(19) .dc-doc-leading-page__links-right {
        max-width: 60%;
        padding-left: 6%;
    }

    /* two columns now, so the padding split changes: even items are on the
     * left, odd ones on the right */
    .dc-doc-leading-page__links-item_root:nth-child(2n) {
        margin-left: 32px;
        margin-right: 0;
    }

    .dc-doc-leading-page__links-item_root:nth-child(2n + 1) {
        margin-left: 0;
        margin-right: 32px;
    }

    .dc-doc-leading-page__links-item_root:nth-child(-n + 5),
    .dc-doc-leading-page__links-item_root:nth-child(n + 18) {
        margin-inline: 0;
    }

    .dc-doc-leading-page__links_root::after {
        grid-area: 4 / 1 / 10 / 13;
    }
}

/* Phones: one per row, and the plate keeps only side padding. */
@media (max-width: 700px) {
    .dc-doc-leading-page__links-item_root {
        grid-column: 1 / -1;
    }

    .dc-doc-leading-page__links-item_root:nth-child(6) { grid-area: 6 / 1 / 7 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(7) { grid-area: 7 / 1 / 8 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(8) { grid-area: 8 / 1 / 9 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(9) { grid-area: 9 / 1 / 10 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(10) { grid-area: 10 / 1 / 11 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(11) { grid-area: 11 / 1 / 12 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(12) { grid-area: 12 / 1 / 13 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(13) { grid-area: 13 / 1 / 14 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(14) { grid-area: 14 / 1 / 15 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(15) { grid-area: 15 / 1 / 16 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(16) { grid-area: 16 / 1 / 17 / 13; }
    .dc-doc-leading-page__links-item_root:nth-child(17) { grid-area: 17 / 1 / 18 / 13; }

    .dc-doc-leading-page__links-item_root:nth-child(19) {
        grid-area: 19 / 1 / 20 / 13;
        padding: 32px 0;
        border-radius: 24px;
    }

    .dc-doc-leading-page__links-item_root:nth-child(19) .dc-doc-leading-page__links-right {
        max-width: 100%;
        padding-inline: 28px;
    }

    /* only the twelve tiles on the plate are inset */
    .dc-doc-leading-page__links-item_root:nth-child(n + 6):nth-child(-n + 17) {
        margin-inline: 16px;
    }

    /* the plate overhangs by 16px here, not 32 */
    .dc-doc-leading-page__links-item_root:nth-child(18) {
        margin-top: 52px;
    }

    .dc-doc-leading-page__links_root::after {
        grid-area: 6 / 1 / 18 / 13;
        margin: -16px 0;
    }
}
