/* MSM Code help panel — built on the same tokens/type as css/style.css
   (--accent, --accent-dark, --green, --red, --border, --panel, --panel2,
   --text, --muted, and the "MakeStuffMove" display font). No separate
   palette or dark-mode switch: the app doesn't have one, so the help
   panel shouldn't either. */

.msm-help {
  --h-width: min(400px, 100vw);

  position: fixed;
  inset: 0 0 0 auto;
  width: var(--h-width);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  color: var(--text);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.25);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 220ms ease-out, visibility 0s linear 220ms;
}
.msm-help.is-open {
  transform: none;
  visibility: visible;
  transition: transform 220ms ease-out, visibility 0s;
}

/* ---- header (matches #topbar: dark chrome, red accent rule) ---- */
.msm-help__bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 10px 10px 18px;
  background: #141312;
  border-bottom: 3px solid var(--accent);
}
.msm-help__back:not([hidden]) + .msm-help__title { margin-left: 0; }
.msm-help__title {
  flex: 1;
  margin: 0;
  font-family: "MakeStuffMove", system-ui, sans-serif;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
}
.msm-help__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  transition: background 0.15s;
}
.msm-help__icon:hover { background: var(--accent-dark); }
.msm-help__icon svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.msm-help__back { margin-left: -4px; }
.msm-help__icon[hidden] { display: none; }

/* ---- body ---- */
.msm-help__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 40px;
  outline: none;
  background: var(--panel);
  color: var(--text);
}
.msm-help__body > p:first-child { font-size: 1.05rem; color: var(--muted); }
.msm-help__body p { margin: 0 0 12px; }
.msm-help__body h2 {
  font-family: "MakeStuffMove", system-ui, sans-serif;
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 26px 0 8px;
  line-height: 1.3;
}
.msm-help__body h3 { font-size: 0.95rem; font-weight: 700; margin: 20px 0 6px; }
.msm-help__body ul { margin: 0 0 12px; padding-left: 20px; }
.msm-help__body li { margin-bottom: 6px; }
.msm-help__body hr { border: 0; border-top: 1px solid var(--border); margin: 30px 0 0; }
.msm-help__body a { color: var(--accent); font-weight: 600; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.msm-help__body a:hover { color: var(--accent-dark); }
.msm-help__body code {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.88em;
  background: var(--panel2);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--text);
}
.msm-help__body :focus-visible,
.msm-help__icon:focus-visible,
.msm-help__action:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---- quickstart: numbered steps joined by a "wire" ---- */
.msm-help__body[data-page="quickstart"] { counter-reset: step; }
.msm-help__body[data-page="quickstart"] h2 {
  counter-increment: step;
  position: relative;
  padding-left: 42px;
  margin-top: 30px;
}
.msm-help__body[data-page="quickstart"] h2::before {
  content: counter(step);
  position: absolute;
  left: 0; top: -3px;
  width: 27px; height: 27px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-family: "MakeStuffMove", system-ui, sans-serif;
  font-size: 0.9rem;
}
/* everything under a step is indented and sits beside the wire */
.msm-help__body[data-page="quickstart"] h2 ~ p,
.msm-help__body[data-page="quickstart"] h2 ~ ul,
.msm-help__body[data-page="quickstart"] h2 ~ .msm-help__action,
.msm-help__body[data-page="quickstart"] h2 ~ .msm-help__note {
  margin-left: 13px;
  padding-left: 29px;
  border-left: 2px solid var(--border);
}
.msm-help__body[data-page="quickstart"] h2 ~ p { padding-bottom: 12px; margin-bottom: 0; }
/* the troubleshooting section after the rule is not a step */
.msm-help__body[data-page="quickstart"] hr ~ p,
.msm-help__body[data-page="quickstart"] hr ~ ul {
  margin-left: 0; padding-left: 0; border-left: 0;
}
.msm-help__body[data-page="quickstart"] hr ~ ul { padding-left: 20px; }

/* ---- action buttons (same shape/type as the toolbar's .btn.primary) ---- */
.msm-help__body p:has(> .msm-help__action) { padding-bottom: 16px; }
.msm-help__action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 16px;
  border: 2px solid var(--accent);
  border-radius: 0;
  background: var(--accent);
  color: #fff;
  font-family: "MakeStuffMove", system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.msm-help__action:hover:not(.is-done):not(.is-error) {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}
.msm-help__action.is-busy { cursor: progress; opacity: 0.75; }
.msm-help__action.is-busy::before {
  content: "";
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: msm-help-spin 0.8s linear infinite;
}
.msm-help__action.is-done {
  background: transparent;
  border-color: var(--green);
  color: var(--green);
  box-shadow: none;
}
.msm-help__action.is-done::before { content: "\2713"; }
.msm-help__action.is-error {
  background: transparent;
  border-color: var(--red);
  color: var(--red);
  box-shadow: none;
}

.msm-help__note {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
  padding-top: 6px;
}
.msm-help__note.is-error { color: var(--red); }

@keyframes msm-help-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .msm-help, .msm-help.is-open { transition: none; }
  .msm-help__action.is-busy::before { animation-duration: 2.4s; }
}
