/**
 * Next steps: "Mitä seuraavaksi?" A heading and 2–4 links the reader can
 * take next: a service page, a booking, the newsletter, another article.
 * Used at the end of an article (the post body carries a site-wide default
 * right after the content, before the author card) and on pages.
 *
 * globalClass: next-steps
 *
 * Variants:
 *   (none)               rows: title and text left, arrow right
 *   next-steps--cards    cards in a grid (2 columns from 768px, 3 from 990px)
 *   next-steps--default  marks the site-wide default in the post body; it
 *                        is dropped on a post whose content has its own
 *                        next-steps (includes/blocks/next-steps.php)
 *
 * Structure:
 *   .next-steps.gb-container [.next-steps--cards]
 *     h2|h3.next-steps-title
 *     .next-steps-list.gb-container
 *       .next-step.gb-container  (one per link)
 *         h4.next-step-title + p.next-step-text + a.gb-button.next-step-link
 *   The whole row or card is clickable: the button's ::after covers it.
 *
 * Tuning: --next-steps-gap (12px rows, 24px cards), --next-step-radius (12px)
 *
 * Chain animations: the list is one group; order the steps 1..n for a
 * stagger, or leave off inside articles.
 */

:root {
    --next-steps-gap: 12px;
    --next-step-radius: 12px;
}

.next-steps {
    margin: 2.5em 0;
}

.next-steps-title {
    margin: 0 0 20px;
    font-size: var(--h3-size);
}

.next-steps-list,
.next-steps-list > .block-editor-inner-blocks > .block-editor-block-list__layout {
    display: grid;
    gap: var(--next-steps-gap);
}

.next-steps-list > .block-editor-inner-blocks {
    width: 100%;
}

.next-step {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 16px;
    align-items: center;
    padding: 18px 20px;
    border: 1px solid color-mix(in srgb, currentColor 15%, transparent);
    border-radius: var(--next-step-radius);
    transition: border-color var(--transition-speed) var(--transition-timing-function),
                background-color var(--transition-speed) var(--transition-timing-function);
}

.next-step:hover {
    border-color: var(--accent-clr);
    background-color: color-mix(in srgb, var(--accent-clr) 6%, transparent);
}

.next-step-title {
    grid-column: 1;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.next-step-text {
    grid-column: 1;
    margin: 4px 0 0;
    font-size: 0.9rem;
    opacity: 0.85;
}

/* The link: an arrow in the right column, its ::after makes the whole row clickable */
.next-step .next-step-link,
.next-step a.gb-button.next-step-link {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background-color: var(--btn-bg);
    color: var(--btn-font-clr);
    font-size: 0;
    text-decoration: none;
    transition: background-color var(--transition-speed) var(--transition-timing-function);
}

.next-step .next-step-link::before {
    content: "";
    width: 10px;
    height: 10px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: translateX(-2px) rotate(45deg);
}

.next-step .next-step-link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--next-step-radius);
}

.next-step:hover .next-step-link,
.next-step .next-step-link:focus-visible {
    background-color: var(--btn-hover-bg);
    color: var(--btn-hover-font);
}

/* Cards */
.next-steps--cards {
    --next-steps-gap: 24px;
}

.next-steps--cards .next-step {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    align-items: start;
    padding: 24px;
}

.next-steps--cards .next-step-text {
    margin-bottom: 20px;
}

/* Same specificity as the row rule above (a.gb-button), so this wins by order. */
.next-steps--cards .next-step .next-step-link,
.next-steps--cards .next-step a.gb-button.next-step-link {
    grid-column: 1;
    grid-row: 3;
}

@media only screen and (min-width: 768px) {
    .next-steps--cards .next-steps-list,
    .next-steps--cards .next-steps-list > .block-editor-inner-blocks > .block-editor-block-list__layout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media only screen and (min-width: 990px) {
    .next-steps--cards.alignwide .next-steps-list,
    .next-steps--cards.alignwide .next-steps-list > .block-editor-inner-blocks > .block-editor-block-list__layout,
    .next-steps--cards:not(.alignwide) .next-steps-list:has(> .next-step:nth-child(3):last-child),
    .next-steps-section .next-steps--cards .next-steps-list,
    .next-steps-section .next-steps--cards .next-steps-list > .block-editor-inner-blocks > .block-editor-block-list__layout {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
