/* =========================================================
   Blocworx Documentation – site styles
   Colours are defined once here; change them to re-theme the site.
   ========================================================= */
:root {
  --brand: #004851;          /* Blocworx teal */
  --brand-strong: #00353c;
  --accent: #e3222b;         /* Blocworx red */
  --bg: #ffffff;
  --bg-soft: #f6f9f9;
  --bg-sunken: #eef3f4;
  --text: #1c2526;
  --text-soft: #4f5d5f;
  --text-faint: #7b8789;
  --border: #e2e8e9;
  --link: #00707d;
  --mark: #fff1a8;
  --shadow: 0 10px 40px rgba(0, 30, 35, .18);
  --hint-info: #2f6fd6;     --hint-info-bg: #eef4fd;
  --hint-success: #1f8a52;  --hint-success-bg: #ecf7f0;
  --hint-warning: #b7791f;  --hint-warning-bg: #fdf6e9;
  --hint-danger: #c9302c;   --hint-danger-bg: #fcefee;
  --topbar-h: 60px;
  --sidebar-w: 290px;
  --toc-w: 230px;
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand: #5fb0ba;
  --brand-strong: #86c7cf;
  --accent: #ff5a5f;
  --bg: #0f1517;
  --bg-soft: #141c1e;
  --bg-sunken: #1a2427;
  --text: #e4ebec;
  --text-soft: #b1bec0;
  --text-faint: #7f8d90;
  --border: #263235;
  --link: #6cc3cd;
  --mark: #5e5214;
  --shadow: 0 10px 40px rgba(0, 0, 0, .55);
  --hint-info: #7aa9f5;     --hint-info-bg: #16233a;
  --hint-success: #5cc68c;  --hint-success-bg: #13281d;
  --hint-warning: #e3b05a;  --hint-warning-bg: #2c2414;
  --hint-danger: #f07c78;   --hint-danger-bg: #2e1817;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.65 var(--font);
}
a { color: var(--link); text-underline-offset: 2px; }
img { max-width: 100%; height: auto; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--bg); padding: 8px 12px; z-index: 100; }
.skip-link:focus { left: 8px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 650; font-size: 17px; white-space: nowrap; }
.spaces { display: flex; gap: 4px; margin: 0 0 0 18px; padding-left: 18px; border-left: 1px solid var(--border); }
.spaces a { padding: 6px 12px; border-radius: 7px; color: var(--text-soft); text-decoration: none; font-size: 14.5px; font-weight: 550; }
.spaces a:hover { background: var(--bg-sunken); color: var(--text); }
.spaces a[aria-current] { color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); }
.sidebar .spaces { display: none; }
.brand img { border-radius: 6px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }
.menu-btn { display: none; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
.search-trigger {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px; width: 300px; height: 38px; padding: 0 10px 0 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-soft); color: var(--text-faint);
  font: inherit; font-size: 14px; cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--brand); color: var(--text-soft); }
.search-label { flex: 1; }
kbd { font: 12px var(--mono); padding: 2px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--bg); color: var(--text-faint); }

/* ---------- layout ---------- */
.layout { display: flex; align-items: flex-start; max-width: 1480px; margin: 0 auto; }
.sidebar {
  position: sticky; top: var(--topbar-h); flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 20px 12px 40px 20px;
  border-right: 1px solid var(--border); font-size: 14.5px;
  scrollbar-width: thin;
}
.main { flex: 1; min-width: 0; padding: 36px 48px 80px; }
.doc { max-width: 780px; margin: 0 auto; }
.toc {
  position: sticky; top: var(--topbar-h); flex: 0 0 var(--toc-w); width: var(--toc-w);
  max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 36px 20px 40px 8px; font-size: 13.5px;
}
.toc:empty { display: none; }

/* ---------- sidebar ---------- */
.nav-group { margin-top: 22px; }
.nav-group-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); padding: 0 10px 6px; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list .nav-list { margin-left: 12px; padding-left: 8px; border-left: 1px solid var(--border); display: none; }
.nav-item.open > .nav-list { display: block; }
.nav-row { display: flex; align-items: stretch; border-radius: 7px; }
.nav-row a { flex: 1; display: block; padding: 5px 10px; color: var(--text-soft); text-decoration: none; border-radius: 7px; line-height: 1.4; }
.nav-row:hover a { color: var(--text); background: var(--bg-sunken); }
.nav-row a.active { color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, transparent); font-weight: 600; }
.nav-toggle { flex: 0 0 28px; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; border-radius: 7px; display: grid; place-items: center; }
.nav-toggle:hover { background: var(--bg-sunken); color: var(--text); }
.nav-toggle svg { transition: transform .15s; }
.nav-item.open > .nav-row .nav-toggle svg { transform: rotate(90deg); }

/* ---------- page content ---------- */
.eyebrow { margin: 0 0 6px; font-size: 13px; font-weight: 650; color: var(--brand); letter-spacing: .02em; }
.eyebrow:empty { display: none; }
.doc h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 24px; letter-spacing: -.01em; }
.doc h2 { font-size: 1.5rem; line-height: 1.3; margin: 2.2em 0 .6em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.doc h3 { font-size: 1.22rem; line-height: 1.35; margin: 1.9em 0 .5em; }
.doc h4 { font-size: 1.05rem; margin: 1.6em 0 .4em; }
.doc h2, .doc h3, .doc h4 { position: relative; }
.anchor { position: absolute; left: -1.1em; padding-right: .3em; color: var(--text-faint); text-decoration: none; opacity: 0; font-weight: 400; }
.doc :is(h2, h3, h4):hover .anchor, .anchor:focus { opacity: 1; }
.doc p, .doc ul, .doc ol { margin: 0 0 1em; }
.doc li { margin: .25em 0; }
.doc li > p { margin: 0 0 .4em; }
.doc img { border-radius: 8px; border: 1px solid var(--border); cursor: zoom-in; display: block; margin: 8px 0; }
.doc figure { margin: 1.2em 0; }
.doc figcaption { font-size: 13.5px; color: var(--text-faint); text-align: center; margin-top: 6px; }
.doc code { font: .88em var(--mono); background: var(--bg-sunken); padding: .15em .4em; border-radius: 5px; }
.doc pre { position: relative; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font-size: 14px; line-height: 1.5; }
.doc pre code { background: none; padding: 0; font-size: inherit; }
.copy-btn { position: absolute; top: 8px; right: 8px; font: 12px var(--font); padding: 3px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text-soft); cursor: pointer; opacity: 0; }
.doc pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.doc blockquote { margin: 1em 0; padding: .2em 1em; border-left: 3px solid var(--border); color: var(--text-soft); }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }
.table-wrap { overflow-x: auto; margin: 1.2em 0; border: 1px solid var(--border); border-radius: var(--radius); }
.doc table { border-collapse: collapse; width: 100%; font-size: 14.5px; }
.doc th, .doc td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.doc th { background: var(--bg-soft); font-weight: 650; }
.doc tr:last-child td { border-bottom: 0; }
.doc td img { margin: 4px 0; }

/* page intro, code titles, inline icons, file + external link cards */
.lead { font-size: 1.12rem; color: var(--text-soft); margin: -12px 0 24px; }
.code-block { margin: 1.2em 0; }
.code-block > pre { margin: 0; }
.code-title { font: 600 13px var(--mono); color: var(--text-soft); background: var(--bg-soft); border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; padding: 8px 14px; }
.code-title + pre { border-top-left-radius: 0; border-top-right-radius: 0; }
.doc img.inline-img { display: inline-block; height: 1.4em; width: auto; margin: 0 4px; vertical-align: middle; border: 0; border-radius: 3px; cursor: default; }
.card-link small { display: block; font-weight: 400; font-size: 13px; color: var(--text-faint); word-break: break-all; }
.card-link.file-link .card-icon { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 3v12m0 0-4-4m4 4 4-4M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 3v12m0 0-4-4m4 4 4-4M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2'/%3E%3C/svg%3E"); }
.card-link .card-icon-ext { mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E"); -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M14 4h6v6M20 4l-9 9M18 14v5a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h5'/%3E%3C/svg%3E"); }
.card-link.ext-link::after { content: "↗"; }

/* hints (callouts) */
.hint { --c: var(--hint-info); --b: var(--hint-info-bg); margin: 1.3em 0; padding: 12px 16px 12px 44px; border-radius: var(--radius); background: var(--b); border: 1px solid color-mix(in srgb, var(--c) 25%, transparent); position: relative; }
.hint::before { content: "i"; position: absolute; left: 14px; top: 13px; width: 20px; height: 20px; border-radius: 50%; background: var(--c); color: var(--bg); font: 700 13px/20px var(--font); text-align: center; }
.hint > :last-child { margin-bottom: 0; }
.hint-success { --c: var(--hint-success); --b: var(--hint-success-bg); }
.hint-success::before { content: "✓"; }
.hint-warning { --c: var(--hint-warning); --b: var(--hint-warning-bg); }
.hint-warning::before { content: "!"; }
.hint-danger { --c: var(--hint-danger); --b: var(--hint-danger-bg); }
.hint-danger::before { content: "!"; }

/* page link cards */
.content-ref { margin: .7em 0; }
.card-link { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); text-decoration: none; font-weight: 550; transition: border-color .15s, background .15s; }
.card-link:hover { border-color: var(--brand); background: var(--bg-soft); }
.card-icon { width: 18px; height: 18px; flex: 0 0 18px; background: var(--brand); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpath d='M14 3v6h6'/%3E%3C/svg%3E") center/contain no-repeat; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpath d='M14 3v6h6'/%3E%3C/svg%3E") center/contain no-repeat; }
.card-link::after { content: "→"; margin-left: auto; color: var(--text-faint); }

/* tabs */
.tabs { margin: 1.3em 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tab-bar { display: flex; flex-wrap: wrap; background: var(--bg-soft); border-bottom: 1px solid var(--border); }
.tab-bar button { border: 0; background: none; padding: 10px 16px; font: inherit; font-size: 14.5px; color: var(--text-soft); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-bar button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tab { padding: 14px 16px 2px; }
.tabs.ready .tab[hidden] { display: none; }

/* video embeds */
.embed { position: relative; aspect-ratio: 16 / 9; margin: 1.2em 0 .4em; border-radius: var(--radius); overflow: hidden; background: #000; }
.embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.embed-link { font-size: 14px; }
.yt > a { position: absolute; inset: 0; display: block; }
.yt img { width: 100%; height: 100%; object-fit: cover; margin: 0; border: 0; border-radius: 0; cursor: pointer; opacity: .92; transition: opacity .15s; }
.yt > a:hover img { opacity: 1; }
.yt-play { position: absolute; left: 50%; top: 50%; width: 72px; height: 50px; margin: -25px 0 0 -36px; border-radius: 14px; background: #e3222b; box-shadow: 0 4px 18px rgba(0,0,0,.35); }
.yt-play::after { content: ""; position: absolute; left: 29px; top: 15px; border-style: solid; border-width: 10px 0 10px 17px; border-color: transparent transparent transparent #fff; }
.yt > a:hover .yt-play { background: #ff0000; }

/* API: method badges, endpoints, coloured text */
.method { display: inline-block; font: 700 12px/1 var(--mono); letter-spacing: .03em; padding: 5px 8px; border-radius: 6px; color: #fff; background: var(--text-faint); vertical-align: middle; }
.method-get { background: #2f6fd6; }
.method-post { background: #1f8a52; }
.method-put, .method-patch { background: #b7791f; }
.method-delete { background: #c9302c; }
.endpoint { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 1em 0 1.2em; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft); }
.endpoint code { background: none; padding: 0; font-size: 14px; word-break: break-all; }
.tint-red { color: var(--hint-danger); font-weight: 600; }
.tint-green { color: var(--hint-success); }
.tint-blue { color: var(--hint-info); }
.tint-orange, .tint-yellow { color: var(--hint-warning); }
.tint-purple { color: #8a4fd3; }
/* code syntax colours */
.tok-k { color: #a626a4; }
.tok-s { color: #50a14f; }
.tok-n { color: #b76b01; }
.tok-c { color: #8a9496; font-style: italic; }
.tok-p { color: #4078f2; }
.tok-v { color: #c9302c; }
:root[data-theme="dark"] .tok-k { color: #d19af7; }
:root[data-theme="dark"] .tok-s { color: #98c379; }
:root[data-theme="dark"] .tok-n { color: #e5a65b; }
:root[data-theme="dark"] .tok-p { color: #74aef7; }
:root[data-theme="dark"] .tok-v { color: #f07c78; }
.tab > pre:first-child { margin-top: 0; }

/* search highlight on page */
mark, .search-hit { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- on this page ---------- */
.toc-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); margin: 0 0 10px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 4px 0 4px 12px; margin-left: -1px; border-left: 2px solid transparent; color: var(--text-soft); text-decoration: none; line-height: 1.4; }
.toc a.lvl-3 { padding-left: 24px; font-size: 13px; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--brand); border-left-color: var(--brand); }

/* ---------- prev / next ---------- */
.pager { max-width: 780px; margin: 56px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pager a { display: block; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); }
.pager a:hover { border-color: var(--brand); }
.pager small { display: block; color: var(--text-faint); font-size: 13px; }
.pager .next { text-align: right; grid-column: 2; }

/* ---------- search modal ---------- */
.search-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0, 20, 24, .45); display: none; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.search-overlay.open { display: flex; }
.search-box { width: 100%; max-width: 680px; max-height: 76vh; display: flex; flex-direction: column; background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--border); }
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); color: var(--text-faint); }
.search-input-row input::-webkit-search-cancel-button { display: none; }
.search-input-row input { flex: 1; height: 56px; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 17px; }
.search-results { overflow-y: auto; padding: 8px; }
.search-results a { display: block; padding: 10px 12px; border-radius: 9px; text-decoration: none; color: var(--text); }
.search-results a.sel, .search-results a:hover { background: var(--bg-sunken); }
.search-results .r-path { font-size: 12px; color: var(--text-faint); }
.search-results .r-title { font-weight: 600; }
.search-results .r-title .r-sec { color: var(--brand); font-weight: 600; }
.search-results .r-snip { font-size: 13.5px; color: var(--text-soft); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.search-msg { padding: 22px 16px; color: var(--text-faint); text-align: center; font-size: 14.5px; }
.search-foot { display: flex; gap: 14px; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-faint); }

/* ---------- image lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .82); display: none; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1240px) { .toc { display: none; } }
@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 10px; gap: 6px; }
  .sidebar {
    position: fixed; z-index: 40; top: 0; left: 0; height: 100vh; width: min(320px, 86vw);
    background: var(--bg); transform: translateX(-100%); transition: transform .2s; padding-top: 20px; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  .topbar > .spaces { display: none; }
  .sidebar .spaces { display: flex; margin: 0 0 8px; padding: 0 0 12px; border: 0; border-bottom: 1px solid var(--border); }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(0, 20, 24, .4); display: none; }
  body.nav-open .sidebar-backdrop { display: block; }
  .main { padding: 24px 16px 60px; }
  .search-trigger { width: auto; flex: 0 0 auto; }
  .search-label, .search-kbd { display: none; }
  .search-trigger { border: 0; background: transparent; width: 38px; justify-content: center; padding: 0; }
  .doc h1 { font-size: 1.7rem; }
  .anchor { display: none; }
}
@media (max-width: 480px) { .brand span { font-size: 15px; } .pager { grid-template-columns: 1fr; } .pager .next { grid-column: 1; } }
@media print { .topbar, .sidebar, .toc, .pager { display: none; } .main { padding: 0; } }
