/*
 * LFAPI documentation stylesheet.
 * Palette and typography follow the LFAPI dopamine design system
 * (src/styles/lfapi-dopamine.css) so /docs/ and the app feel like one product:
 * cream canvas, paper cards, ink borders, purple primary, mint accents.
 * Light surface only, no external fonts, no external assets.
 */

:root {
  color-scheme: light;
  --ink: #252640;
  --muted: #62647a;
  --line: #e8e1d7;
  --cream: #fff9ef;
  --surface: #fffdf8;
  --canvas: #fff9ef;
  --brand: #6557e8;
  --brand-deep: #463bb1;
  --code: #252640;
  --mint: #d9f2e7;
  --mint-ink: #26785d;
  --purple-soft: #eeecff;
  --sand: #f3eee5;
  --yellow: #ffe08a;
  --radius: 14px;
  --card-shadow: 0 12px 28px rgba(37, 38, 64, 0.07);
  --header-h: 68px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 78% 4%, rgba(217, 242, 231, 0.7), transparent 30rem),
    radial-gradient(circle at 10% 8%, rgba(238, 236, 255, 0.95), transparent 32rem),
    radial-gradient(circle at 55% 100%, rgba(255, 224, 138, 0.2), transparent 36rem),
    var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.65;
}

a { color: inherit; text-decoration: none; }

/* Shared small print colour. */
.brand-label, .header-nav, .side-nav a, .sidebar-foot, .site-footer, .facts span,
.endpoint-list p, .steps p, .lead, .doc-section > p:not(.section-kicker), .closing p,
.nav-group, .sidebar-label { color: var(--muted); }

.skip-link { position: fixed; top: -4rem; left: 1rem; z-index: 30; border-radius: 8px; background: var(--ink); color: var(--cream); padding: 0.5rem 0.75rem; }
.skip-link:focus { top: 1rem; }

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 249, 239, 0.92);
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  width: min(1180px, calc(100% - 3rem));
  min-height: var(--header-h);
  margin: 0 auto;
}

.brand { display: inline-flex; align-items: center; gap: 0.62rem; font-weight: 750; white-space: nowrap; }
.brand img { display: block; flex: 0 0 auto; border-radius: 7px; }
.brand-label { border-left: 1px solid var(--line); padding-left: 0.62rem; font-size: 0.875rem; font-weight: 500; }

.header-nav { display: flex; align-items: center; gap: 1.35rem; font-size: 0.9rem; }
.header-nav a { padding: 0.5rem 0; border-bottom: 1px solid transparent; }
.header-nav a:hover { border-color: var(--brand); color: var(--brand-deep); }
.ext-mark { margin-left: 0.15rem; font-size: 0.85em; }

/* ----------------------------------------------------------------- shell */

.docs-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 760px);
  gap: clamp(2.2rem, 5vw, 5.4rem);
  width: min(1180px, calc(100% - 3rem));
  margin: 0 auto;
}

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 22px);
  align-self: start;
  max-height: calc(100vh - var(--header-h) - 3rem);
  overflow-y: auto;
  padding: clamp(3.7rem, 6vw, 5.4rem) 0 2rem;
  scrollbar-width: thin;
}

.sidebar-label, .section-kicker, .eyebrow { margin: 0 0 0.7rem; color: var(--brand-deep); font-size: 0.74rem; font-weight: 750; letter-spacing: 0.08em; }

.side-nav { display: grid; border-left: 1px solid var(--line); }
.nav-group { margin: 1.15rem 0 0.3rem; padding-left: 1rem; font-size: 0.7rem; font-weight: 750; letter-spacing: 0.1em; }
.nav-group:first-child { margin-top: 0; }
.side-nav a { margin-left: -1px; padding: 0.4rem 0 0.4rem 1rem; border-left: 2px solid transparent; font-size: 0.9rem; }
.side-nav a:hover { color: var(--ink); }
.side-nav a.active { border-left-color: var(--brand); color: var(--ink); font-weight: 650; }

.sidebar-foot { margin-top: 2rem; font-size: 0.78rem; line-height: 1.55; }
.sidebar-foot a, .site-footer a { color: var(--brand-deep); font-weight: 650; }

.content { min-width: 0; padding: clamp(3rem, 6vw, 5.4rem) 0 5rem; }

/* ------------------------------------------------------------ typography */

h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 11ch; margin-bottom: 1.2rem; font-size: clamp(2.65rem, 5vw, 4.35rem); line-height: 1.04; letter-spacing: -0.01em; }
h2 { margin-bottom: 1rem; font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.2; }
.lead { max-width: 62ch; font-size: 1.13rem; }

.section-head { display: flex; align-items: baseline; gap: 0.45rem; margin-bottom: 1rem; }
.section-head h2 { margin-bottom: 0; }

.heading-anchor { position: relative; flex: 0 0 auto; color: var(--line); font-size: 0.62em; font-weight: 700; line-height: 1; opacity: 0; transition: opacity 0.15s ease, color 0.15s ease; }
.section-head:hover .heading-anchor, .heading-anchor:focus-visible { opacity: 1; }
.heading-anchor:hover { color: var(--brand-deep); }
.heading-anchor::after {
  content: "复制链接";
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  background: var(--ink);
  color: var(--cream);
  font-size: 0.68rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.heading-anchor:hover::after { opacity: 1; }
.heading-anchor.is-copied::after { content: "已复制"; opacity: 1; }

@media (hover: none) {
  .heading-anchor { opacity: 1; }
}

/* ------------------------------------------------------------ components */

.intro { border-bottom: 1px solid var(--line); padding-bottom: 3.6rem; }
.intro-actions, .button-row { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.8rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 1.05rem;
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-size: 0.94rem;
  font-weight: 680;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.button.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 0 var(--brand-deep); }
.button.primary:hover { background: #7669ed; transform: translateY(-2px); box-shadow: 0 6px 0 var(--brand-deep); }

.button.secondary { background: var(--surface); color: var(--ink); box-shadow: 0 3px 0 var(--ink); }
.button.secondary:hover { border-color: var(--brand); color: var(--brand-deep); transform: translateY(-1px); box-shadow: 0 4px 0 var(--brand); }

.facts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin-top: 2.2rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.9);
  box-shadow: var(--card-shadow);
}
.facts div { min-width: 0; padding: 1.35rem 1.4rem; }
.facts div + div { border-left: 1px solid var(--line); }
.facts span { display: block; font-size: 0.75rem; }
.facts strong { display: block; overflow-wrap: anywhere; color: var(--ink); font-size: 0.83rem; font-weight: 650; line-height: 1.35; }

.doc-section { scroll-margin-top: calc(var(--header-h) + 20px); border-bottom: 1px solid var(--line); padding: 4.1rem 0; }
.intro { scroll-margin-top: calc(var(--header-h) + 20px); }
.doc-section > p:not(.section-kicker) { max-width: 66ch; }
.doc-section h3 { margin: 2.2rem 0 0.55rem; font-size: 1.06rem; line-height: 1.45; }
.doc-section ul { margin: 1rem 0 0; padding-left: 1.25rem; color: var(--muted); }
.doc-section ul li + li { margin-top: 0.35rem; }
.doc-section ul li::marker { color: var(--brand); }
.doc-section ul strong { color: var(--ink); }
.doc-section a:not(.button):not(.heading-anchor) { color: var(--brand-deep); font-weight: 600; }
.doc-section a:not(.button):not(.heading-anchor):hover { color: var(--brand); text-decoration: underline; }

.steps { display: grid; gap: 1.25rem; margin: 1.8rem 0 0; padding: 0; list-style: none; }
.steps li { display: grid; grid-template-columns: 2rem 1fr; gap: 0.9rem; }
.steps li > span { display: grid; width: 2rem; height: 2rem; place-items: center; border: 2px solid var(--brand); border-radius: 50%; background: var(--purple-soft); color: var(--brand-deep); font-size: 0.82rem; font-weight: 750; }
.steps strong { font-size: 1rem; }
.steps p { margin: 0.15rem 0 0; font-size: 0.93rem; }

code {
  border-radius: 5px;
  background: var(--purple-soft);
  padding: 0.1em 0.32em;
  color: var(--brand-deep);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
}

p code, li code { overflow-wrap: anywhere; }

.code-block { margin-top: 1.55rem; overflow: hidden; border-radius: 12px; background: var(--code); color: #e5f4ef; box-shadow: var(--card-shadow); }
.code-title { display: flex; justify-content: space-between; align-items: center; min-height: 42px; padding: 0 0.6rem 0 0.9rem; border-bottom: 1px solid #3c3e5b; color: #b9b7c9; font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.76rem; }
.copy-button { border: 1px solid #5a53a8; border-radius: 7px; background: transparent; color: #dcd9f5; padding: 0.25rem 0.6rem; font: inherit; cursor: pointer; }
.copy-button:hover { border-color: var(--brand); background: rgba(101, 87, 232, 0.18); color: #fff; }
pre { margin: 0; overflow-x: auto; padding: 1rem; font-size: 0.84rem; line-height: 1.6; }
.code-block.compact pre { padding: 0.85rem 1rem; }
.code-block pre code { padding: 0; background: transparent; color: inherit; font-size: inherit; }

.endpoint-list { display: grid; margin-top: 1.3rem; border-top: 1px solid var(--line); }
.endpoint-list article { display: grid; grid-template-columns: 58px minmax(0, 1fr); align-items: start; gap: 0.8rem; border-bottom: 1px solid var(--line); padding: 1rem 0; }
.method { width: fit-content; border-radius: 4px; padding: 0.15rem 0.35rem; font-size: 0.69rem; font-weight: 800; letter-spacing: 0.04em; }
.method.get { background: var(--mint); color: var(--mint-ink); }
.method.post { background: var(--purple-soft); color: var(--brand-deep); }
.endpoint-list code { overflow-wrap: anywhere; }
.endpoint-list p { margin: 0.2rem 0 0; font-size: 0.88rem; }

.note { display: grid; gap: 0.2rem; margin-top: 1.6rem; border: 1px solid #b8e2d1; border-left: 4px solid #3aa982; border-radius: 12px; background: var(--mint); padding: 1rem 1.1rem; box-shadow: 0 10px 22px rgba(58, 169, 130, 0.1); }
.note p { margin: 0; color: #365c50; }
.note strong { color: #1f4a3d; }

.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.1rem; }
.tag-list code { padding: 0.3em 0.6em; border-radius: 8px; font-size: 0.83rem; }

.link-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem 0.8rem; margin-top: 1.2rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 0.6rem 0.8rem; box-shadow: var(--card-shadow); }
.link-row code { flex: 1 1 14rem; min-width: 0; background: transparent; padding: 0; color: var(--ink); font-size: 0.86rem; overflow-wrap: anywhere; }
.copy-inline { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: var(--cream); color: var(--brand-deep); padding: 0.3rem 0.75rem; font: inherit; font-size: 0.8rem; font-weight: 650; cursor: pointer; }
.copy-inline:hover { border-color: var(--brand); background: var(--purple-soft); }

.response-table { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 10px 22px rgba(37, 38, 64, 0.06); font-size: 0.88rem; }
.response-table + p { margin-top: 1.1rem; }
.response-row { display: grid; grid-template-columns: 72px minmax(130px, 0.9fr) minmax(180px, 1.2fr); gap: 1rem; padding: 0.78rem 1rem; }
.response-row + .response-row { border-top: 1px solid var(--line); }
.response-row.header { background: var(--sand); color: var(--muted); font-size: 0.74rem; font-weight: 750; letter-spacing: 0.02em; }
.response-row code { overflow-wrap: anywhere; }
.response-row a { color: var(--brand-deep); font-weight: 600; }
.response-row a:hover { text-decoration: underline; }
.response-row.cols-2 { grid-template-columns: minmax(150px, 0.72fr) minmax(0, 1.28fr); }
.response-row.cols-3 { grid-template-columns: minmax(96px, 0.48fr) minmax(0, 1.2fr) minmax(150px, 1fr); }

.script-list { display: grid; gap: 0.7rem; margin-top: 1.5rem; max-width: 34rem; }
.script-list .button { justify-content: flex-start; text-align: left; }
.script-name { margin-left: auto; padding-left: 1rem; color: var(--muted); font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 0.78em; font-weight: 600; }

.closing { margin-top: 4.4rem; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 14px; background: var(--surface); padding: 1.4rem 1.5rem; box-shadow: var(--card-shadow); }
.closing h2 { margin-bottom: 0.45rem; }

.site-footer { display: flex; gap: 1.2rem; flex-wrap: wrap; width: min(1180px, calc(100% - 3rem)); margin: 0 auto; border-top: 1px solid var(--line); padding: 1.5rem 0 2.4rem; font-size: 0.8rem; }
.site-footer span:first-child { color: var(--ink); font-weight: 750; }

/* -------------------------------------------------------------- narrow */

@media (max-width: 820px) {
  :root { --header-h: 104px; }

  .header-inner { flex-wrap: wrap; gap: 0.4rem 1rem; width: min(100% - 2rem, 720px); min-height: 0; padding: 0.75rem 0 0; }
  .header-nav { order: 3; flex: 1 1 100%; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.6rem; font-size: 0.84rem; scrollbar-width: thin; }
  .header-nav a { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 40px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); padding: 0 0.85rem; white-space: nowrap; }
  .header-nav a:hover { border-color: var(--brand); }

  .docs-shell { display: block; width: min(100% - 2rem, 720px); }
  .sidebar { position: static; max-height: none; overflow: visible; padding: 1.1rem 0 0; }
  .sidebar-label, .sidebar-foot, .nav-group { display: none; }
  .side-nav { display: flex; gap: 0.4rem; overflow-x: auto; border-left: 0; border-bottom: 0; padding-bottom: 0.5rem; scrollbar-width: thin; }
  .side-nav a { display: inline-flex; align-items: center; flex: 0 0 auto; min-height: 40px; margin: 0; padding: 0 0.75rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 0.86rem; white-space: nowrap; }
  .side-nav a.active { border-color: var(--brand); background: var(--purple-soft); color: var(--brand-deep); font-weight: 650; }

  .content { padding: 2.4rem 0 3.6rem; }
  .facts { grid-template-columns: 1fr; }
  .facts div + div { border-top: 1px solid var(--line); border-left: 0; }
  .code-title { min-height: 52px; }
  .copy-button { min-height: 40px; padding: 0.35rem 0.8rem; }
  .copy-inline { min-height: 40px; }
}

@media (max-width: 560px) {
  body { font-size: 15px; }
  .brand-label { display: none; }
  h1 { font-size: 2.55rem; }
  .facts div { display: grid; grid-template-columns: 84px 1fr; gap: 0.6rem; align-items: baseline; padding: 1rem 1.15rem; }
  .facts span { font-size: 0.71rem; }
  .doc-section { padding: 3.1rem 0; }
  .endpoint-list article { grid-template-columns: 52px minmax(0, 1fr); }
  pre { font-size: 0.8rem; }

  /* Tables become stacked cards so nothing needs horizontal panning. */
  .response-table { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .response-row { display: block; margin-top: 0.65rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 6px 16px rgba(37, 38, 64, 0.05); padding: 0.8rem 0.95rem; }
  .response-row + .response-row { border-top: 1px solid var(--line); }
  .response-row.header { display: none; }
  .response-row > span { display: block; min-width: 0; }
  .response-row > span + span { margin-top: 0.3rem; }
  .response-row > span:first-child { color: var(--ink); font-weight: 700; }
  .response-row > span:last-child { color: var(--muted); font-size: 0.93em; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .button, .heading-anchor, .heading-anchor::after { transition: none; }
  .button.primary:hover, .button.secondary:hover { transform: none; }
}

/* Keep keyboard focus visible everywhere; no rule below removes it. */
:focus-visible { outline: 2px solid var(--brand-deep); outline-offset: 2px; }
