/* Form Builder field performance - the list panel (section 7.29), the canvas overlay (7.30) and the
 * properties strip (7.31). Every class is fp-. Loads after the shipped FormEditor stack:
 * threshold-reset, threshold-tokens, threshold-chrome, threshold-feedback, app, threshold-switcher,
 * rules-editor, form-editor-tokens, form-builder-properties, form-editor and the FormEditor scoped
 * bundle. Reads tokens only; no hex.
 */

/* The --cx-perf-* tokens (the shade bands and the overlay's ink) live in form-editor-tokens.css. */

/* Icons drawn with the builder's stroked set (Icon.razor carries the same rule inline). */
.fp-icon {
    display: inline-block;
    vertical-align: -2px;
    flex: 0 0 auto;
}

/* ── Top-bar toggle ────────────────────────────────────────────────────────────────────────
 * .fb-btn.is-ghost in the context bar's action group, after Diff. Pressed while the panel is open. */
.fp-toggle {
    flex: none;
    white-space: nowrap;
}

/* In the expanded palette's header, between the "Insert" title and the collapse chevron: a rule
 * sets it off from the title, and it is an outlined small button (the shipped .fb-btn.is-sm), so it
 * reads as a tool, not as one of the palette's insertable items. Tightened to fit the 240px header. */
.fp-palette-divider {
    flex: none;
    width: 1px;
    height: 18px;
    margin: 0 5px;
    background: var(--cx-border-strong);
}

.fb-btn.is-sm.fp-palette-toggle {
    gap: 3px;
    padding: 3px 5px;
    margin-right: 2px;
}

/* At the top of the folded 44px strip, directly under its expand chevron. */
.fp-rail-entry {
    display: flex;
    justify-content: center;
    padding: var(--cx-space-2) 0;
    border-bottom: 1px solid var(--cx-border);
}

/* Read-only published and superseded views (no palette): a slim entry strip where the palette would
 * be, with the folded palette's surface, width and header geometry, holding only the icon button.
 * The panel opens to its right. */
.fp-entry-rail {
    flex: 0 0 44px;
    width: 44px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--cx-surface-rail);
    border-right: 1px solid var(--cx-border);
}

.fp-entry-rail__head {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--cx-border);
}

/* The icon forms' visible tooltip, on hover and on keyboard focus; it is also their accessible name
 * (aria-labelledby). Opens to the right of the 44px strip. */
.fp-rail-toggle {
    position: relative;
}

.fp-tooltip {
    display: none;
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    z-index: 30;
    padding: 3px 8px;
    border-radius: var(--cx-radius-xs);
    background: var(--cx-ink-strong);
    color: var(--cx-surface);
    font-family: var(--cx-font);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    box-shadow: var(--cx-shadow-popover);
    pointer-events: none;
}

.fp-rail-toggle:hover .fp-tooltip,
.fp-rail-toggle:focus-visible .fp-tooltip {
    display: block;
}

.fb-icon-btn.fp-rail-toggle[aria-pressed="true"],
.fb-btn.fp-toggle[aria-pressed="true"] {
    background: var(--cx-surface-sunken);
    border-color: var(--cx-border);
    color: var(--cx-ink-strong);
}

/* ── The panel (section 7.29) ─────────────────────────────────────────────────────────────
 * Docked between the palette (folded to its 44px rail while this is open) and the canvas host.
 * 300px: between the palette's 240px and the properties panel's 340px. Leftmost when the palette is
 * absent (read-only views). The head stays put; the body scrolls. */
.fp-panel {
    position: relative;
    flex: 0 0 300px;
    width: 300px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: var(--cx-surface);
    border-right: 1px solid var(--cx-border);
    font-family: var(--cx-font);
    color: var(--cx-ink);
    overflow: hidden;
}

.fp-live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.fp-head {
    display: flex;
    align-items: center;
    gap: var(--cx-space-2);
    min-height: 44px;
    padding: var(--cx-space-3) var(--cx-space-4) var(--cx-space-3) var(--cx-space-6);
    border-bottom: 1px solid var(--cx-border);
}

.fp-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--cx-ink-strong);
}

.fp-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: var(--cx-space-7);
}

/* Switch and legend, directly under the head. */
.fp-controls {
    padding: var(--cx-space-5) var(--cx-space-6);
    border-bottom: 1px solid var(--cx-border-faint);
}

.fp-switch-row {
    display: flex;
    align-items: center;
    gap: var(--cx-space-4);
}

.fp-switch-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--cx-ink-strong);
    cursor: pointer;
}

.fp-legend {
    margin-top: var(--cx-space-4);
}

.fp-legend-head {
    margin: 0 0 var(--cx-space-3);
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--cx-ink-muted);
}

.fp-legend-bands {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--cx-space-2);
    font-size: 11.5px;
    line-height: 1.35;
    color: var(--cx-ink-muted);
}

.fp-legend-bands > li {
    display: flex;
    align-items: center;
    gap: var(--cx-space-4);
}

/* A swatch is a card-coloured chip with the band's shade over it, as the canvas draws it. */
.fp-swatch {
    position: relative;
    flex: 0 0 auto;
    width: 18px;
    height: 12px;
    border: 1px solid var(--cx-border-strong);
    border-radius: var(--cx-radius-xs);
    background: var(--cx-surface);
    isolation: isolate;
}

/* Version, order, caveat and notes. */
.fp-meta {
    padding: var(--cx-space-5) var(--cx-space-6) var(--cx-space-4);
    display: grid;
    gap: var(--cx-space-3);
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--cx-ink-muted);
}

.fp-meta > p {
    margin: 0;
}

.fp-asof {
    font-weight: 600;
    color: var(--cx-ink-strong);
    font-variant-numeric: tabular-nums;
}

/* The version's total, the base every count line carries. */
.fp-total {
    color: var(--cx-ink-strong);
    font-variant-numeric: tabular-nums;
}

/* After the last row: the questions with no row. */
.fp-end {
    margin: 0;
    padding: var(--cx-space-4) var(--cx-space-6) 0;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--cx-ink-muted);
}

/* The draft or open version is not the published version's own content. */
.fp-note {
    margin: 0;
    padding: var(--cx-space-3) var(--cx-space-4);
    border-left: 2px solid var(--cx-perf-ink);
    background: var(--cx-surface-sunken);
    border-radius: 0 var(--cx-radius-xs) var(--cx-radius-xs) 0;
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--cx-ink-strong);
}

.fp-noprev {
    color: var(--cx-ink-muted);
}

/* No figures yet / Nothing recorded on the version yet. */
.fp-empty {
    font-size: 13px;
    color: var(--cx-ink-strong);
}

/* The read-failure notice sits in a narrow surface: name it th-surface so the error-feedback
 * canon's own narrow rules (Reference stacked, Copy beneath) apply. The strip does the same. */
.fp-state {
    padding: var(--cx-space-5) var(--cx-space-4);
    container: th-surface / inline-size;
}

/* ── Rows ───────────────────────────────────────────────────────────────────────────────── */
.fp-list {
    list-style: none;
    margin: 0;
    padding: 0 0 var(--cx-space-4);
    border-top: 1px solid var(--cx-border-faint);
}

.fp-row {
    border-bottom: 1px solid var(--cx-border-faint);
}

.fp-row-btn,
.fp-row-static {
    position: relative;
    display: grid;
    gap: 3px;
    width: 100%;
    padding: var(--cx-space-4) var(--cx-space-6) var(--cx-space-4) var(--cx-space-6);
    border: 0;
    background: transparent;
    font: inherit;
    font-size: 12px;
    line-height: 1.4;
    text-align: left;
    color: var(--cx-ink-muted);
}

.fp-row-btn {
    cursor: pointer;
}

.fp-row-btn:hover {
    background: var(--cx-btn-hover-bg);
}

.fp-row-btn:focus-visible {
    outline: 2px solid var(--cx-action);
    outline-offset: -2px;
}

/* The row whose field is the canvas selection, however it was selected: the canvas's own
 * selection treatment (soft marigold ground, copper bar). */
.fp-row-btn[aria-current="true"] {
    background: var(--cx-selection-bg);
}

.fp-row-btn[aria-current="true"]::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--cx-selection-bar);
}

.fp-row-head {
    display: flex;
    align-items: baseline;
    gap: var(--cx-space-3);
}

.fp-rank {
    flex: 0 0 auto;
    min-width: 2.2em;
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--cx-ink-muted);
}

.fp-row-title {
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--cx-ink-strong);
    overflow-wrap: anywhere;
}

.fp-row-section,
.fp-line {
    padding-left: calc(2.2em + var(--cx-space-3));
}

.fp-row-section {
    font-size: 11.5px;
    color: var(--cx-ink-muted);
}

.fp-line {
    display: flex;
    align-items: center;
    gap: var(--cx-space-4);
    font-variant-numeric: tabular-nums;
}

/* The count line: the bar on its own line, left-aligned in every row so bars compare at a glance,
 * then the count and share in words. */
.fp-line-unsub {
    flex-wrap: wrap;
    row-gap: 3px;
}

.fp-line-unsub > .fp-count {
    flex: 1 0 100%;
}

.fp-line strong {
    font-weight: 700;
    color: var(--cx-ink-strong);
}

.fp-compare {
    color: var(--cx-ink-muted);
    font-style: italic;
}

/* A row whose field is not on the open draft: not a button, keeps its rank and figures. */
.fp-tag {
    justify-self: start;
    margin-left: calc(2.2em + var(--cx-space-3));
    padding: 1px 7px;
    border: 1px solid var(--cx-border-strong);
    border-radius: var(--cx-radius-pill);
    background: var(--cx-surface-sunken);
    font-size: 11px;
    font-weight: 600;
    color: var(--cx-ink-strong);
}

/* ── Share bar ──────────────────────────────────────────────────────────────────────────────
 * 70px on a row, 60px on the strip. The fill width is the displayed whole percent (fp-w-N); "under
 * 1%" draws a 2px sliver. Decoration only: the words carry the count and share. */
.fp-bar {
    position: relative;
    flex: 0 0 70px;
    width: 70px;
    height: 6px;
    border-radius: var(--cx-radius-pill);
    background: var(--cx-surface-sunken);
    box-shadow: inset 0 0 0 1px var(--cx-border);
    overflow: hidden;
}

.fp-bar.is-strip {
    flex-basis: 60px;
    width: 60px;
}

.fp-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--cx-perf-ink);
    border-radius: var(--cx-radius-pill);
}

.fp-w-under1 { width: 2px; }

/* ── Loading placeholders ───────────────────────────────────────────────────────────────── */
.fp-skel {
    display: grid;
    gap: var(--cx-space-3);
}

.fp-skel-row {
    display: grid;
    gap: var(--cx-space-3);
    padding: var(--cx-space-5) var(--cx-space-6);
    border-bottom: 1px solid var(--cx-border-faint);
}

.fp-skel-bar {
    display: block;
    height: 9px;
    border-radius: var(--cx-radius-xs);
    background: var(--cx-surface-sunken);
}

.fp-skel-rank { width: 24px; }
.fp-skel-a { width: 72%; }
.fp-skel-b { width: 58%; }
.fp-skel-c { width: 40%; }
.fp-skel-d { width: 84%; }
.fp-skel-e { width: 64%; }

/* ── The canvas overlay (section 7.30) ─────────────────────────────────────────────────────
 * On the shipped .fb-cell-shell: a shade under the card's content (the shell becomes its own
 * stacking context, so the shade paints above the card's background and below its text; the
 * copper selection bar still draws over it), and one line of words at the card's foot. The shade
 * is never the only signal. */
.fb-cell-shell.fp-shade-1,
.fb-cell-shell.fp-shade-2,
.fb-cell-shell.fp-shade-3 {
    isolation: isolate;
}

.fp-shade-1::before,
.fp-shade-2::before,
.fp-shade-3::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    pointer-events: none;
}

/* Under a shade, the card's quiet text (the meta row, the key chip) takes the muted ink instead of
 * the subtle ink, so it keeps 4.5:1 on every band (README, "Contrast"). */
.fb-cell-shell.fp-shade-1 .fb-content-field__meta,
.fb-cell-shell.fp-shade-2 .fb-content-field__meta,
.fb-cell-shell.fp-shade-3 .fb-content-field__meta,
.fb-cell-shell.fp-shade-1 .fb-key-chip,
.fb-cell-shell.fp-shade-2 .fb-key-chip,
.fb-cell-shell.fp-shade-3 .fb-key-chip {
    color: var(--cx-ink-muted);
}

.fp-shade-1::before { background: var(--cx-perf-1); }
.fp-shade-2::before { background: var(--cx-perf-2); }
.fp-shade-3::before { background: var(--cx-perf-3); }

.fp-words {
    display: grid;
    gap: 1px;
    margin: var(--cx-space-4) 0 0;
    padding-top: var(--cx-space-3);
    border-top: 1px dashed var(--cx-border-dashed);
    font-family: var(--cx-font);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--cx-perf-ink);
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/* ── The strip (section 7.31) ─────────────────────────────────────────────────────────────
 * After Historical responses at the foot of the field's properties, in the same soft-separator
 * register (dashed rule, small muted text), kept separate from it. */
.fp-strip {
    padding: var(--cx-space-4) var(--cx-space-6) var(--cx-space-3);
    border-top: 1px dashed var(--cx-border-dashed);
    display: grid;
    gap: var(--cx-space-2);
    font-size: 11.5px;
    line-height: 1.45;
    color: var(--cx-ink-muted);
    container: th-surface / inline-size;
}

.fp-strip-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px var(--cx-space-4);
}

.fp-strip-title {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--cx-ink-strong);
}

.fp-strip-asof {
    font-variant-numeric: tabular-nums;
}

.fp-strip-line {
    margin: 0;
    font-variant-numeric: tabular-nums;
}

.fp-strip-line.fp-line-unsub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px var(--cx-space-4);
    padding-top: 2px;
}

.fp-strip-line strong {
    font-weight: 700;
    color: var(--cx-ink-strong);
}

.fp-strip .fp-note {
    margin: 2px 0;
}

.fp-strip-foot {
    margin: var(--cx-space-2) 0 0;
    padding-top: var(--cx-space-3);
    border-top: 1px solid var(--cx-border-faint);
}

.fp-strip-skel {
    padding: var(--cx-space-2) 0;
}

.fp-strip .th-fb-load.is-compact {
    padding: var(--cx-space-5) 0 var(--cx-space-3);
}

/* "Open field performance": a text button in the strip's register (as .fb-responses-retry). */
.fp-link {
    font: inherit;
    font-weight: 500;
    color: var(--cx-ink-strong);
    background: transparent;
    border: 0;
    padding: 0;
    text-decoration: underline;
    text-decoration-color: var(--cx-border-strong);
    text-underline-offset: 2px;
    cursor: pointer;
}

.fp-link:hover {
    text-decoration-color: currentColor;
}

.fp-link:focus-visible {
    outline: 2px solid var(--cx-action);
    outline-offset: 1px;
    border-radius: var(--cx-radius-xs);
}

/* ── Fill widths: the displayed whole percent ───────────────────────────────────────────── */
.fp-w-1 { width: 1%; } .fp-w-2 { width: 2%; } .fp-w-3 { width: 3%; } .fp-w-4 { width: 4%; } .fp-w-5 { width: 5%; }
.fp-w-6 { width: 6%; } .fp-w-7 { width: 7%; } .fp-w-8 { width: 8%; } .fp-w-9 { width: 9%; } .fp-w-10 { width: 10%; }
.fp-w-11 { width: 11%; } .fp-w-12 { width: 12%; } .fp-w-13 { width: 13%; } .fp-w-14 { width: 14%; } .fp-w-15 { width: 15%; }
.fp-w-16 { width: 16%; } .fp-w-17 { width: 17%; } .fp-w-18 { width: 18%; } .fp-w-19 { width: 19%; } .fp-w-20 { width: 20%; }
.fp-w-21 { width: 21%; } .fp-w-22 { width: 22%; } .fp-w-23 { width: 23%; } .fp-w-24 { width: 24%; } .fp-w-25 { width: 25%; }
.fp-w-26 { width: 26%; } .fp-w-27 { width: 27%; } .fp-w-28 { width: 28%; } .fp-w-29 { width: 29%; } .fp-w-30 { width: 30%; }
.fp-w-31 { width: 31%; } .fp-w-32 { width: 32%; } .fp-w-33 { width: 33%; } .fp-w-34 { width: 34%; } .fp-w-35 { width: 35%; }
.fp-w-36 { width: 36%; } .fp-w-37 { width: 37%; } .fp-w-38 { width: 38%; } .fp-w-39 { width: 39%; } .fp-w-40 { width: 40%; }
.fp-w-41 { width: 41%; } .fp-w-42 { width: 42%; } .fp-w-43 { width: 43%; } .fp-w-44 { width: 44%; } .fp-w-45 { width: 45%; }
.fp-w-46 { width: 46%; } .fp-w-47 { width: 47%; } .fp-w-48 { width: 48%; } .fp-w-49 { width: 49%; } .fp-w-50 { width: 50%; }
.fp-w-51 { width: 51%; } .fp-w-52 { width: 52%; } .fp-w-53 { width: 53%; } .fp-w-54 { width: 54%; } .fp-w-55 { width: 55%; }
.fp-w-56 { width: 56%; } .fp-w-57 { width: 57%; } .fp-w-58 { width: 58%; } .fp-w-59 { width: 59%; } .fp-w-60 { width: 60%; }
.fp-w-61 { width: 61%; } .fp-w-62 { width: 62%; } .fp-w-63 { width: 63%; } .fp-w-64 { width: 64%; } .fp-w-65 { width: 65%; }
.fp-w-66 { width: 66%; } .fp-w-67 { width: 67%; } .fp-w-68 { width: 68%; } .fp-w-69 { width: 69%; } .fp-w-70 { width: 70%; }
.fp-w-71 { width: 71%; } .fp-w-72 { width: 72%; } .fp-w-73 { width: 73%; } .fp-w-74 { width: 74%; } .fp-w-75 { width: 75%; }
.fp-w-76 { width: 76%; } .fp-w-77 { width: 77%; } .fp-w-78 { width: 78%; } .fp-w-79 { width: 79%; } .fp-w-80 { width: 80%; }
.fp-w-81 { width: 81%; } .fp-w-82 { width: 82%; } .fp-w-83 { width: 83%; } .fp-w-84 { width: 84%; } .fp-w-85 { width: 85%; }
.fp-w-86 { width: 86%; } .fp-w-87 { width: 87%; } .fp-w-88 { width: 88%; } .fp-w-89 { width: 89%; } .fp-w-90 { width: 90%; }
.fp-w-91 { width: 91%; } .fp-w-92 { width: 92%; } .fp-w-93 { width: 93%; } .fp-w-94 { width: 94%; } .fp-w-95 { width: 95%; }
.fp-w-96 { width: 96%; } .fp-w-97 { width: 97%; } .fp-w-98 { width: 98%; } .fp-w-99 { width: 99%; } .fp-w-100 { width: 100%; }
