/* RECATOOLS tool pattern: rtp-matrix — a two-way table of measured values
 * (rows × columns, e.g. town × flat type) whose cells are tinted by value and
 * can be buttons that load the cell into the tool above.
 *
 * OPT-IN. Nothing links this file except a widget that wants it:
 *   <link rel="stylesheet" href="{{ asset('assets/css/tool-patterns/rtp-matrix.css') }}">
 * Presentation only — no maths. The widget decides each cell's level
 * (rtp-matrix-l1 … rtp-matrix-l5) and prints its own legend.
 * Colours are rt-tokens, so the [data-theme="dark"] swap carries through.
 * Documented in docs/tool-design-patterns.md. First used by
 * /price-to-rent-ratio-calculator/ (2026-11-07).
 */
.rtp-matrix { margin: 0; }
.rtp-matrix-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--rt-hairline); border-radius: var(--rt-r-card, 8px); background: var(--rt-surface); }
.rtp-matrix-table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 520px; font-family: var(--rt-font-sans); font-size: 14px; color: var(--rt-ink); }
.rtp-matrix-table caption { caption-side: top; text-align: left; padding: 10px 12px; font-size: 13px; color: var(--rt-ink-muted); }
.rtp-matrix-table th, .rtp-matrix-table td { padding: 0; border-bottom: 1px solid var(--rt-hairline); text-align: center; white-space: nowrap; }
.rtp-matrix-table thead th { position: sticky; top: 0; background: var(--rt-surface-2); font-family: var(--rt-font-mono); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--rt-ink-soft); padding: 10px 8px; }
.rtp-matrix-table tbody th { position: sticky; left: 0; z-index: 1; background: var(--rt-surface); text-align: left; font-weight: 500; padding: 0 12px; min-width: 9.5em; border-right: 1px solid var(--rt-hairline); }
.rtp-matrix-table tfoot th, .rtp-matrix-table tfoot td { background: var(--rt-surface-2); font-weight: 600; padding: 9px 8px; border-bottom: 0; }
.rtp-matrix-table tfoot th { text-align: left; padding-left: 12px; position: sticky; left: 0; }
.rtp-matrix-table tr:last-child td, .rtp-matrix-table tr:last-child th { border-bottom: 0; }

/* A cell: a button when it can be loaded, a span when it is empty. */
.rtp-matrix-cell { display: block; width: 100%; min-height: 40px; padding: 9px 8px; border: 0; background: transparent; color: inherit; font: inherit; font-variant-numeric: tabular-nums; cursor: default; }
button.rtp-matrix-cell { cursor: pointer; }
button.rtp-matrix-cell:hover { outline: 2px solid var(--rt-ink); outline-offset: -2px; }
button.rtp-matrix-cell:focus-visible { outline: 3px solid var(--rt-link, #2A6FDB); outline-offset: -3px; }
button.rtp-matrix-cell[aria-pressed="true"] { outline: 3px solid var(--rt-ink); outline-offset: -3px; font-weight: 700; }
.rtp-matrix-empty { color: var(--rt-ink-muted); }

/* Five tint levels, lightest = lowest. Mixed from the accent into the
 * surface, so the same rule reads on light and dark themes. Text stays
 * --rt-ink, which keeps at least 4.5:1 on every level in both themes. */
.rtp-matrix-l1 { background: var(--rt-surface-2); background: color-mix(in srgb, var(--rt-accent) 4%, var(--rt-surface)); }
.rtp-matrix-l2 { background: var(--rt-surface-2); background: color-mix(in srgb, var(--rt-accent) 12%, var(--rt-surface)); }
.rtp-matrix-l3 { background: var(--rt-bg-inset); background: color-mix(in srgb, var(--rt-accent) 22%, var(--rt-surface)); }
.rtp-matrix-l4 { background: var(--rt-bg-inset); background: color-mix(in srgb, var(--rt-accent) 33%, var(--rt-surface)); }
.rtp-matrix-l5 { background: var(--rt-bg-inset); background: color-mix(in srgb, var(--rt-accent) 45%, var(--rt-surface)); }

.rtp-matrix-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 10px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--rt-ink-muted); }
.rtp-matrix-legend li { display: inline-flex; align-items: center; gap: 6px; }
.rtp-matrix-swatch { display: inline-block; width: 18px; height: 12px; border-radius: 3px; border: 1px solid var(--rt-hairline); }
.rtp-matrix-note { margin: 10px 0 0; font-size: 12.5px; line-height: 1.55; color: var(--rt-ink-muted); }
