// A collapsible GM/player panel section (M4 UX): native
/, so a long column // collapses without custom state, keyboard handling or ARIA. Every string still goes through // `textContent` (spec #63 decision 15). // // The section id stays on the
element, so existing selectors (`#gm-roster`, ...) keep // working and tests can read `.open` or click the summary to toggle. export interface PanelSection { details: HTMLDetailsElement summary: HTMLElement body: HTMLDivElement } export function panelSection(id: string, title: string, open = false): PanelSection { const details = document.createElement('details') details.id = id details.open = open details.className = 'panel-section' const summary = document.createElement('summary') summary.textContent = title const body = document.createElement('div') body.className = 'panel-body' details.append(summary, body) return { details, summary, body } } /** Update a summary without touching the body (the count in "Tokens (50)"). */ export function setSectionTitle(section: PanelSection, title: string): void { if (section.summary.textContent !== title) section.summary.textContent = title } /** The nearest scrollable ancestor's viewport; `scrollIntoView` would also scroll the page. */ export function revealInColumn(node: HTMLElement): void { node.scrollIntoView({ block: 'nearest', inline: 'nearest' }) }