/* Build phases chart, rendered by layouts/shortcodes/build-phases.html.

   Colors come from the Tugboat Design System Foundations: Coal, Storm, Blue: Bright (Sky), Ocean and Blue: Light.
   Each text color has a contrast ratio of at least 4.5:1 with its background (WCAG AA for small text).
   The chart shows one card per action, and switches to a grid with a column per command group when it has room.
   In both layouts, the snapshot is a pill with an icon of an arrow pointing down into a tray. */

.build-phases {
    --bp-lane: 4.5rem;
    --bp-snapshot-width: 7.5rem;
    --bp-radius: 9px;

    --bp-text: #1c2428;
    --bp-muted: #3e4548;
    --bp-lane-bg: #f0f9fc;
    --bp-lane-text: #07688c;
    --bp-box-bg: #ffffff;
    --bp-box-border: #d7dfe3;
    --bp-chip: #07688c;
    --bp-chip-text: #ffffff;
    --bp-line: #afc0c6;
    --bp-separator: #e9eef1;
    --bp-snapshot: #03384b;
    --bp-snapshot-text: #ffffff;

    container-type: inline-size;
    margin: 2rem 0;
    color: var(--bp-text);
    font-family: "Poppins", sans-serif;
    line-height: 1.4;
}

@media (prefers-color-scheme: dark) {
    .build-phases {
        --bp-text: #f0f2f3;
        --bp-muted: #afc0c6;
        --bp-lane-bg: #052835;
        --bp-lane-text: #80cbe5;
        --bp-box-bg: #1c2428;
        --bp-box-border: #3e4548;
        --bp-line: #5f818e;
        --bp-separator: #3e4548;
        --bp-snapshot: #f0f9fc;
        --bp-snapshot-text: #03384b;
    }
}

/* Narrow layout: one card per action */

.build-phases .bp-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.build-phases .bp-head,
.build-phases .bp-lane,
.build-phases .bp-lane-head,
.build-phases .bp-flow,
.build-phases .bp-sep {
    display: none;
}

.build-phases .bp-row {
    border: 1px solid var(--bp-box-border);
    border-radius: var(--bp-radius);
    padding: 1rem;
}

.build-phases .bp-title {
    display: block;
    font-size: 1rem;
    font-weight: 600;
}

.build-phases .bp-description {
    display: block;
    color: var(--bp-muted);
    font-size: 0.8125rem;
}

.build-phases .bp-start {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.build-phases .bp-start-label {
    font-weight: 600;
}

/* Each step has an arrow in the space to its left. The list starts that space before the card's content edge, and
   clips it, so the first step on each line has no arrow. */
.build-phases .bp-steps {
    --bp-step-gap: 1.5rem;

    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0;
    margin: 0.75rem 0 0 calc(-1 * var(--bp-step-gap));
    padding: 0;
    list-style: none;
    clip-path: inset(-4px -4px -4px calc(var(--bp-step-gap) - 4px));
}

.build-phases .bp-steps > li {
    margin: 0 0 0 var(--bp-step-gap);
}

.build-phases .bp-chip,
.build-phases .bp-snap-step {
    position: relative;
    padding: 0.375rem 0.875rem;
    border-radius: 999px;
    background: var(--bp-chip);
    color: var(--bp-chip-text);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.4;
}

/* A command links to the section that describes its command group. The link covers the whole chip. The selectors
   start with #R-body, because the theme variant's link colors are wrapped in :root selectors that outrank classes. */
#R-body .build-phases .bp-chip a {
    color: inherit;
    font-weight: inherit;
    text-decoration: none;
}

#R-body .build-phases .bp-chip a::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
}

#R-body .build-phases .bp-chip a:hover,
#R-body .build-phases .bp-chip a:focus-visible {
    color: inherit;
    text-decoration: underline;
}

#R-body .build-phases .bp-chip:has(a:focus-visible) {
    outline: 2px solid var(--bp-chip);
    outline-offset: 2px;
}

.build-phases .bp-snap-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4375rem;
    background: var(--bp-snapshot);
    color: var(--bp-snapshot-text);
    font-family: "Poppins", sans-serif;
    white-space: nowrap;
}

.build-phases .bp-snap-step i {
    font-size: 0.75rem;
}

/* Arrowhead between steps */
.build-phases .bp-steps > li::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -1.125rem;
    border: 0.3125rem solid transparent;
    border-left: 0.5rem solid var(--bp-line);
    transform: translateY(-50%);
}

/* Wide layout: a grid with a column per command group, and a Snapshot column */

@container (min-width: 56rem) {
    .build-phases .bp-grid {
        display: grid;
        grid-template-columns:
            minmax(11rem, 1.3fr) minmax(9rem, 1fr) repeat(var(--bp-before), var(--bp-lane))
            var(--bp-snapshot-width) repeat(var(--bp-after), var(--bp-lane));
        gap: 0 0.5rem;
    }

    .build-phases .bp-head {
        display: block;
        grid-row: 1;
        padding-bottom: 0.5rem;
        color: var(--bp-muted);
        font-size: 0.6875rem;
        font-weight: 600;
        letter-spacing: 0.1em;
        text-transform: uppercase;
    }

    .build-phases .bp-lane {
        display: block;
        z-index: 0;
        border-radius: var(--bp-radius);
        background: var(--bp-lane-bg);
    }

    .build-phases .bp-lane-head {
        display: block;
        grid-row: 2;
        z-index: 1;
        padding: 0.75rem 0 0.25rem;
        color: var(--bp-lane-text);
        font-family: ui-monospace, Menlo, Consolas, monospace;
        font-size: 0.8125rem;
        font-weight: 600;
        text-align: center;
    }

    .build-phases .bp-row {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: subgrid;
        align-items: center;
        position: relative;
        z-index: 2;
        min-height: 5.5rem;
        padding: 0;
        border: 0;
        border-radius: 0;
    }

    .build-phases .bp-row > *,
    .build-phases .bp-steps > li {
        grid-row: 1;
    }

    .build-phases .bp-sep {
        display: block;
        grid-column: 1 / 3;
        align-self: start;
        border-top: 1px solid var(--bp-separator);
    }

    .build-phases .bp-flow {
        display: block;
        height: 2px;
        margin-right: calc(var(--bp-lane) / 2);
        background: var(--bp-line);
    }

    .build-phases .bp-action {
        grid-column: 1;
        padding-right: 1rem;
    }

    .build-phases .bp-title {
        font-size: 0.9375rem;
    }

    .build-phases .bp-start {
        display: flex;
        grid-column: 2;
        align-items: center;
        align-self: stretch;
        position: relative;
        margin: 0.5rem 0;
        padding: 0.5rem 0.75rem;
        border: 1.5px solid var(--bp-box-border);
        border-radius: var(--bp-radius);
        background: var(--bp-box-bg);
        font-size: 0.8125rem;
    }

    /* The column heading says this, so only screen readers get it */
    .build-phases .bp-start-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .build-phases .bp-steps {
        display: contents;
    }

    .build-phases .bp-steps > li {
        margin: 0;
    }

    .build-phases .bp-steps > li::before {
        content: none;
    }

    .build-phases .bp-chip,
    .build-phases .bp-snap-step {
        justify-self: center;
        width: calc(100% - 0.5rem);
        padding: 0.375rem 0;
        text-align: center;
    }
}
