/* Design tokens follow apisix.apache.org (Base.css) so the site feels at home next to it. */
:root {
  --color-primary: #e8433e;
  --color-primary-dark: #9a2521;
  --color-badge-bg: #fcebeb;
  --color-badge-text: #a32d2d;
  --color-hover-border: #f3b6b3;
  --color-border: #eaecef;
  --color-code-bg: #f6f7f8;
  --color-surface: #fff;
  --color-surface-alt: #f8f8fa;
  --color-surface-warm: #faf7f7;
  --color-text: #1c1e21;
  --color-text-soft: #525860;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --header-height: 60px;
  --max-width: 1140px;
  --radius-card: .75rem;
  --shadow-card-hover: 0 10px 28px rgb(0 0 0 / 7%);
  --dur: .18s;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-primary: #f0625d; --color-primary-dark: #ff8a85;
    --color-badge-bg: #3a1d1c; --color-badge-text: #ffb3ae; --color-hover-border: #7a3431;
    --color-border: #2e3238; --color-code-bg: #1d2024; --color-surface: #141619;
    --color-surface-alt: #1a1d21; --color-surface-warm: #1c1a1a;
    --color-text: #e6e8eb; --color-text-soft: #a3a9b1; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --color-primary: #f0625d; --color-primary-dark: #ff8a85;
  --color-badge-bg: #3a1d1c; --color-badge-text: #ffb3ae; --color-hover-border: #7a3431;
  --color-border: #2e3238; --color-code-bg: #1d2024; --color-surface: #141619;
  --color-surface-alt: #1a1d21; --color-surface-warm: #1c1a1a;
  --color-text: #e6e8eb; --color-text-soft: #a3a9b1; color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-height) + 16px); }
body {
  margin: 0; background: var(--color-surface); color: var(--color-text);
  font: 16px/1.65 var(--font-sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--font-mono); font-size: .875em; }
:not(pre) > code {
  background: var(--color-code-bg); border: 1px solid var(--color-border);
  border-radius: 4px; padding: .1em .35em;
}
pre {
  background: var(--color-code-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-card); padding: 1rem 1.25rem; overflow-x: auto; line-height: 1.5;
}
pre code { background: none; padding: 0; }
.wrap { max-width: var(--max-width); margin: 0 auto; padding: 0 16px; }

/* header */
.nav {
  position: sticky; top: 0; z-index: 10; height: var(--header-height);
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--color-border);
}
.nav .wrap { display: flex; align-items: center; gap: 1.5rem; height: 100%; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--color-text); }
.brand:hover { text-decoration: none; }
.brand svg { flex: none; }
.nav-links { display: flex; gap: 1.25rem; margin-left: auto; align-items: center; }
.nav-links a { color: var(--color-text); font-weight: 500; font-size: .95rem; }
.nav-links a:hover, .nav-links a.active { color: var(--color-primary); text-decoration: none; }
.theme-btn {
  background: none; border: 1px solid var(--color-border); border-radius: 999px;
  width: 34px; height: 34px; cursor: pointer; color: var(--color-text); font-size: 1rem;
}
@media (max-width: 640px) { .nav-links .hide-sm { display: none; } .nav .wrap { gap: .75rem; } }

/* buttons, badges */
.btn {
  display: inline-block; padding: .7rem 1.4rem; border-radius: 999px; font-weight: 600;
  border: 1px solid var(--color-primary); transition: all var(--dur) ease;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); }
.btn-ghost { color: var(--color-primary); background: transparent; }
.btn-ghost:hover { background: var(--color-badge-bg); }
.badge {
  display: inline-block; background: var(--color-badge-bg); color: var(--color-badge-text);
  border-radius: 999px; padding: .2rem .75rem; font-size: .8rem; font-weight: 600;
}

/* landing */
.hero {
  padding: 5rem 0 4rem; text-align: center;
  background: radial-gradient(60rem 22rem at 50% -6rem, var(--color-badge-bg), transparent 70%);
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.15; margin: 1rem auto .75rem; max-width: 18ch; }
.hero h1 em { color: var(--color-primary); font-style: normal; }
.hero p.lead { color: var(--color-text-soft); font-size: 1.15rem; max-width: 46rem; margin: 0 auto 2rem; }
.hero .actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
section.block { padding: 4rem 0; }
section.alt { background: var(--color-surface-alt); border-block: 1px solid var(--color-border); }
.section-title { text-align: center; margin-bottom: 2.5rem; }
.section-title h2 { font-size: 2rem; margin: .5rem 0; }
.section-title p { color: var(--color-text-soft); margin: 0 auto; max-width: 40rem; }
.grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-card); padding: 1.5rem; transition: all var(--dur) ease;
}
.card:hover { border-color: var(--color-hover-border); box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.card h3 { margin: .25rem 0 .5rem; font-size: 1.1rem; }
.card p { margin: 0; color: var(--color-text-soft); font-size: .95rem; }
.card .icon { color: var(--color-primary); }
.flow { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); counter-reset: step; }
.flow .card::before {
  counter-increment: step; content: counter(step);
  display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--color-primary); color: #fff; font-weight: 700; font-size: .85rem;
}
.two-col { display: grid; gap: 2rem; grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--color-border); vertical-align: top; }
th { background: var(--color-surface-alt); font-weight: 600; }
.table-scroll { overflow-x: auto; }

/* footer */
footer { border-top: 1px solid var(--color-border); padding: 2rem 0; color: var(--color-text-soft); font-size: .9rem; }
footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }

/* docs */
.docs { display: grid; grid-template-columns: 250px minmax(0, 1fr) 220px; gap: 2.5rem; max-width: 92rem; margin: 0 auto; padding: 0 16px; }
.docs aside { position: sticky; top: var(--header-height); align-self: start; max-height: calc(100vh - var(--header-height)); overflow-y: auto; padding: 1.5rem 0; }
.sidebar a { display: block; padding: .4rem .75rem; border-radius: 6px; color: var(--color-text); font-size: .95rem; }
.sidebar a:hover { background: var(--color-surface-alt); text-decoration: none; }
.sidebar a.active { background: var(--color-badge-bg); color: var(--color-primary); font-weight: 600; }
.sidebar .group { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-soft); margin: 1rem .75rem .35rem; }
.toc { font-size: .85rem; border-left: 1px solid var(--color-border); padding-left: 1rem !important; }
.toc a { display: block; color: var(--color-text-soft); padding: .2rem 0; }
.toc a.l3 { padding-left: .75rem; }
.toc a:hover { color: var(--color-primary); text-decoration: none; }
.toc .title { font-weight: 600; color: var(--color-text); margin-bottom: .5rem; }
article.md { padding: 2rem 0 4rem; max-width: 85ch; }
article.md h1 { font-size: 2.4rem; margin: 0 0 1rem; line-height: 1.2; }
article.md h2 { font-size: 1.6rem; margin: 2.5rem 0 1rem; padding-top: .5rem; }
article.md h3 { font-size: 1.2rem; margin: 2rem 0 .75rem; }
article.md .admonition {
  border-left: 4px solid var(--color-primary); background: var(--color-surface-warm);
  border-radius: 0 var(--radius-card) var(--radius-card) 0; padding: .75rem 1rem; margin: 1rem 0;
}
article.md .admonition > .label { font-weight: 700; text-transform: uppercase; font-size: .8rem; color: var(--color-primary); }
.anchor { margin-left: .4rem; opacity: 0; color: var(--color-text-soft); }
h2:hover .anchor, h3:hover .anchor { opacity: 1; }
.menu-btn { display: none; }
@media (max-width: 1100px) { .docs { grid-template-columns: 220px minmax(0, 1fr); } .docs .toc { display: none; } }
@media (max-width: 760px) {
  .docs { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .docs .sidebar { position: static; max-height: none; padding: .75rem 0 0; display: none; }
  .docs .sidebar.open { display: block; }
  .menu-btn { display: inline-block; margin-top: 1rem; background: none; border: 1px solid var(--color-border); color: var(--color-text); border-radius: 6px; padding: .35rem .75rem; }
  article.md h1 { font-size: 1.9rem; }
}

/* highlight.js, light + dark */
.hljs-keyword, .hljs-literal, .hljs-built_in { color: #c0392b; }
.hljs-string, .hljs-attr + .hljs-string { color: #1a7f37; }
.hljs-attr, .hljs-property, .hljs-variable { color: #0550ae; }
.hljs-number { color: #953800; }
.hljs-comment { color: #6e7781; font-style: italic; }
:root[data-theme="dark"] .hljs-string { color: #7ee787; }
:root[data-theme="dark"] .hljs-attr, :root[data-theme="dark"] .hljs-property { color: #79c0ff; }
:root[data-theme="dark"] .hljs-keyword, :root[data-theme="dark"] .hljs-literal { color: #ff7b72; }
:root[data-theme="dark"] .hljs-number { color: #ffa657; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hljs-string { color: #7ee787; }
  :root:not([data-theme="light"]) .hljs-attr, :root:not([data-theme="light"]) .hljs-property { color: #79c0ff; }
  :root:not([data-theme="light"]) .hljs-keyword, :root:not([data-theme="light"]) .hljs-literal { color: #ff7b72; }
  :root:not([data-theme="light"]) .hljs-number { color: #ffa657; }
}

/* keep grid children from growing past the viewport (wide <pre>/tables scroll instead) */
.two-col > *, .docs > * { min-width: 0; }
@media (max-width: 480px) {
  .brand span { display: none; }
  .nav-links { gap: .9rem; }
}

/* docs tables: full width, scroll sideways only on narrow screens */
article.md .table-scroll { overflow-x: auto; margin: 1rem 0; }
article.md table { display: table; width: 100%; min-width: 640px; font-size: .88rem; }
article.md td code { white-space: normal; overflow-wrap: anywhere; }
