/**
 * Theia — Matriz 4×4: módulos × atores do ecossistema
 * Estilo institucional com cores da marca; hover na célula mostra texto abaixo.
 */

/* —— Seção e cabeçalho —— */
.section-theia-matrix {
  background: linear-gradient(180deg, var(--color-bg) 0%, rgba(247, 248, 247, 0.6) 100%);
}

/* Menos espaço quando a matriz vem logo após a seção de cards */
.section-cards + .section-theia-matrix {
  margin-top: 0;
}

.section-theia-matrix .theia-head {
  padding-bottom: var(--section-gap);
}

.section-theia-matrix .theia-head__title {
  color: var(--color-green-dark);
  font-family: var(--font-primary);
}

.section-theia-matrix img.theia-head__title {
  display: block;
  max-width: 100%;
  height: auto;
}

.section-theia-matrix .theia-head__subtitle {
  margin-bottom: 0;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

/* —— Container da tabela —— */
.theia-matrix-wrap {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 var(--space);
}

.theia-matrix-table {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) repeat(4, minmax(0, 1fr));
  gap: 0;
  background: var(--color-border);
  border: 1px solid rgba(56, 113, 132, 0.2);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(59, 70, 64, 0.08);
}

.theia-matrix-row {
  display: contents;
}

/* —— Células base —— */
.theia-matrix-cell {
  padding: 0.75rem 0.6rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  background: var(--color-bg-section);
  min-height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

/* —— Cabeçalhos de coluna (atores) —— */
.theia-matrix-row--header .theia-matrix-cell--header {
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-white);
  background: linear-gradient(135deg, var(--header-gradient-1) 0%, var(--header-gradient-2) 100%);
  padding: 0.85rem 0.5rem;
  border-bottom: 2px solid rgba(56, 113, 132, 0.3);
}

.theia-matrix-row--header .theia-matrix-cell--header:not(:first-of-type) {
  border-left: 1px solid rgba(255, 255, 255, 0.15);
}

/* —— Canto vazio do cabeçalho —— */
.theia-matrix-cell--corner {
  background: linear-gradient(135deg, var(--header-gradient-1) 0%, #2d5a6b 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  border-bottom: 2px solid rgba(56, 113, 132, 0.3);
}

/* —— Cabeçalhos de linha (módulos) —— */
.theia-matrix-row:not(.theia-matrix-row--header) .theia-matrix-cell--header {
  font-weight: 600;
  color: var(--color-green-dark);
  background: linear-gradient(90deg, rgba(56, 113, 132, 0.12) 0%, rgba(56, 113, 132, 0.06) 100%);
  border-right: 1px solid rgba(56, 113, 132, 0.12);
  justify-content: flex-start;
  padding-left: 1rem;
  text-align: left;
}

/* —— Células de dados (interativas) —— */
.theia-matrix-row:not(.theia-matrix-row--header) .theia-matrix-cell:not(.theia-matrix-cell--header) {
  cursor: pointer;
  color: var(--color-text-muted);
  background: var(--color-bg-section);
  border-bottom: 1px solid rgba(56, 113, 132, 0.06);
}

.theia-matrix-row:not(.theia-matrix-row--header) .theia-matrix-cell:not(.theia-matrix-cell--header):not(:first-of-type) {
  border-left: 1px solid rgba(56, 113, 132, 0.06);
}

.theia-matrix-row:not(.theia-matrix-row--header) .theia-matrix-cell[data-desc]:hover,
.theia-matrix-row:not(.theia-matrix-row--header) .theia-matrix-cell[data-desc]:focus {
  outline: none;
  background: rgba(17, 128, 76, 0.08);
  color: var(--color-accent);
  z-index: 1;
  box-shadow: inset 0 0 0 1px rgba(17, 128, 76, 0.25);
}

.theia-matrix-row:not(.theia-matrix-row--header) .theia-matrix-cell[data-desc]:focus-visible {
  box-shadow: inset 0 0 0 2px var(--color-accent);
}

/* —— Área de texto abaixo da matriz —— */
.theia-matrix-desc {
  max-width: 800px;
  margin: var(--section-gap) auto 0;
  padding: 1rem var(--space);
  min-height: 4.5em;
  background: rgba(255, 255, 255, 0.7);
  border-left: 4px solid var(--color-accent);
  border-radius: 0 8px 8px 0;
  box-shadow: 0 1px 3px rgba(59, 70, 64, 0.06);
}

.theia-matrix-desc__text {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
  transition: color 0.25s ease, opacity 0.25s ease;
}

.theia-matrix-desc__text.theia-matrix-desc__text--active {
  color: var(--color-green-dark);
}

/* —— CTA (mantém alinhamento) —— */
.section-theia-matrix .theia-cta-wrap {
  margin-top: var(--section-gap);
}

/* —— Mobile —— */
@media (max-width: 600px) {
  .theia-matrix-table {
    grid-template-columns: minmax(5rem, 1fr) repeat(4, minmax(0, 1fr));
    border-radius: 8px;
  }

  .theia-matrix-cell {
    padding: 0.5rem 0.35rem;
    min-height: 2.75rem;
    font-size: 0.75rem;
  }

  .theia-matrix-row--header .theia-matrix-cell--header {
    font-size: 0.65rem;
    padding: 0.6rem 0.35rem;
    word-break: break-word;
  }

  .theia-matrix-row:not(.theia-matrix-row--header) .theia-matrix-cell--header {
    font-size: 0.75rem;
    padding-left: 0.6rem;
  }

  .theia-matrix-desc {
    padding: 0.85rem var(--space);
    min-height: 4em;
  }

  .theia-matrix-desc__text {
    font-size: 0.875rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theia-matrix-cell,
  .theia-matrix-desc__text {
    transition-duration: 0.01ms;
  }
}
