/* Step bar — redesigned May 2026.
   Top-of-screen card. Header (phase · counter) and a 4 px segmented
   progress strip share a single row; the Space Grotesk instruction
   sits beneath. The Continue / Unpause CTA is absolutely positioned
   on the bottom-right and hangs slightly below the bar.
   Figma: Galileo-Cloud → WIP → 1815:41. */
#step-bar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;

    width: 620px;
    max-width: calc(100vw - 40px);
    min-width: 280px;

    background: var(--color-surface, #FFFDF5);
    border: 2px solid var(--color-text, #1A1A1A);
    border-radius: 12px;
    /* Single offset shadow follows the silhouette of card + protruding
       CTA button. Using filter: drop-shadow() (instead of one shadow on
       the card and another on the button) keeps the shadow continuous
       across the button's hanging edge. */
    filter: drop-shadow(6px 6px 0 rgba(26, 26, 26, 0.18));

    padding: 15px 20px 20px;
    display: flex;
    flex-direction: column;
    /* Figma spec — Default/With-Continue/Unpause/Completed/Error variants
       all use 6 px between the progress row and the instruction. Sim adds
       a right-edge phase chip and uses 10 px; revisit if/when Sim is wired
       in StepBarHandler (currently the chip stays hidden). */
    gap: 6px;

    pointer-events: auto;
}

#step-bar[hidden] {
    display: none;
}

/* ── Top row: header (left) + progress strip (centre) + phase chip (right slot) ── */

.sb-progress-row {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
}

/* ---- progress bar ---- */

.sb-progress {
    flex: 1;
    display: flex;
    gap: 4px;
    height: 4px;
    min-width: 0;
}

.sb-segment {
    flex: 1;
    /* Empty-segment ink — kept at 0.20 for low-vision contrast on cream. */
    background: rgba(26, 26, 26, 0.20);
    border-radius: 3px;
    overflow: hidden;
    min-width: 0;
}

.sb-segment-fill {
    height: 100%;
    background: var(--color-success, #1F8F4E);
    border-radius: 3px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 300ms ease-out, background 200ms ease-out;
}

/* Completed step — full-width green. */
.sb-segment-fill.is-completed {
    transform: scaleX(1);
}

/* Active step — full-width black with a 1 px ring (halved from 2 px
   now that the segment is 4 px tall — a 2 px ring would overpower it). */
.sb-segment-fill.is-active {
    transform: scaleX(1);
    background: var(--color-text, #1A1A1A);
    box-shadow: 0 0 0 1px rgba(26, 26, 26, 0.12);
}

/* ---- header ---- */

.sb-header {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    flex-wrap: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Phase + counter — plain Inter pair, separated by a bullet.
   Reads as "Observation • Step 5 of 8". */
.sb-phase,
.sb-counter {
    font-family: var(--font-family);
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary, #43423D);
    white-space: nowrap;
}

.sb-phase::after {
    content: '•';
    margin-left: 8px;
    color: var(--color-text-tertiary, #6A695F);
}

.sb-phase[hidden] { display: none; }
.sb-phase[hidden]::after { content: none; }

/* "Completed!" — overlays the header in place, so the progress strip
   doesn't shift while the flash is up. Phase + counter are made
   visibility: hidden (not display: none) to preserve their width. */
.sb-completed-pill {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    font-family: var(--font-family, 'Inter', sans-serif);
    font-size: 12px;
    font-weight: 600;
    color: var(--color-success, #1F8F4E);
    letter-spacing: 0;
}

.sb-completed-pill[hidden] {
    display: none;
}

.sb-header.is-complete .sb-phase,
.sb-header.is-complete .sb-counter {
    visibility: hidden;
}

/* ---- phase chip (right of progress strip) ----
   Reserved slot for the FROZEN / SIMULATING chip seen in layout block D
   of mockups/lab-layout-candidates.html. Hidden by default — no
   upstream phase signal is wired into StepBarHandler today; remove the
   hidden attribute and set data-phase once one exists. */

.sb-phase-chip {
    flex-shrink: 0;
    align-items: center;
    gap: 6px;
    padding: 2px 8px 2px 6px;
    border: 1px solid rgba(26, 26, 26, 0.20);
    border-radius: 9999px;
    font-family: var(--font-mono, 'IBM Plex Mono', monospace);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text);
}

.sb-phase-chip[hidden] { display: none; }
.sb-phase-chip:not([hidden]) { display: inline-flex; }

/* SIM (Simulating) variant — green dot + tinted green capsule. */
.sb-phase-chip[data-phase="sim"] {
    background: var(--color-success-tint, #D8EFDF);
    border-color: var(--color-success, #1F8F4E);
}

.sb-phase-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success, #1F8F4E);
}

/* ---- instruction ----
   v1 proportions: 22 px / 1.3 / -0.02em. Weight 600 (semibold). */

.sb-instruction {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
    letter-spacing: -0.02em;
    line-height: 1.3;
    color: var(--color-text, #1A1A1A);
    text-wrap: pretty;
}

/* ---- Continue / Unpause CTA ----
   Visual styling lives in /css/atoms/button.css under .btn-step-continue.
   Here we only re-anchor: the button hangs off the bottom-right edge of
   the bar (overlay), so the bar stays compact even when the CTA is up. */

#step-bar .btn-step-continue,
.preview-step-bar .btn-step-continue {
    position: absolute;
    right: 18px;
    bottom: -15px;
    margin: 0;
    align-self: auto;
    z-index: 1;
}

/* ---- step-complete flash ----
   Border-color rides the keyframes (rather than being set statically on
   .sb-complete) so the green outline reverts to the default dark border
   when the animation ends — the class itself can stay on the element. */

@keyframes sb-flash {
    0%   {
        box-shadow: 0 0 0 0 rgba(26, 122, 101, 0.35);
        border-color: var(--color-success, #1F8F4E);
    }
    50%  {
        box-shadow: 0 0 0 6px rgba(26, 122, 101, 0.15);
        border-color: var(--color-success, #1F8F4E);
    }
    100% { box-shadow: 0 0 0 0 rgba(26, 122, 101, 0); }
}

#step-bar.sb-complete,
.preview-step-bar.sb-complete {
    animation: sb-flash 600ms ease-out;
}

/* ---- responsive ----
   Below 480 px the inline header+progress row eats segment width; stack
   the header above the strip so a long counter doesn't crowd it. */

@media (max-width: 600px) {
    .sb-instruction {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    #step-bar {
        padding: 12px 14px 14px;
    }
    .sb-progress-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .sb-progress {
        width: 100%;
    }
    .sb-instruction {
        font-size: 16px;
    }
}
