/* Estilos da Matriz de Dedução Canônica — Design Monástico da Landing Page */

.grid-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-card);
  border: 1px solid var(--border-gold);
  border-radius: var(--border-radius-md);
  box-shadow: 0 0 25px rgba(201, 162, 75, 0.15), 0 8px 24px rgba(0, 0, 0, 0.6);
  padding: 0.65rem;
  position: relative;
}

@media (min-width: 768px) {
  .grid-wrapper {
    padding: 1.1rem;
  }
}

.puzzle-matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 3px;
  user-select: none;
  table-layout: fixed;
  min-width: var(--matrix-min-width);
}

@media (min-width: 768px) {
  .puzzle-matrix-table {
    border-spacing: 5px;
  }
}

/* Colunas do Colgroup */
col.col-figure {
  width: var(--col-figure-width);
}

col.col-data {
  min-width: var(--col-data-min-width);
}

/* Grupos de Cabeçalho Superior */
.matrix-group-header {
  font-family: var(--font-title);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.5rem 0.3rem;
  border-radius: var(--border-radius-sm);
  text-align: center;
  font-weight: 700;
}

@media (min-width: 768px) {
  .matrix-group-header {
    font-size: 0.82rem;
    letter-spacing: 0.1em;
    padding: 0.6rem 0.4rem;
  }
}

/* Canto Superior Esquerdo: Fixo (Sticky) */
.matrix-group-header.corner {
  background: var(--bg-surface-low);
  border: 1px solid var(--border-gold);
  color: var(--gold-primary);
  width: var(--col-figure-width);
  min-width: var(--col-figure-width);
  max-width: var(--col-figure-width);
  vertical-align: middle;
  padding: 0.6rem 0.4rem;
  line-height: 1.2;
  position: sticky;
  left: 0;
  z-index: 10;
  box-shadow: 3px 0 8px rgba(0, 0, 0, 0.6);
}

.matrix-group-header.artifacts {
  background: rgba(201, 162, 75, 0.15);
  color: var(--gold-light);
  border: 1px solid var(--border-gold);
}

.matrix-group-header.locations {
  background: rgba(130, 37, 48, 0.25);
  color: #ffb3b5;
  border: 1px solid var(--red-liturgical);
}

/* Cabeçalhos de Coluna Individuais */
.matrix-col-header {
  font-family: var(--font-title);
  font-size: 0.68rem;
  padding: 0.4rem 0.2rem;
  text-align: center;
  background: var(--bg-surface-lowest);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  white-space: normal;
  line-height: 1.2;
  height: 52px;
  vertical-align: middle;
  word-break: break-word;
  overflow: hidden;
  transition: all var(--transition-fast);
}

@media (min-width: 768px) {
  .matrix-col-header {
    font-size: 0.75rem;
    padding: 0.5rem 0.25rem;
    height: 56px;
    line-height: 1.25;
  }
}

.matrix-col-header.highlight {
  border-color: var(--gold-primary);
  color: var(--gold-primary);
  background: rgba(201, 162, 75, 0.08);
}

/* Cabeçalho de Linha (Personagem) — Sticky na Esquerda */
.matrix-row-header {
  font-family: var(--font-title);
  font-size: 0.76rem;
  padding: 0.5rem 0.45rem;
  text-align: left;
  background: var(--bg-surface-low);
  color: var(--text-primary);
  border: 1px solid var(--border-gold);
  border-radius: var(--border-radius-sm);
  font-weight: 600;
  white-space: normal;
  width: var(--col-figure-width);
  min-width: var(--col-figure-width);
  max-width: var(--col-figure-width);
  overflow: hidden;
  box-sizing: border-box;
  position: sticky;
  left: 0;
  z-index: 9;
  box-shadow: 3px 0 8px rgba(0, 0, 0, 0.6);
  transition: all var(--transition-fast);
}

@media (min-width: 768px) {
  .matrix-row-header {
    font-size: 0.85rem;
    padding: 0.65rem 0.75rem;
  }
}

.matrix-row-header.highlight {
  border-color: var(--gold-primary);
  color: var(--gold-primary);
  background: rgba(201, 162, 75, 0.12);
}

.matrix-row-header .figure-title {
  display: block;
  font-family: var(--font-body);
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: normal;
  margin-top: 0.1rem;
  line-height: 1.15;
}

/* Células Interativas de Dedução — Touch Targets ≥ 44px */
.matrix-cell {
  background: var(--bg-surface-lowest);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  height: 48px;
  min-height: 44px;
  min-width: 44px;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  touch-action: manipulation;
}

@media (min-width: 768px) {
  .matrix-cell {
    height: 52px;
  }
}

.matrix-cell:hover {
  background: var(--bg-surface-high);
  border-color: var(--gold-primary);
  transform: scale(1.02);
}

.matrix-cell.highlight-row,
.matrix-cell.highlight-col {
  background: rgba(201, 162, 75, 0.06);
}

/* Estado: Eliminado (Falso / ✕) */
.matrix-cell[data-state="eliminated"] {
  background: var(--bg-surface-lowest);
  border-color: rgba(130, 37, 48, 0.6);
}

.matrix-cell[data-state="eliminated"]::after {
  content: "✕";
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--red-liturgical-light);
  opacity: 0.85;
  display: inline-block;
  line-height: 1;
}

/* Estado: Confirmado (Verdadeiro / ✓) */
.matrix-cell[data-state="confirmed"] {
  background: var(--bg-surface-highest);
  border-color: var(--border-gold-strong);
  box-shadow: inset 0 0 10px rgba(201, 162, 75, 0.35);
}

.matrix-cell[data-state="confirmed"]::after {
  content: "✓";
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--gold-primary);
  text-shadow: 0 0 10px var(--gold-glow-intense);
  display: inline-block;
  line-height: 1;
}

/* Legenda de Ações — Mobile-First */
.grid-instructions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.legend-items {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
}

@media (min-width: 640px) {
  .grid-instructions {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .legend-items {
    gap: 1.25rem;
  }
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: bold;
}

.legend-icon.empty {
  background: var(--bg-surface-lowest);
  border: 1px solid var(--border-subtle);
}

.legend-icon.eliminated {
  background: var(--bg-surface-lowest);
  border: 1px solid rgba(130, 37, 48, 0.6);
  color: var(--red-liturgical-light);
}

.legend-icon.confirmed {
  background: var(--bg-surface-highest);
  border: 1px solid var(--border-gold-strong);
  color: var(--gold-primary);
  box-shadow: inset 0 0 6px rgba(201, 162, 75, 0.35);
}

.mobile-scroll-hint {
  display: block;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--gold-primary);
  margin-bottom: 0.5rem;
  letter-spacing: 0.03em;
}

@media (min-width: 768px) {
  .mobile-scroll-hint {
    display: none;
  }
}
