/* ============================================================
   MATCHING COCKPIT UX — ranked-results-first layout + candidate
   affordances (mission matching-cockpit-ux-01KXJKXM, WP02)

   Loaded AFTER matching-cockpit.css. This file re-homes the
   cockpit engine's stage WITHOUT touching the engine:
     • ranked results (the .mc-stage) become the PRIMARY column;
     • the parameters panel (.mc-params) docks RIGHT;
     • ≤1024px the panel overlays from the right (collapsible via
       the engine's own Tune / close buttons);
     • per-row candidate affordances (View CV / Smart Profile),
       evidence pips, contribution-bar slot and the chart-point
       flyout injected by matching-manager.js are styled here.

   Motion (FLIP re-ranking, drag-time bars) is WP03 territory and
   lives in matching-cockpit-motion.css — NOT here.
   ============================================================ */

/* ------------------------------------------------------------
   1. RANKED-FIRST SHELL — stage left (primary), params right
   ------------------------------------------------------------ */
.mc-cockpit.mc-panel-open {
    /* engine default is "300px 1fr" (params left) — flip it */
    grid-template-columns: minmax(0, 1fr) 300px;
}

.mc-cockpit .mc-stage {
    grid-column: 1;
    grid-row: 1;
}

.mc-cockpit.mc-panel-open .mc-params {
    grid-column: 2;
    grid-row: 1;
    border-right: none;
    border-left: 1px solid var(--border);
    /* the engine's slide-in animates from the left — re-home it */
    animation: mcux-slide-in-right 0.3s ease-out both;
}

@keyframes mcux-slide-in-right {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* The engine's collapse glyphs (◀ / ▶) assume a LEFT dock; mirror them
   so they keep pointing the right way on the right dock. */
.mc-cockpit .mc-params-collapse {
    transform: scaleX(-1);
}

/* ------------------------------------------------------------
   ≤1024 — params panel becomes a right-hand overlay drawer.
   Results stay full-width (primary); Tune / ✕ open and close it.
   Overrides the engine's 900px stacking rules (higher specificity
   + later in the cascade).
   ------------------------------------------------------------ */
@media (max-width: 1024px) {
    .mc-cockpit {
        position: relative;
    }
    .mc-cockpit.mc-panel-open {
        grid-template-columns: minmax(0, 1fr);
    }
    .mc-cockpit.mc-panel-open .mc-params {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        grid-column: auto;
        grid-row: auto;
        width: min(320px, 85vw);
        max-height: none;
        z-index: 40;
        border-left: 1px solid var(--border);
        border-bottom: none;
        box-shadow: -14px 0 34px rgba(15, 23, 42, 0.22);
    }
}

/* ------------------------------------------------------------
   2. ROW ANATOMY — injected columns (matching-manager.js)
      [select] | rank | name+band | score(+contrib slot) | … |
      evidence pips | affordances
   ------------------------------------------------------------ */

/* Header cells injected to keep the thead aligned with the
   manager-injected body cells. */
.mc-table th.mm-th-select   { width: 32px; }
.mc-table th.mm-th-evidence { white-space: nowrap; }
.mc-table th.mm-th-actions  { width: 168px; }

/* ------------------------------------------------------------
   Fit the full row anatomy INSIDE the primary column — the View
   CV / Smart Profile affordances must never hide behind
   horizontal scroll (the whole point of FR-002). Compact cell
   padding + ellipsized profile line; below 1280px the
   Availability/Rate sub-columns yield (out-of-scope dimensions
   for these tenders — full detail stays in the flyout/modal),
   below 900px all five sub-score columns yield to the
   contribution micro-bars.
   Column order after manager injection (1-based):
   1 select · 2 rank · 3 candidate · 4 overall · 5 skills ·
   6 exp · 7 lang · 8 avail · 9 rate · 10 must-haves ·
   11 evidence · 12 actions
   ------------------------------------------------------------ */
.mc-table th,
.mc-table td {
    padding-left: 6px;
    padding-right: 6px;
}
.mc-table .mc-candidate-name {
    white-space: nowrap;
}
.mc-table .mc-candidate-profile {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Visual compression of the engine's score cell so the affordances fit
   (presentation-only override; the engine markup is untouched). */
.mc-table .mc-score-bar { width: 44px; }
.mc-table th.mm-th-actions { width: 150px; }
@media (max-width: 1280px) {
    .mc-table th:nth-child(8), .mc-table td:nth-child(8),
    .mc-table th:nth-child(9), .mc-table td:nth-child(9) {
        display: none;
    }
    .mc-table .mc-candidate-profile { max-width: 180px; }
}
@media (max-width: 900px) {
    .mc-table th:nth-child(5), .mc-table td:nth-child(5),
    .mc-table th:nth-child(6), .mc-table td:nth-child(6),
    .mc-table th:nth-child(7), .mc-table td:nth-child(7) {
        display: none;
    }
    .mc-table .mc-candidate-profile { max-width: 140px; }
    /* the contribution micro-bars carry the per-dimension story here */
    .mc-table .mc-score-bar { display: none; }
}

/* Contribution-bar slot — sits under the Overall score. WP02 renders a
   static snapshot from the stored breakdown; WP03 re-renders its content
   live during slider drags (same container, same classes). */
.mm-contrib-slot {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    margin-top: 4px;
    width: 54px;
    height: 12px;
    flex-shrink: 0;
}
.mm-contrib-seg {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    border-radius: 2px;
    background: var(--border); /* fallback */
    background: color-mix(in srgb, var(--border) 72%, transparent);
    overflow: hidden;
    position: relative;
}
.mm-contrib-seg > i {
    display: block;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 2px;
    background: var(--primary-color);
    opacity: 0.75;
}

/* Evidence pips (A-5 continuity) — mean 0–3 stored-evidence quality. */
.mm-evi-td { white-space: nowrap; }
.mm-evi-pips {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    cursor: help;
}
.mm-evi-pip {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--text-muted);
}
.mm-evi-pip--on {
    background: var(--success-color);
    border-color: var(--success-color);
}
.mm-evi-none {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* Affordance buttons — View CV / Smart Profile on every row. */
.mm-actions-td {
    white-space: nowrap;
    padding-right: 10px !important;
}
.mm-aff-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    margin-left: 3px;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.mm-aff-btn svg {
    width: 12px;
    height: 12px;
    flex: none;
}
.mm-aff-btn:hover:not(:disabled) {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: var(--surface); /* fallback */
    background: color-mix(in srgb, var(--primary-color) 8%, var(--surface));
}
.mm-aff-btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
}
/* FR-006 — honest degradation: visible but disabled, tooltip explains. */
.mm-aff-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ------------------------------------------------------------
   3. LINKED SELECTION — chart point ↔ result row (T005)
   ------------------------------------------------------------ */
.mc-table-row.mm-linked > td {
    background: rgba(59, 130, 246, 0.10); /* fallback */
    background: color-mix(in srgb, var(--primary-color) 10%, transparent);
}
.mc-table-row.mm-linked td:first-child {
    box-shadow: inset 3px 0 0 var(--primary-color);
}
.mc-dot.mm-linked {
    stroke: var(--primary-color);
    stroke-width: 3px;
}

/* ------------------------------------------------------------
   4. CHART-POINT FLYOUT — manager-owned click flyout carrying the
      candidate affordances (FR-002 "every chart point").
   ------------------------------------------------------------ */
.mm-dot-flyout {
    position: fixed;
    z-index: 9500;
    min-width: 210px;
    max-width: 280px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    font-size: 0.82rem;
    color: var(--text-primary);
}
.mm-dot-flyout-name {
    font-weight: 700;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.mm-dot-flyout-profile {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-bottom: 8px;
}
.mm-dot-flyout-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.mm-dot-flyout-actions .mm-aff-btn {
    margin-left: 0;
}
.mm-dot-flyout-close {
    position: absolute;
    top: 6px;
    right: 8px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px;
}
.mm-dot-flyout-close:hover { color: var(--text-primary); }

/* Compare toggle inside the flyout reuses the affordance button look but
   flags the active (selected-for-compare) state. */
.mm-aff-btn.mm-aff-compare--on {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* ------------------------------------------------------------
   5. THEME GUARDS — tokens above are theme-aware already; the two
      rules below cover the places where light/dark diverge.
   ------------------------------------------------------------ */
[data-theme="dark"] .mm-dot-flyout {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
[data-theme="dark"] .mm-contrib-seg {
    background: rgba(148, 163, 184, 0.22);
}
