/* Qubit Playground — sim-specific styles.
   Design tokens, reset and page chrome come from /shared/base.css. */

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: 16px;
  align-items: start;
  margin: 18px 0 28px;
}
.col { display: grid; gap: 16px; min-width: 0; }

@media (max-width: 900px) {
  .workbench { grid-template-columns: 1fr; }
}

.card.stage-card { padding: 8px 8px 12px; }

/* -------------------------------------------------------- bloch stage */

.stage { position: relative; width: 100%; aspect-ratio: 1 / 1; max-height: 62vh; }
.stage canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.stage canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }

.stage-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center; justify-content: space-between;
  padding: 0 6px; font-size: .8rem; color: var(--muted);
}
.stage-bar kbd {
  font-family: var(--mono); font-size: .74rem; background: var(--bg-raised);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--text);
}

.flash {
  position: absolute; inset: 0; display: grid; place-items: center;
  pointer-events: none; opacity: 0; transition: opacity .18s ease;
}
.flash.on { opacity: 1; }
.flash b {
  font-family: var(--mono); font-size: clamp(2.2rem, 9vw, 4rem); font-weight: 700;
  padding: .1em .35em; border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border: 2px solid currentColor;
}
.flash.zero b { color: var(--good); }
.flash.one b { color: var(--warn); }

/* ------------------------------------------------------------- gates */

.gates { display: flex; flex-wrap: wrap; gap: 7px; }
.gate {
  position: relative; min-width: 44px; text-align: center;
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; cursor: pointer;
  font-family: var(--mono); font-weight: 600; letter-spacing: .02em;
  transition: border-color .12s ease, background .12s ease, transform .06s ease;
}
.gate:hover { border-color: var(--accent); }
.gate:active { transform: translateY(1px); }
.gate[disabled] { opacity: .45; cursor: not-allowed; transform: none; }
.gate.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.matrix-pop {
  position: fixed; z-index: 40; pointer-events: none;
  background: var(--bg-raised); border: 1px solid var(--accent-dim);
  border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow);
  font-family: var(--mono); font-size: .78rem; color: var(--text);
  opacity: 0; transition: opacity .1s ease; max-width: 88vw;
}
.matrix-pop.on { opacity: 1; }
.matrix-pop table { border-collapse: collapse; }
.matrix-pop td { padding: 1px 7px; text-align: right; white-space: nowrap; }
.matrix-pop .mtitle { color: var(--muted); font-family: var(--sans); margin-bottom: 4px; font-size: .75rem; }
.matrix-pop .brk { color: var(--accent); font-size: 1.9em; line-height: .8; vertical-align: middle; }

.rot { display: grid; gap: 8px; margin-top: 12px; }
.rot-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rot-row label { color: var(--muted); font-size: .85rem; }
.rot-row input[type="range"] { flex: 1 1 150px; min-width: 120px; accent-color: var(--accent); }
.rot-angle { font-family: var(--mono); min-width: 4.6em; text-align: right; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button {
  background: var(--bg-raised); border: 0; border-right: 1px solid var(--line);
  padding: 7px 11px; cursor: pointer; font-family: var(--mono);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #04121b; font-weight: 600; }
@media (prefers-color-scheme: light) { .seg button[aria-pressed="true"] { color: #fff; } }


/* ------------------------------------------------------------ history */

.history-strip {
  margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px;
  overflow-x: auto; scrollbar-width: thin;
}
.circuit { display: flex; align-items: center; gap: 0; min-height: 44px; padding: 2px 0; }
.circuit .q { font-family: var(--mono); color: var(--muted); font-size: .85rem; padding-right: 6px; white-space: nowrap; }
.circuit .wire { height: 1px; background: var(--line); flex: 0 0 14px; }
.circuit .wire.grow { flex: 1 1 auto; min-width: 18px; }
.circuit .hgate {
  font-family: var(--mono); font-size: .82rem; font-weight: 600;
  border: 1px solid var(--accent-dim); background: var(--bg-raised);
  border-radius: 6px; padding: 5px 7px; white-space: nowrap;
}
.circuit .hgate.last { border-color: var(--accent); }
.circuit .hgate.meas { border-color: var(--warn); color: var(--warn); }
.circuit .empty { color: var(--muted); font-size: .85rem; }

/* -------------------------------------------------------- state panel */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: .84rem; }
.kv dd { margin: 0; font-family: var(--mono); font-size: .86rem; overflow-wrap: anywhere; }
.kv dd.hl { color: var(--accent); }

.probbar { height: 8px; border-radius: 4px; background: var(--bg-raised); overflow: hidden; display: flex; margin: 10px 0 4px; }
.probbar i { display: block; height: 100%; width: 0; }
.probbar i.p0 { background: var(--good); }
.probbar i.p1 { background: var(--warn); }
.problabels { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); font-family: var(--mono); }

.phasors { display: flex; gap: 14px; margin-top: 12px; }
.phasor { text-align: center; }
.phasor canvas { width: 84px; height: 84px; display: block; }
.phasor figcaption { font-size: .74rem; color: var(--muted); font-family: var(--mono); margin-top: 2px; }

.pulse { animation: pulse .6s ease; }
@keyframes pulse { 0% { background: var(--accent-dim); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* ------------------------------------------------------- measurement */

.hist { margin-top: 12px; }
.hist-rows { display: grid; gap: 8px; }
.hist-row { display: grid; grid-template-columns: 3.4em 1fr 5.6em; gap: 8px; align-items: center; }
.hist-row .lbl { font-family: var(--mono); font-size: .85rem; }
.hist-track { position: relative; height: 22px; background: var(--bg-raised); border-radius: 5px; overflow: hidden; }
.hist-fill { height: 100%; width: 0; border-radius: 5px; transition: width .09s linear; }
.hist-fill.p0 { background: var(--good); }
.hist-fill.p1 { background: var(--warn); }
.hist-theory {
  position: absolute; top: -2px; bottom: -2px; width: 0;
  border-right: 2px dashed var(--text); opacity: .75;
}
.hist-row .num { font-family: var(--mono); font-size: .82rem; text-align: right; color: var(--muted); }

/* ----------------------------------------------------------- lessons */

.lesson { border: 1px solid var(--line); border-radius: 8px; background: var(--bg-raised); margin-bottom: 8px; }
.lesson > summary {
  cursor: pointer; padding: 9px 11px; font-weight: 600; font-size: .92rem;
  list-style: none; display: flex; gap: 8px; align-items: baseline;
}
.lesson > summary::-webkit-details-marker { display: none; }
.lesson > summary::before { content: "▸"; color: var(--accent); font-size: .8em; }
.lesson[open] > summary::before { content: "▾"; }
.lesson-body { padding: 0 11px 11px; border-top: 1px solid var(--line); }
.step { padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.step:last-child { border-bottom: 0; }
.step p { margin: 0 0 7px; }
.step .num { color: var(--accent); font-family: var(--mono); font-size: .78rem; margin-right: 4px; }
.step code { font-family: var(--mono); font-size: .88em; background: var(--bg-panel); padding: 1px 4px; border-radius: 4px; }


/* ------------------------------------------------------- embed mode */

body.embed .prose, body.embed .serieslinks, body.embed .topnav .hide-embed { display: none; }
body.embed .topbar { padding: 8px 0; }
body.embed .workbench { margin-top: 10px; }

.hist .hist-note { margin-top: 8px; }
