/* Developer guide (/docs). Hand-written, same palette as the landing page. */

:root {
    --bg: #fbfcfb;
    --bg-alt: #f1f5f3;
    --surface: #ffffff;
    --text: #0f1a16;
    --text-2: #42504a;
    --muted: #66746e;
    --border: #dfe6e2;
    --primary: #047857;
    --primary-hover: #065f46;
    --primary-soft: #e3f5ec;
    --primary-ink: #ffffff;
    --tip-bg: #fff8e6;
    --tip-border: #f1d58a;
    --code-bg: #0d1714;
    --code-text: #d5e7df;
    --code-muted: #7f9a8f;
    --inline-code: #eef3f0;
    --radius: 12px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b100e;
        --bg-alt: #101814;
        --surface: #141d19;
        --text: #e8efeb;
        --text-2: #b6c4bd;
        --muted: #8a9a93;
        --border: #24312b;
        --primary: #10b981;
        --primary-hover: #34d399;
        --primary-soft: #0f2a20;
        --primary-ink: #04140d;
        --tip-bg: #2a2412;
        --tip-border: #5c4b1c;
        --code-bg: #070b09;
        --inline-code: #1b2621;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-hover); }
code, pre { font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace; }
:not(pre) > code { background: var(--inline-code); border-radius: 5px; padding: .1em .35em; font-size: .875em; overflow-wrap: anywhere; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.brand-sub { font-weight: 500; color: var(--muted); }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a { color: var(--text-2); text-decoration: none; font-weight: 500; font-size: .9375rem; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.topnav a:hover, .topnav a[aria-current="page"] { color: var(--text); background: var(--bg-alt); }
.topnav .btn { background: var(--primary); color: var(--primary-ink); margin-inline-start: 6px; }
.topnav .btn:hover { background: var(--primary-hover); color: var(--primary-ink); }

/* Layout */
.layout { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; }
.sidebar { position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 72px); overflow-y: auto; padding: 32px 0; }
.toc summary { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); list-style: none; cursor: default; margin-bottom: 8px; }
.toc summary::-webkit-details-marker { display: none; }
.toc nav { display: grid; gap: 2px; }
.toc a { color: var(--text-2); text-decoration: none; font-size: .9375rem; padding: 5px 12px; border-inline-start: 2px solid var(--border); }
.toc a:hover { color: var(--text); border-color: var(--muted); }
.toc a.active { color: var(--primary); border-color: var(--primary); font-weight: 600; }
.toc .toc-ref { margin-top: 14px; border: 0; padding-inline-start: 0; color: var(--primary); font-weight: 600; }

.content { max-width: 780px; padding: 40px 0 80px; min-width: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.5rem); line-height: 1.2; margin: 0 0 12px; letter-spacing: -.02em; }
.lead { font-size: 1.125rem; color: var(--text-2); margin: 0 0 8px; }
section { padding-top: 40px; margin-top: 40px; border-top: 1px solid var(--border); }
section:first-of-type { border-top: 0; margin-top: 16px; padding-top: 16px; }
h2 { font-size: 1.5rem; line-height: 1.3; margin: 0 0 14px; display: flex; align-items: center; gap: 12px; letter-spacing: -.01em; }
h3 { font-size: 1.0625rem; margin: 28px 0 8px; }
p { margin: 0 0 14px; color: var(--text-2); }
p b, li b { color: var(--text); }
.step { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-size: 1rem; }

/* How it works */
.flow { list-style: none; counter-reset: flow; padding: 0; margin: 0 0 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.flow li { counter-increment: flow; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 4px; }
.flow li b::before { content: counter(flow) ". "; color: var(--primary); }
.flow li span { color: var(--muted); font-size: .875rem; line-height: 1.5; }
.facts { display: grid; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin: 0 0 16px; }
.facts div { background: var(--surface); padding: 10px 16px; display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.facts span { color: var(--muted); font-size: .875rem; min-width: 110px; }

/* Steps, notes */
.steps { margin: 0 0 16px; padding-inline-start: 22px; color: var(--text-2); display: grid; gap: 6px; }
.steps li::marker { color: var(--primary); font-weight: 700; }
.note, .tip { border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; font-size: .9375rem; color: var(--text-2); line-height: 1.6; }
.note { background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent); }
.tip { background: var(--tip-bg); border: 1px solid var(--tip-border); }

/* Code blocks */
.code { position: relative; background: var(--code-bg); border-radius: var(--radius); margin: 0 0 18px; overflow: hidden; }
.code-tabs { display: flex; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); padding-inline-end: 72px; overflow-x: auto; }
.code-tabs button, .code-label { font: inherit; font-size: .8125rem; font-weight: 600; color: var(--code-muted); background: none; border: 0; padding: 7px 12px; border-radius: 8px 8px 0 0; white-space: nowrap; }
.code-tabs button { cursor: pointer; }
.code-tabs button:hover { color: #ffffff; }
.code-tabs button[aria-selected="true"] { color: #ffffff; background: rgba(255, 255, 255, .08); }
.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; color: var(--code-text); font-size: .8125rem; line-height: 1.65; tab-size: 4; }
.copy { position: absolute; top: 6px; inset-inline-end: 6px; font: inherit; font-size: .75rem; font-weight: 600; color: var(--code-text); background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12); border-radius: 7px; padding: 4px 10px; cursor: pointer; }
.copy:hover { background: rgba(255, 255, 255, .16); }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 0 0 18px; font-size: .9rem; display: block; overflow-x: auto; }
th, td { text-align: start; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text-2); }
th { color: var(--text); font-weight: 600; background: var(--bg-alt); white-space: nowrap; }
td code { white-space: nowrap; }

/* FAQ */
#faq details { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 0 16px; margin-bottom: 8px; }
#faq summary { cursor: pointer; padding: 12px 0; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 12px; }
#faq summary::-webkit-details-marker { display: none; }
#faq summary::after { content: "+"; color: var(--primary); font-size: 1.25rem; line-height: 1; }
#faq details[open] summary::after { content: "−"; }
#faq details p { margin-bottom: 12px; }

.content-footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; font-size: .9375rem; color: var(--muted); }
.content-footer a { font-weight: 600; }

/* Small screens: the table of contents folds above the content. */
@media (max-width: 900px) {
    .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .sidebar { position: static; max-height: none; padding: 16px 0 0; }
    .toc { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 10px 14px; }
    .toc summary { cursor: pointer; margin: 0; }
    .toc[open] summary { margin-bottom: 8px; }
    .content { padding-top: 24px; }
    .topnav a[aria-current] { display: none; }
}
@media (max-width: 480px) {
    .brand-sub { display: none; }
    .topnav a { padding: 6px 8px; font-size: .875rem; }
    .topbar-inner { gap: 8px; }
}
