/* Rigfile registry — a plain, server-rendered site (CSP: no script, no inline style, images only from
   this origin and GitHub avatars). All "modern" affordances below are CSS-only: no icon fonts, no
   background-image assets (data: URIs are blocked by the img-src policy on purpose). */

:root {
  color-scheme: light dark;
  --fg: #1f2328;
  --fg-muted: #59636e;
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-inset: #eef1f4;
  --line: #d1d9e0;
  --line-strong: #b6bec6;
  --accent: #0969da;
  --accent-emphasis: #0550ae;
  --accent-subtle: #ddf1ff;
  --warn: #9a6700;
  --warn-fg: #7d4e00;
  --warn-bg: #fff8c5;
  --warn-line: #f0d878;
  --bad: #cf222e;
  --bad-fg: #a40e26;
  --bad-bg: #ffebe9;
  --bad-line: #ffc1bc;
  --ok: #1a7f37;
  --ok-fg: #116329;
  --ok-bg: #dafbe1;
  --ok-line: #aceebb;
  --code-bg: #f6f8fa;
  --shadow-sm: 0 1px 0 rgba(31, 35, 40, 0.04);
  --shadow-card: 0 1px 3px rgba(31, 35, 40, 0.07), 0 1px 2px rgba(31, 35, 40, 0.05);
  --radius: 8px;
  --radius-sm: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6edf3;
    --fg-muted: #9aa7b4;
    --bg: #0d1117;
    --bg-subtle: #161b22;
    --bg-inset: #1c2129;
    --line: #30363d;
    --line-strong: #3d444d;
    --accent: #4493f8;
    --accent-emphasis: #79c0ff;
    --accent-subtle: #0d2d4d;
    --warn: #d29922;
    --warn-fg: #e3b341;
    --warn-bg: #2b2111;
    --warn-line: #4d3c14;
    --bad: #f85149;
    --bad-fg: #ff7b72;
    --bad-bg: #2c1214;
    --bad-line: #572426;
    --ok: #3fb950;
    --ok-fg: #56d364;
    --ok-bg: #12261b;
    --ok-line: #23422f;
    --code-bg: #161b22;
    --shadow-sm: 0 1px 0 rgba(0, 0, 0, 0.15);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.55 -apple-system, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
}
h1, h2, h3 { line-height: 1.25; font-weight: 600; margin: 1.4em 0 0.6em; }
h1 { font-size: 1.7em; margin-top: 0; }
h2 { font-size: 1.25em; padding-bottom: 0.3em; border-bottom: 1px solid var(--line); }
h3 { font-size: 1.05em; margin-bottom: 0.3em; }
p { margin: 0.6em 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-subtle); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- layout ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 28px; padding-bottom: 64px; min-height: 50vh; }

/* ---------- header ---------- */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
header.top .wrap { display: flex; align-items: center; gap: 18px; padding: 12px 20px; flex-wrap: wrap; }
a.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 1.05em; color: var(--fg); flex-shrink: 0; }
a.brand:hover { text-decoration: none; }
a.brand .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--fg); color: var(--bg);
  font-size: 13px; font-weight: 700;
}
form.search { flex: 1; min-width: 160px; max-width: 480px; display: flex; gap: 8px; }
form.search input[type=search] {
  flex: 1; min-width: 0; background: var(--bg-subtle);
}
form.search input[type=search]:focus { background: var(--bg); }
.navlinks { display: flex; align-items: center; gap: 14px; margin-left: auto; font-size: 14px; }
.navlinks form { margin: 0; }
.who { display: inline-flex; align-items: center; gap: 6px; color: var(--fg); }

/* ---------- buttons & form controls ---------- */
input, select, textarea {
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 10px;
}
textarea { width: 100%; max-width: 560px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label { display: block; margin: 0.5em 0; font-size: 14px; }
label input, label select, label textarea { margin-top: 4px; }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-weight: 500; font-size: 14px; line-height: 20px;
  padding: 5px 14px; margin: 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg-subtle); color: var(--fg);
  cursor: pointer; transition: background-color 100ms, border-color 100ms;
}
button:hover, .btn:hover { background: var(--bg-inset); text-decoration: none; }
button:active, .btn:active { background: var(--line); }
button.primary, .btn.primary {
  background: var(--accent); border-color: var(--accent-emphasis); color: #fff;
}
button.primary:hover, .btn.primary:hover { background: var(--accent-emphasis); }
button.danger { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad-fg); }
button.danger:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
button.link, a.link {
  background: none; border: 0; color: var(--accent); padding: 0; font: inherit; cursor: pointer;
}
button.link:hover, a.link:hover { text-decoration: underline; }
form.inline { display: inline; margin: 0 0 0 10px; }

/* ---------- text helpers ---------- */
.muted { color: var(--fg-muted); }
.warn { color: var(--warn-fg); }
.bad { color: var(--bad-fg); }
.ok { color: var(--ok-fg); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- badges/tags ---------- */
.tag {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 1px 10px; font-size: 12px; font-weight: 500;
  color: var(--fg-muted); background: var(--bg-subtle);
  margin-right: 4px; line-height: 18px; white-space: nowrap;
}
.tag.ok { color: var(--ok-fg); background: var(--ok-bg); border-color: var(--ok-line); }
.tag.warn { color: var(--warn-fg); background: var(--warn-bg); border-color: var(--warn-line); }
.tag.bad { color: var(--bad-fg); background: var(--bad-bg); border-color: var(--bad-line); }

.trust-pub { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }

/* ---------- avatars ---------- */
.avatar { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); vertical-align: middle; }
.identicon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7em; height: 1.7em; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 0.85em;
  text-transform: uppercase; vertical-align: middle; flex-shrink: 0;
}
.identicon.lg { width: 56px; height: 56px; font-size: 1.4em; }

/* ---------- cards ---------- */
.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); box-shadow: var(--shadow-sm);
  padding: 14px 16px; margin: 14px 0;
}
.card h3 { margin: 0 0 4px; }
.card > strong:first-child { display: block; margin-bottom: 8px; font-size: 14px; }
.card + .card { margin-top: 14px; }

/* rig list rows (search, home, profile, collections) */
.rig-list { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 14px 0; }
.rig-row {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 16px; border-bottom: 1px solid var(--line);
}
.rig-list .rig-row:last-child { border-bottom: none; }
.rig-row:hover { background: var(--bg-subtle); }
.rig-row h3 { margin: 0 0 4px; font-size: 15px; }
.rig-row .desc { color: var(--fg-muted); font-size: 14px; margin: 2px 0 6px; }
.rig-row .meta { flex-shrink: 0; text-align: right; font-size: 13px; color: var(--fg-muted); white-space: nowrap; }
.empty { padding: 32px 16px; text-align: center; color: var(--fg-muted); }

/* ---------- repo header (rig page) ---------- */
.repo-head { padding-bottom: 16px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.repo-head .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.repo-head h1 { margin: 0; font-size: 1.5em; word-break: break-word; }
.repo-head h1 .sep { color: var(--fg-muted); font-weight: 400; padding: 0 2px; }
.repo-head .desc { margin-top: 6px; color: var(--fg-muted); }
.repo-head h1.with-avatar { display: flex; align-items: center; gap: 12px; }
.repo-head .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- two-column layout ---------- */
.grid { display: grid; grid-template-columns: 1fr 296px; gap: 32px; align-items: start; }
@media (max-width: 780px) { .grid { grid-template-columns: 1fr; } }
aside .card:first-child { margin-top: 0; }

/* ---------- code ---------- */
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code {
  background: var(--code-bg); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 6px; font-size: 13px;
}
pre {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; overflow: auto; font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
pre code { background: none; border: 0; padding: 0; }
.hero-cmd { max-width: 640px; }
.hero-cmd pre { background: var(--fg); border-color: var(--fg); border-radius: var(--radius); }
@media (prefers-color-scheme: dark) { .hero-cmd pre { background: #010409; border-color: var(--line); } }
.hero-cmd code { color: #d1f7c4; background: none; }

/* ---------- numbered step lists (quickstart) ---------- */
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 16px 0; }
ol.steps > li { counter-increment: step; position: relative; padding-left: 40px; margin: 18px 0; }
ol.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--bg-inset); color: var(--fg); font-weight: 600; font-size: 13px;
}
ol.steps > li p { margin: 0 0 6px; }
ol.steps > li pre { margin: 0; max-width: 560px; }

/* ---------- tables ---------- */
table {
  border-collapse: collapse; width: 100%; font-size: 14px;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th, tr:first-child th { background: var(--bg-subtle); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-subtle); }

/* ---------- banners / alerts ---------- */
.banner {
  border: 1px solid var(--line); border-left: 4px solid var(--fg-muted);
  border-radius: var(--radius-sm); background: var(--bg-subtle);
  padding: 10px 14px; margin: 14px 0;
}
.banner.warn { border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn-fg); }
.banner.bad { border-left-color: var(--bad); background: var(--bad-bg); color: var(--bad-fg); }
.banner ul { margin: 6px 0 0; padding-left: 1.2em; }
.banner strong { display: block; margin-bottom: 2px; }

/* ---------- diff ---------- */
table.diff { font-size: 13px; }
table.diff td { padding: 5px 10px; }
table.diff td.mark { width: 1.4em; text-align: center; font-weight: 700; font-family: ui-monospace, monospace; }
tr.added td.mark { color: var(--ok-fg); } tr.added { background: color-mix(in srgb, var(--ok-bg) 45%, transparent); }
tr.removed td.mark { color: var(--bad-fg); } tr.removed { background: color-mix(in srgb, var(--bad-bg) 45%, transparent); }
tr.changed td.mark { color: var(--warn-fg); }
pre.udiff { padding: 0; }
pre.udiff span { display: block; padding: 1px 14px; white-space: pre; }
pre.udiff .add { color: var(--ok-fg); background: color-mix(in srgb, var(--ok-bg) 55%, transparent); }
pre.udiff .del { color: var(--bad-fg); background: color-mix(in srgb, var(--bad-bg) 55%, transparent); }
pre.udiff .hunk { color: var(--accent); }
pre.udiff .file { color: var(--fg-muted); }

/* ---------- device code (CLI sign-in) ---------- */
.otp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 2.2em; letter-spacing: 0.12em;
  background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 20px; display: inline-block; margin: 8px 0;
}

/* ---------- readme / rendered markdown ---------- */
.readme { max-width: 100%; }
.readme h1, .readme h2, .readme h3 { border-bottom: 0; }
.readme h1 { font-size: 1.4em; } .readme h2 { font-size: 1.2em; } .readme h3 { font-size: 1.05em; }
.readme img { max-width: 100%; border-radius: 4px; }
.readme ul, .readme ol { padding-left: 1.6em; }
.readme li { margin: 0.2em 0; }
.readme blockquote { margin: 0.8em 0; padding: 0 1em; border-left: 3px solid var(--line); color: var(--fg-muted); }
.readme hr { border: 0; border-top: 1px solid var(--line); margin: 1.5em 0; }
.readme table { margin: 0.8em 0; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--line); margin-top: 40px; }
footer .wrap { padding: 20px; color: var(--fg-muted); font-size: 13px; }
footer a { color: var(--fg-muted); }
footer a:hover { color: var(--accent); }
