/* sessions-matrix-layout.css — Shell, page header, legend, context strip, grid structure, and column headers */

/* ── CSS Tooltip (must precede sticky header rules — equal specificity, source order decides) ── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-neutral-800, #1a1a2e);
    color: var(--color-neutral-50, #fafafa);
    font-size: 11px;
    line-height: 1.4;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition-fast, 120ms) ease;
    transition-delay: 200ms;
    z-index: 30;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ── Matrix view shell (class set by mountMatrixView) ───────── */
.matrix-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.spr-tab-panel.matrix-view[hidden] {
    display: none !important;
}

/* ── Page header bar ─────────────────────────────────────────── */
.matrix-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px 16px;
    flex-shrink: 0;
}
.matrix-page-title {
    font-size: var(--text-h2, 18px);
    font-weight: var(--weight-semibold, 600);
    color: var(--fg-primary, #111827);
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.matrix-page-count {
    font-size: var(--text-xs, 12px);
    font-weight: var(--weight-medium, 500);
    color: var(--fg-tertiary, #9ca3af);
    letter-spacing: 0;
}
.matrix-start-session-btn {
    height: 34px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-primary-700, #1d4ed8);
    color: #fff;
    border: 1px solid var(--color-primary-700, #1d4ed8);
    border-radius: var(--radius-md, 6px);
    font-size: 13px;
    font-weight: var(--weight-semibold, 600);
    cursor: pointer;
    box-shadow: var(--shadow-primary, 0 4px 14px rgba(26,79,207,0.28));
}
.matrix-start-session-btn:hover {
    background: var(--color-primary-800, #1e40af);
    border-color: var(--color-primary-800, #1e40af);
}

/* ── Header actions group ────────────────────────────────────── */
.matrix-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Legend anchor + button ──────────────────────────────────── */
.matrix-legend-anchor {
    position: relative;
}
.matrix-legend-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-default, #e5e7eb);
    background: var(--bg-surface, #fff);
    color: var(--fg-tertiary, #9ca3af);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.matrix-legend-btn:hover {
    background: var(--bg-page, #f9fafb);
    color: var(--fg-secondary, #374151);
}
.matrix-legend-btn[aria-expanded="true"] {
    background: var(--color-primary-50, #eff6ff);
    color: var(--color-primary-700, #1d4ed8);
    border-color: var(--color-primary-200, #bfdbfe);
}

/* ── Legend popover ──────────────────────────────────────────── */
.matrix-legend-popover {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-surface, #fff);
    border: 1px solid var(--border-default, #e5e7eb);
    border-radius: var(--radius-md, 6px);
    box-shadow: var(--shadow-md, 0 4px 16px rgba(15, 23, 42, 0.12));
    padding: 12px 14px;
    min-width: 240px;
    z-index: 50;
}
.matrix-legend-title {
    font-size: 10px;
    font-weight: var(--weight-bold, 700);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-tertiary, #9ca3af);
    margin-bottom: 8px;
}
.matrix-legend-list {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 5px 10px;
    margin: 0;
}
.matrix-legend-abbr {
    font-size: 11.5px;
    font-weight: var(--weight-bold, 700);
    color: var(--fg-secondary, #374151);
    letter-spacing: 0.04em;
}
.matrix-legend-name {
    font-size: 12px;
    color: var(--fg-secondary, #374151);
    margin: 0;
}

/* ── Student context strip ──────────────────────────────────── */
.matrix-ctx {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-default);
    flex-shrink: 0;
}
.matrix-ctx-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--color-primary-600, #2563eb), var(--color-primary-800, #1a4fcf));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--weight-bold, 700);
    font-size: 14px;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}
.matrix-ctx-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.matrix-ctx-name {
    font-size: 14px;
    font-weight: var(--weight-semibold, 600);
    color: var(--fg-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.matrix-ctx-level {
    font-weight: var(--weight-medium, 500);
    color: var(--fg-secondary);
}
.matrix-ctx-meta {
    font-size: var(--text-xs, 11px);
    color: var(--fg-tertiary);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.matrix-ctx-dot {
    width: 3px;
    height: 3px;
    border-radius: 99px;
    background: var(--color-neutral-300, #d1d5db);
    flex-shrink: 0;
}

/* ── Grid wrap (padding + flex context for card) ─────────────── */
.matrix-grid-wrap {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0 24px 24px;
}

/* ── Grid card ───────────────────────────────────────────────── */
.matrix-grid-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    background: var(--bg-surface, #fff);
    border: 1px solid var(--border-default, #e5e7eb);
    border-radius: var(--radius-lg, 14px);
    box-shadow: var(--shadow-xs, 0 1px 2px rgba(15,23,42,0.04));
    overflow: hidden;
}

/* ── Grid table ──────────────────────────────────────────────── */
.matrix-grid {
    display: grid;
    grid-template-columns:
        80px
        var(--matrix-score-cols, repeat(4, 42px))
        minmax(180px, 1fr)
        minmax(280px, 2fr)
        36px;
    grid-template-rows: 22px 22px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* ── Header ──────────────────────────────────────────────────── */
.matrix-header-category,
.matrix-header-metric {
    position: sticky;
    background: var(--bg-page, #f9fafb);
    border-bottom: 1px solid var(--border-default, #e5e7eb);
    padding: 0 4px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 10;
}
.matrix-header-category-text {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}
.matrix-header-category {
    top: 0;
    font-size: 9.5px;
    font-weight: var(--weight-semibold, 600);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-tertiary, #9ca3af);
}
.matrix-header-metric {
    top: 22px;
    border-top: 1px solid var(--border-subtle, #f0f0f0);
    font-size: 11px;
    font-weight: var(--weight-bold, 700);
    color: var(--fg-secondary, #374151);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
/* Score column guide lines */
.matrix-header-category.score-start,
.matrix-header-metric.score-start { box-shadow: inset 1px 0 0 var(--border-default, #e5e7eb); }
.matrix-header-category.score-end,
.matrix-header-metric.score-end   { box-shadow: inset -1px 0 0 var(--border-default, #e5e7eb); }
/* Category boundary divider */
.matrix-header-category.cat-start,
.matrix-header-metric.cat-start   { box-shadow: inset 1px 0 0 var(--border-default, #e5e7eb); }
.matrix-cell-score.cat-start      { border-left: 1px solid var(--border-subtle, #f0f0f0); }

.matrix-header-date,
.matrix-header-topics,
.matrix-header-observations,
.matrix-header-chev {
    position: sticky;
    top: 0;
    background: var(--bg-page, #f9fafb);
    border-bottom: 1px solid var(--border-default, #e5e7eb);
    z-index: 10;
    grid-row: span 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 12px;
}
.matrix-header-date .ghead-row1,
.matrix-header-topics .ghead-row1,
.matrix-header-observations .ghead-row1 {
    font-size: 9.5px;
    font-weight: var(--weight-semibold, 600);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--fg-tertiary, #9ca3af);
    margin-bottom: 2px;
}
.matrix-header-date .ghead-row2,
.matrix-header-topics .ghead-row2,
.matrix-header-observations .ghead-row2 {
    font-size: 11px;
    font-weight: var(--weight-bold, 700);
    color: var(--fg-secondary, #374151);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.matrix-header-chev { padding: 0; }
