/*
 * Software Engineering's light object, Connected Systems (approved by the Owner on 2026-11-27): one custom
 * system moving an order through the systems around it, with the circuit field faint behind it. It sits in
 * the frame service-visuals.css gives every service visual, and only adds what is below. Colours, type and
 * radii are the site's own tokens. sequence-drawings.js adds is-travelling and is-done step by step; with
 * reduced motion it shows every step finished, still.
 * Design: Design/software-engineering-visual-2026-11-27/direction-b-connected-systems.html.
 */

/* ---------- Text inside the drawings ---------- */

.visual-drawing {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.visual-title {
    fill: var(--color-text);
    font-family: var(--font-display);
    font-weight: 620;
    font-stretch: 108%;
    letter-spacing: -0.01em;
}

.visual-body {
    fill: var(--color-text);
    font-family: var(--font-body);
    font-weight: 500;
}

.visual-muted {
    fill: var(--color-text-muted);
}

.visual-label {
    fill: var(--color-text-faint);
    font-family: var(--font-mono);
    font-weight: 500;
    letter-spacing: 0.08em;
}

.visual-hue-text {
    fill: var(--service-hue);
}

/* ---------- Surfaces and lines inside the drawings ---------- */

.visual-panel {
    fill: var(--color-raised);
    stroke: var(--color-line-strong);
    stroke-width: 1;
}

.visual-rule {
    stroke: var(--color-line);
    stroke-width: 1;
}

/* ---------- A value that changes when its step completes ---------- */

.sequence-before,
.sequence-after {
    transition: opacity var(--duration-slow) var(--ease-out);
}

.sequence-before.is-done {
    opacity: 0;
}

.sequence-after {
    opacity: 0;
}

.sequence-after.is-done {
    opacity: 1;
}

/* ---------- The frame: the circuit field faint behind, the drawing centred over it ---------- */

.service-visual-systems .service-visual-bleed img {
    object-position: 40% 50%;
    opacity: 0.32;
}

.software-systems {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
}

.software-systems-object {
    width: min(100%, 760px);
    aspect-ratio: 760 / 600;
}

.software-systems-phone {
    display: none;
}

/* ---------- Traces and the custom software in the middle ---------- */

.systems-trace {
    fill: none;
    stroke: var(--color-line-strong);
    stroke-width: 1;
}

.systems-trace-faint {
    fill: none;
    stroke: var(--color-line);
    stroke-width: 1;
}

.systems-trace-end {
    fill: var(--color-line-strong);
}

.systems-core {
    fill: var(--color-raised);
    stroke: color-mix(in srgb, var(--service-hue) 40%, transparent);
    stroke-width: 1;
}

/* A point of light that runs along a trace when the order moves */
.systems-pulse {
    fill: none;
    stroke: var(--service-hue);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 12 100;
    stroke-dashoffset: 12;
    opacity: 0;
    filter: drop-shadow(0 0 4px var(--service-hue));
}

.systems-pulse.is-travelling {
    animation: systems-pulse-travel 900ms linear forwards;
}

@keyframes systems-pulse-travel {
    0% {
        stroke-dashoffset: 12;
        opacity: 1;
    }

    92% {
        opacity: 1;
    }

    100% {
        stroke-dashoffset: -100;
        opacity: 0;
    }
}

/* A system's edge lights up when the order reaches it */
.systems-node {
    transition: stroke var(--duration-gentle) var(--ease-out);
}

.systems-node-group.is-done .systems-node {
    stroke: color-mix(in srgb, var(--service-hue) 45%, transparent);
}

/* ---------- The checklist inside the core ---------- */

.systems-check-ring {
    fill: transparent;
    stroke: var(--color-line-strong);
    stroke-width: 1;
    transition: fill var(--duration-gentle) var(--ease-out), stroke var(--duration-gentle) var(--ease-out);
}

.systems-check-mark {
    fill: none;
    stroke: var(--service-hue);
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    transition: stroke-dashoffset var(--duration-gentle) var(--ease-out);
}

.systems-step-text {
    fill: var(--color-text-faint);
    transition: fill var(--duration-gentle) var(--ease-out);
}

.systems-step.is-done .systems-check-ring {
    fill: color-mix(in srgb, var(--service-hue) 16%, transparent);
    stroke: color-mix(in srgb, var(--service-hue) 60%, transparent);
}

.systems-step.is-done .systems-check-mark {
    stroke-dashoffset: 0;
}

.systems-step.is-done .systems-step-text {
    fill: var(--color-text);
}

/* ---------- Tablet and phone: the simpler drawing, sized to read on a small screen ---------- */

@media (max-width: 1023px) {
    .software-systems-desktop {
        display: none;
    }

    .software-systems-phone {
        display: block;
    }

    /* Connected Systems keeps the full-width band, a little taller than the other services' bands */
    .service-visual.service-visual-systems {
        aspect-ratio: 400 / 330;
    }

    /* The band runs to the window's edges; the drawing keeps the page gutter */
    .software-systems-object {
        width: calc(100% - 2 * var(--page-gutter));
        aspect-ratio: 400 / 330;
    }
}

/* ---------- Reduced motion: the finished state, still (the script also stops) ---------- */

@media (prefers-reduced-motion: reduce) {
    .sequence-before,
    .sequence-after,
    .systems-node,
    .systems-check-ring,
    .systems-check-mark,
    .systems-step-text {
        transition: none;
    }

    .systems-pulse {
        display: none;
    }
}
