/* QUANTUM LABS — State Analyzer Page */

.sa {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Sa Controls */
.sa-controls {
  display: block;
  background: var(--carbon);
  overflow-y: auto;
  border-right: 1px solid var(--wire);
}

/* Sa Output */
.sa-output {
  display: block;
  padding: var(--sp-6);
  background: var(--obsidian);
  grid-column: 2;
  grid-row: 1;
  overflow-y: auto;
}
.sa-output .sa-card:not(:last-child) {
  margin-bottom: var(--sp-4);
}

/* Sidebar hint text */
.sa-hint {
  display: block;
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--ash);
}

/* Disabled gate grid */
.sa-disabled { opacity: 0.35; pointer-events: none; }

/* Multi-gate span */
.sa-gate-multi { grid-column: span 1; }

/* Output cards */
.sa-card {
  background: var(--carbon);
  border: 1px solid var(--wire);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* Sa Card Result */
.sa-card-result { border-color: var(--ember); }

/* Sa Card Head */
.sa-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--wire);
}

/* Sa Card Result */
.sa-card-result .sa-card-head {
  background: var(--ember-06);
  border-bottom-color: var(--ember-30);
}

/* Sa Step Num */
.sa-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 20px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1;
  color: var(--ember);
  background: var(--ember-10);
  border-radius: 4px;
}

/* Sa Step Title */
.sa-step-title {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--bone);
}

/* Sa Card Body */
.sa-card-body { padding: 16px 20px; }

/* Accordion */
.sa-toggle { transition: background 0.15s; cursor: pointer; user-select: none; }

/* Sa Toggle */
.sa-toggle:hover { background: var(--white-03); }

/* Ql Chevron */
.ql-chevron {
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2;
  transition: transform 0.2s ease, stroke 0.2s ease;
  width: 16px;
  height: 16px;
}

/* Sa Card Head */
.sa-card-head:hover .ql-chevron { stroke: var(--ember); }

/* Sa Card */
.sa-card:not(.sa-open) .ql-chevron { transform: rotate(-90deg); }
.sa-card:not(.sa-open) .sa-card-head { border-bottom-color: transparent; }

/* Sa Collapsible */
.sa-collapsible {
  transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
  overflow: hidden;
}

/* Sa Collapsed */
.sa-collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; opacity: 0; }

/* Math blocks */
.sa-math-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Sa Math Block */
.sa-math-block {
  flex: 1;
  min-width: 180px;
  padding: 12px 16px;
  text-align: center;
  background: var(--graphite);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}
.sa-math-block.sa-full { flex-basis: 100%; }
.sa-math-block .sa-math-caption {
  display: block;
  margin-bottom: 8px;
  font-size: var(--text-xs);
  color: var(--ash);
  letter-spacing: 0.5px;
}
.sa-math-block .sa-math-caption .katex {
  font-size: 1em !important;
}
.sa-math-block .sa-math-content { min-height: 24px; }
.sa-math-block .sa-math-content .katex { font-size: 0.9em; }

/* Circuit preview wires */
.sa-wire-row {
  position: relative;
  display: flex;
  align-items: center;
  height: 36px;
}

/* Sa Wire Label */
.sa-wire-label {
  width: 44px;
  padding-right: 10px;
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--ash);
  text-align: right;
  transform: translateY(-2px); /* Optically adjust KaTeX baseline to match wire */
  flex-shrink: 0;
}

/* Sa Wire Line */
.sa-wire-line {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  height: 1px;
  background: var(--wire-light);
}

/* Sa Wire Gate */
.sa-wire-gate {
  position: relative;
  z-index: var(--z-top);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: 40px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: normal;
  color: var(--bone);
  background: var(--carbon);
  border: 1px solid var(--wire);
  border-radius: 2px;
  flex-shrink: 0;
}
.sa-wire-gate .katex {
  font-size: 1em !important;
}

/* Sa Wire Ctrl */
.sa-wire-ctrl {
  position: relative;
  z-index: var(--z-top);
  width: 12px;
  height: 12px;
  margin-left: 50px;
  background: var(--bone);
  border-radius: 50%;
  flex-shrink: 0;
}

/* Sa Wire Conn */
.sa-wire-conn {
  position: absolute;
  z-index: var(--z-elevated);
  width: 1px;
  background: var(--wire-light);
}

/* Circuit preview card body */
.sa-circuit-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 24px;
}

/* Result step — highlighted Dirac block */
.sa-math-block--result {
  border-left: 3px solid var(--ember);
}

/* Responsive */
@media (max-width: 900px) {
  .sa {
    display: flex;
    flex-direction: column;
    overflow-y: auto !important;
  }

  /* Sa Output */
  .sa-output {
    overflow-y: visible;
    padding: var(--sp-4);
    padding-bottom: 80px; /* Space for the FAB */
  }

  /* Make sure math blocks can shrink or wrap on tiny screens */
  .sa-math-row {
    flex-direction: column;
  }

  /* Sa Math Block */
  .sa-math-block {
    width: 100%;
    min-width: 0;
  }
}
