/* The grid mode of mso-table (ADR 0035): a light-DOM table, laid out as a CSS grid with subgrid rows (mso.css lays
   every table out that way), with a row heading and number boxes or checkboxes in edit mode. */

mso-table {
    min-width: 0;
}

.msoGrid {
    /* The row heading column's least width (its default track is minmax(this, 1fr)); narrower on small screens. */
    --grid-header-min: 8rem;
    width: 100%;
    font-variant-numeric: tabular-nums;
}

/* The row draws the line under itself, so it sits at the row's height, which the grid sets from its tallest cell;
   a cell's own border would sit under that cell's content, lower under a text box than a checkbox (#47). */
.msoGrid tr {
    border: 0;
    border-bottom: var(--border-width) solid var(--color-border);
    align-items: center;
}

/* The row under the pointer, and the row with the cursor, are tinted so the eye can follow a name across to its
   boxes (Gary, 2026-10-09). */
.msoGrid tbody tr:not(.msoGridEmpty):hover,
.msoGrid tbody tr:not(.msoGridEmpty):focus-within {
    background: var(--color-surface-hover);
}

.msoGrid th,
.msoGrid td {
    padding: var(--space-1);
    text-align: center;
    border: 0;
    white-space: nowrap;
    overflow: visible;
}

.msoGrid thead th {
    position: static;
    background: none;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    font-weight: var(--weight-medium);
}

/* The row heading: the name, and a note under it; its column heading lines up with it. */
.msoGrid thead th:first-child {
    text-align: left;
}

.msoGrid th[scope="row"] {
    position: static;
    background: none;
    text-align: left;
    font-weight: var(--weight-medium);
    white-space: normal;
}

.msoGridNote {
    display: block;
    font-size: var(--text-xs);
    font-weight: var(--weight-regular);
    color: var(--color-text-subtle);
}

.msoGridNote:empty {
    display: none;
}

.msoGridEmpty td {
    grid-column: 1 / -1;
    text-align: left;
    color: var(--color-text-muted);
}

/* Edit mode: every box shows where it is, empty or not (3:1 against the page), and the one with the cursor has a
   ring, stronger than hover's border. */
.msoGrid-edit input:not([type="checkbox"]) {
    width: 3rem;
    min-height: var(--control-h-md);
    font: inherit;
    font-size: var(--text-md);
    text-align: center;
    border: var(--border-width) solid var(--color-border-input);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
}

.msoGrid-edit input:not([type="checkbox"]):hover {
    border-color: var(--color-accent);
}

.msoGrid-edit input[type="checkbox"] {
    width: var(--icon-md);
    height: var(--icon-md);
    accent-color: var(--color-accent);
}

.msoGrid-edit input:focus-visible {
    outline: 2px solid transparent;
    box-shadow: var(--focus-ring);
}

.msoGrid-edit .msoGridInvalid input:not([type="checkbox"]) {
    border-color: var(--color-danger);
    background: var(--color-danger-bg);
}

/* Compact: tighter rows, so more shooters fit while entering scores. The row's height is still the grid's (the row
   draws its line); a fingertip keeps the full-size box (below). */
.msoGrid-compact th,
.msoGrid-compact td {
    padding-block: 2px;
}

.msoGrid-compact.msoGrid-edit input:not([type="checkbox"]) {
    min-height: var(--control-h-sm);
}

.msoGrid-compact th[scope="row"] .msoGridNote {
    display: inline;
    margin-left: var(--space-2);
}

.msoGrid-compact th[scope="row"] .msoGridNote:empty {
    display: none;
}

@media (pointer: coarse) {
    .msoGrid-edit input:not([type="checkbox"]) {
        min-height: var(--control-h-lg);
    }
}

@media (max-width: 1023px) {
    .msoGrid {
        --grid-header-min: 5.5rem;
    }

    .msoGrid th,
    .msoGrid td {
        padding: var(--space-1) 1px;
    }

    .msoGrid th[scope="row"] {
        font-size: var(--text-sm);
    }

    .msoGrid-edit input:not([type="checkbox"]) {
        width: 2.6rem;
    }
}
