/* LINEAR-ALGEBRA.CSS
   Linear algebra keyboard operators for Calcunator.
   Handles matrix picker + inserted matrix styling.
*/

/* Matrix picker overlay */
.matrix-picker {
  position: absolute;
  z-index: 10000;
  display: none;
  grid-template-columns: repeat(10, 24px);
  grid-template-rows: repeat(10, 24px);
  gap: 2px;
  padding: 8px;
  border: 1px solid #cccccc;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
}

.matrix-picker.is-open {
  display: grid;
}

.matrix-picker .cell {
  width: 24px;
  height: 24px;
  border: 1px solid #dddddd;
  background: #ffffff;
  cursor: pointer;
  box-sizing: border-box;
}

.matrix-picker .cell.hovered {
  background: #e8f0ff;
  border-color: #9db8ff;
}

/* Inserted matrix */
.matrix,
.calcunator-matrix-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin: 0 8px;
  padding: 2px 12px;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  font-family: inherit;
  overflow: visible;
}

/* Stretch brackets */
.matrix::before,
.matrix::after,
.calcunator-matrix-container::before,
.calcunator-matrix-container::after {
  content: "";
  position: absolute;
  top: -4px;
  width: 8px;
  height: calc(100% + 8px);
  border: 2px solid currentColor;
  box-sizing: border-box;
  pointer-events: none;
}

.matrix::before,
.calcunator-matrix-container::before {
  left: 0;
  border-right: none;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.matrix::after,
.calcunator-matrix-container::after {
  right: 0;
  border-left: none;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

/* Matrix grid */
.matrix-table,
.matrix table,
.calcunator-matrix-table {
  border-collapse: collapse;
  border-spacing: 0;
  margin: 0;
  padding: 0;
}

.matrix-row,
.calcunator-matrix-row {
  margin: 0;
  padding: 0;
}

.matrix-cell-wrap,
.calcunator-matrix-cell-wrap {
  padding: 2px;
}

/* Editable matrix cells */
.matrix-cell,
.calcunator-matrix-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-width: 40px;
  height: 30px;
  min-height: 30px;
  padding: 0 4px;
  border: 1px solid #cccccc;
  box-sizing: border-box;
  text-align: center;
  white-space: nowrap;
  line-height: 1.2;
  outline: none;
  pointer-events: auto;
  background: #ffffff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
}

.matrix-cell[data-empty="true"],
.calcunator-matrix-cell[data-empty="true"] {
  background: #f7f7f7;
}

.matrix-cell[data-empty="false"],
.calcunator-matrix-cell[data-empty="false"] {
  background: #ffffff;
}

.matrix:focus-within .matrix-cell,
.calcunator-matrix-container:focus-within .calcunator-matrix-cell {
  border-color: #999999;
}

/* Simple linear algebra inline atoms */
.linear-simple-token {
  display: inline-block;
  white-space: nowrap;
  line-height: 1.15;
  vertical-align: baseline;
  pointer-events: none;
}

.linear-spaced-token {
  display: inline-block;
  margin-left: 6px;
  margin-right: 6px;
  white-space: nowrap;
  line-height: 1.15;
  vertical-align: baseline;
  pointer-events: none;
}