/* 全局字体与颜色变量 */
:root {
  --color-basic-bg: #e6f4ea;
  --color-basic-text: #1b5e20;
  --color-standard-bg: #fff3e0;
  --color-standard-text: #e65100;
  --color-enterprise-bg: #e3f2fd;
  --color-enterprise-text: #0d47a1;

  --color-border-soft: rgba(15, 23, 42, 0.08);
  --color-border-strong: rgba(15, 23, 42, 0.18);
  --color-surface: #ffffff;
  --color-surface-soft: #f8fafc;
}

body {
  font-family: "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.matrix-shell {
  border-radius: 1rem;
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.08), transparent 55%),
    radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.08), transparent 55%);
  padding: 1.25rem;
  border: 1px solid var(--color-border-soft);
}

.matrix-scroll {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.matrix-scroll::-webkit-scrollbar {
  height: 8px;
}

.matrix-scroll::-webkit-scrollbar-thumb {
  background-color: rgba(148, 163, 184, 0.65);
  border-radius: 999px;
}

.matrix-scroll::-webkit-scrollbar-track {
  background-color: transparent;
}


.matrix-grid {
  display: grid;
  grid-auto-rows: minmax(3rem, auto);
  border-radius: 0.75rem;
  background: var(--color-surface);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  border: 1px solid var(--color-border-strong);
}

.matrix-header-cell,
.matrix-row-header {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--color-border-soft);
  border-right: 1px solid var(--color-border-soft);
  font-size: 0.82rem;
}

.matrix-header-cell:last-child,
.matrix-row-header:last-child,
.matrix-cell:last-child {
  border-right: none;
}

.matrix-header-cell {
  background: linear-gradient(to bottom, #f8fafc, #eef2ff);
  font-weight: 600;
  color: #0f172a;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
}

.matrix-header-sticky {
  position: sticky;
  top: 0;
  z-index: 10;
}

.matrix-row-header {
  position: sticky;
  left: 0;
  z-index: 15;
  background: #f9fafb;
  font-weight: 500;
  color: #111827;
}

.matrix-row-header strong {
  font-weight: 600;
}

/* 屏幕阅读器可见但视觉隐藏 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 列内合并块背景 */
.matrix-block {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.18rem 0.22rem;
  border-radius: 0.75rem;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
  overflow: hidden;
  z-index: 1;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.matrix-block-label {
  font-weight: 600;
  font-size: 0.82rem;
  position: relative;
  z-index: 1;
}

.matrix-block::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: transparent;
  opacity: 0;
  transition: opacity 150ms ease;
}

.matrix-block.dimmed {
  filter: saturate(0.85) brightness(0.96);
}

.matrix-block.dimmed::before {
  background: rgba(248, 250, 252, 0.88);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.28);
  opacity: 1;
}

.matrix-block.focus-block {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.32);
  filter: saturate(1.08) brightness(1.03);
}

.matrix-cell {
  padding: 0.75rem 0.9rem;
  border-right: 1px solid var(--color-border-soft);
  font-size: 0.82rem;
  text-align: center;
  cursor: default;
  position: relative;
  background: transparent;
  z-index: 2;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease, filter 150ms ease;
}

.matrix-cell.group-divider {
  border-bottom: 1px solid var(--color-border-soft);
}

.matrix-cell span {
  font-weight: 600;
}

.level-basic {
  background: radial-gradient(circle at top left, rgba(34, 197, 94, 0.16), transparent 55%),
    var(--color-basic-bg);
  color: var(--color-basic-text);
}

.level-standard {
  background: radial-gradient(circle at top left, rgba(245, 158, 11, 0.18), transparent 55%),
    var(--color-standard-bg);
  color: var(--color-standard-text);
}

.level-enterprise {
  background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.22), transparent 55%),
    var(--color-enterprise-bg);
  color: var(--color-enterprise-text);
}

.matrix-cell:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
  z-index: 5;
}

.matrix-cell.issue-focus-ring {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.9), 0 12px 26px rgba(15, 23, 42, 0.32);
  z-index: 4;
}

.matrix-cell.intersection-ring {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.96), 0 16px 34px rgba(30, 64, 175, 0.55);
  z-index: 5;
}

.matrix-row-header.dimmed,
.matrix-header-cell.dimmed {
  opacity: 0.4;
}

.matrix-cell.focus-cell {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.92), 0 12px 25px rgba(15, 23, 42, 0.28);
}

.matrix-cell.focus-intersection {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.95), 0 16px 32px rgba(30, 64, 175, 0.45);
}

/* tooltip */
.matrix-tooltip {
  position: fixed;
  z-index: 50;
  max-width: 19rem;
  padding: 0.75rem 0.9rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.96);
  color: #e5e7eb;
  font-size: 0.78rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.6);
  pointer-events: none;
}

.matrix-tooltip h4 {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.matrix-tooltip p {
  opacity: 0.9;
}

.matrix-tooltip small {
  display: block;
  margin-top: 0.28rem;
  opacity: 0.78;
}

.matrix-tooltip[data-level="basic"] {
  border: 1px solid rgba(34, 197, 94, 0.85);
}

.matrix-tooltip[data-level="standard"] {
  border: 1px solid rgba(245, 158, 11, 0.9);
}

.matrix-tooltip[data-level="enterprise"] {
  border: 1px solid rgba(59, 130, 246, 0.95);
}

/* 小徽标 */
.badge-pill {
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-size: 0.7rem;
  font-weight: 500;
}

.badge-basic {
  border: 1px solid rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.08);
  color: #15803d;
}

.badge-standard {
  border: 1px solid rgba(245, 158, 11, 0.6);
  background: rgba(245, 158, 11, 0.08);
  color: #c2410c;
}

.badge-enterprise {
  border: 1px solid rgba(59, 130, 246, 0.6);
  background: rgba(59, 130, 246, 0.08);
  color: #1d4ed8;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--color-border-soft);
  box-shadow: 0 10px 22px rgba(148, 163, 184, 0.32);
}

.legend-swatch {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 0.45rem;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.25);
}

.legend-swatch.basic {
  background: var(--color-basic-bg);
}

.legend-swatch.standard {
  background: var(--color-standard-bg);
}

.legend-swatch.enterprise {
  background: var(--color-enterprise-bg);
}

.legend-label {
  font-size: 0.78rem;
}

.legend-label strong {
  font-weight: 600;
}

/* 轻量 loading 骨架 */
.matrix-loading {
  border-radius: 0.75rem;
  border: 1px dashed var(--color-border-soft);
  padding: 1.5rem 1.75rem;
  background: repeating-linear-gradient(
      135deg,
      #f9fafb,
      #f9fafb 8px,
      #f3f4f6 8px,
      #f3f4f6 16px
    );
}

.matrix-loading-bar {
  height: 0.6rem;
  border-radius: 999px;
  background: linear-gradient(90deg, #e5e7eb, #d1d5db, #e5e7eb);
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
}

@keyframes shimmer {
  0% {
    background-position: -120% 0;
  }
  100% {
    background-position: 120% 0;
  }
}
