/* Shared stylesheet for every publisher page (index.html, about.html, and the generated docs pages
   under apps/publisher/build/docs.ts). Served alongside the other static assets at /publish/styles.css.

   Pages that need a rule other pages don't apply a body class: `doc` for the generated docs pages,
   `about` for about.html. index.html has no body class — its rules are the unscoped base. */

/* Tokens: design-token palette, identical across every page, plus the dark-mode override. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #16181c;
  --muted: #626772;
  --border: #d7dbe0;
  --accent: #2f6feb;
  --accent-fg: #ffffff;
  --ok: #1a7f37;
  --err: #b4232c;
  --card: #f7f8fa;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101215;
    --fg: #e6e8eb;
    --muted: #9aa2ad;
    --border: #2a2e35;
    --accent: #4d84f0;
    --accent-fg: #ffffff;
    --ok: #4ac26b;
    --err: #f0616d;
    --card: #191c21;
  }
}

/* Base: page structure and shared elements every page starts from. Docs and about pages diverge on a
   few of these (main's width, the heading sizes, code's background) — those overrides are scoped to
   .doc / .about right next to the rule they change, rather than duplicating the whole rule. */
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  justify-content: center;
  padding: 6vh 20px;
}
main { width: 100%; max-width: 640px; }
.doc main { max-width: 720px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
.doc h1 { font-size: 1.6rem; margin: 0 0 6px; }
/* index.html's own h2 ("Your sites") is smaller and tighter than the docs/about long-form h2. */
h2 { font-size: 1rem; margin: 0 0 10px; }
.about h2 { font-size: 1.05rem; margin: 32px 0 4px; }
.doc h2 { font-size: 1.2rem; margin: 34px 0 8px; padding-top: 4px; }
.sub { color: var(--muted); margin: 0 0 28px; }
/* index.html leaves inline links at their default color; about/docs tint them to the accent. */
.about a, .doc a { color: var(--accent); }
code { background: var(--bg); padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border); }
.about code, .doc code { background: var(--card); font-size: 0.9em; }
.doc code { overflow-wrap: anywhere; }

.back { display: inline-block; margin-bottom: 20px; color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.back:hover { color: var(--accent); text-decoration: underline; }
.back-spaced { margin-top: 28px; }

/* App: rules unique to index.html — the sign-in/publish flow. */
/* Intro block: subheading sits tight under the h1, then the elevator-pitch line. */
h1 + .sub { margin-bottom: 8px; }
.pitch { margin: 0 0 28px; }
section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  background: var(--card);
}
label.field { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
}
button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  background: var(--accent);
  color: var(--accent-fg);
  cursor: pointer;
}
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 0.9rem; word-break: break-all; display: flex; align-items: center; gap: 8px; }
/* Signed-in shell: identity on the left, Sign out pushed to the right — one row */
.signed-in-row { display: flex; align-items: center; gap: 10px; }
.signed-in-row .who { flex: 1; min-width: 0; }
.signed-in-row #signout { flex-shrink: 0; }
.avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--border); }
#name-field { margin-top: 14px; }
#name-field .field { margin-top: 0; }
/* Staged-files panel: a scrollable list of the dropped files with a ✕ to clear the drop */
#file-list { margin-top: 14px; }
.file-list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
#file-list-count { font-weight: 600; font-size: 0.9rem; }
#file-list-items {
  list-style: none; margin: 0; padding: 0; max-height: 180px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
#file-list-items li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 5px 10px; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
#file-list-items li:last-child { border-bottom: 0; }
.file-path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.file-bytes { color: var(--muted); flex-shrink: 0; white-space: nowrap; }
#drop {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
#drop.hot { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
/* Sandboxed preview panel (§14): renders the just-built site before publish is enabled */
#preview { margin-top: 14px; }
.preview-head { font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
.preview-note { color: var(--muted); font-weight: 400; }
#preview-frame {
  width: 100%; height: 300px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg);
}
#status { margin: 4px 2px 0; min-height: 1.5em; }
#status.err { color: var(--err); }
.hidden { display: none !important; }

/* Handle typeahead dropdown */
.typeahead { position: relative; }
.suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 4px; list-style: none; z-index: 10;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14); max-height: 260px; overflow-y: auto;
}
.suggestions li {
  padding: 6px 9px; border-radius: 6px; cursor: pointer;
  display: flex; align-items: center; gap: 8px;
}
.suggestions li:hover, .suggestions li.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.suggestion-avatar {
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
  flex-shrink: 0; background: var(--border);
}
.suggestion-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* "Continue as" — one-click re-login with the last-used account, styled like a typeahead row */
#last-account { margin-bottom: 16px; }
.last-account-label { margin: 0 0 8px; font-weight: 600; }
.last-account-row { display: flex; align-items: center; gap: 8px; }
.last-account-row .account-chip { flex: 1; min-width: 0; }
.account-chip {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--fg); font: inherit; font-weight: 400;
  cursor: pointer; text-align: left;
}
.account-chip:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.signin-divider { color: var(--muted); font-size: 0.85rem; margin: 14px 0 0; }

/* "Updating an existing site" banner */
#update-banner {
  display: flex; align-items: center; gap: 10px; margin: 0 0 12px;
  padding: 8px 11px; border-radius: 8px; font-size: 0.9rem;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
#update-banner .grow { flex: 1; }
#update-banner button { padding: 4px 10px; font-size: 0.85rem; }

/* Version history (shown in update mode): prior deployments of the site being edited, each
   revertable by re-pointing the site record at that deployment. */
#version-history { margin: 0 0 12px; }
.vh-head { font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; }
#version-list { list-style: none; margin: 0; padding: 0; }
#version-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 2px; border-bottom: 1px solid var(--border); font-size: 0.88rem;
}
#version-list li:last-child { border-bottom: 0; }
.vh-when { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vh-current { color: var(--muted); font-size: 0.82rem; font-weight: 600; flex-shrink: 0; }
.vh-empty { color: var(--muted); font-size: 0.85rem; padding: 4px 2px; }
#version-list button { padding: 4px 10px; font-size: 0.82rem; flex-shrink: 0; }
/* Retention control: explicit, opt-in "keep newest N, delete the rest" prune (spec §16/§17.6). */
#retention { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
#retention label { font-size: 0.85rem; color: var(--muted); display: flex; align-items: center; gap: 6px; }
#retention-keep { width: 4em; padding: 4px 6px; font-size: 0.85rem; }
#retention button { padding: 4px 10px; font-size: 0.82rem; flex-shrink: 0; }
#retention-hint { color: var(--muted); font-size: 0.82rem; margin: 6px 0 0; }

/* Published-sites list */
/* Legacy-migration notice (see setSitesNotice in main.ts): the same inline-banner treatment as
   #update-banner, since both are "something is happening" notices scoped to their own section. */
#sites-notice {
  margin: 0 0 12px; padding: 8px 11px; border-radius: 8px; font-size: 0.9rem;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
#sites-notice.err { background: color-mix(in srgb, var(--err) 10%, transparent); color: var(--err); }
#sites { list-style: none; margin: 0; padding: 0; }
.site {
  display: flex; flex-direction: column; gap: 8px;
  padding: 9px 2px; border-bottom: 1px solid var(--border);
}
/* The header row: label at left, action buttons pinned right. Never wraps, so the icons keep
   a static position regardless of how long the site name or claimed slug URL is. */
.site-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.site:last-child { border-bottom: 0; }
.site-label { display: flex; flex: 1 1 auto; flex-wrap: wrap; align-items: baseline; gap: 6px; min-width: 0; }
.site-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; cursor: pointer; }
.site-name:hover { color: var(--accent); text-decoration: underline; }
.site-size { color: var(--muted); font-size: 0.82rem; font-weight: 400; flex-shrink: 0; white-space: nowrap; }
.site-slug { color: var(--accent); font-size: 0.82rem; font-weight: 400; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-slug:hover { text-decoration: underline; }
.site-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon {
  background: transparent; color: var(--fg); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 9px; font-size: 0.95rem; line-height: 1;
  text-decoration: none; display: inline-flex; align-items: center; cursor: pointer;
}
.icon:hover { border-color: var(--accent); color: var(--accent); }
.icon.danger:hover { border-color: var(--err); color: var(--err); }
.icon svg { display: block; width: 1em; height: 1em; }
/* Inline short-name (slug) editor, revealed under a site row by its tag action */
.slug-editor { display: flex; gap: 6px; width: 100%; margin-top: 8px; }
.slug-input {
  flex: 1; min-width: 0; padding: 6px 9px; font-size: 0.9rem;
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg); color: var(--fg); font-family: inherit;
}

/* Subtle footer link to the About / roadmap page */
.about-link { text-align: center; margin: 20px 0 0; font-size: 0.85rem; }
.about-link a { color: var(--muted); text-decoration: none; }
.about-link a:hover { color: var(--accent); text-decoration: underline; }

/* Optional mirror (BYO CDN / IPFS) config — collapsed disclosures so they don't dominate the flow */
#r2-config summary, #ipfs-config summary { font-weight: 600; cursor: pointer; list-style: revert; }
#r2-config .sub, #ipfs-config .sub { margin: 8px 0 14px; }
#r2-config .field, #ipfs-config .field { margin-top: 12px; }
#r2-config .field:first-of-type, #ipfs-config .field:first-of-type { margin-top: 0; }
#r2-status, #ipfs-status { color: var(--muted); font-size: 0.88rem; margin: 12px 2px 0; min-height: 1.4em; }
#r2-status.err, #ipfs-status.err { color: var(--err); }
#r2-status.ok, #ipfs-status.ok { color: var(--ok); }

/* Prose: long-form Markdown rendering, used by the generated docs pages (content-spec is table-heavy). */
h3 { font-size: 1.02rem; margin: 24px 0 6px; }
h4 { font-size: 0.95rem; margin: 20px 0 4px; color: var(--muted); }
p, li { overflow-wrap: anywhere; }

pre { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
pre code { background: none; border: none; padding: 0; font-size: 0.85em; }

blockquote { margin: 14px 0; padding: 2px 16px; border-left: 3px solid var(--border); color: var(--muted); }
blockquote p { margin: 8px 0; }

hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

ul, ol { padding-left: 22px; }
li { margin: 3px 0; }

table { border-collapse: collapse; width: 100%; margin: 14px 0; font-size: 0.92em; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
th { background: var(--card); font-weight: 600; }

.doc-list { list-style: none; padding: 0; margin: 8px 0 0; }
.doc-list li { margin: 0 0 16px; }
.doc-list a { font-weight: 600; font-size: 1.02rem; text-decoration: none; }
.doc-list a:hover { text-decoration: underline; }
.doc-list .item-desc { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }

/* Timeline: the roadmap's dot-and-line layout, used only by about.html. */
/* Legend for the timeline dot states */
.legend {
  display: flex; gap: 18px; flex-wrap: wrap;
  color: var(--muted); font-size: 0.85rem; margin: 6px 0 4px;
}
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend .dot { position: static; }

/* Vertical roadmap timeline: a single line running down the left edge, a status dot per row. */
.timeline { list-style: none; margin: 4px 0 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; top: 6px; bottom: 6px; left: 7px;
  width: 2px; background: var(--border);
}
.timeline li {
  position: relative; padding: 10px 0 10px 34px; min-height: 1em;
}
/* The dot sits on the vertical line. Filled (--ok) = done, hollow outline = planned. */
.dot {
  position: absolute; left: 0; top: 13px;
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--bg);
  box-sizing: border-box;
}
.done .dot { background: var(--ok); border-color: var(--ok); }
.planned .dot { background: var(--bg); border-color: var(--muted); }
.legend .done.dot { background: var(--ok); border-color: var(--ok); }
.legend .planned.dot { background: var(--bg); border-color: var(--muted); }

.item-title { font-weight: 600; }
.item-desc { color: var(--muted); font-size: 0.9rem; margin-top: 1px; }
.planned .item-title { color: var(--fg); }

.credit { color: var(--muted); font-size: 0.85rem; margin: 16px 0 0; }
.credit a { color: var(--muted); text-decoration: none; }
.credit a:hover { color: var(--accent); text-decoration: underline; }
