/* --------------------------------------------------------------------------
   Process diagrams — pipeline, V-model, gated stages, test rig, pyramid.
   Drawn with HTML and SVG so every label stays real, translatable text.
   -------------------------------------------------------------------------- */

.s-process {
    --sp-line: color-mix(in srgb, var(--s-fg) 22%, transparent);
    --sp-box: #fff;
    --sp-accent: var(--v2-accent);
    scroll-margin-top: 120px;
}

.s--dark.s-process {
    --sp-box: rgba(255, 255, 255, 0.04);
    --sp-accent: #e0575a;
}

.sp-icon {
    display: block;
    width: 22px;
    height: 22px;
}

.sp-note {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: var(--v2-s3) 0 0;
    font-size: 0.9375rem;
    color: var(--s-fg-soft);
}

.sp-note::before {
    content: "";
    flex: none;
    width: 24px;
    height: 2px;
    background: var(--sp-accent);
}

/* Flow: numbered nodes joined by arrows, bracketed by group. ------------- */

.sp-flow {
    display: flex;
    flex-direction: column;
    gap: var(--v2-s3);
}

.sp-flow__group-label {
    margin: 0 0 var(--v2-s2);
    padding-top: 8px;
    border-top: 2px solid var(--sp-line);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--s-fg-mute);
}

.sp-flow__steps {
    display: grid;
    gap: var(--v2-s2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-flow__step {
    position: relative;
    display: grid;
    grid-template-columns: 48px 1fr;
    column-gap: var(--v2-s2);
    align-items: start;
    align-content: start;
}

.sp-flow__node {
    position: relative;
    grid-row: span 2;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border: 1.5px solid var(--sp-line);
    border-radius: 50%;
    background: var(--sp-box);
    color: var(--sp-accent);
    z-index: 1;
}

.sp-flow__num {
    position: absolute;
    top: -4px;
    right: -6px;
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    border-radius: 10px;
    background: var(--s-fg);
    color: var(--v2-paper);
    font-size: 0.6875rem;
    font-weight: 700;
}

.s--dark .sp-flow__num {
    color: var(--v2-night);
}

.sp-flow__step.is-final .sp-flow__node {
    border-color: var(--sp-accent);
    background: var(--sp-accent);
    color: #fff;
}

.sp-flow__title {
    margin: 2px 0 0;
    font-family: var(--v2-head-font);
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--s-fg);
}

.sp-flow__text {
    margin: 4px 0 0;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--s-fg-soft);
}

/* On a phone the nodes hang from one vertical line. */
.sp-flow__step:not(.is-final)::after {
    content: "";
    position: absolute;
    top: 48px;
    bottom: calc(-1 * var(--v2-s2));
    left: 23px;
    border-left: 1.5px solid var(--sp-line);
}

.sp-flow__group:not(:last-child) .sp-flow__step:last-child::after {
    bottom: calc(-1 * var(--v2-s3) - var(--v2-s2) - 30px);
}

.sp-flow__loop {
    position: relative;
    margin: var(--v2-s3) 0 0;
    font-size: 0.875rem;
    color: var(--s-fg-soft);
}

.sp-flow__loop span::before {
    content: "\21BA  ";
    font-weight: 700;
    color: var(--sp-accent);
}

@media (min-width: 1024px) {
    .sp-flow {
        flex-direction: row;
        gap: var(--v2-s2);
    }

    .sp-flow__group {
        flex: var(--count) 1 0;
        min-width: 0;
    }

    .sp-flow__steps {
        grid-template-columns: repeat(var(--count), minmax(0, 1fr));
    }

    .sp-flow__step {
        grid-template-columns: 1fr;
        row-gap: 10px;
    }

    .sp-flow__node {
        grid-row: auto;
    }

    /* Titles take two lines' room so every step's text starts on one line. */
    .sp-flow__title {
        min-height: 2.6em;
    }

    /* An arrow from each node to the next, across group borders too. */
    .sp-flow__step:not(.is-final)::after {
        top: 24px;
        bottom: auto;
        left: 56px;
        right: calc(-1 * var(--v2-s2) + 8px);
        border-left: 0;
        border-top: 1.5px solid var(--sp-line);
    }

    .sp-flow__group:not(:last-child) .sp-flow__step:last-child::after {
        bottom: auto;
    }

    .sp-flow__step:not(.is-final)::before {
        content: "";
        position: absolute;
        top: 20px;
        right: calc(-1 * var(--v2-s2) + 6px);
        border: 4.5px solid transparent;
        border-left: 7px solid color-mix(in srgb, var(--s-fg) 45%, transparent);
        border-right: 0;
    }

    /* The way back: a dashed return under the whole pipeline. */
    .sp-flow__loop {
        margin-top: 14px;
        padding-top: 18px;
        text-align: center;
    }

    .sp-flow__loop::before {
        content: "";
        position: absolute;
        top: 0;
        left: 24px;
        right: calc(100% / var(--n, 8) - 24px);
        height: 12px;
        border: 2px dashed var(--sp-accent);
        border-top: 0;
        border-radius: 0 0 10px 10px;
    }

    .sp-flow__loop::after {
        content: "";
        position: absolute;
        top: -7px;
        left: 21px;
        border: 5px solid transparent;
        border-bottom: 7px solid var(--sp-accent);
        border-top: 0;
    }
}

/* V-model: boxes on two arms, joined by an SVG drawn after layout. ------- */

.sp-v {
    position: relative;
    display: grid;
    gap: 10px;
}

.sp-v__arms {
    display: none;
}

.sp-v__box {
    position: relative;
    display: grid;
    grid-template-columns: 34px 1fr;
    gap: 10px;
    align-items: start;
    padding: 10px 14px;
    border: 1px solid var(--s-rule);
    border-left: 3px solid var(--s-fg);
    background: var(--sp-box);
    z-index: 1;
}

.sp-v__box--bottom { border-left-color: var(--s-fg-mute); }
.sp-v__box--right { border-left-color: var(--sp-accent); }

.sp-v__icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--s-fg) 7%, transparent);
    color: var(--s-fg);
}

.sp-v__box--right .sp-v__icon {
    background: color-mix(in srgb, var(--sp-accent) 12%, transparent);
    color: var(--sp-accent);
}

.sp-v__title {
    margin: 0;
    font-family: var(--v2-head-font);
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--s-fg);
}

.sp-v__text,
.sp-v__pairs {
    margin: 2px 0 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--s-fg-soft);
}

.sp-v__pairs {
    color: var(--sp-accent);
    font-weight: 600;
}

@media (min-width: 1024px) {
    .sp-v {
        --w: 30%;
        --step: 4.5%;
        gap: 6px;
    }

    .sp-v__box {
        padding-block: 8px;
    }

    .sp-v__arms {
        display: block;
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        overflow: visible;
        pointer-events: none;
    }

    .sp-v__arm {
        fill: none;
        stroke: color-mix(in srgb, var(--s-fg) 35%, transparent);
        stroke-width: 3;
        stroke-linejoin: round;
    }

    .sp-v__pair {
        stroke: color-mix(in srgb, var(--sp-accent) 55%, transparent);
        stroke-width: 1.5;
        stroke-dasharray: 5 5;
    }

    .sp-v__pair-label {
        fill: var(--sp-accent);
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
    }

    .sp-v__box {
        grid-row: var(--row);
        grid-column: 1;
        width: var(--w);
    }

    .sp-v__box--left {
        justify-self: start;
        margin-left: calc(var(--r) * var(--step));
    }

    .sp-v__box--right {
        justify-self: end;
        margin-right: calc(var(--r) * var(--step));
    }

    .sp-v__box--bottom {
        justify-self: center;
    }

    .sp-v__pairs {
        display: none;
    }
}

/* Stages: chevrons in a row, a gate between each. ------------------------ */

.sp-stages {
    display: grid;
    gap: var(--v2-s3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-stage {
    position: relative;
}

.sp-stage__head {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 72px;
    padding: 10px 34px 10px 20px;
    background: color-mix(in srgb, var(--v2-accent) calc(35% + var(--i) * 20%), var(--v2-night));
    color: #fff;
    clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%);
}

.sp-stage__code {
    font-family: var(--v2-head-font);
    font-size: 1.375rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.sp-stage__title {
    font-size: 0.8125rem;
    opacity: 0.85;
}

.sp-stage__body {
    margin-top: var(--v2-s2);
    font-size: 0.9375rem;
}

.sp-stage__body ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-stage__body li {
    position: relative;
    margin: 0 0 6px;
    padding-left: 18px;
    line-height: 1.4;
}

.sp-stage__body li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0.5em;
    width: 7px;
    height: 7px;
    border: 1.5px solid var(--sp-accent);
    border-radius: 50%;
}

.sp-stage__gate {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--s-fg-mute);
}

.sp-stage__gate i {
    width: 9px;
    height: 9px;
    background: var(--sp-accent);
    transform: rotate(45deg);
}

@media (min-width: 1024px) {
    .sp-stages {
        grid-template-columns: repeat(var(--n), minmax(0, 1fr));
        gap: 6px;
    }

    .sp-stage:not(:first-child) .sp-stage__head {
        padding-left: 32px;
        clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%, 18px 50%);
    }

    .sp-stage__body {
        padding: 30px var(--v2-s2) 0 0;
    }

    /* The gate sits under the arrow's tip, between two stages. */
    .sp-stage__gate {
        position: absolute;
        top: 80px;
        right: -3px;
        margin: 0;
        flex-direction: column;
        gap: 4px;
        transform: translateX(50%);
        z-index: 1;
    }
}

/* Rig: the device under test in the middle, wired to what drives it. ----- */

.sp-rig {
    display: grid;
    gap: var(--v2-s3);
}

.sp-rig__side {
    display: grid;
    gap: var(--v2-s2);
    align-content: center;
}

.sp-rig__box {
    position: relative;
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--s-rule);
    background: var(--sp-box);
}

.sp-rig__icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--sp-accent) 14%, transparent);
    color: var(--sp-accent);
}

.sp-rig__title,
.sp-rig__core-title {
    margin: 0;
    font-family: var(--v2-head-font);
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--s-fg);
}

.sp-rig__core-title {
    margin-top: var(--v2-s2);
    font-size: 1.125rem;
}

.sp-rig__text {
    margin: 3px 0 0;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--s-fg-soft);
}

.sp-rig__core {
    padding: var(--v2-s3);
    border: 1.5px solid var(--sp-accent);
    background: color-mix(in srgb, var(--sp-accent) 8%, transparent);
    text-align: center;
}

.sp-rig__board {
    display: block;
    width: min(100%, 260px);
    margin: 0 auto;
}

.sp-rig__board .b-pcb { fill: #1d4a3a; stroke: #2f6b55; stroke-width: 2; }
.sp-rig__board .b-trace { fill: none; stroke: #c9a24a; stroke-width: 1.6; opacity: 0.8; }
.sp-rig__board .b-chip { fill: #10161f; stroke: #3a4655; }
.sp-rig__board .b-pin { stroke: #b8c0c9; stroke-width: 1.6; }
.sp-rig__board .b-part { fill: #2b333d; stroke: #4a5563; }
.sp-rig__board .b-conn { fill: #e9e6df; stroke: #9aa3ad; }
.sp-rig__board .b-led { fill: #ff5a5d; animation: sp-blink 1.6s ease-in-out infinite; }
.sp-rig__board .b-hole { fill: #f3f1ec; stroke: #c9a24a; }

@keyframes sp-blink {
    50% { opacity: 0.25; }
}

@media (min-width: 1024px) {
    .sp-rig {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
        column-gap: 56px;
        align-items: center;
    }

    /* A wire from every side box to the device, with data running along it. */
    .sp-rig__box::after {
        content: "";
        position: absolute;
        top: 50%;
        width: 56px;
        height: 2px;
        background: repeating-linear-gradient(90deg, var(--sp-accent) 0 6px, transparent 6px 11px);
        background-size: 22px 2px;
        animation: sp-wire 1.2s linear infinite;
    }

    .sp-rig__side--left .sp-rig__box::after { left: 100%; }
    .sp-rig__side--right .sp-rig__box::after { right: 100%; animation-direction: reverse; }
}

@keyframes sp-wire {
    to { background-position: 22px 0; }
}

@media (prefers-reduced-motion: reduce) {
    .sp-rig__board .b-led,
    .sp-rig__box::after {
        animation: none;
    }
}

/* Pyramid: one triangle cut into levels, each level's words beside it. -- */

.sp-pyr {
    display: grid;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-pyr__row {
    display: grid;
    grid-template-columns: minmax(120px, 38%) 1fr;
    gap: var(--v2-s3);
    align-items: stretch;
}

.sp-pyr__layer {
    display: grid;
    place-items: center;
    min-height: 64px;
    background: color-mix(in srgb, var(--v2-accent) calc(100% - var(--i) * 22%), var(--v2-night));
    color: #fff;
}

.sp-pyr__copy {
    align-self: center;
    padding: 6px 0;
}

.sp-pyr__title {
    margin: 0;
    font-family: var(--v2-head-font);
    font-size: 1rem;
    font-weight: 700;
    color: var(--s-fg);
}

.sp-pyr__text {
    margin: 2px 0 0;
    font-size: 0.875rem;
    color: var(--s-fg-soft);
}

@media (min-width: 1024px) {
    .sp-pyr {
        max-width: 60rem;
    }
}

/* Cycle: a ring of numbered nodes with an arc running round it, the steps listed beside. */

.sp-cycle {
    display: grid;
    gap: var(--v2-s4);
    align-items: center;
}

.sp-cycle__ring {
    position: relative;
    width: min(100%, 320px);
    aspect-ratio: 1;
    margin: 0 auto;
}

.sp-cycle__track {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.sp-cycle__track circle {
    fill: none;
    stroke: var(--sp-line);
    stroke-width: 1.2;
}

.sp-cycle__track .sp-cycle__run {
    stroke: var(--sp-accent);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-dasharray: 18 82;
    animation: sp-run 6s linear infinite;
}

@keyframes sp-run {
    to { stroke-dashoffset: -100; }
}

.sp-cycle__node {
    position: absolute;
    display: grid;
    place-items: center;
    width: 50px;
    height: 50px;
    border: 1.5px solid var(--sp-line);
    border-radius: 50%;
    background: var(--v2-paper);
    color: var(--sp-accent);
    transform: translate(-50%, -50%);
}

.s--muted .sp-cycle__node { background: var(--v2-paper-sunk); }
.s--dark .sp-cycle__node { background: var(--v2-night); }

.sp-cycle__node b {
    position: absolute;
    top: -6px;
    right: -6px;
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--s-fg);
    color: var(--v2-paper);
    font-size: 0.6875rem;
}

.s--dark .sp-cycle__node b { color: var(--v2-night); }

.sp-cycle__node.is-final {
    border-color: var(--sp-accent);
    background: var(--sp-accent);
    color: #fff;
}

.sp-cycle__center {
    position: absolute;
    inset: 30%;
    display: grid;
    place-items: center;
    text-align: center;
    font-family: var(--v2-head-font);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.25;
    color: var(--s-fg);
}

.sp-cycle__center::before {
    content: "\21BB";
    display: block;
    font-size: 1.75rem;
    color: var(--sp-accent);
}

.sp-cycle__list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sp-cycle__list li {
    display: grid;
    grid-template-columns: 28px 1fr;
    gap: 12px;
    align-items: start;
}

.sp-cycle__list li > b {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: 1.5px solid var(--sp-line);
    border-radius: 50%;
    font-size: 0.75rem;
    color: var(--s-fg);
}

.sp-cycle__list li.is-final > b {
    border-color: var(--sp-accent);
    background: var(--sp-accent);
    color: #fff;
}

.sp-cycle__title {
    margin: 2px 0 0;
    font-family: var(--v2-head-font);
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--s-fg);
}

.sp-cycle__text {
    margin: 2px 0 0;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--s-fg-soft);
}

@media (min-width: 1024px) {
    .sp-cycle {
        grid-template-columns: 330px 1fr;
        gap: var(--v2-s5);
    }

    /* Two columns of steps beside the ring, read down then across. */
    .sp-cycle__list {
        grid-template-columns: 1fr 1fr;
        grid-auto-flow: column;
        grid-template-rows: repeat(var(--rows), auto);
        column-gap: var(--v2-s4);
        row-gap: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sp-cycle__track .sp-cycle__run {
        animation: none;
    }
}

/* Diagram sections sit tighter so a whole diagram fits one desktop screen. */
@media (min-width: 1024px) {
    .s-process {
        padding-block: clamp(32px, 3.4vw, 56px);
    }

    .s-process .s-head {
        margin-bottom: var(--v2-s3);
    }

    .s-process .s-title {
        font-size: clamp(1.5rem, 1rem + 1.1vw, 2rem);
    }

    .s-process .s-lead {
        font-size: 1rem;
    }
}

@media (min-width: 1024px) and (max-height: 820px) {
    .s-process {
        padding-block: 24px;
    }

    .sp-cycle {
        grid-template-columns: 290px 1fr;
    }

    .sp-cycle__ring {
        width: 280px;
    }

    .s-process .s-head {
        margin-bottom: var(--v2-s2);
    }
}
