/* WaSparks Social developer portal.
   Layout: top bar, left nav, reading column and a right "on this page" rail.
   Tokens come first; light is the default, dark follows the system unless the page sets data-theme. */
:root {
  --bg: #f7f8f6; --surface: #ffffff; --fg: #1d2420; --muted: #5b655f; --line: #d9dfda; --line-soft: #e8ece9;
  --accent: #0f6e56; --accent-soft: #e1f5ee; --accent-ink: #085041;
  --code-bg: #1d2420; --code-fg: #e6ebe7; --code-muted: #9aa69f; --code-accent: #9fe1cb;
  --get: #185fa5; --get-soft: #e6f1fb; --post: #3b6d11; --post-soft: #eaf3de; --del: #a32d2d; --del-soft: #fcebeb; --patch: #854f0b; --patch-soft: #faeeda;
  --note: #faeeda; --note-ink: #633806;
  --display: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #141917; --surface: #1c2320; --fg: #e6ebe7; --muted: #9aa69f; --line: #2d3733; --line-soft: #242c29;
  --accent: #5dcaa5; --accent-soft: #0f3a2f; --accent-ink: #9fe1cb;
  --code-bg: #0f1412; --code-fg: #e6ebe7; --code-muted: #8a958f; --code-accent: #9fe1cb;
  --get: #85b7eb; --get-soft: #0c2a48; --post: #c0dd97; --post-soft: #1f3a0a; --del: #f09595; --del-soft: #4a1515; --patch: #fac775; --patch-soft: #4a2a06;
  --note: #4a2a06; --note-ink: #fac775;
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #141917; --surface: #1c2320; --fg: #e6ebe7; --muted: #9aa69f; --line: #2d3733; --line-soft: #242c29;
  --accent: #5dcaa5; --accent-soft: #0f3a2f; --accent-ink: #9fe1cb;
  --code-bg: #0f1412; --code-fg: #e6ebe7; --code-muted: #8a958f; --code-accent: #9fe1cb;
  --get: #85b7eb; --get-soft: #0c2a48; --post: #c0dd97; --post-soft: #1f3a0a; --del: #f09595; --del-soft: #4a1515; --patch: #fac775; --patch-soft: #4a2a06;
  --note: #4a2a06; --note-ink: #fac775;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--fg); font-family: var(--display); font-size: 16px; line-height: 1.6; margin: 0;
  padding-block: 0 3rem; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

/* top bar */
.topbar { display: flex; align-items: center; gap: 1.25rem; padding: .9rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 600; font-size: 1.05rem; color: var(--fg); text-decoration: none; }
.brand .w { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; font-family: var(--mono); }
.brand small { color: var(--muted); font-weight: 400; }
.search { position: relative; flex: 1; min-width: 180px; max-width: 420px; display: flex; align-items: center; gap: .5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .7rem; color: var(--muted); font-size: .9rem; }
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--fg); font: inherit; padding: 0; }
.search input::placeholder { color: var(--muted); opacity: 1; }
.search kbd { margin-left: auto; font-family: var(--mono); font-size: .75rem; border: 1px solid var(--line); border-radius: 4px; padding: 0 .35rem; }
.results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: .35rem; max-height: 70vh; overflow-y: auto; }
.results a { display: block; text-decoration: none; color: var(--fg); padding: .45rem .6rem; border-radius: 6px; line-height: 1.35; }
.results a small { display: block; color: var(--muted); font-size: .8rem; }
.results a.on, .results a:hover { background: var(--accent-soft); color: var(--accent-ink); }
.results a.on small, .results a:hover small { color: var(--accent-ink); }
.results .none { padding: .5rem .6rem; color: var(--muted); font-size: .9rem; }
.topnav { display: flex; gap: .25rem; margin-left: auto; }
.topnav a { text-decoration: none; color: var(--muted); padding: .35rem .7rem; border-radius: 6px; font-size: .95rem; }
.topnav a.on { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }

/* shell */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr) 190px; gap: 2.5rem; max-width: 1180px; margin: 0 auto; padding-top: 1.75rem; }
.side { font-size: .93rem; position: sticky; top: 1rem; align-self: start; }
.side h4 { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 1.25rem 0 .4rem; font-weight: 500; }
.side h4:first-child { margin-top: 0; }
.side a { display: block; text-decoration: none; color: var(--fg); padding: .3rem .6rem; border-radius: 6px; }
.side a.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.side a:hover { background: var(--line-soft); }
main { min-width: 0; }
.rail { font-size: .85rem; color: var(--muted); position: sticky; top: 1rem; align-self: start; }
.rail h4 { font-family: var(--mono); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; margin: 0 0 .5rem; font-weight: 500; }
.rail a { display: block; color: var(--muted); text-decoration: none; padding: .2rem 0 .2rem .75rem; border-left: 2px solid var(--line); }
.rail a.on { color: var(--accent); border-left-color: var(--accent); }

/* reading column */
.crumb { font-size: .85rem; color: var(--muted); margin: 0 0 .5rem; }
h1 { font-size: 2rem; font-weight: 600; line-height: 1.15; margin: 0 0 .5rem; text-wrap: balance; }
h2 { font-size: 1.3rem; font-weight: 600; margin: 2.25rem 0 .6rem; text-wrap: balance; scroll-margin-top: 1rem; }
h3 { font-size: 1.05rem; font-weight: 600; margin: 1.5rem 0 .4rem; scroll-margin-top: 1rem; }
p, li { max-width: 70ch; } p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.4rem; }
li { margin-bottom: .3rem; }
.lede { font-size: 1.1rem; color: var(--muted); }
main a { color: var(--accent); }
code { font-family: var(--mono); font-size: .86em; background: var(--accent-soft); color: var(--accent-ink); padding: .08em .35em; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2rem 0; }

/* fork cards (Start here) */
.fork { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.25rem 0 .5rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.2rem; }
.card h3 { margin: 0 0 .3rem; }
.card p { font-size: .95rem; color: var(--muted); margin: 0 0 .6rem; }
.card .key { font-family: var(--mono); font-size: .8rem; color: var(--accent-ink); background: var(--accent-soft); padding: .15rem .5rem; border-radius: 4px; display: inline-block; }
.card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* numbered steps: an ordered list whose items start with bold text */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 1rem 0; }
.steps li { counter-increment: s; position: relative; padding-left: 2.5rem; margin-bottom: 1.25rem; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: .05rem; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--accent); color: #fff; font-family: var(--mono); font-size: .85rem; font-weight: 500; display: grid; place-items: center; }
.steps li strong { display: block; margin-bottom: .2rem; }

/* code blocks, with or without tabs */
.codeblock { background: var(--code-bg); color: var(--code-fg); border-radius: 10px; margin: .75rem 0 1.25rem; overflow: hidden; font-family: var(--mono); font-size: .82rem; line-height: 1.55; }
.codeblock .tabs { display: flex; gap: .25rem; padding: .45rem .6rem 0; border-bottom: 1px solid #2d3733; align-items: flex-end; }
.codeblock .tabs button { background: none; border: 0; color: var(--code-muted); font-family: var(--mono); font-size: .78rem; padding: .35rem .6rem; border-radius: 6px 6px 0 0; cursor: pointer; }
.codeblock .tabs button.on { color: var(--code-fg); background: #2d3733; }
.codeblock .tabs .lang { color: var(--code-muted); font-size: .75rem; padding: .35rem .6rem; }
.codeblock .tabs .copy { margin-left: auto; }
.codeblock pre { margin: 0; padding: .9rem 1rem; overflow-x: auto; }
.codeblock, code { font-variant-ligatures: none; }
main code { overflow-wrap: anywhere; }
.codeblock code { overflow-wrap: normal; }
.codeblock code { background: none; color: inherit; padding: 0; font-size: inherit; }
.codeblock .k { color: var(--code-accent); } .codeblock .c { color: var(--code-muted); }
.codeblock .tabs button:focus-visible, .search input:focus-visible { outline: 2px solid var(--code-accent); outline-offset: 1px; }

/* callouts: blockquotes that start with **Note** or **Warning** */
.callout { border-left: 3px solid var(--accent); background: var(--surface); padding: .8rem 1rem; border-radius: 0 10px 10px 0; margin: 1.25rem 0; font-size: .95rem; }
.callout.warn { border-left-color: var(--patch); }
.callout > :last-child { margin-bottom: 0; }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: 0 0 1.25rem; }
.tablewrap { overflow-x: auto; margin: 0 0 1.25rem; }
.tablewrap table { margin: 0; }
td, th { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { font-weight: 600; font-size: .8rem; color: var(--muted); }
td code { font-size: .8em; }

/* "Next:" link at the end of every page */
.next { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* method pills, used in reference tables */
.pill { font-family: var(--mono); font-size: .7rem; font-weight: 600; letter-spacing: .04em; text-align: center; padding: .2rem .5rem; border-radius: 5px; display: inline-block; }
.GET { background: var(--get-soft); color: var(--get); } .POST { background: var(--post-soft); color: var(--post); } .DELETE { background: var(--del-soft); color: var(--del); } .PATCH { background: var(--patch-soft); color: var(--patch); }

/* API reference page */
.ref-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.ref-head .ver { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.dl { font-size: .9rem; color: var(--accent); text-decoration: none; }
.ref-head .dl:first-of-type { margin-left: auto; }
.shell.wide { grid-template-columns: minmax(0, 1fr); max-width: 1400px; gap: 0; }
#scalar { margin: 1rem -16px 0; border-top: 1px solid var(--line); min-height: 60vh; }
.noscript { background: var(--note); color: var(--note-ink); padding: .8rem 1rem; border-radius: 8px; }

.foot { max-width: 1180px; margin: 3rem auto 0; padding-top: 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .85rem; }

/* inline SVG diagrams */
.diagram { margin: 1rem 0 1.5rem; padding: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
.diagram svg { display: block; min-width: 640px; width: 100%; height: auto; font-family: var(--display); font-size: 13px; }
.diagram svg text { fill: var(--fg); }
.diagram svg .m { fill: var(--muted); font-size: 12px; }
.diagram svg .mono { font-family: var(--mono); font-size: 12px; }
.diagram svg .box { fill: var(--accent-soft); stroke: var(--accent); }
.diagram svg .life { stroke: var(--line); stroke-dasharray: 4 4; }
.diagram svg .arrow { stroke: var(--fg); fill: none; }
.diagram svg .arrow.back { stroke-dasharray: 5 3; stroke: var(--muted); }
.diagram figcaption { color: var(--muted); font-size: .85rem; margin-top: .5rem; }

@media (max-width: 980px) { .shell { grid-template-columns: 200px minmax(0,1fr); } .rail { display: none; } }
@media (max-width: 680px) { .shell { grid-template-columns: minmax(0, 1fr); gap: 1rem; } .side { position: static; display: flex; flex-wrap: wrap; gap: .25rem; } .side h4 { width: 100%; margin: .5rem 0 .1rem; } .fork { grid-template-columns: 1fr; } .topnav { margin-left: 0; } h1 { font-size: 1.7rem; } }
