/* YAML parser results report (used with report.js) */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e1e4e9;
    --border-strong: #c9ced6;
    --text: #1b2129;
    --muted: #5d6877;
    --accent: #2f5bd3;
    --accent-soft: #e6ecfb;
    --row-hover: #f3f6fc;
    --row-active: #e6ecfb;

    /* Result colours */
    --passed: #cfe8d7;
    --passed-strong: #2f9a5a;
    --passed-fg: #1f6b3d;
    --rejected: #dc4c43;
    --accepted: #3565d6;
    --crashed: #1f242b;
    --timeout: #9ba4ae;
    --on-status: #ffffff;

    --valid: #1f7a45;
    --valid-bg: #e0f2e7;
    --invalid: #a8352e;
    --invalid-bg: #fbe5e3;

    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lg: 0 20px 50px rgba(16, 24, 40, .25);
    --radius: 10px;
    --cell: 22px;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1216;
        --surface: #171b21;
        --surface-2: #1f242c;
        --border: #2a3039;
        --border-strong: #3a414c;
        --text: #e5e8ec;
        --muted: #9aa4b1;
        --accent: #8aa9ff;
        --accent-soft: #1f2a44;
        --row-hover: #1c222b;
        --row-active: #1f2a44;

        --passed: #1f4430;
        --passed-strong: #3fb872;
        --passed-fg: #9fe0b8;
        --rejected: #e5625a;
        --accepted: #5b86f0;
        --crashed: #d5d9df;
        --timeout: #6b7480;

        --valid: #8fdcaf;
        --valid-bg: #1d3a2a;
        --invalid: #f4a19b;
        --invalid-bg: #45211f;

        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
        color-scheme: dark;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 var(--font);
}

body.viewer-open {
    overflow: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button,
input,
select {
    font: inherit;
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Header ---------- */

.page-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 28px 0 22px;
    margin-bottom: 24px;
}

.back-link {
    display: inline-block;
    margin-bottom: 14px;
    font-size: 13px;
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
}

h1 {
    margin: 2px 0 12px;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -.01em;
}

h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}

.summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    margin: 0;
    color: var(--muted);
}

.summary b {
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ---------- Panels ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px 20px;
    margin-bottom: 24px;
}

.panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 16px;
    margin-bottom: 14px;
}

.hint {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Scoreboard ---------- */

.scoreboard {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(520px, 1fr));
    column-gap: 32px;
}

.score-row {
    display: grid;
    grid-template-columns: 22px 150px 1fr 52px 104px;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
}

.rank {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pname {
    color: var(--text);
    font-weight: 550;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar {
    display: flex;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-2);
}

.seg-bar {
    height: 100%;
}

.seg-bar.PASSED {
    background: var(--passed-strong);
}

.rate {
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.devs {
    justify-self: end;
    border: 0;
    background: none;
    padding: 2px 4px;
    border-radius: 4px;
    color: var(--accent);
    font-size: 12.5px;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.devs:hover {
    background: var(--accent-soft);
}

.devs:disabled {
    color: var(--muted);
    cursor: default;
    background: none;
}

/* ---------- Toolbar & legend ---------- */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 12px;
    margin-bottom: 12px;
}

.toolbar input[type="search"],
.toolbar select {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
}

.toolbar input[type="search"] {
    flex: 1 1 240px;
    min-width: 0;
    max-width: 360px;
}

.seg {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    overflow: hidden;
}

.seg button {
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-right: 1px solid var(--border-strong);
    background: var(--surface);
    cursor: pointer;
}

.seg button:last-child {
    border-right: 0;
}

.seg button[aria-pressed="true"] {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.link-btn {
    border: 0;
    background: none;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
}

.link-btn[hidden] {
    display: none;
}

.link-btn:hover {
    background: var(--accent-soft);
    text-decoration: none;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 30px;
    padding: 0 10px 0 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer;
    font-size: 13px;
}

.chip:hover {
    border-color: var(--border-strong);
}

.chip[aria-pressed="true"] {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.chip .n {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.count {
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 13px;
}

/* ---------- Status colours (cells, swatches, bars) ---------- */

.c {
    text-align: center;
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
}

.PASSED {
    background: var(--passed);
    color: var(--passed-fg);
}

.SHOULD_HAVE_PASSED {
    background: var(--rejected);
    color: var(--on-status);
}

.SHOULD_HAVE_FAILED {
    background: var(--accepted);
    color: var(--on-status);
}

.CRASHED {
    background: var(--crashed);
    color: var(--bg);
}

.TIMEOUT {
    background: var(--timeout);
    color: var(--on-status);
}

.UNKNOWN {
    background: var(--surface);
    color: var(--muted);
    box-shadow: inset 0 0 0 1px var(--border-strong);
}

.swatch {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    flex: none;
}

.swatch.PASSED:empty::before {
    content: "✓";
}

/* ---------- Matrix ---------- */

.matrix-wrap {
    max-height: calc(100vh - 120px);
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.matrix {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}

.matrix th,
.matrix td {
    padding: 0;
    border: 0;
}

.matrix thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface);
    border-bottom: 1px solid var(--border-strong);
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    vertical-align: bottom;
}

.matrix thead th.test-col {
    left: 0;
    z-index: 3;
    padding: 8px 12px;
    text-align: left;
}

.matrix th.pcol {
    width: var(--cell);
    min-width: var(--cell);
    padding: 8px 0 8px;
}

.matrix th.pcol span {
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    color: var(--text);
    font-weight: 550;
}

.matrix th.pcol.col-focus span {
    color: var(--accent);
}

.matrix .score-col {
    padding: 0 12px;
    text-align: right;
    white-space: nowrap;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.matrix thead th.score-col {
    padding: 8px 12px;
}

.matrix tbody th.test-col {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--surface);
    text-align: left;
    font-weight: 400;
    max-width: 440px;
    border-right: 1px solid var(--border);
}

.matrix tbody tr > * {
    border-bottom: 1px solid var(--surface);
}

.matrix td.c {
    width: var(--cell);
    min-width: var(--cell);
    height: var(--cell);
    border-left: 1px solid var(--surface);
    cursor: pointer;
}

.matrix td.c.col-focus {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.matrix tbody tr:hover > th,
.matrix tbody tr:hover > .score-col {
    background: var(--row-hover);
}

.matrix tbody tr.active > th,
.matrix tbody tr.active > .score-col {
    background: var(--row-active);
}

.matrix tbody tr:hover td.c {
    filter: brightness(.94);
}

.test-link {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-width: 0;
    padding: 3px 12px;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
}

.test-link:hover .tname {
    color: var(--accent);
    text-decoration: underline;
}

.tname {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: var(--mono);
    font-size: 12.5px;
}

.tag {
    flex: none;
    display: inline-block;
    min-width: 50px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .04em;
    text-align: center;
    text-transform: uppercase;
}

.tag.valid {
    background: var(--valid-bg);
    color: var(--valid);
}

.tag.invalid {
    background: var(--invalid-bg);
    color: var(--invalid);
}

.mini {
    display: inline-block;
    width: 36px;
    height: 6px;
    margin-right: 8px;
    border-radius: 999px;
    vertical-align: middle;
    background: linear-gradient(90deg, var(--passed-strong) var(--p), var(--surface-2) var(--p));
}

.empty {
    margin: 0;
    padding: 32px;
    text-align: center;
    color: var(--muted);
}

/* ---------- File viewer ---------- */

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: rgba(10, 14, 20, .45);
}

.viewer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 11;
    display: flex;
    flex-direction: column;
    width: min(820px, 100%);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    animation: slide-in .18s ease-out;
}

.backdrop[hidden],
.viewer[hidden] {
    display: none;
}

@keyframes slide-in {
    from {
        transform: translateX(24px);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .viewer {
        animation: none;
    }
}

.viewer-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--border);
}

.viewer-title {
    flex: 1;
    min-width: 0;
}

.viewer-title h2 {
    margin: 6px 0 2px;
    font-family: var(--mono);
    font-size: 14.5px;
    word-break: break-all;
}

.meta {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
}

.viewer-nav {
    display: flex;
    gap: 4px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.icon-btn:hover:not(:disabled) {
    background: var(--surface-2);
}

.icon-btn:disabled {
    opacity: .4;
    cursor: default;
}

.viewer-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 14px 20px 16px;
    gap: 12px;
}

.v-verdict {
    margin: 0;
    color: var(--muted);
}

.v-verdict b {
    color: var(--text);
}

.v-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 4px 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.res {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 13px;
}

.res .swatch {
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 700;
}

.res-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.res-status {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.code-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.code-toolbar .spacer {
    flex: 1;
}

.code {
    flex: 0 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 10px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    font: 13px/1.6 var(--mono);
    tab-size: 4;
}

.ln {
    display: flex;
    min-width: max-content;
}

.code.wrap .ln {
    min-width: 0;
}

.ln:hover {
    background: var(--row-hover);
}

.ln .no {
    position: sticky;
    left: 0;
    flex: none;
    width: 4.5em;
    padding-right: 1em;
    background: inherit;
    background-color: var(--surface-2);
    color: var(--muted);
    opacity: .7;
    text-align: right;
    user-select: none;
}

.ln .lc {
    padding-right: 16px;
    white-space: pre;
}

.code.wrap .lc {
    white-space: pre-wrap;
    word-break: break-all;
}

.ws {
    position: relative;
}

.ws::before {
    position: absolute;
    left: 0;
    color: var(--muted);
    opacity: .55;
    pointer-events: none;
}

.ws.sp::before {
    content: "·";
    width: 1ch;
    text-align: center;
}

.ws.tab::before {
    content: "→";
    color: var(--accepted);
    opacity: .8;
}

.sc {
    margin: 0 1px;
    padding: 0 3px;
    border-radius: 3px;
    background: var(--invalid-bg);
    color: var(--invalid);
    font-size: 10.5px;
    vertical-align: 1px;
}

.code-empty {
    margin: 0;
    padding: 8px 16px;
    color: var(--muted);
    font-family: var(--font);
}

.v-note {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
}

.v-note[hidden] {
    display: none;
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
    .wrap {
        padding: 0 16px;
    }

    h1 {
        font-size: 21px;
    }

    .panel {
        padding: 14px 14px 16px;
    }

    .scoreboard {
        grid-template-columns: 1fr;
    }

    .score-row {
        grid-template-columns: 18px minmax(0, 110px) 1fr 48px;
    }

    .score-row .devs {
        grid-column: 2 / -1;
        justify-self: start;
        padding-left: 0;
    }

    .matrix tbody th.test-col {
        max-width: 200px;
    }

    .test-link .tag {
        min-width: 0;
    }

    .viewer-head,
    .viewer-body {
        padding-left: 14px;
        padding-right: 14px;
    }
}
