/* ============= Nightly / Weekly Tests — failure deep-dive modal ============
 *
 * Two pieces:
 *   1. `.nt-fx-count` — the small clickable Fail/Error numbers in the run
 *      table. Visually almost identical to the plain numbers they replace;
 *      the only difference is an underline + hover state, so a card with no
 *      failures looks completely unchanged.
 *   2. `.nt-fx-modal-*` — the popup itself, styled after the pattern the
 *      Multi-Arch Release tab already uses for its "Failure context" modal:
 *      a header meta grid, a violet "AI Investigation" panel, then a list of
 *      per-test detail cards. Reuses the HUD's existing CSS variables
 *      (--card-border, --text-secondary, --status-fail, ...) rather than
 *      introducing a palette.
 */

/* ── Clickable counts in the run table ──────────────────────────────────── */

.nt-fx-count {
    font: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--status-fail, #ef4444);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}
.nt-fx-count:hover { color: #fca5a5; text-decoration-style: solid; }
.nt-fx-count:focus-visible {
    outline: 2px solid var(--primary-light, #818cf8);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Overlay + panel ─────────────────────────────────────────────────────── */

.nt-fx-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(6, 8, 13, 0.72);
    align-items: flex-start;
    justify-content: center;
    padding: 5vh 16px;
    overflow-y: auto;
}
.nt-fx-modal-overlay.is-open { display: flex; }
body.nt-fx-scroll-lock { overflow: hidden; }

.nt-fx-modal {
    width: 100%;
    max-width: 780px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    background: var(--card-bg, #12151d);
    border: 1px solid var(--card-border, rgba(148, 163, 184, 0.18));
    border-radius: 12px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    animation: nt-fx-modal-in 0.16s ease-out;
}
@keyframes nt-fx-modal-in {
    from { opacity: 0; transform: translateY(6px) scale(0.99); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .nt-fx-modal { animation: none; }
}

.nt-fx-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--card-border, rgba(148, 163, 184, 0.16));
    flex-shrink: 0;
}
.nt-fx-modal-title { margin: 0; font-size: 1.02rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.nt-fx-modal-subtitle { margin-top: 3px; font-size: 0.78rem; color: var(--text-secondary, #94a3b8); }
.nt-fx-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid var(--card-border, rgba(148, 163, 184, 0.16));
    border-radius: 7px;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    flex-shrink: 0;
}
.nt-fx-modal-close:hover { background: rgba(148, 163, 184, 0.16); color: var(--text-primary, #e5e7eb); }
.nt-fx-modal-close:focus-visible { outline: 2px solid var(--primary-light, #818cf8); outline-offset: 2px; }
.nt-fx-modal-close i { width: 15px; height: 15px; }

.nt-fx-modal-body {
    padding: 16px 18px 20px;
    overflow-y: auto;
}
.nt-fx-modal-loading,
.nt-fx-modal-note {
    padding: 18px 4px;
    font-size: 0.85rem;
    color: var(--text-secondary, #94a3b8);
}
.nt-fx-modal-error {
    padding: 14px;
    font-size: 0.84rem;
    color: var(--status-fail, #ef4444);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
}
.nt-fx-retry {
    margin-left: 10px;
    padding: 4px 12px;
    font: inherit;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--primary-light, #818cf8);
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid var(--card-border, rgba(148, 163, 184, 0.18));
    border-radius: 6px;
    cursor: pointer;
}
.nt-fx-retry:hover { background: rgba(99, 102, 241, 0.2); }

/* ── Meta grid ──────────────────────────────────────────────────────────── */

.nt-fx-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px 18px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--card-border, rgba(148, 163, 184, 0.14));
}
.nt-fx-meta-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nt-fx-meta-k { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-muted, #64748b); }
.nt-fx-meta-v { font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nt-fx-meta-v a { color: var(--primary-light, #818cf8); text-decoration: none; }
.nt-fx-meta-v a:hover { text-decoration: underline; }
.nt-fx-meta-v code { background: rgba(148, 163, 184, 0.1); padding: 1px 5px; border-radius: 3px; font-size: 0.8rem; }

.nt-fx-stats { font-size: 0.82rem; color: var(--text-secondary, #94a3b8); margin-bottom: 14px; }
.nt-fx-stats strong { color: var(--text-primary, inherit); }
.nt-fx-dot { margin: 0 6px; opacity: 0.45; }
.nt-fx-stat-arch { color: #f59e0b; font-weight: 600; }
.nt-fx-stat-new { color: var(--status-fail, #ef4444); font-weight: 600; }
.nt-fx-stat-unknown { color: var(--text-muted, #64748b); font-style: italic; }
.nt-fx-cmp { margin-left: 8px; font-size: 0.72rem; opacity: 0.7; border-bottom: 1px dotted currentColor; cursor: help; }

/* ── AI Investigation panel ────────────────────────────────────────────── */

.nt-fx-ai {
    padding: 14px 16px;
    margin-bottom: 16px;
    background: linear-gradient(165deg, rgba(99, 102, 241, 0.1), rgba(99, 102, 241, 0.04));
    border: 1px solid rgba(99, 102, 241, 0.28);
    border-radius: 9px;
}
.nt-fx-ai-pending { background: rgba(148, 163, 184, 0.06); border-color: var(--card-border, rgba(148, 163, 184, 0.18)); }
.nt-fx-ai-eyebrow {
    display: inline-block;
    margin-bottom: 8px;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-light, #a5b4fc);
}
.nt-fx-ai-headline { font-size: 0.94rem; font-weight: 650; line-height: 1.4; margin-bottom: 10px; }
.nt-fx-ai-block { margin-bottom: 10px; }
.nt-fx-ai-h {
    display: block;
    margin-bottom: 3px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-secondary, #94a3b8);
}
.nt-fx-ai-body { margin: 0; font-size: 0.85rem; line-height: 1.58; }
.nt-fx-steps { margin: 0; padding-left: 20px; font-size: 0.83rem; line-height: 1.55; }
.nt-fx-steps li { margin-bottom: 3px; }
.nt-fx-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.nt-fx-tags code { padding: 1px 8px; font-size: 0.7rem; background: rgba(99, 102, 241, 0.16); border-radius: 3px; }
.nt-fx-ai-caveat { margin-bottom: 6px; font-size: 0.72rem; line-height: 1.45; color: var(--text-muted, #94a3b8); }
.nt-fx-ai-src { font-size: 0.71rem; line-height: 1.4; color: var(--text-muted, #94a3b8); padding-top: 4px; border-top: 1px solid rgba(99, 102, 241, 0.15); }

/* ── One failing test ───────────────────────────────────────────────────── */

.nt-fx-groups { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.nt-fx-group {
    padding: 11px 13px;
    background: rgba(148, 163, 184, 0.045);
    border: 1px solid var(--card-border, rgba(148, 163, 184, 0.16));
    border-left: 3px solid var(--text-muted, #64748b);
    border-radius: 7px;
    transition: box-shadow 0.15s ease;
}
.nt-fx-group-focus {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3);
}
/* Scope colour = the headline conclusion. Amber: isolated to one GPU, so
 * suspect the hardware/arch path. Red: everywhere, so suspect the change. */
.nt-fx-scope-arch-specific     { border-left-color: #f59e0b; }
.nt-fx-scope-platform-specific { border-left-color: #f59e0b; }
.nt-fx-scope-partial           { border-left-color: #fb923c; }
.nt-fx-scope-every-platform    { border-left-color: var(--status-fail, #ef4444); }

.nt-fx-group-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.nt-fx-test { font-size: 0.84rem; font-weight: 600; word-break: break-all; }
.nt-fx-file { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.71rem; color: var(--text-muted, #94a3b8); }

.nt-fx-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 7px 0 6px; }
.nt-fx-chip { padding: 1px 7px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em; border-radius: 3px; cursor: help; }
.nt-fx-chip-arch  { color: #f59e0b; background: rgba(245, 158, 11, 0.15); }
.nt-fx-chip-part  { color: #fb923c; background: rgba(251, 146, 60, 0.15); }
.nt-fx-chip-all   { color: var(--status-fail, #ef4444); background: rgba(239, 68, 68, 0.15); }
.nt-fx-chip-new   { color: var(--status-fail, #ef4444); background: rgba(239, 68, 68, 0.15); }
.nt-fx-chip-recur { color: var(--text-secondary, #94a3b8); background: rgba(148, 163, 184, 0.14); }
.nt-fx-chip-same  { color: #06b6d4; background: rgba(6, 182, 212, 0.15); }
/* Neutral by design — no cross-arch comparison exists, so this must not read
 * as either an arch verdict or a broad outage. */
.nt-fx-chip-solo    { color: var(--text-secondary, #94a3b8); background: rgba(148, 163, 184, 0.14); }
.nt-fx-chip-unknown { color: var(--text-muted, #64748b); background: rgba(148, 163, 184, 0.1); font-style: italic; }

.nt-fx-plat {
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.67rem;
    color: var(--text-secondary, #94a3b8);
    background: rgba(148, 163, 184, 0.1);
    border-radius: 3px;
}

.nt-fx-headline {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.76rem;
    line-height: 1.45;
    color: var(--text-secondary, #94a3b8);
    word-break: break-word;
}

.nt-fx-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    font-size: 0.71rem;
    color: var(--text-muted, #94a3b8);
}
.nt-fx-sub, .nt-fx-trunc { cursor: help; border-bottom: 1px dotted currentColor; }
.nt-fx-link { display: inline-flex; align-items: center; gap: 3px; color: var(--primary-light, #818cf8); }
.nt-fx-link i { width: 11px; height: 11px; }
.nt-fx-copy {
    margin-left: auto;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary, #94a3b8);
    background: rgba(148, 163, 184, 0.1);
    border: 1px solid var(--card-border, rgba(148, 163, 184, 0.16));
    border-radius: 5px;
    padding: 2px 9px;
    cursor: pointer;
}
.nt-fx-copy:hover { background: rgba(148, 163, 184, 0.18); color: var(--text-primary, inherit); }
.nt-fx-copy:disabled { opacity: 0.7; cursor: default; color: #86efac; }

.nt-fx-ai-note {
    margin-top: 8px;
    padding: 7px 10px;
    font-size: 0.79rem;
    line-height: 1.5;
    background: rgba(99, 102, 241, 0.08);
    border-radius: 5px;
}
.nt-fx-ai-tag {
    margin-right: 6px;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--primary-light, #a5b4fc);
}
.nt-fx-conf { margin-left: 6px; font-size: 0.66rem; color: var(--text-muted, #94a3b8); }

.nt-fx-msg { margin-top: 7px; }
.nt-fx-msg summary { font-size: 0.72rem; color: var(--text-muted, #94a3b8); cursor: pointer; }
.nt-fx-msg pre {
    margin: 7px 0 0;
    padding: 9px 11px;
    max-height: 260px;
    overflow: auto;
    font-size: 0.71rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(0, 0, 0, 0.22);
    border-radius: 5px;
}

/* ── Quality floor ──────────────────────────────────────────────────────── */

.nt-fx-copy:focus-visible,
.nt-fx-retry:focus-visible,
.nt-fx-msg summary:focus-visible,
.nt-fx-link:focus-visible {
    outline: 2px solid var(--primary-light, #818cf8);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    .nt-fx-modal-overlay { padding: 0; align-items: stretch; }
    .nt-fx-modal { max-width: none; max-height: none; height: 100%; border-radius: 0; }
    .nt-fx-meta-grid { grid-template-columns: repeat(2, 1fr); }
    .nt-fx-copy { margin-left: 0; }
}
