/* The Modules page (modules.html). The tokens, the app bar (`header`), the base `button`,
   `.primary-btn` and the module list (`.modules-*`) come from style.css, which this page loads
   first; only what is particular to the page is here. */

/* The app hides with a `.hidden` class; this page uses the attribute, which a display rule on
   any class would otherwise outrank. */
[hidden] { display: none !important; }

/* ---------- Page frame ---------- */
body.mp { min-height: 100vh; background: var(--bg); }
/* Until modules-page.js has confirmed the writer is signed in, only the bar is drawn: a
   visitor about to be sent to sign in is not shown an empty workbench. */
.mp[data-state="checking"] > .mp-tabs, .mp[data-state="checking"] > .mp-main { visibility: hidden; }
.mp-brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.mp-brand img { height: 22px; width: auto; display: block; }
.mp-brand-sub {
  padding: 1px 8px; border: 1px solid var(--border-strong); border-radius: 10px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim);
}
.mp-spacer { flex: 1; }
.mp-back { font-size: 13px; color: var(--accent); text-decoration: none; }
.mp-back:hover { text-decoration: underline; }

.mp-tabs {
  display: flex; gap: 4px; height: 44px; padding: 0 24px; overflow-x: auto;
  background: var(--chrome-bg); border-bottom: 1px solid var(--border);
}
.mp-tab {
  padding: 0 14px; white-space: nowrap;
  border: none; border-bottom: 2px solid transparent; border-radius: 0;
  background: transparent; color: var(--text-dim); font-size: 14px;
}
.mp-tab:hover { background: var(--tint); color: var(--text); border-color: transparent; border-bottom-color: var(--border-strong); }
.mp-tab[aria-selected="true"],
.mp-tab[aria-selected="true"]:hover { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
.mp-tab-count { margin-left: 4px; font-size: 12px; font-weight: 400; color: var(--text-dim); }

.mp-main { padding: 20px 24px 56px; }
.mp-section { max-width: 1440px; margin: 0 auto; }
.mp-narrow { max-width: 760px; }
.mp-error {
  max-width: 1440px; margin: 0 auto 14px; padding: 10px 14px; border-radius: 6px;
  background: var(--accent-light); color: var(--accent-800); font-size: 14px;
}

/* ---------- What a module is, and how building one works ---------- */
.mp-intro { margin-bottom: 16px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.mp-intro h2 { margin: 0 0 8px; font-size: 19px; }
.mp-intro p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.55; max-width: 120ch; }
.mp-howto { margin: 0; padding-left: 22px; font-size: 14px; line-height: 1.55; }
.mp-howto li { margin: 3px 0; }
.mp-numbered { margin: 0 0 10px; padding-left: 22px; font-size: 14px; line-height: 1.5; }
.mp-numbered > li { margin: 0 0 10px; }
.mp-numbered .mp-copy-row, .mp-numbered .mp-tools { margin-top: 6px; }
.mp-plain-list { margin: 0 0 14px; padding-left: 20px; font-size: 14px; line-height: 1.55; }
.mp-plain-list li { margin: 3px 0; }

/* ---------- Steps ---------- */
.mp-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.mp-step { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.mp-step h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; font-size: 17px; }
.mp-step p { margin: 0 0 10px; font-size: 14px; line-height: 1.5; }
.mp-step-n {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: none;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; font-weight: 600;
}
.mp-small { font-size: 13px !important; color: var(--text-dim); }
.mp-subhead { margin: 14px 0 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.mp-empty { margin: 0; font-size: 13px; color: var(--text-dim); }

.mp-copy-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 10px; }
.mp-code {
  flex: 1; min-width: 0; padding: 7px 10px; overflow-wrap: anywhere;
  font-size: 13px; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
}
.mp-copy { flex: none; padding: 5px 12px; font-size: 13px; }
.mp-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.mp-tool { padding: 4px 11px; font-size: 13px; border-radius: 999px; }
.mp-tool[aria-selected="true"], .mp-tool[aria-selected="true"]:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent-800); }
.mp-tool-steps { padding: 10px 12px 2px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface2); }
.mp-tool-steps p { font-size: 13.5px; }
.mp-paste-text {
  display: block; width: 100%; box-sizing: border-box; margin: 6px 0 8px; padding: 6px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 4px;
}
.mp-connections { margin: 0; padding-left: 18px; font-size: 13px; }
.mp-connections li { margin: 2px 0; }

.mp-starters { list-style: none; margin: 0; padding: 0; }
.mp-starter {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; margin-bottom: 6px;
  font-size: 13.5px; line-height: 1.45; border: 1px solid var(--border); border-radius: 6px;
}
.mp-starter span { flex: 1; }

/* ---------- Drafts and the preview ---------- */
.mp-bench { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.mp-drafts .mp-subhead { margin-top: 0; }
.mp-draft-list { list-style: none; margin: 0; padding: 0; }
.mp-draft {
  display: block; width: 100%; padding: 8px 10px; margin-bottom: 6px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.mp-draft[aria-current="true"] { border-color: var(--accent); background: var(--accent-light); }
.mp-draft-name { display: block; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.mp-draft-meta { display: block; font-size: 12px; color: var(--text-dim); overflow-wrap: anywhere; }

.mp-preview { min-width: 0; }
.mp-preview-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.mp-preview-title { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.mp-btn { padding: 6px 14px; font-size: 13px; white-space: nowrap; }
.mp-frame { display: block; width: 100%; height: 640px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--bg); }
.mp-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mp-pre {
  margin: 0; padding: 8px 10px; min-height: 2.6em; white-space: pre-wrap; overflow-wrap: anywhere;
  font-size: 12.5px; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px;
}
.mp-status { margin: 10px 0 0; font-size: 14px; white-space: pre-wrap; }

/* ---------- Adding a module file yourself ---------- */
.mp-addfile {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px;
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
}
.mp-addfile h3 { margin: 0 0 8px; font-size: 16px; }
.mp-addfile p { font-size: 14px; }
.mp-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 110px; padding: 16px; text-align: center; cursor: pointer; font-size: 14px;
  border: 2px dashed var(--border-strong); border-radius: 8px; background: var(--surface2); color: var(--text-dim);
}
.mp-drop strong { color: var(--text); }
.mp-drop:hover, .mp-drop:focus-visible, .mp-drop.is-over { border-color: var(--accent); background: var(--accent-light); color: var(--text); outline: none; }
.mp-addfile-do label { display: block; margin-top: 12px; }
.mp-addfile-do .mp-pre { margin-top: 10px; }

@media (max-width: 900px) {
  .mp-main { padding: 16px 16px 40px; }
  .mp-tabs { padding: 0 16px; }
  .mp-steps, .mp-bench, .mp-results, .mp-addfile { grid-template-columns: minmax(0, 1fr); }
  .mp-frame { height: 520px; }
}
