/* ── Project Relation ─────────────────────────────────────────────────
   The page is a sequence of screens, so its own chrome is just the rail
   and the current step's frame; the info bar, round chips and buttons are
   borrowed from the other Analysis pages (.pe-infobar, .sp-rounds,
   .analysis-continue-btn) so all three read as one product. */

.pr-page {
    padding-bottom: 48px;
}

.pr-rail-slot {
    padding: 24px 32px 0;
}

.pr-rail {
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex-wrap: wrap;
}

.pr-rail-empty {
    font-size: 13px;
    color: var(--color-text-muted);
}

.pr-rail-step {
    flex: 1 1 160px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background-color: var(--color-bg-surface);
    /* Three states, not two: a step behind the cursor and one ahead of it
       are both "not current" but mean opposite things. */
    transition: border-color 0.15s, background-color 0.15s;
}

.pr-rail-step--done {
    border-color: var(--color-success);
}

.pr-rail-step--current {
    border-color: var(--color-accent);
    box-shadow: 0 2px 10px rgba(var(--color-shadow-rgb), 0.1);
}

.pr-rail-step--ahead {
    opacity: 0.55;
}

.pr-rail-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 50%;
    font-size: 11.5px;
    font-weight: 700;
    color: #fff;
    background-color: var(--color-text-muted);
}

.pr-rail-step--done .pr-rail-number {
    background-color: var(--color-success);
}

.pr-rail-step--current .pr-rail-number {
    background-color: var(--color-accent);
}

.pr-rail-labels {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pr-rail-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-main);
}

.pr-rail-file {
    font-size: 11px;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pr-step-slot {
    padding: 24px 32px 0;
}

.pr-step-body {
    padding: 24px 28px;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    background-color: var(--color-bg-surface);
    box-shadow: 0 2px 10px rgba(var(--color-shadow-rgb), 0.06);
}

.pr-step-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 6px;
}

.pr-step-hint {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0 0 20px;
}

.pr-step-file {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.pr-step-file-name {
    font-size: 13.5px;
    font-weight: 600;
}

.pr-step-file-meta {
    font-size: 12px;
    color: var(--color-text-muted);
}

.pr-column-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pr-column {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12.5px;
}

.pr-column-name {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The parser's guess at what kind of variable a column holds — see
   components/RelationList.py's _describe. Colour-coded because the Select
   step will offer a different control per kind, so the difference has to
   be visible before it is acted on. */
.pr-column-kind {
    flex-shrink: 0;
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background-color: var(--color-text-muted);
}

.pr-column-kind--numeric {
    background-color: var(--color-accent);
}

.pr-column-kind--category {
    background-color: var(--color-secondary);
}

.pr-column-kind--empty {
    background-color: var(--color-error);
}

.pr-column-meta {
    flex-shrink: 0;
    font-size: 11.5px;
    color: var(--color-text-muted);
}

.pr-step-nav {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 24px 32px 0;
}

.pr-step-nav .analysis-continue-btn {
    margin-top: 0;
    padding: 10px 32px;
}

/* ── Select step: the variables built from one file's columns ────────── */
.pr-variable-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.pr-variable {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pr-variable-name {
    flex: 1 1 40%;
    min-width: 0;
    padding: 8px 10px;
    font-family: var(--font-family);
    font-size: 13px;
    color: var(--color-text-main);
    background-color: var(--color-bg-page);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.pr-variable-name:focus {
    outline: none;
    border-color: var(--color-accent-light);
}

.pr-variable-column {
    flex: 1 1 60%;
    min-width: 0;
}

.pr-variable-remove {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
    color: var(--color-text-muted);
    background: none;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.pr-variable-remove:hover {
    color: var(--color-error);
    border-color: var(--color-error);
}

.pr-variable-empty {
    font-size: 12.5px;
    color: var(--color-text-muted);
    padding: 6px 0;
}

.pr-variable-add {
    padding: 8px 16px;
    font-family: var(--font-family);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent);
    background: none;
    border: 1px dashed var(--color-accent);
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.pr-variable-add:hover {
    background-color: rgba(var(--color-shadow-rgb), 0.06);
}

/* ── Validation step: the file checked against the chosen rounds ─────── */
.pr-verify-summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-success);
    margin: 0 0 16px;
}

.pr-verify-summary--warn {
    color: var(--color-secondary);
}

.pr-verify-summary--ok {
    color: var(--color-success);
}

.pr-verify-sections {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pr-verify-section {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 14px 16px;
}

.pr-verify-title {
    font-size: 13.5px;
    font-weight: 700;
}

/* The explanation belongs to the section, never to a row — it is about the
   situation, not about the person named in it. */
.pr-verify-explanation {
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-text-muted);
    margin: 4px 0 10px;
}

.pr-verify-table {
    display: flex;
    flex-direction: column;
    max-height: 220px;
    overflow-y: auto;
}

.pr-verify-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 4px 0;
    font-size: 12.5px;
    border-top: 1px solid var(--color-border);
}

/* Sticky so the columns stay named while a long list scrolls. */
.pr-verify-row--head {
    position: sticky;
    top: 0;
    z-index: 1;
    border-top: none;
    font-weight: 700;
    color: var(--color-text-muted);
    background-color: var(--color-bg-surface);
}

.pr-verify-cell {
    flex: 0 0 auto;
    text-align: right;
    color: var(--color-text-muted);
}

/* The name takes the slack; everything after it sizes to its content. */
.pr-verify-cell--name {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    color: var(--color-text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pr-verify-row--head .pr-verify-cell:first-child {
    flex: 1 1 auto;
    text-align: left;
}

.pr-column-list--footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

/* ── Analysis step ───────────────────────────────────────────────────── */
.pr-infobar-interface--hidden {
    display: none;
}

.pr-interface-select {
    min-width: 180px;
}

.pr-axis-controls {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.pr-axis-field {
    flex: 1 1 240px;
    min-width: 0;
}

.pr-axis-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.pr-analysis-plot {
    height: 520px;
}

/* The matrix's own control row: which measures it is a matrix of. Hidden
   with the matrix, the way .pr-axis-controls is hidden with the scatter. */
.pr-matrix-controls {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* Takes the room, so the chips of a dozen picked measures wrap inside the
   dropdown rather than pushing the buttons off the row. */
.pr-matrix-field {
    flex: 1 1 420px;
    min-width: 0;
}

.pr-matrix-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Deliberately the same look as Grade Calculation's sidebar pair
   (.gc-sidebar-select-btn), since it is the same control doing the same
   job — not shared outright because that class carries `flex: 1` for the
   sidebar's full-width column. */
.pr-matrix-btn {
    padding: 6px 12px;
    font-family: var(--font-family);
    font-size: 11.5px;
    font-weight: 600;
    color: var(--color-text-muted);
    background-color: var(--color-bg-page);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.pr-matrix-btn:hover {
    color: var(--color-accent);
    border-color: var(--color-accent-light);
}

/* Two visualisations, both mounted, one shown — see switch_pr_interface.
   The wrapper hides rather than the graph, so the matrix's caption goes
   with it. */
.pr-analysis-view {
    min-width: 0;
}

/* Taller than the scatter on purpose: with two rounds and a couple of
   outside variables the matrix is sixteen measures square, and its labels
   need the room the cells don't. */
.pr-analysis-plot--matrix {
    height: 660px;
}

.pr-analysis-note {
    margin-top: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--color-text-muted);
}

/* A screen that is mounted but not current. Every screen stays in the DOM
   so no callback ever writes into a component that has gone — see
   step_bodies in pages/analysis_project_relation.py. */
.pr-hidden {
    display: none !important;
}
