/* ============================================
   Simulation Theater
   Overlay that covers the lineup pool while a simulation runs. The pool is
   still mounted underneath (scroll position and grid state survive) — this
   just blurs it out and takes over the panel.

   Layout mirrors .generation-progress: centred column, one accent colour,
   the panel header (and its Run Sims / cancel button) stays reachable.
   ============================================ */

.panel-content.sim-theater-host {
    position: relative;
}

.sim-theater-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    /* Not align-items: center. In a scrolling flex box, centering a card
       taller than the box pushes its top above the scroll origin, where it
       cannot be scrolled to: on a phone the headline and the bar were cut
       off. The card's margin: auto centers it when it fits and lets it
       start at the top and scroll when it does not. */
    align-items: flex-start;
    justify-content: center;
    padding: 1.25rem;
    background: color-mix(in srgb, var(--liq-bg-primary) 88%, transparent);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    overflow-y: auto;
}

/* color-mix fallback for older engines */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
    .sim-theater-overlay {
        background: var(--liq-bg-primary);
        opacity: 0.98;
    }
}

/* Backdrop blur is the most expensive effect a phone GPU can be asked
   for, and it recomposites on every counter repaint - measured as a
   real sim slowdown on mobile. A more opaque ground replaces it. */
@media (max-width: 1023.98px), (pointer: coarse) {
    .sim-theater-overlay {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: color-mix(in srgb, var(--liq-bg-primary) 96%, transparent);
    }
}

.sim-theater {
    width: 100%;
    max-width: 420px;
    margin: auto 0;
    text-align: center;
}

/* ---------- hero ---------- */

.sim-theater-hero {
    margin-bottom: 1.1rem;
}

.sim-theater-title {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--liq-text-primary);
}

.sim-theater-scale {
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--liq-text-secondary);
}

/* ---------- progress bar ---------- */

.sim-theater-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--liq-bg-tertiary);
    overflow: hidden;
}

.sim-theater-bar-fill {
    height: 100%;
    width: 0;
    border-radius: 4px;
    background: var(--liq-accent-green);
    transition: width 0.4s ease-out;
}

/* Indeterminate: stages with no measurable progress (queue, finalize,
   assign) sweep instead of sitting at a misleading percentage. */
.sim-theater-bar-fill.is-indeterminate {
    width: 35%;
    transition: none;
    animation: sim-theater-sweep 1.4s ease-in-out infinite;
}

@keyframes sim-theater-sweep {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(320%); }
}

.sim-theater-meta {
    margin-top: 0.45rem;
    min-height: 1.1em;
    font-size: 0.75rem;
    color: var(--liq-text-secondary);
    font-variant-numeric: tabular-nums;
}

/* ---------- stage rail ---------- */

.sim-theater-stages {
    list-style: none;
    margin: 1.25rem 0 0;
    padding: 0;
    text-align: left;
}

.sim-theater-stage {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.3rem 0;
    font-size: 0.82rem;
    color: var(--liq-text-secondary);
}

.sim-theater-stage-icon {
    flex: 0 0 1.15rem;
    text-align: center;
    line-height: 1.4;
}

.sim-theater-stage-body {
    flex: 1 1 auto;
    min-width: 0;
}

.sim-theater-stage-detail {
    font-size: 0.72rem;
    color: var(--liq-text-secondary);
    opacity: 0.85;
}

/* pending */
.sim-theater-stage.is-pending {
    opacity: 0.45;
}

/* done */
.sim-theater-stage.is-done .sim-theater-stage-icon {
    color: var(--liq-accent-green);
}

/* active */
.sim-theater-stage.is-active {
    color: var(--liq-text-primary);
    font-weight: 600;
}

.sim-theater-stage.is-active .sim-theater-stage-icon {
    color: var(--liq-accent-green);
    animation: sim-theater-pulse 1.5s ease-in-out infinite;
}

@keyframes sim-theater-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* ---------- note (the honest warning for the blocking greedy) ---------- */

.sim-theater-note {
    margin-top: 0.9rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--liq-border-color);
    border-radius: 6px;
    background: var(--liq-bg-secondary);
    font-size: 0.73rem;
    color: var(--liq-text-secondary);
    text-align: left;
}

.sim-theater-note:empty {
    display: none;
}

/* ---------- cancel (in the overlay, where the user is looking) ---------- */

.sim-theater-cancel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    margin: 0.75rem 0 0.25rem;   /* right under the bar: seen without scrolling */
}

.sim-theater-cancel-btn {
    min-width: 7.5rem;
    border: 1px solid var(--liq-border-color);
    background: var(--liq-bg-secondary);
    color: var(--liq-text-primary);
    font-weight: 600;
}

.sim-theater-cancel-btn:hover:not(:disabled) {
    border-color: #e8776c;
    color: #e8776c;
}

.sim-theater-cancel-btn:disabled {
    opacity: 0.7;
}

.sim-theater-cancel-note {
    max-width: 22rem;
    font-size: 0.72rem;
    color: var(--liq-text-muted);
    text-align: center;
}
