/* Bare element styles: headings, links, table, dl, details.
   Element-first — every table on this site is a stat table, so a bare <table>
   simply looks right; a class marks only deliberate deviation.
   See docs/agents/styling.md. */

@layer base {
    body {
        background: var(--bg);
        color: var(--text);
        font-family: var(--font-sans);
        font-size: var(--text-body);
    }

    /* --- Hierarchy --- */
    h1,
    h2,
    h3 {
        line-height: 1.2;
        text-wrap: balance;
    }

    h1 {
        font-size: var(--text-h1);
        margin-block: var(--space-lg) var(--space-md);
    }

    h2 {
        font-size: var(--text-h2);
        margin-block: var(--space-lg) var(--space-sm);
    }

    h3 {
        font-size: var(--text-h3);
        margin-block: var(--space-md) var(--space-xs);
    }

    p {
        margin-block: var(--space-sm);
    }

    ul,
    ol {
        margin-block: var(--space-sm);
        padding-inline-start: var(--space-lg);
    }

    a {
        color: var(--link);
        text-decoration-thickness: from-font;
        text-underline-offset: 0.15em;
    }

    /* One focus indicator for every interactive element, sortable column
       headers included. */
    :focus-visible {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }

    /* FocusOnNavigate moves focus to the h1 for assistive tech on every
       navigation; a focus ring on a non-interactive heading is noise. */
    h1:focus {
        outline: none;
    }

    /* --- Stat tables --- */
    /* Fixed type size and tabular digits: density is the design, and equal-width
       digits align down a column so magnitudes read at a glance. Restrained to
       borders, padding, and a header background so a genuinely non-tabular table
       can opt out cheaply. */
    table {
        /* separate, not collapse: collapsed borders detach from position:sticky
           cells, so the sticky identity column would leave its seam behind. */
        border-collapse: separate;
        border-spacing: 0;
        font-size: var(--text-stat);
        font-variant-numeric: tabular-nums;
        line-height: 1.25;
        margin-block: var(--space-sm);
    }

    th,
    td {
        border-block-end: 1px solid var(--border);
        padding: var(--space-2xs) var(--space-xs);
        text-align: start;
        white-space: nowrap;
    }

    thead th {
        background: var(--surface-alt);
        border-block-end: 1px solid var(--border-strong);
    }

    /* League-leading values: the accent's one appearance inside a table. */
    td strong {
        color: var(--accent);
    }

    /* --- Stat legend --- */
    details {
        margin-block: var(--space-md);
    }

    summary {
        color: var(--text-muted);
        cursor: pointer;
        font-size: var(--text-sm);
    }

    /* Legend definitions are prose-shaped, so they get a readable measure. */
    dl {
        display: grid;
        gap: var(--space-3xs) var(--space-sm);
        grid-template-columns: max-content 1fr;
        font-size: var(--text-sm);
        margin-block: var(--space-xs);
        max-inline-size: 60ch;
    }

    dt {
        font-weight: 600;
    }

    dd {
        color: var(--text-muted);
        margin: 0;
    }
}
