/* Character Modules documentation, laid out like an engine documentation site (from the PortLink documentation template). */

:root {
  --bg: #ffffff;
  --text: #1f1f1f;
  --muted: #5c5c5c;
  --rule: #e2e2e2;
  --link: #1565c0;
  --link-hover: #0d47a1;
  --bar: #161616;
  --bar-text: #f2f2f2;
  --bar-muted: #a8a8a8;
  --side: #f6f6f6;
  --side-active: #e6eefa;
  --code-bg: #f4f4f4;
  --code-text: #1f1f1f;
  --table-head: #f2f2f2;
  --note-bg: #eef5fd;
  --note-rule: #5b9bd5;
  --tip-bg: #eef8f1;
  --tip-rule: #4caf6e;
  --warn-bg: #fdf6ea;
  --warn-rule: #e0a43a;
  --kw: #0b51a8;
  --type: #1f7a7a;
  --str: #a3511b;
  --com: #6a737d;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1c1c;
    --text: #e4e4e4;
    --muted: #a6a6a6;
    --rule: #333333;
    --link: #7fb3f5;
    --link-hover: #a9cbf8;
    --side: #232323;
    --side-active: #2c3a4f;
    --code-bg: #262626;
    --code-text: #e4e4e4;
    --table-head: #262626;
    --note-bg: #1f2a38;
    --tip-bg: #1f2e25;
    --warn-bg: #33291a;
    --kw: #7fb3f5;
    --type: #5fc4c4;
    --str: #e2a06b;
    --com: #8b949e;
  }
}

:root[data-theme="dark"] {
  --bg: #1c1c1c;
  --text: #e4e4e4;
  --muted: #a6a6a6;
  --rule: #333333;
  --link: #7fb3f5;
  --link-hover: #a9cbf8;
  --side: #232323;
  --side-active: #2c3a4f;
  --code-bg: #262626;
  --code-text: #e4e4e4;
  --table-head: #262626;
  --note-bg: #1f2a38;
  --tip-bg: #1f2e25;
  --warn-bg: #33291a;
  --kw: #7fb3f5;
  --type: #5fc4c4;
  --str: #e2a06b;
  --com: #8b949e;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  height: 56px; padding: 0 20px;
  background: var(--bar); color: var(--bar-text);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; color: var(--bar-text); font-weight: 600; font-size: 17px; }
.topbar .brand:hover { text-decoration: none; }
.topbar .brand .mark {
  width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center;
  background: linear-gradient(135deg, #f0a52c, #4a9fe8); color: #111; font-weight: 800; font-size: 13px;
}
.topbar .version { color: var(--bar-muted); font-size: 13px; font-weight: 400; }
.topbar nav { display: flex; height: 100%; }
.topbar nav a {
  display: flex; align-items: center; padding: 0 14px; color: var(--bar-muted); font-size: 14px;
  border-bottom: 3px solid transparent;
}
.topbar nav a:hover { color: var(--bar-text); text-decoration: none; }
.topbar nav a.current { color: var(--bar-text); border-bottom-color: #f0a52c; }
.topbar .spacer { flex: 1; }
.topbar input[type="search"] {
  width: 240px; height: 32px; padding: 0 10px; border-radius: 4px; border: 1px solid #3a3a3a;
  background: #262626; color: var(--bar-text); font: inherit; font-size: 14px;
}
.topbar .menu-toggle { display: none; background: none; border: 0; color: var(--bar-text); font-size: 22px; cursor: pointer; }

/* ---------------------------------------------------------------- layout */

.layout { display: flex; min-height: calc(100vh - 56px); }

.sidebar {
  width: 290px; flex-shrink: 0; background: var(--side); border-right: 1px solid var(--rule);
  padding: 16px 0 40px; position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto;
  font-size: 14px;
}
.sidebar .section-title { padding: 4px 20px 8px; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a { display: block; padding: 4px 20px; color: var(--text); }
.sidebar li li a { padding-left: 36px; }
.sidebar li li li a { padding-left: 52px; }
.sidebar li a:hover { background: var(--side-active); text-decoration: none; }
.sidebar li a.current { background: var(--side-active); color: var(--link); font-weight: 600; border-left: 3px solid var(--link); padding-left: 17px; }
.sidebar li li a.current { padding-left: 33px; }
.sidebar li li li a.current { padding-left: 49px; }
.sidebar .group { margin-top: 10px; }

.content { flex: 1; min-width: 0; padding: 28px 48px 80px; }
.content article { max-width: 860px; }

.breadcrumbs { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs span.sep { margin: 0 6px; }

.pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 16px; border-top: 1px solid var(--rule); font-size: 14px; }

.footer { margin-top: 32px; font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- text */

h1 { font-size: 32px; line-height: 1.25; font-weight: 600; margin: 0 0 16px; }
h2 { font-size: 22px; font-weight: 600; margin: 36px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--rule); }
h3 { font-size: 17px; font-weight: 600; margin: 26px 0 8px; }
p { margin: 0 0 14px; }
ul, ol { margin: 0 0 14px; padding-left: 26px; }
li { margin: 3px 0; }
strong { font-weight: 600; }
.lead { font-size: 16px; }

code {
  font-family: "SF Mono", Menlo, Consolas, "Liberation Mono", monospace; font-size: 13px;
  background: var(--code-bg); color: var(--code-text); padding: 1px 5px; border-radius: 3px;
}
pre {
  background: var(--code-bg); border: 1px solid var(--rule); border-radius: 4px; padding: 14px 16px;
  overflow-x: auto; font-size: 13px; line-height: 1.5; margin: 0 0 18px;
}
pre code { background: none; padding: 0; font-size: 13px; }
.kw { color: var(--kw); }
.ty { color: var(--type); }
.st { color: var(--str); }
.cm { color: var(--com); font-style: italic; }

table { border-collapse: collapse; width: 100%; margin: 0 0 20px; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 8px 12px; border: 1px solid var(--rule); }
th { background: var(--table-head); font-weight: 600; }
td:first-child { white-space: nowrap; }
td.wrap { white-space: normal; }

.note, .tip, .warning { border-left: 4px solid var(--note-rule); background: var(--note-bg); padding: 10px 14px; margin: 0 0 18px; border-radius: 0 4px 4px 0; }
.tip { border-left-color: var(--tip-rule); background: var(--tip-bg); }
.warning { border-left-color: var(--warn-rule); background: var(--warn-bg); }
.note p:last-child, .tip p:last-child, .warning p:last-child { margin-bottom: 0; }

figure { margin: 6px 0 24px; }
figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; font-style: italic; }

/* ---------------------------------------------------------------- scripting reference */

.api-kind { color: var(--muted); font-size: 14px; margin: -8px 0 4px; }
.api-kind a { color: var(--link); }
.api-inherits { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.signature {
  font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 14px; background: var(--code-bg);
  border: 1px solid var(--rule); border-radius: 4px; padding: 10px 14px; margin: 0 0 18px; overflow-x: auto;
}
.member-table td:first-child { width: 220px; }
.member-table td:first-child a { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
.hidden-api { color: var(--muted); }

/* ---------------------------------------------------------------- drawn editor screenshots (dark theme) */

.editor {
  --ed-bg: #383838; --ed-header: #3e3e3e; --ed-field: #2a2a2a; --ed-border: #212121; --ed-text: #d2d2d2;
  --ed-label: #c4c4c4; --ed-dim: #8a8a8a; --ed-sel: #2c5d87; --ed-line: #2f2f2f;
  display: inline-block; max-width: 100%; background: var(--ed-bg); color: var(--ed-text);
  border: 1px solid #191919; border-radius: 4px; overflow: hidden;
  font: 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.editor .tab { background: #282828; padding: 5px 10px; font-size: 12px; color: var(--ed-text); border-bottom: 1px solid var(--ed-border); display: flex; gap: 8px; align-items: center; }
.editor .tab .t { background: var(--ed-bg); padding: 3px 10px; border-radius: 3px 3px 0 0; }
.editor .comp { border-bottom: 1px solid var(--ed-border); }
.editor .comp-head { display: flex; align-items: center; gap: 6px; background: var(--ed-header); padding: 4px 8px; font-weight: 600; border-bottom: 1px solid var(--ed-line); }
.editor .comp-head .menu { margin-left: auto; color: var(--ed-dim); letter-spacing: 1px; }
.editor .ico { width: 14px; height: 14px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.editor .ico.script { background: #9aa0a6; }
.editor .ico.link { background: linear-gradient(135deg, #f0a52c, #4a9fe8); }
.editor .ico.go { background: #8ab4e8; border-radius: 3px; }
.editor .ico.asset { background: #6fa8dc; }
.editor .arrow { color: var(--ed-dim); font-size: 10px; width: 10px; }
.editor .body { padding: 4px 8px 6px; }
.editor .row { display: flex; align-items: center; min-height: 22px; gap: 4px; }
.editor .row.indent .label { padding-left: 14px; }
.editor .label { width: 150px; flex-shrink: 0; color: var(--ed-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.editor .field { flex: 1; min-width: 0; height: 18px; background: var(--ed-field); border: 1px solid var(--ed-border); border-radius: 3px; padding: 0 6px; display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.editor .field.obj::after { content: "◉"; margin-left: auto; color: var(--ed-dim); font-size: 10px; }
.editor .field.num { max-width: 120px; }
.editor .field.empty { color: var(--ed-dim); }
.editor .badge { display: inline-grid; place-items: center; width: 22px; height: 14px; border-radius: 3px; font-size: 9px; font-weight: 700; color: #fff; flex-shrink: 0; }
.editor .badge.r { background: #2b80cc; }
.editor .badge.w { background: #de8021; }
.editor .badge.rw { background: #8561c7; }
.editor .mode { display: inline-flex; align-items: center; gap: 3px; height: 18px; padding: 0 3px; background: #515151; border: 1px solid var(--ed-border); border-radius: 3px; flex-shrink: 0; }
.editor .mode::after { content: "▾"; color: var(--ed-text); font-size: 9px; }
.editor .btn { display: inline-grid; place-items: center; min-width: 18px; height: 16px; padding: 0 6px; background: #585858; border: 1px solid var(--ed-border); border-radius: 3px; color: var(--ed-text); flex-shrink: 0; }
.editor .btn.wide { padding: 0 18px; height: 20px; }
.editor .err { width: 14px; height: 14px; border-radius: 50%; background: #e0543e; color: #fff; font-size: 10px; font-weight: 700; display: inline-grid; place-items: center; flex-shrink: 0; }
.editor .heading { color: var(--ed-text); font-weight: 600; padding: 6px 0 2px; }
.editor .help { background: #474747; border: 1px solid var(--ed-border); border-radius: 3px; padding: 6px 8px; margin: 4px 0; color: var(--ed-text); }
.editor .toolbar { display: flex; gap: 0; background: #3c3c3c; border: 1px solid var(--ed-border); margin: 4px 0; }
.editor .toolbar span { padding: 2px 8px; border-right: 1px solid var(--ed-border); }
.editor .toolbar span.on { background: #4d6a8a; }
.editor .list { border: 1px solid var(--ed-border); border-radius: 3px; margin: 4px 0; }
.editor .list .item { padding: 3px 8px; border-bottom: 1px solid var(--ed-line); display: flex; gap: 6px; align-items: center; }
.editor .list .item:last-child { border-bottom: 0; }
.editor .list .group { background: #333; padding: 3px 8px; font-weight: 600; }
.editor .menu-pop { background: #2d2d2d; border: 1px solid #191919; border-radius: 4px; padding: 4px 0; box-shadow: 0 4px 14px rgba(0,0,0,.4); display: inline-block; min-width: 180px; }
.editor .menu-pop div { padding: 3px 16px; }
.editor .menu-pop div.hl { background: var(--ed-sel); }
.editor .menu-pop div.dim { color: var(--ed-dim); }
.editor .menu-pop hr { border: 0; border-top: 1px solid #444; margin: 4px 0; }
.editor .event { border: 1px solid var(--ed-border); border-radius: 3px; margin: 4px 0; }
.editor .event-head { background: #333; padding: 3px 8px; font-weight: 600; border-bottom: 1px solid var(--ed-border); }
.editor .event-head .sig { color: var(--ed-dim); font-weight: 400; }
.editor .event-row { display: flex; gap: 6px; padding: 4px 8px; align-items: center; border-bottom: 1px solid var(--ed-line); }
.editor .event-row .target { width: 34%; }
.editor .event-param { display: flex; gap: 6px; padding: 2px 8px 4px 8px; align-items: center; }
.editor .event-param .pname { width: 34%; color: var(--ed-label); padding-left: 10px; }
.editor .src { display: inline-grid; place-items: center; width: 18px; height: 16px; border-radius: 3px; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.editor .src.c { background: #4b4b4b; color: #bdbdbd; }
.editor .src.a { background: #6a4a12; color: #f6c35a; }
.editor .src.l { background: #1d3f63; color: #8cc2ff; }
.editor .event-foot { display: flex; justify-content: flex-end; gap: 2px; padding: 2px 6px; background: #333; }
.editor .hier { width: 100%; }
.editor .hier .item { display: flex; align-items: center; gap: 6px; padding: 2px 8px; }
.editor .hier .item.sel { background: var(--ed-sel); }
.editor .hier .item .end { margin-left: auto; font-weight: 700; }
.editor .send { color: #f0a52c; }
.editor .recv { color: #5bb8ff; }
.editor .problem { color: #ff6b58; }
.editor .console .line { display: flex; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--ed-line); align-items: flex-start; }
.editor .console .line .err { margin-top: 2px; }
.editor .console .line a { color: #7fb3f5; }
.editor .project .item { display: flex; align-items: center; gap: 6px; padding: 2px 8px; }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 900px) {
  .topbar { gap: 12px; padding: 0 16px; }
  .topbar input[type="search"] { display: none; }
  .topbar .menu-toggle { display: block; }
  .sidebar { position: fixed; left: 0; top: 56px; z-index: 9; transform: translateX(-100%); transition: transform .2s; }
  body.menu-open .sidebar { transform: none; }
  .content { padding: 20px 16px 60px; }
  h1 { font-size: 26px; }
  td:first-child { white-space: normal; }
  .editor { font-size: 11px; }
  .editor .label { width: 110px; }
}

/* Character Modules: the package's 16 x 16 pixel icons, drawn crisp at any size. */
img.px { image-rendering: pixelated; vertical-align: middle; }
h1 img.px { width: 32px; height: 32px; margin-right: 10px; position: relative; top: -3px; }
.editor img.ico { width: 16px; height: 16px; background: none; border-radius: 0; image-rendering: pixelated; }
.facts { color: var(--muted); font-size: 14px; margin: -8px 0 18px; }
.facts b { color: var(--text); font-weight: 600; }
.origin { border-left: 4px solid #f0a52c; background: var(--warn-bg); padding: 10px 14px; margin: 0 0 18px; border-radius: 0 4px 4px 0; }
.icon-grid { display: flex; flex-wrap: wrap; gap: 14px 18px; margin: 0 0 20px; }
.icon-grid div { width: 92px; text-align: center; font-size: 13px; }
.icon-grid img { display: block; margin: 0 auto 6px; width: 48px; height: 48px; image-rendering: pixelated; }
.editor .check { width: 14px; height: 14px; border: 1px solid var(--ed-border); border-radius: 3px; background: var(--ed-field); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; color: var(--ed-text); }
