/* Respondent-ranking (ROC) explainer -- public demo page, Listen step.
   Kept out of app.css so the widget can be diffed and reverted on its own.
   Tokens come from app.css (:root). */

.roc-explainer {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-top: 1.5rem;
    padding: 1.35rem;
    scroll-margin-top: 5rem;
}

/* The Listen panel is a two-column grid; the explainer needs the full width below it. */
.demo-panel-grid-listen > .roc-explainer {
    grid-column: 1 / -1;
}

.roc-explainer-head h3 {
    font-size: 1.32rem;
    margin: 0 0 0.5rem;
}

.roc-explainer-head p {
    color: var(--ink-soft);
    margin: 0;
    max-width: 62ch;
}

/* --- delivery stepper: the question dots carry the respondent's own order --- */

.roc-stepper {
    align-items: center;
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    margin: 1.15rem 0 1.25rem;
    padding: 0.5rem 0.9rem;
}

.roc-step-edge {
    color: var(--ink-muted);
    font-size: 0.78rem;
    font-weight: 680;
}

.roc-step-edge.is-current {
    background: var(--blue);
    border-radius: 999px;
    color: #fff;
    padding: 0.15rem 0.6rem;
}

.roc-step-run {
    align-items: center;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    display: flex;
    gap: 0.35rem;
    padding: 0 0.75rem;
}

.roc-step-run small {
    color: var(--ink-muted);
    font-size: 0.72rem;
    margin-left: 0.3rem;
}

.roc-step-dot {
    align-items: center;
    background: var(--cat);
    border-radius: 999px;
    color: var(--cat-ink);
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 780;
    height: 1.45rem;
    justify-content: center;
    transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
    width: 1.45rem;
}

/* --- layout --- */

.roc-grid {
    display: grid;
    gap: 1.15rem;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}

.roc-instructions {
    background: #eef4ff;
    border: 1px solid #cddcfb;
    border-radius: var(--radius);
    color: var(--ink-soft);
    font-size: 0.86rem;
    line-height: 1.5;
    margin-bottom: 0.9rem;
    padding: 0.7rem 0.85rem;
}

.roc-rank-list {
    display: flex;
    flex-direction: column;
}

/* --- ranked category cards --- */

.roc-card {
    align-items: center;
    background: color-mix(in srgb, var(--cat) 16%, #fff);
    border: 1px solid color-mix(in srgb, var(--cat) 42%, #fff);
    border-radius: var(--radius);
    display: grid;
    gap: 0.7rem;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    /* Fixed row height: a two-line category name and any tie state all sit in the
       same box, so toggling a tie never reflows the list. */
    min-height: 3.6rem;
    padding: 0.6rem 0.75rem;
    transition: opacity 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.roc-card:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

.roc-card.is-dragging {
    opacity: 0.45;
}

.roc-grip {
    background-image: radial-gradient(circle, var(--ink-muted) 1.1px, transparent 1.2px);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 4px 4px;
    height: 1.9rem;
    opacity: 0.75;
    width: 1.15rem;
}

.roc-badge {
    align-items: center;
    background: var(--cat);
    border-radius: 999px;
    color: var(--cat-ink);
    display: inline-flex;
    font-size: 0.8rem;
    font-weight: 780;
    height: 1.7rem;
    justify-content: center;
    width: 1.7rem;
}

.roc-card-name {
    align-items: baseline;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-width: 0;
}

.roc-card-name strong {
    font-size: 0.95rem;
}


.roc-card-weight {
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    font-weight: 780;
}

.roc-move {
    display: inline-flex;
    gap: 0.25rem;
}

.roc-move button {
    background: #fff;
    border: 1px solid color-mix(in srgb, var(--cat) 45%, #fff);
    border-radius: 6px;
    color: var(--ink);
    cursor: pointer;
    font-size: 0.8rem;
    height: 1.7rem;
    line-height: 1;
    width: 1.7rem;
}

.roc-move button:disabled {
    color: #b8c2d2;
    cursor: default;
}

/* --- tie slots between adjacent cards (top three only, as in the product) --- */

.roc-tie-slot {
    align-items: center;
    display: flex;
    justify-content: flex-end;
    min-height: 1.85rem;
    padding: 0.2rem 2.6rem 0.2rem 0;
    position: relative;
}

.roc-tie-slot::before {
    border-left: 2px dashed #cbd6e6;
    content: "";
    height: 100%;
    left: 1.55rem;
    position: absolute;
    top: 0;
}

.roc-tie-slot label {
    align-items: center;
    color: var(--ink-muted);
    cursor: pointer;
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 680;
    gap: 0.3rem;
    white-space: nowrap;
}

.roc-tie-slot.is-active label {
    background: #fff;
    border-radius: 999px;
    padding: 0.05rem 0.5rem 0.05rem 0.35rem;
}

.roc-tie-slot.is-active label {
    color: var(--blue-dark);
}

/* --- output side --- */

.roc-output-tabs {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}

.roc-output-tabs button {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 680;
    padding: 0.35rem 0.85rem;
}

.roc-output-tabs button.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

.roc-pane[hidden] {
    display: none;
}

.roc-donut-wrap {
    align-items: center;
    display: grid;
    gap: 1rem;
    grid-template-columns: 170px minmax(0, 1fr);
}

.roc-donut {
    height: 170px;
    width: 170px;
}

.roc-arc {
    transition: opacity 0.12s ease, stroke-width 0.12s ease;
}

.roc-donut-value {
    fill: var(--ink);
    font-size: 1.25rem;
    font-weight: 780;
}

.roc-donut-label {
    fill: var(--ink-muted);
    font-size: 0.62rem;
    font-weight: 680;
}

.roc-donut-caption {
    color: var(--ink-soft);
    font-size: 0.84rem;
    margin: 0;
}

.roc-formula {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin: 1rem 0 0.75rem;
    padding: 0.65rem 0.8rem;
}

.roc-formula b {
    color: var(--blue-dark);
}

.roc-note {
    color: var(--ink-muted);
    font-size: 0.8rem;
    line-height: 1.55;
    margin: 0;
}

/* --- tab B: the ranked answer --- */

.roc-answer-row {
    align-items: center;
    display: grid;
    gap: 0.6rem;
    grid-template-columns: auto minmax(0, 1fr) minmax(70px, 0.8fr) auto;
    padding: 0.45rem 0;
    transition: opacity 0.12s ease;
}

.roc-answer-row + .roc-answer-row {
    border-top: 1px solid var(--line);
}

.roc-answer-rank {
    align-items: center;
    background: var(--cat);
    border-radius: 999px;
    color: var(--cat-ink);
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 780;
    height: 1.45rem;
    justify-content: center;
    width: 1.45rem;
}

.roc-answer-name {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.roc-answer-name strong {
    font-size: 0.88rem;
}

.roc-answer-name em {
    color: var(--ink-muted);
    font-size: 0.74rem;
    font-style: normal;
}

.roc-answer-track {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: block;
    height: 0.7rem;
    overflow: hidden;
}

.roc-answer-track i {
    background: var(--cat);
    display: block;
    height: 100%;
}

.roc-answer-value {
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    font-weight: 780;
}

/* --- shared focus paint, both directions --- */

.roc-explainer.is-focusing .roc-card,
.roc-explainer.is-focusing .roc-answer-row,
.roc-explainer.is-focusing .roc-step-dot {
    opacity: 0.42;
}

.roc-explainer.is-focusing .roc-arc {
    opacity: 0.3;
}

.roc-explainer .roc-card.is-focused,
.roc-explainer .roc-answer-row.is-focused,
.roc-explainer .roc-step-dot.is-focused {
    opacity: 1;
}

.roc-explainer .roc-card.is-focused {
    box-shadow: 0 6px 18px rgba(13, 35, 78, 0.12);
    transform: translateX(2px);
}

.roc-explainer .roc-step-dot.is-focused {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat) 35%, #fff);
}

.roc-explainer .roc-arc.is-focused {
    opacity: 1;
    stroke-width: 22;
}

@media (max-width: 980px) {
    .roc-grid {
        grid-template-columns: 1fr;
    }

    .roc-donut-wrap {
        grid-template-columns: 140px minmax(0, 1fr);
    }

    .roc-donut {
        height: 140px;
        width: 140px;
    }
}

@media (max-width: 640px) {
    .roc-card {
        grid-template-columns: auto auto minmax(0, 1fr);
        row-gap: 0.4rem;
    }

    .roc-card-weight {
        grid-column: 3;
        justify-self: end;
    }

    .roc-move {
        grid-column: 2 / -1;
        justify-self: end;
    }

    .roc-donut-wrap {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }

    .roc-answer-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .roc-answer-track {
        grid-column: 2 / -1;
    }
}

/* --- demo Priorities pane: caption for the alignment-adjusted tick --- */

.demo-priority-legend {
    border-top: 1px solid var(--line);
    color: var(--ink-muted);
    font-size: 0.78rem;
    line-height: 1.55;
    margin: 0.9rem 0 0;
    padding-top: 0.75rem;
}

/* ============================================================
   Drivers and Act demo panes -- rebuilt to match the shipped
   modules (two-axis driver crossing, portfolio coverage).
   ============================================================ */

.demo-pattern-callout {
    background: #fff7f5;
    border: 1px solid #f3d3cb;
    border-left: 4px solid var(--coral);
    border-radius: var(--radius);
    margin-bottom: 1.15rem;
    padding: 0.9rem 1.05rem;
}

.demo-pattern-kicker {
    color: var(--coral);
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 780;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
}

.demo-pattern-callout h3 {
    font-size: 1.02rem;
    margin: 0 0 0.4rem;
}

.demo-pattern-callout p {
    color: var(--ink-soft);
    font-size: 0.86rem;
    margin: 0 0 0.5rem;
}

.demo-pattern-callout small {
    color: var(--ink-muted);
    font-size: 0.74rem;
    font-weight: 680;
}

.demo-driver-layout,
.demo-act-layout {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.demo-driver-plot {
    margin-top: 0.5rem;
}

.demo-plot-note {
    color: var(--ink-muted);
    font-size: 0.78rem;
    line-height: 1.5;
    margin: 0.75rem 0 0;
}

/* --- evidence order list --- */

.demo-evidence-order {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    padding: 1.05rem;
}

.demo-evidence-order ol {
    display: flex;
    flex-direction: column;
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0;
}

.demo-evidence-order li {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: auto minmax(0, 1fr);
    padding: 0.6rem 0;
}

.demo-evidence-order li + li {
    border-top: 1px solid var(--line);
}

.demo-evidence-order li b {
    align-items: center;
    border-radius: 999px;
    color: #fff;
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 780;
    height: 1.5rem;
    justify-content: center;
    width: 1.5rem;
}

.demo-evidence-order li strong {
    display: block;
    font-size: 0.85rem;
    line-height: 1.45;
    margin-bottom: 0.35rem;
}

.demo-evidence-order > small {
    border-top: 1px solid var(--line);
    color: var(--ink-muted);
    font-size: 0.76rem;
    font-weight: 680;
    margin-top: 0.6rem;
    padding-top: 0.7rem;
}

.demo-role-chip {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-soft);
    display: inline-flex;
    font-size: 0.7rem;
    font-style: normal;
    font-weight: 680;
    margin-right: 0.35rem;
    padding: 0.1rem 0.5rem;
}

.demo-role-chip.is-priority {
    background: #fdeeeb;
    border-color: #f2cec5;
    color: #b23c26;
}

.demo-role-chip.is-critical {
    background: #fdeeeb;
    border-color: #f2cec5;
    color: #b23c26;
}

.demo-role-chip.is-validate {
    background: #eef4ff;
    border-color: #cddcfb;
    color: var(--blue-dark);
}

.demo-role-chip.is-monitor {
    background: var(--paper-soft);
    border-color: var(--line);
    color: var(--ink-muted);
}

.demo-role-chip.is-selected-now {
    background: #e8f6ee;
    border-color: #bfe3cd;
    color: #17734a;
}

.demo-role-chip.is-next-best {
    background: #fdf6e0;
    border-color: #eddba4;
    color: #8a6a10;
}

/* --- Act: coverage and initiatives --- */

.demo-coverage-card,
.demo-initiative-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.05rem;
}

.demo-portfolio-tally {
    color: var(--ink-muted);
    font-size: 0.76rem;
    font-weight: 680;
    white-space: nowrap;
}

.demo-coverage-row {
    align-items: center;
    display: grid;
    gap: 0.65rem;
    grid-template-columns: auto minmax(0, 1fr) minmax(90px, 0.85fr) auto;
    padding: 0.6rem 0;
}

.demo-coverage-row + .demo-coverage-row {
    border-top: 1px solid var(--line);
}

.demo-coverage-tag {
    align-items: center;
    background: var(--blue);
    border-radius: 6px;
    color: #fff;
    display: inline-flex;
    font-size: 0.72rem;
    font-weight: 780;
    height: 1.6rem;
    justify-content: center;
    width: 1.9rem;
}

.demo-coverage-row.is-gap .demo-coverage-tag {
    background: #b8c2d2;
}

.demo-coverage-row strong {
    display: block;
    font-size: 0.86rem;
}

.demo-coverage-row em {
    color: var(--ink-muted);
    font-size: 0.74rem;
    font-style: normal;
}

.demo-coverage-track {
    background: var(--paper-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    display: flex;
    height: 0.7rem;
    overflow: hidden;
}

.demo-coverage-track i {
    background: var(--blue);
    display: block;
    height: 100%;
}

.demo-coverage-track u {
    background: #bcd0f7;
    display: block;
    height: 100%;
}

.demo-coverage-row > b {
    font-size: 0.84rem;
    font-variant-numeric: tabular-nums;
    font-weight: 780;
    white-space: nowrap;
}

.demo-coverage-row.is-gap > b {
    color: var(--ink-muted);
}

.demo-initiative-row {
    display: grid;
    gap: 0.65rem;
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 0.65rem 0.5rem;
}

.demo-initiative-row + .demo-initiative-row {
    border-top: 1px solid var(--line);
}

.demo-initiative-row.is-selected {
    background: #f5f9f7;
    border-left: 3px solid var(--green);
    border-radius: 6px;
}

.demo-initiative-row.is-next {
    background: #fffbf1;
    border-left: 3px solid var(--amber);
    border-radius: 6px;
}

.demo-initiative-index {
    color: var(--ink-muted);
    font-size: 0.76rem;
    font-variant-numeric: tabular-nums;
    font-weight: 780;
}

.demo-initiative-row strong {
    display: block;
    font-size: 0.86rem;
    margin-bottom: 0.35rem;
}

.demo-initiative-meta {
    display: inline-flex;
    flex-wrap: wrap;
    margin-bottom: 0.3rem;
}

.demo-initiative-detail {
    color: var(--ink-muted);
    display: block;
    font-size: 0.74rem;
    font-style: normal;
}

.demo-initiative-value {
    color: var(--ink-muted);
    display: flex;
    flex-direction: column;
    font-size: 0.7rem;
    font-weight: 680;
    text-align: right;
    white-space: nowrap;
}

.demo-initiative-value b {
    color: var(--ink);
    font-size: 0.86rem;
    font-variant-numeric: tabular-nums;
}

.demo-initiative-note {
    border-top: 1px solid var(--line);
    color: var(--ink-muted);
    font-size: 0.78rem;
    line-height: 1.55;
    margin: 0.7rem 0 0;
    padding-top: 0.7rem;
}

@media (max-width: 980px) {
    .demo-driver-layout,
    .demo-act-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .demo-coverage-row {
        grid-template-columns: auto minmax(0, 1fr) auto;
    }

    .demo-coverage-track {
        grid-column: 2 / -1;
    }

    .demo-initiative-row {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .demo-initiative-value {
        flex-direction: row;
        gap: 0.35rem;
        grid-column: 2;
        text-align: left;
    }
}

/* ============================================================
   Drag to reorder -- drop-slot ghosts ported from the app's
   survey-editor-shared.css (.question-category-drop-slot /
   .question-category-drop-ghost) so the landing zone reads the
   same way here as it does inside Ranx.
   ============================================================ */

.roc-explainer {
    --primary-rgb: 37, 99, 235;
}

.roc-rank-list-wrap {
    position: relative;
}

.roc-card {
    user-select: none;
}

/* Only the grip swallows touch gestures, so the page still scrolls over the cards. */
.roc-grip {
    cursor: grab;
    touch-action: none;
}

.roc-explainer.is-dragging .roc-grip {
    cursor: grabbing;
}

.roc-card.is-dragging {
    opacity: 0.35;
}

/* While a drag is in flight the tie rail steps aside and the drop ghosts take the gaps. */
.roc-explainer.is-dragging .roc-tie-slot {
    display: none;
}

.roc-drop-slot {
    display: none;
}

.roc-explainer.is-dragging .roc-drop-slot {
    display: block;
}

.roc-drop-ghost {
    align-items: center;
    background: rgba(var(--primary-rgb), 0.08);
    border: 1px dashed rgba(var(--primary-rgb), 0.32);
    border-radius: var(--radius);
    display: flex;
    justify-content: center;
    margin: 0.15rem 0;
    min-height: 2.35rem;
    opacity: 0.9;
    padding: 0.45rem 1rem;
    transform: scaleY(0.97);
    transition: min-height 0.18s ease, padding 0.18s ease, border-color 0.18s ease,
        background-color 0.18s ease, opacity 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.roc-drop-ghost span {
    color: rgba(var(--primary-rgb), 0.88);
    font-size: 0.84rem;
    font-weight: 600;
}

.roc-drop-slot.is-active .roc-drop-ghost {
    background: rgba(var(--primary-rgb), 0.14);
    border-color: rgba(var(--primary-rgb), 0.66);
    box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.08);
    min-height: 4.1rem;
    opacity: 1;
    padding: 0.85rem 1rem;
    transform: scaleY(1);
}

.roc-drop-slot.is-active .roc-drop-ghost span {
    color: var(--blue-dark);
    font-size: 0.92rem;
    font-weight: 700;
}

/* The gap the card already occupies: shown as a target, but plainly inert. */
.roc-drop-slot.is-noop .roc-drop-ghost {
    background: var(--paper-soft);
    border-color: var(--line);
    border-style: dashed;
    opacity: 0.75;
}

.roc-drop-slot.is-noop .roc-drop-ghost span {
    color: var(--ink-muted);
}

/* Floating copy of the card that follows the pointer. */
.roc-drag-preview {
    box-shadow: 0 1rem 2.1rem rgba(15, 23, 42, 0.22);
    opacity: 0.85;
    pointer-events: none;
    position: fixed;
    z-index: 9999;
}
