/* ta Blueprint Scribe documentation theme. Copyright 2026 tridiART. All Rights Reserved. */

:root {
  --bg: #f6f6f9;
  --surface: #ffffff;
  --surface-2: #f0f0f5;
  --border: #e2e2ea;
  --text: #1c1c24;
  --muted: #6a6a78;
  --accent: #6b42d6;
  --accent-soft: rgba(107, 66, 214, 0.10);
  --code-bg: #f2f0f9;
  --error: #c93c3c;
  --error-soft: rgba(201, 60, 60, 0.12);
  --warning: #b77507;
  --warning-soft: rgba(212, 140, 20, 0.14);
  --info: #2a72c4;
  --info-soft: rgba(42, 114, 196, 0.12);
  --ok: #3a8f46;
  --ok-soft: rgba(58, 143, 70, 0.12);
  --shadow: 0 1px 2px rgba(20, 20, 40, 0.06), 0 4px 16px rgba(20, 20, 40, 0.05);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131317;
    --surface: #1b1b21;
    --surface-2: #23232b;
    --border: #30303a;
    --text: #e8e8ef;
    --muted: #9b9bab;
    --accent: #a98bf5;
    --accent-soft: rgba(169, 139, 245, 0.14);
    --code-bg: #24212f;
    --error: #f09595;
    --error-soft: rgba(240, 149, 149, 0.14);
    --warning: #efa93a;
    --warning-soft: rgba(239, 169, 58, 0.14);
    --info: #85b7eb;
    --info-soft: rgba(133, 183, 235, 0.14);
    --ok: #97c459;
    --ok-soft: rgba(151, 196, 89, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131317;
  --surface: #1b1b21;
  --surface-2: #23232b;
  --border: #30303a;
  --text: #e8e8ef;
  --muted: #9b9bab;
  --accent: #a98bf5;
  --accent-soft: rgba(169, 139, 245, 0.14);
  --code-bg: #24212f;
  --error: #f09595;
  --error-soft: rgba(240, 149, 149, 0.14);
  --warning: #efa93a;
  --warning-soft: rgba(239, 169, 58, 0.14);
  --info: #85b7eb;
  --info-soft: rgba(133, 183, 235, 0.14);
  --ok: #97c459;
  --ok-soft: rgba(151, 196, 89, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { scroll-padding-top: 72px; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

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

code, pre, kbd { font-family: var(--mono); font-size: 0.88em; }
code { background: var(--code-bg); padding: 0.1em 0.38em; border-radius: 5px; overflow-wrap: anywhere; }
pre { margin: 0; }
pre code { display: block; padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; }

h1 { font-size: 1.9rem; line-height: 1.25; margin: 4px 0 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; overflow-wrap: anywhere; }
h2 { font-size: 1.3rem; margin: 0 0 14px; display: flex; align-items: baseline; gap: 8px; }
h3 { font-size: 1.02rem; margin: 0 0 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.lead { font-size: 1.06rem; margin: 0 0 18px; max-width: 72ch; }
.count { color: var(--muted); font-weight: 500; font-size: 0.8em; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  height: 56px;
  padding: 0 18px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 6px; flex: none; }
.brand span { overflow: hidden; text-overflow: ellipsis; }
.top-links { display: flex; gap: 4px; }
.top-links a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 500; }
.top-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.top-links a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.search { position: relative; margin-left: auto; width: min(420px, 40vw); }
.search input {
  width: 100%;
  height: 36px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}
.search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.search kbd { position: absolute; right: 10px; top: 8px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 0.72rem; }
.search-results {
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
}
.search-results a { display: flex; align-items: baseline; gap: 8px; padding: 7px 10px; border-radius: 7px; color: var(--text); }
.search-results a:hover, .search-results a.active { background: var(--accent-soft); text-decoration: none; }
.search-results .type { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; min-width: 70px; }
.search-results .where { margin-left: auto; color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.search-results .empty { padding: 10px; color: var(--muted); }

.icon-button {
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}
.icon-button:hover { border-color: var(--accent); }
.menu-toggle { display: none; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 210px;
  gap: 28px;
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 22px;
  flex: 1;
}
body[data-page="index"] .layout, body[data-page="audit"] .layout { grid-template-columns: 270px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 18px 4px 24px 0;
  font-size: 0.9rem;
}
.sidebar .filter {
  width: 100%;
  height: 32px;
  margin-bottom: 10px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
}
.sidebar details { margin-bottom: 2px; }
.sidebar summary {
  cursor: pointer;
  list-style: none;
  padding: 5px 8px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::before { content: "\25B8"; display: inline-block; width: 14px; transition: transform 0.15s; }
.sidebar details[open] > summary::before { transform: rotate(90deg); }
.sidebar summary:hover { background: var(--surface-2); }
.sidebar ul { list-style: none; margin: 0 0 6px; padding: 0 0 0 10px; }
.sidebar li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 7px;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
}
.sidebar li a span.name { overflow: hidden; text-overflow: ellipsis; }
.sidebar li a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar li a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--kind, var(--muted)); }
.sidebar .flag { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--warning); flex: none; }

.content { min-width: 0; padding: 26px 0 60px; }
.crumbs { color: var(--muted); font-size: 0.85rem; font-family: var(--mono); overflow-wrap: anywhere; }

.toc {
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  padding: 26px 0;
  font-size: 0.86rem;
}
.toc-title { font-weight: 700; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 8px; }
.toc a { display: block; padding: 3px 0 3px 10px; color: var(--muted); border-left: 2px solid var(--border); }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }

section { margin-top: 34px; }

/* Facts */
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.facts > div { padding: 10px 14px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); min-width: 0; }
.facts dt { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 2px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.meter { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--surface-2); vertical-align: middle; overflow: hidden; margin-right: 6px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* Kinds */
.kind {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--kind);
  background: color-mix(in srgb, var(--kind) 15%, transparent);
  white-space: nowrap;
}
h1 .kind { font-size: 0.8rem; }
.kind-actor { --kind: #4a8be0; }
.kind-component { --kind: #2a9f8f; }
.kind-object { --kind: #858b95; }
.kind-widget { --kind: #5aa84a; }
.kind-animation { --kind: #d0832a; }
.kind-interface { --kind: #8e6ae8; }
.kind-functionlibrary { --kind: #c45fa9; }
.kind-macrolibrary { --kind: #8572bd; }
.kind-structure { --kind: #b49d2b; }
.kind-enum { --kind: #3aa9c9; }

/* Badges and pills */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
  font-family: var(--font);
}
.badge-muted, .badge-category { background: var(--surface-2); color: var(--muted); }
.badge-access { background: var(--surface-2); color: var(--text); }
.badge-warn { background: var(--warning-soft); color: var(--warning); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.flags { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }

.pill { display: inline-block; min-width: 24px; text-align: center; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; margin-left: 4px; }
.pill.sev-error { background: var(--error-soft); color: var(--error); }
.pill.sev-warning { background: var(--warning-soft); color: var(--warning); }
.pill.sev-info { background: var(--info-soft); color: var(--info); }
.reasons { margin: 4px 0 8px; padding-left: 18px; color: var(--muted); font-size: 0.88rem; }
.reasons li { margin: 2px 0; }
.reasons.upgrade { color: var(--warning); }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
table.members, table.params { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.members th, table.params th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
table.members td, table.params td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.members tr:last-child td, table.params tr:last-child td { border-bottom: none; }
table.members tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 40%, transparent); }
table.compact td { padding: 6px 14px; }
th.num, td.num { text-align: right; white-space: nowrap; }
table.sortable th { cursor: pointer; user-select: none; }
table.sortable th[aria-sort="ascending"]::after { content: " \25B4"; }
table.sortable th[aria-sort="descending"]::after { content: " \25BE"; }
code.name { font-weight: 600; background: none; padding: 0; color: var(--text); }
table.params { margin: 10px 0 4px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
table.params .dir { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; width: 40px; }

/* Member cards */
.member {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin-bottom: 14px;
  min-width: 0;
}
.member h3 code { background: none; padding: 0; font-size: 1.02rem; color: var(--text); }
.member p { margin: 8px 0; }
.signature code { background: var(--code-bg); border-radius: 7px; }
details summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; margin: 8px 0; }
details .table-wrap { box-shadow: none; }

/* Graph images */
figure.graph { margin: 14px 0 0; }
figure.graph .graph-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #262626;
  cursor: zoom-in;
  overflow: hidden;
  max-height: 520px;
}
figure.graph img { display: block; max-width: 100%; height: auto; margin: 0 auto; }
figure.graph figcaption { margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
section#graphs figure.graph { margin-top: 22px; }

/* Lists */
ul.tree { list-style: none; margin: 0; padding: 10px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
ul.tree li { padding: 5px 16px 5px calc(16px + var(--depth, 0) * 22px); position: relative; }
ul.tree li::before { content: ""; position: absolute; left: calc(6px + var(--depth, 0) * 22px); top: 14px; width: 6px; height: 6px; border-radius: 2px; background: var(--border); }

ul.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
li.issue {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sev);
  border-radius: 8px;
  padding: 9px 14px;
}
li.issue .sev { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--sev); }
li.issue .rule { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
li.issue .where { margin-left: 6px; font-size: 0.85rem; }
.sev-error { --sev: var(--error); }
.sev-warning { --sev: var(--warning); }
.sev-info { --sev: var(--info); }

ul.notes { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
ul.notes li { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
ul.notes li span { font-size: 0.8rem; }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
ul.refs { list-style: none; padding: 0; margin: 0; columns: 2 220px; column-gap: 16px; font-size: 0.92rem; }
ul.refs li { padding: 3px 0; break-inside: avoid; overflow-wrap: anywhere; }

/* Overview */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 18px 0 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .value { font-size: 1.6rem; font-weight: 750; line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 0.85rem; }
.stat.good .value { color: var(--ok); }
.stat.fair .value { color: var(--warning); }
.stat.poor .value, .stat.error .value { color: var(--error); }
.stat.warning .value { color: var(--warning); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip[aria-pressed="true"] .count { color: rgba(255, 255, 255, 0.8); }

/* Footer */
.footer { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; padding: 22px; color: var(--muted); font-size: 0.82rem; border-top: 1px solid var(--border); }

/* Image viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(10, 10, 14, 0.94); display: flex; flex-direction: column; }
.viewer[hidden] { display: none; }
.viewer-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: #e8e8ef; border-bottom: 1px solid rgba(255, 255, 255, 0.1); }
.viewer-bar span:first-child { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-hint { margin-left: auto; color: #9b9bab; font-size: 0.85rem; white-space: nowrap; }
.viewer-bar button { background: rgba(255, 255, 255, 0.08); color: #e8e8ef; border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 7px; padding: 5px 12px; font: inherit; font-size: 0.85rem; cursor: pointer; }
.viewer-bar button:hover { background: rgba(255, 255, 255, 0.16); }
.viewer-stage { flex: 1; overflow: hidden; position: relative; cursor: grab; touch-action: none; }
.viewer-stage.dragging { cursor: grabbing; }
.viewer-stage img { position: absolute; left: 0; top: 0; transform-origin: 0 0; max-width: none; user-select: none; -webkit-user-drag: none; image-rendering: auto; }

/* Responsive */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 250px minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 820px) {
  .layout, body[data-page="index"] .layout, body[data-page="audit"] .layout { grid-template-columns: minmax(0, 1fr); padding: 0 16px; }
  .menu-toggle { display: inline-block; }
  .top-links { display: none; }
  .search { width: auto; flex: 1; min-width: 0; }
  .search kbd { display: none; }
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    bottom: 0;
    width: min(320px, 86vw);
    height: auto;
    z-index: 30;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 14px;
    transform: translateX(-102%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  body.menu-open .sidebar { transform: none; }
  .columns { grid-template-columns: 1fr; }
  h1 { font-size: 1.5rem; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  table.stack tr:last-child { border-bottom: none; }
  table.stack td { border: none; padding: 3px 14px; }
  table.stack td[data-label]::before { content: attr(data-label); display: block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
  table.stack td:empty { display: none; }
  li.issue { grid-template-columns: auto 1fr; }
  li.issue .msg { grid-column: 1 / -1; }
  .viewer-hint { display: none; }
}
