/* Threat-catalog UI: the threat chips inside each category's sub-matrix, and
   the badges they carry. The blocks and tables around them live in
   security-matrix.css. */
.threat-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}



/* HEIGHT IS LOAD-BEARING (2026-10-18). Chrome's reload restore is anchor-based
   and lands against this index's exact height while the page is still loading
   (see lib/layout-boot.js). A 15px change -- pills as <a> instead of <button>,
   which only swapped the font -- sent rapid reloads 280-1100px off target. After
   any change to a pill's font, padding, wrapping, or to the threat list itself,
   run tests/frontend/site-reload-cls.spec.mjs "reloading repeatedly" before
   shipping. */
.threat-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    /* Named properties rather than `all`: the hover applies transform/colour
       only, and `all` had the browser watching every animatable property,
       including layout ones, on every pill in a 111-item index. */
    transition: background-color 0.15s ease, border-color 0.15s ease,
                color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    text-decoration: none;
    line-height: 1.3;
    white-space: nowrap;
    gap: 0.55rem;
}

.threat-pill:focus-visible {
    /* The focus ring is drawn in --accent-text, not --accent-2.
     *
     * --accent-2 is a raw pale seed token with no repair pass, and measured
     * against --surface it lands under 3:1 on every one of the 15 light
     * themes — 1.45 on arctic, 1.86 on the DEFAULT theme — so the ring was
     * effectively invisible out of the box. It is worse still against
     * --surface-2 and --surface-3. --accent is no fix either (2.77 on sky).
     * --accent-text is repaired against the content surfaces and its worst
     * case across every theme is 4.51 (ember, on --surface-3), still well over
     * the 3:1 a non-text indicator needs. Pinned by tests/frontend/theme-focus-ring.spec.mjs.
     *
     * Same swap in the five matching rules in security-matrix.css. */
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

.threat-pill-title {
    min-width: 0;
}

.threat-pill-title small,
/* #threat-modal, not #modal-body: see the note in security-matrix.css. */
#threat-modal .threat-modal-title small {
    font-size: 0.62em;
    font-weight: 600;
    opacity: 0.78;
    white-space: nowrap;
}

.threat-priority {
    display: inline-flex;
    align-items: center;
    /* Optically centred against the label rather than the chip's full line box:
       the badge is 0.68rem inside a 0.85rem row, so baseline alignment left it
       sitting low. */
    align-self: center;
    flex: 0 0 auto;
    padding: 0.16rem 0.42rem;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: nowrap;
    /* Inset, so it costs no layout. currentColor makes the ring the tier's own
       colour: barely visible in light mode, where the fill already separates
       from the chip, and load-bearing in dark mode, where the fills sit 82% of
       the way toward the page background and nearly meet. */
    box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 32%, transparent);
}

.threat-attention-badge {
    display: inline-flex;
    align-items: center;
    align-self: center;
    flex: 0 0 auto;
    padding: 0.16rem 0.42rem;
    border: 1px solid color-mix(in srgb, var(--danger) 68%, var(--border));
    border-radius: 999px;
    background: color-mix(in srgb, var(--danger-soft) 80%, var(--surface));
    color: var(--text-strong);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 30%, transparent);
}

/* Key sits outside the ramp, not above it: gold rather than a hotter yellow,
   because knowledge-capital is a different kind of entry, not a worse threat. */
.threat-priority-key {
    background: var(--priority-key-bg);
    color: var(--priority-key-fg);
}

/* The five severity tiers. Backgrounds descend in lightness as severity rises,
   so the ramp reads as one spectrum and the loudest chip is the worst threat. */
.threat-priority-watch {
    background: var(--priority-watch-bg);
    color: var(--priority-watch-fg);
}

.threat-priority-notable {
    background: var(--priority-notable-bg);
    color: var(--priority-notable-fg);
}

.threat-priority-elevated {
    background: var(--priority-elevated-bg);
    color: var(--priority-elevated-fg);
}

.threat-priority-severe {
    background: var(--priority-severe-bg);
    color: var(--priority-severe-fg);
}

.threat-priority-critical {
    background: var(--priority-critical-bg);
    color: var(--priority-critical-fg);
}

.threat-pill:hover {
    background: var(--accent);
    color: var(--text-on-accent);
    border-color: var(--accent);
    transform: scale(1.02);
}

/* Tier colour survives hover. The fill alone is not enough to separate the
   badge from an accent-filled pill, so it gets a double ring: the inner 1px is
   currentColor, guaranteed against the badge's own fill by the --priority-*
   audit, and the outer 1px is --text-on-accent, guaranteed against the accent
   by the --text-on-accent/--accent audit. box-shadow only, so no layout shift,
   and it re-declares the resting inset ring a plain override would drop. */
.threat-pill:hover .threat-priority {
    box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 32%, transparent),
                0 0 0 1px currentColor,
                0 0 0 2px var(--text-on-accent);
}

.threat-pill:hover .threat-attention-badge {
    background: color-mix(in srgb, var(--danger-soft) 90%, var(--surface));
    border-color: color-mix(in srgb, var(--danger) 80%, var(--border));
    color: var(--text-strong);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 35%, transparent),
                0 0 0 1px var(--text-on-accent),
                0 0 0 2px color-mix(in srgb, var(--danger) 70%, transparent);
}


/* Same treatment for the inline knowledge-capital link in the section heading. */
.threat-featured-link {
    display: inline-flex;
    align-items: center;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--featured);
    background: color-mix(in srgb, var(--featured-soft) 55%, transparent);
    text-decoration: none;
}

.threat-featured-link:hover,
.threat-featured-link:focus-visible {
    background: color-mix(in srgb, var(--featured) 35%, var(--surface));
    color: var(--text-strong);
}

/* The pill of the threat whose modal just closed. */
.threat-pill.is-modal-closed-highlight {
    background: color-mix(in srgb, var(--accent-soft) 90%, transparent);
    border-color: var(--accent);
    color: var(--accent-strong);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
    animation: threatPillClosedHighlight 1.8s ease-out;
}

@keyframes threatPillClosedHighlight {
    0% {
        box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 42%, transparent);
    }
    100% {
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
    }
}

@media (prefers-reduced-motion: reduce) {
    .threat-pill.is-modal-closed-highlight {
        animation: none;
    }
}

/* The pill whose modal is waiting on the demo index (main.js openThreatModal).
   The delay keeps a quick fetch from flashing it. */
.threat-pill[aria-busy="true"] {
    cursor: progress;
    animation: threatPillWaiting 1.2s ease-in-out 0.3s infinite;
}

@keyframes threatPillWaiting {
    50% {
        border-color: var(--accent);
        box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
    }
}

@media (prefers-reduced-motion: reduce) {
    .threat-pill[aria-busy="true"] {
        animation: none;
        border-color: var(--accent);
    }
}

@media (max-width: 640px) {
    /* Too narrow for anything to wrap around: the label takes its own line and
       the pills get the whole cell. */
    .threat-group-label {
        float: none;
        width: auto;
        max-width: none;
        padding-right: 0;
        margin-bottom: 0.5rem;
    }

    .threat-pill {
        white-space: normal;
    }
}

/* The asterisk that marks a threat whose answer is a host-triggered reVerify.
   Deliberately not a badge: a badge means work still needed, and this mark
   means the opposite. It points at .threat-group-note under its block. */
.threat-reverify-marker {
    display: inline-flex;
    align-self: flex-start;
    flex: 0 0 auto;
    margin-left: -0.2rem;
    color: var(--accent-text);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
}

.threat-pill:hover .threat-reverify-marker {
    color: var(--text-on-accent);
}

/* The footnote the asterisk points at, at the foot of the block whose threats
   wear the mark. It has been a paragraph in the name cell and a full-width row
   of its own; it is now simply the last child of .threat-block, which is the
   thing it qualifies. */
.threat-group-note {
    margin: 0.6rem 0 0;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.5;
    text-wrap: pretty;
}

/* Knowledge-capital index refresh
 *
 * The index is a reading surface, not another glowing status banner.  Keep the
 * featured row gold, then turn everything below it into a quiet catalogue:
 * warm paper background, clear category cards, and compact verdict tables.
 * This lives last because responsive.css paints the opened row's old edge
 * gradients and threat-catalog.css is the final theme-aware stylesheet.
 */
.matrix > tbody > tr.matrix-dropdown-row > td {
    padding: 1rem clamp(0.75rem, 2vw, 1.5rem) 1.35rem;
    background: color-mix(in srgb, var(--featured-soft) 16%, var(--surface)) !important;
    background-image: none !important;
    border-top: 1px solid color-mix(in srgb, var(--featured) 35%, var(--border));
    border-bottom: 1px solid color-mix(in srgb, var(--featured) 28%, var(--border));
}

.matrix-dropdown-cell .matrix-wrapper {
    max-width: 110rem;
}

.threat-matrix-grid {
    display: block;
    columns: 2 28rem;
    column-gap: 1rem;
}

.threat-matrix-footnote {
    column-span: all;
}

.threat-matrix-footnote {
    margin: 0.15rem 0 0;
    padding: 0.85rem 0.5rem 0;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

.threat-block {
    break-inside: avoid;
    page-break-inside: avoid;
    min-width: 0;
    margin: 0 0 1rem;
    padding: 0;
    background: var(--surface) !important;
    border: 1px solid color-mix(in srgb, var(--featured) 24%, var(--border));
    border-radius: 0.75rem;
    box-shadow: 0 3px 12px color-mix(in srgb, var(--text-strong) 6%, transparent);
    overflow: hidden;
}

.threat-group-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid color-mix(in srgb, var(--featured) 32%, var(--border));
    background: linear-gradient(
        90deg,
        color-mix(in srgb, var(--featured-soft) 55%, var(--surface)),
        color-mix(in srgb, var(--featured-soft) 18%, var(--surface))
    );
    color: var(--text-strong);
    font-size: 1rem;
    letter-spacing: -0.01em;
}

.threat-group-count {
    flex: 0 0 auto;
    margin: 0;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
}

.threat-submatrix {
    table-layout: fixed;
    border-spacing: 0;
    border: 0;
    border-radius: 0;
}

.threat-submatrix thead th {
    padding: 0.48rem 0.55rem;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.67rem;
    letter-spacing: 0.06em;
}

.threat-submatrix thead th:first-child {
    width: 60%;
}

.threat-submatrix thead th:nth-child(2) {
    width: 17%;
}

.threat-submatrix thead th:last-child {
    width: 23%;
    padding-right: 0.7rem;
}

.threat-submatrix .threat-verdict-cell {
    width: auto;
    min-width: 0;
}

.threat-submatrix tbody th,
.threat-submatrix td {
    padding: 0.36rem 0.48rem;
    border: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
}

.threat-submatrix tbody tr:last-child th,
.threat-submatrix tbody tr:last-child td {
    border-bottom: 0;
}

.threat-submatrix tbody tr.is-alt {
    background: var(--surface-2);
}

.threat-submatrix .threat-pill {
    width: 100%;
    justify-content: flex-start;
    margin: 0;
    padding: 0.32rem 0.45rem;
    border-color: transparent;
    background: transparent;
    border-radius: 0.45rem;
    font-size: 0.79rem;
    gap: 0.35rem;
}

.threat-submatrix .threat-pill:hover {
    background: color-mix(in srgb, var(--accent-soft) 72%, var(--surface));
    color: var(--text-strong);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
    transform: none;
}

.threat-block > .threat-group-note {
    margin: 0;
    padding: 0.7rem 0.85rem;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
    font-size: 0.72rem;
    line-height: 1.45;
}

/* Multi-column layout fills top-to-bottom, so short categories naturally sit
 * below one another instead of inheriting the height of a tall neighbour. */
@media (max-width: 800px) {
    .threat-matrix-grid {
        columns: 1;
    }

    .threat-submatrix thead th:first-child {
        width: 60%;
    }
}

@media (max-width: 520px) {
    .matrix > tbody > tr.matrix-dropdown-row > td {
        padding-inline: 0.55rem;
    }

    .threat-block {
        border-radius: 0.65rem;
    }

    .threat-group-label {
        display: block;
    }

    .threat-group-count {
        display: block;
        margin-top: 0.2rem;
    }

    .threat-submatrix thead th,
    .threat-submatrix tbody th,
    .threat-submatrix td {
        padding-inline: 0.35rem;
    }

    .threat-submatrix thead th:first-child {
        width: 56%;
    }

    .threat-submatrix thead th:nth-child(2) {
        width: 17%;
    }

    .threat-submatrix thead th:last-child {
        width: 27%;
        padding-right: 0.45rem;
    }
}
