/* Preserve the existing breadcrumb, panel-top and history-actions country hooks.
   Position controls only after their translated, country-styled sizes are known. */
:where([data-procedure-navigation="ready"]) .breadcrumbs {
    border-block-end: 0;
}
:where([data-procedure-navigation="ready"]) .panel-top {
    margin-block-end: 0;
}
:where([data-procedure-navigation="ready"]) .history-actions {
    margin-block-end: 0;
}
@media (min-width: 1024px) {
    :where([data-procedure-navigation="ready"] .history-actions) .back-link {
        position: absolute;
        top: var(--procedure-back-top);
        inset-inline-start: var(--procedure-back-start);
        z-index: 2;
    }
    /* Only the title reserves room for controls; the trail uses the full row. */
    :where([data-procedure-navigation="ready"]) .breadcrumbs li:where(:first-child) {
        padding-inline-end: var(--procedure-actions-space, 0px);
        box-sizing: border-box;
    }
    :where([data-procedure-navigation="ready"] .history-actions) .step-actions {
        position: absolute;
        top: var(--procedure-actions-top);
        inset-inline-end: 15px;
        width: max-content;
    }
}
@media (max-width: 1023px) {
    :where([data-procedure-navigation="ready"]) .history-actions {
        justify-content: flex-start;
    }
    :where([data-procedure-navigation="ready"]) .history-actions .step-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
        width: auto;
    }
    :where([data-procedure-navigation="ready"]) .panel-top {
        margin-block-end: 16px;
    }
}

/* Keep the final separator with its label when a long breadcrumb wraps. */
.breadcrumb-trailing-separator {
    color: var(--gray-600);
    margin-inline-start: 8px;
    white-space: nowrap;
}

/* Center both chevrons above the baseline in proportion to the text size. */
:where(app-breadcrumb) .breadcrumbs li + li + li::before,
.breadcrumb-trailing-separator::after {
    content: "";
    display: inline-block;
    box-sizing: border-box;
    flex: none;
    inline-size: 7px;
    block-size: 7px;
    border-block-start: 1px solid currentColor;
    border-inline-end: 1px solid currentColor;
    transform: translate(-2px, calc(50% - 0.3em)) rotate(45deg);
}
:where([dir="rtl"] app-breadcrumb) .breadcrumbs li + li + li::before,
:where([dir="rtl"]) .breadcrumb-trailing-separator::after {
    transform: translate(2px, calc(50% - 0.3em)) rotate(-45deg);
}

@media screen and (max-width: 767.98px) {
    app-breadcrumb:where(:has(> .breadcrumbs > li + li)) {
        --procedure-breadcrumb-gutter: 15px;
        display: block;
        margin-inline: calc(-1 * var(--procedure-breadcrumb-gutter));
        padding-inline: var(--procedure-breadcrumb-gutter);
        overflow-x: auto;
        scrollbar-width: none;
    }
    :where(app-breadcrumb) .breadcrumbs:where(:has(> li + li)) {
        inline-size: max-content;
        min-inline-size: 100%;
    }
    :where(app-breadcrumb) .breadcrumbs > li + li {
        white-space: nowrap;
    }
    /* Keep the title on its own row without changing the list's sibling selectors. */
    :where(app-breadcrumb) .breadcrumbs:where(:has(> li + li))::after {
        content: "";
        flex: 0 0 100%;
        order: 1;
    }
    :where(app-breadcrumb) .breadcrumbs:where(:has(> li + li)) > li:first-child {
        order: 2;
        flex: 1 0 1px; /* A nonzero basis puts the title after the full-width break. */
        min-inline-size: 0;
        max-inline-size: calc(100vw - 2 * var(--procedure-breadcrumb-gutter));
        contain: inline-size;
        position: sticky;
        inset-inline-start: 0;
    }
    /* Raise the sticky title so its open action menu can cover the context panel. */
    :where(app-breadcrumb) .breadcrumbs > li:where(:first-child:not(:last-child):has(> .procedure-actions-menu[open])) {
        z-index: 1;
    }
    /* Let the open action menu extend below the breadcrumb. */
    app-breadcrumb:where(:has(> .breadcrumbs > li:first-child:not(:last-child) > details[open])) {
        overflow-x: clip;
    }
}
