/* Sites (items #5494, #5512; Plan #5493 — views/sites.js, its pages and the
   Sites pane). Per-view stylesheet, the routed-view convention: loaded from
   index.html after files.css so it inherits the entry's token palette.
   Tokens only, so both themes follow the app; colour carries meaning only
   (a site's state). The site page's header and Overview are the portal's
   own (wp-sites.css). */

/* == the Sites pane (#5512, views/panes/sites.js) ============================
   The panes/boards.js shape: head + a scope switch, then one line per site
   (a status dot and the name), group headings in All my sites, a legend at
   the foot. */
.mm-sites-scope {
  display: flex; gap: 2px; margin: 0 8px 8px; padding: 2px;
  background: var(--panel-2); border-radius: 8px;
}
.mm-sites-scope-btn {
  flex: 1; min-width: 0; padding: 5px 6px; border: 0; border-radius: 6px;
  font: inherit; font-size: 12px; color: var(--text-dim); background: none; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mm-sites-scope-btn:hover { color: var(--text); }
.mm-sites-scope-btn.on { color: var(--text); background: var(--panel); font-weight: 600; }
.mm-sites-scope-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.mm-sites-add { text-decoration: none; }
.mm-sites-group-head {
  margin: 12px 8px 2px; padding: 0 10px; font-size: 11px; font-weight: 600;
  color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mm-sites-group-head:first-child { margin-top: 2px; }
.mm-site-row {
  display: flex; align-items: center; gap: 9px; width: calc(100% - 16px); box-sizing: border-box;
  margin: 1px 8px; padding: 7px 10px; border-radius: 7px;
  color: var(--text-dim); font-size: 12.5px; text-decoration: none;
}
.mm-site-row:hover { color: var(--text); background: var(--panel-2); }
.mm-site-row.active { color: var(--accent-ink); background: var(--accent-soft); }
.mm-site-row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.mm-site-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The dot: filled for live/paused/error, hollow for nothing to see yet. */
.mm-site-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none; box-sizing: border-box;
  border: 1.5px solid var(--text-dim); background: none;
}
.mm-site-dot.tone-ok { background: var(--ok); border-color: var(--ok); }
.mm-site-dot.tone-warn { background: var(--warn); border-color: var(--warn); }
.mm-site-dot.tone-danger { background: var(--danger); border-color: var(--danger); }

.mm-sites-empty { padding: 4px 18px 8px; font-size: 12.5px; color: var(--text-dim); }
.mm-sites-empty p { margin: 0 0 6px; }
.mm-sites-first { color: var(--accent-ink); text-decoration: none; }
.mm-sites-first:hover { text-decoration: underline; }
.mm-sites-retry {
  padding: 0; border: 0; background: none; font: inherit; color: var(--accent-ink); cursor: pointer;
}
.mm-sites-note { margin: 10px 18px 0; font-size: 11.5px; color: var(--text-dim); }
.mm-sites-legend {
  display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 18px 8px 0; padding: 10px 10px 0;
  border-top: 1px solid var(--border-soft); font-size: 11px; color: var(--text-dim);
}
.mm-sites-legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }

/* == the bare route's landing (#5512, views/siteshome.js) ===================== */
.mm-siteshome { box-sizing: border-box; height: 100%; padding: 24px 36px; }

/* == site page (#5495, views/sitepage.js) =====================================
   A frame around the workspace app's own site page (site_detail/, styled by
   wp-sites.css), and the edit sheet. */
.mm-sitepage {
  box-sizing: border-box; height: 100%; min-height: 0; overflow-y: auto;
  padding: 28px 32px 40px; font-family: var(--sans);
}
.mm-sitepage-missing { padding: 24px 0; color: var(--text-dim); font-size: 14px; }
.mm-sitepage-body { min-width: 0; max-width: 1100px; margin: 0 auto; container-type: inline-size; }
.mm-sitepage-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mm-sitepage-edit, .mm-sitepage-discuss { white-space: nowrap; }
.mm-sitepage .sd-title-h { font-size: 26px; font-weight: 650; letter-spacing: -.025em; line-height: 1.3; }
.mm-sitepage .sd-primary-nav, .mm-sitepage .sd-secondary-nav { overflow-x: auto; }
@container (max-width: 760px) {
  .mm-sitepage .sd-head { flex-direction: column; gap: 14px; }
  .mm-sitepage .sd-head-actions { flex-wrap: wrap; max-width: 100%; }
  .mm-sitepage .sd-head-meta { row-gap: 6px; }
  .mm-sitepage .sd-ov-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .mm-sitepage .sd-ov-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
  .mm-sitepage .sd-fact, .mm-sitepage .sd-fact:first-child { padding: 14px 0; border-top: 1px solid var(--border-soft); }
}
@container (max-width: 380px) {
  .mm-sitepage .sd-ov-facts { grid-template-columns: minmax(0, 1fr); }
}

/* -- the edit sheet ------------------------------------------------------------ */
.mm-sitepage-sheet { display: flex; flex-direction: column; gap: 10px; }
.mm-sitepage-lead, .mm-sitepage-question { margin: 0; font-size: 13px; color: var(--text); }
.mm-sitepage-message {
  box-sizing: border-box; width: 100%; min-height: 250px; resize: vertical; padding: 10px 12px;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
}
.mm-sitepage-message:focus { outline: none; border-color: var(--accent); }
.mm-sitepage-setup { font-size: 12.5px; align-self: flex-start; }

@media (max-width: 1100px) {
  .mm-sitepage { padding: 16px 24px 24px; }
  .mm-siteshome { padding: 20px 24px; }
}

/* == new site how-to (#5496, views/sitenew.js) ================================
   Tabs per AI app, four numbered steps, and a side card. The connection
   steps inside step 2 are connectclients.js's own cn-* blocks, styled by
   wp-connect.css (loaded through app.css). */
.mm-sitenew {
  box-sizing: border-box; height: 100%; min-height: 0; overflow-y: auto;
  padding: 20px 36px 28px; font-family: var(--sans);
}
.mm-sitenew-head { margin-bottom: 18px; }
.mm-sitenew-title { font-size: 19px; font-weight: 700; margin: 0 0 4px; }
.mm-sitenew-sub { margin: 0; font-size: 13px; color: var(--text-dim); }
.mm-sitenew-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; align-items: start;
  max-width: 1080px;
}
.mm-sitenew-main { min-width: 0; }

/* -- the app tabs ------------------------------------------------------------ */
.mm-sitenew-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.mm-sitenew-tab {
  font: inherit; font-size: 13px; color: var(--text-dim); background: none;
  border: none; border-bottom: 2px solid transparent; margin-bottom: -1px;
  padding: 8px 12px; cursor: pointer; border-radius: 6px 6px 0 0;
}
.mm-sitenew-tab:hover { color: var(--text); }
.mm-sitenew-tab.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.mm-sitenew-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* -- the steps --------------------------------------------------------------- */
.mm-sitenew-steps { display: flex; flex-direction: column; gap: 22px; }
.mm-sitenew-connect { display: flex; flex-direction: column; gap: 22px; }
.mm-sitenew-step { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; }
.mm-sitenew-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; font-size: 12.5px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
}
.mm-sitenew-stepbody { min-width: 0; }
.mm-sitenew-steptitle { font-size: 14.5px; font-weight: 600; margin: 3px 0 8px; }
.mm-sitenew-text, .mm-sitenew-muted, .mm-sitenew-error, .mm-sitenew-ok {
  margin: 0 0 10px; font-size: 13px; line-height: 1.55;
}
.mm-sitenew-text { color: var(--muted); }
.mm-sitenew-muted { color: var(--text-dim); }
.mm-sitenew-error { color: var(--danger); }
.mm-sitenew-ok { color: var(--ok); }
.mm-sitenew-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.mm-sitenew-reveal { margin-top: -4px; }

/* -- step 3: the message ------------------------------------------------------ */
.mm-sitenew-label {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px;
  font-size: 12.5px; color: var(--muted);
}
.mm-sitenew-what {
  box-sizing: border-box; width: 100%; max-width: 360px; height: 34px; padding: 0 10px;
  font: inherit; font-size: 13.5px; color: var(--text);
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.mm-sitenew-what:focus { outline: none; border-color: var(--accent); }
.mm-sitenew-message {
  margin: 0 0 10px; padding: 12px; border-radius: 8px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border-soft);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.mm-sitenew-message.blank { color: var(--muted); }
.mm-sitenew-hint { margin: 0; font-size: 12px; color: var(--text-dim); }

/* -- step 4: watching for the site ------------------------------------------- */
.mm-sitenew-watch {
  padding: 12px 14px; border-radius: 8px;
  background: var(--panel-2); border: 1px solid var(--border-soft);
}
.mm-sitenew-watch.ok { background: var(--ok-soft); }
.mm-sitenew-watch > :last-child { margin-bottom: 0; }
.mm-sitenew-result {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px;
  margin: 0 0 6px; font-size: 13.5px; color: var(--text);
}
.mm-sitenew-watch.ok .mm-sitenew-result { margin-bottom: 10px; }
.mm-sitenew-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.mm-sitenew-dot.ok { background: var(--ok); }
.mm-sitenew-dot.pulse { background: var(--accent); animation: mm-sitenew-pulse 1.6s ease-in-out infinite; }
@keyframes mm-sitenew-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .mm-sitenew-dot.pulse { animation: none; } }
.mm-sitenew-open { text-decoration: none; }

/* -- the side cards ------------------------------------------------------------ */
.mm-sitenew-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.mm-sitenew-card {
  padding: 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--border);
}
.mm-sitenew-card[hidden] { display: none; }
.mm-sitenew-card-title { font-size: 13.5px; font-weight: 600; margin: 0 0 8px; }
.mm-sitenew-card-text { margin: 0 0 12px; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.mm-sitenew-asklist { list-style: none; margin: 0; padding: 0; }
.mm-sitenew-askrow {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 0;
  font-size: 12.5px; line-height: 1.45; color: var(--text);
  border-top: 1px solid var(--border-soft);
}
.mm-sitenew-askrow:first-child { border-top: none; padding-top: 2px; }
.mm-sitenew-askrow span { flex: 1; min-width: 0; }
.mm-sitenew-askcopy { flex: none; padding: 2px 8px; font-size: 12px; }

/* -- narrow: one column ------------------------------------------------------- */
@media (max-width: 980px) {
  .mm-sitenew { padding: 14px 20px 24px; }
  .mm-sitenew-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 480px) {
  .mm-sitenew { padding: 12px 16px 20px; }
  .mm-sitenew-step { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .mm-sitenew-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .mm-sitenew-tab { flex: none; }
}
