/* SPDX-License-Identifier: Apache-2.0 */
/* Maqāyīs (مَقاييس) — Specialized View Components (Book, Matrices, Lab, MT X-Ray) */

/* Command Palette */
.cmd-input-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
}
.cmd-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 1.02rem;
  color: var(--text-primary);
}
.cmd-input:focus {
  outline: none;
  box-shadow: none;
}
.cmd-results {
  max-height: 62vh;
  overflow-y: auto;
  padding: 0.5rem;
}
.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.62rem 0.8rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: start;
  cursor: pointer;
}
.cmd-item:hover,
.cmd-item:focus {
  background: var(--bg-elevated);
}

/* Book v2.0 Reader */
.book-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 230px;
  gap: 1.25rem;
  align-items: start;
}
.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
}
.toc-btn {
  width: 100%;
  text-align: start;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.84rem;
  cursor: pointer;
}
.toc-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}
.toc-btn.active {
  background: var(--accent-gold-soft);
  color: var(--accent-gold-strong);
  border-color: var(--border-strong);
  font-weight: 700;
}
.book-prose {
  font-family: var(--font-serif-ar);
  font-size: 1.18rem;
  line-height: 2.02;
  color: var(--text-primary);
}
html[lang="en"] .book-prose.en-prose {
  font-family: var(--font-sans-en);
  font-size: 1.02rem;
  line-height: 1.75;
}
.book-prose h1,
.book-prose h2,
.book-prose h3 {
  color: var(--accent-gold-strong);
  line-height: 1.4;
  margin-top: 1.6em;
}
.book-prose pre,
.code-block {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  direction: ltr;
  text-align: left;
  background: var(--bg-canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  overflow-x: auto;
}

/* 28 Letter Periodic Bucket Grid & 28x28 OCP Heatmap */
.letter-bucket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.42rem;
}
.letter-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.45rem 0.3rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all 0.14s ease;
}
.letter-tile:hover,
.letter-tile.active {
  border-color: var(--accent-gold);
  background: var(--accent-gold-soft);
}
.letter-tile .char {
  font-family: var(--font-serif-ar);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-gold-strong);
  line-height: 1.1;
}
.letter-tile .cnt {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
}

.matrix-scroll {
  overflow: auto;
  max-width: 100%;
  max-height: 540px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}
.matrix-table {
  border-collapse: collapse;
  font-size: 0.72rem;
}
.matrix-table th,
.matrix-table td {
  border: 1px solid var(--border-subtle);
  padding: 0.22rem 0.3rem;
  text-align: center;
  min-width: 26px;
  height: 26px;
}
.matrix-table th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 2;
}
.matrix-cell-btn {
  width: 100%;
  height: 100%;
  min-height: 22px;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-primary);
}
.regime-res {
  background: rgba(52, 211, 153, 0.34);
}
.regime-neu {
  background: rgba(96, 165, 250, 0.18);
}
.regime-ten {
  background: rgba(251, 191, 36, 0.28);
}
.regime-blk {
  background: rgba(251, 113, 133, 0.32);
}

/* Lab 5-Law Switchboard & Score Bars */
.law-switch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 0.65rem;
}
.law-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  cursor: pointer;
  text-align: start;
}
.law-toggle.on {
  border-color: var(--accent-teal);
  background: var(--accent-teal-soft);
}
.meter-track {
  height: 8px;
  background: var(--bg-canvas);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 0.3rem;
}
.meter-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent-teal), var(--accent-gold));
  transition: width 0.22s ease;
}

/* MT Side-by-Side Sentence Reader & X-Ray Highlighting */
.sentence-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  padding: 0.8rem 0.95rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  border-bottom-color: var(--border-subtle);
  transition: background 0.14s ease, border-color 0.14s ease;
}
.sentence-pair:hover,
.sentence-pair.active {
  background: var(--bg-elevated);
  border-color: var(--border-teal);
}
.xray-term {
  display: inline;
  padding: 0.06rem 0.32rem;
  margin-inline: 0.06rem;
  border-radius: 5px;
  background: var(--accent-gold-soft);
  border-bottom: 2px solid var(--accent-gold);
  color: var(--accent-gold-strong);
  cursor: pointer;
}
.xray-badge {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  padding: 0.04rem 0.28rem;
  margin-inline-start: 0.22rem;
  border-radius: 4px;
  background: var(--accent-teal-soft);
  color: var(--accent-teal-strong);
  vertical-align: middle;
}

@media (max-width: 1120px) {
  .book-layout {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 820px) {
  .sentence-pair {
    grid-template-columns: 1fr;
  }
}
