/* Mechanism tap sandbox (Phase B) */

.mech-sandbox .mech-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.mech-sandbox .mech-title {
  margin: 0;
  font-size: 1.05rem;
}

.mech-step-banner {
  margin: 0;
  flex: 1 1 100%;
  font-size: 0.95rem;
  color: #3a4a5a;
  font-weight: 600;
}

.mech-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 800px) {
  .mech-workspace {
    grid-template-columns: 1fr;
  }
}

/* Canvas + worked answer share one column width so polish / Show answer /
   student stage all display the 400×300 SVG at the same CSS scale. */
.mech-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 480px;
  min-width: 0;
}

.mech-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.mech-stage {
  position: relative;
  width: 100%;
  background: #fff;
  border: 1px solid #c8d0d8;
  border-radius: 4px;
  overflow: hidden;
  touch-action: manipulation;
}

.mech-stage-label {
  margin: 0;
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #3a4a5a;
  background: #f0f3f6;
  border-bottom: 1px solid #c8d0d8;
}

.mech-stage-body {
  position: relative;
}

.mech-stage-done {
  opacity: 0.92;
}

.mech-stage-done .mech-hits {
  pointer-events: none;
  display: none;
}

.mech-stage-done .mech-stage-label {
  display: block;
}

.mech-stage-products {
  border-color: #8a9a7a;
  box-shadow: 0 0 0 1px rgba(70, 110, 70, 0.12);
}

.mech-stage-products .mech-stage-label {
  background: #e8f0e6;
  color: #2f4a32;
  border-bottom-color: #b8c8b4;
}

.mech-svg-host {
  display: block;
  line-height: 0;
}

.mech-svg-host svg {
  width: 100%;
  height: auto;
  display: block;
}

.mech-overlay-arrow {
  fill: none;
  stroke: #103CFF;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* Markers inherit fill from the referencing path in some browsers; keep heads solid. */
.mech-overlay marker path {
  fill: #103CFF;
  stroke: none;
}

/* Wide invisible stroke so the thin arrow is easy to click/tap to remove.
   Overlay sits above tap targets (z-index) so the arrow wins when they overlap. */
.mech-overlay-arrow-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 16;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
  cursor: pointer;
}

.mech-overlay-arrow-hit:hover {
  stroke: rgba(16, 60, 255, 0.16);
}

.mech-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
  overflow: visible;
}

.mech-hits {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  /* Empty space passes through; individual .mech-hit buttons stay clickable. */
  pointer-events: none;
}

.mech-hit {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 2px solid transparent;
  border-radius: 50%;
  background: rgba(30, 100, 180, 0.08);
  cursor: pointer;
  box-sizing: border-box;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.mech-hit.drag-sink-hover {
  background: rgba(30, 100, 180, 0.32);
  border-color: #1e64b4;
  transform: translate(-50%, -50%) scale(1.12);
}

.mech-overlay-arrow.mech-drag-preview {
  opacity: 0.55;
  stroke-dasharray: 5 4;
  pointer-events: none;
}

.mech-hit.bond {
  border-radius: 6px;
  width: 28px !important;
  height: 14px !important;
}

/* Mapped hydrogens (EAS ipso H, acidic H, …) — slightly stronger so they
   remain findable next to dense sigma-complex drawings. */
.mech-hit.hydrogen {
  background: rgba(30, 100, 180, 0.16);
  border-color: rgba(30, 100, 180, 0.35);
}

.mech-hit:hover,
.mech-hit:focus-visible {
  background: rgba(30, 100, 180, 0.22);
  border-color: #1e64b4;
  outline: none;
}

.mech-hit.pending-source {
  background: rgba(200, 120, 20, 0.35);
  border-color: #c87814;
}

/* Lone-pair taps: soft grey cloud + two Lewis dots. */
.mech-hit.lone_pair {
  background: rgba(90, 100, 115, 0.16);
  border-color: transparent;
}

/* One pseudo-element + box-shadow keeps both dots the same size
   (two separate circles + subpixel positions often look uneven).
   --lp-rot orients the pair perpendicular to the atom→LP radial
   (VSEPR / Lewis style) instead of always drawing •• horizontally. */
.mech-hit.lone_pair::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #3a4550;
  box-shadow: 6px 0 0 #3a4550; /* second identical dot along local +x */
  /* translate centres the 10px-wide pair, then rotate about that centre */
  transform: translate(-5px, -2px) rotate(var(--lp-rot, 0deg));
  transform-origin: 5px 2px;
  pointer-events: none;
}

.mech-hit.lone_pair::after {
  content: none;
}

.mech-hit.lone_pair:hover,
.mech-hit.lone_pair:focus-visible,
.mech-hit.lone_pair.drag-sink-hover {
  background: rgba(90, 100, 115, 0.28);
  border-color: #5a6473;
}

.mech-hit.lone_pair.pending-source {
  background: rgba(200, 120, 20, 0.35);
  border-color: #c87814;
}

.mech-hit.lone_pair.pending-source::before {
  background: #5a3a00;
  box-shadow: 6px 0 0 #5a3a00;
}

/* Radical taps: soft cloud + single Lewis-style unpaired electron. */
.mech-hit.radical {
  background: rgba(160, 60, 40, 0.14);
  border-color: transparent;
}

.mech-hit.radical::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: #8a2a18;
  pointer-events: none;
}

.mech-hit.radical::after {
  content: none;
}

.mech-hit.radical:hover,
.mech-hit.radical:focus-visible,
.mech-hit.radical.drag-sink-hover {
  background: rgba(160, 60, 40, 0.26);
  border-color: #a03c28;
}

.mech-hit.radical.pending-source {
  background: rgba(200, 120, 20, 0.35);
  border-color: #c87814;
}

.mech-hit.radical.pending-source::before {
  background: #5a3a00;
}

.mech-side h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

/* Collapsed by default so instructions stay out of the drawing area. */
.mech-howto {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  color: #5a6570;
}
.mech-howto summary {
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: #3a4a5a;
}
.mech-howto .help {
  margin: 0.5rem 0 0;
  line-height: 1.4;
}

.mech-arrow-list {
  min-height: 4rem;
  margin: 0 0 1rem;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.mech-arrow-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.2rem 0;
}

.mech-arrow-label {
  flex: 1 1 auto;
  min-width: 0;
}

.mech-arrow-remove {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  line-height: 1.3;
  color: #6a3a3a;
  background: #f7ecec;
  border: 1px solid #d8b0b0;
  border-radius: 3px;
  cursor: pointer;
}

.mech-arrow-remove:hover,
.mech-arrow-remove:focus-visible {
  color: #5a2020;
  background: #f0d8d8;
  border-color: #c07878;
  outline: none;
}

.mech-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.mech-actions button.primary {
  background: #1e64b4;
  color: #fff;
  border-color: #1e64b4;
}

.mech-pending {
  color: #8a5a00;
  font-size: 0.9rem;
}

.mech-warnings {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  font-size: 0.85rem;
  color: #6a4a00;
}

.mech-warnings li {
  margin: 0.25rem 0;
}

.mech-result {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.95rem;
}

.mech-result.ok {
  background: #e6f4ea;
  border: 1px solid #a8d5b5;
}

.mech-result.fail {
  background: #fce8e6;
  border: 1px solid #e6b4ae;
}

.mech-worked {
  margin: 0;
  padding-top: 0.75rem;
  border-top: 1px solid #c8d0d8;
}

.mech-worked-polish {
  margin: -0.25rem 0 0.65rem;
}

.mech-worked-polish-link {
  font-size: 0.85rem;
  font-weight: 600;
}

.mech-worked-panel {
  margin: 0 0 0.85rem;
  padding: 0;
  border: 1px solid #c8d0d8;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.mech-worked-panel figcaption {
  margin: 0;
  padding: 0.35rem 0.55rem;
  font-size: 0.85rem;
  font-weight: 600;
  background: #f0f3f6;
  border-bottom: 1px solid #c8d0d8;
}

.mech-worked-svg {
  line-height: 0;
  padding: 0.25rem;
}

.mech-worked-svg svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Arrow list sits below the worked SVG panels (Show answer). */
.mech-worked-arrows {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid #c8d0d8;
}
.mech-worked-arrows h4 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
}
.mech-worked-arrows-step {
  margin: 0 0 0.55rem;
}
.mech-worked-arrows-step-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #445;
  margin-bottom: 0.15rem;
}
.mech-worked-arrow-ol {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.85rem;
  line-height: 1.35;
}
.mech-worked-arrow-ol li {
  margin: 0.1rem 0;
}

.mech-result ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.mech-hits-feedback {
  list-style: none;
  padding-left: 0;
}

.mech-hit-fb {
  margin: 0.4rem 0;
  padding: 0.35rem 0.5rem;
  border-left: 3px solid #b55;
  background: rgba(180, 60, 40, 0.06);
}

.mech-hit-fb.severity-minor {
  border-left-color: #1e64b4;
  background: rgba(30, 100, 180, 0.06);
}
