/* Scoped developer blueprint & API console polish for ai-api.html.
   Strictly isolated under .wqb-api so other pages using business.css remain untouched. */
.wqb-api {
  --api-indigo: #9cb0ff;
  --api-indigo-hi: #cad5ff;
  --api-mint: #7de2d8;
  --api-line: #323747;
  --api-line-hi: rgb(156 176 255 / 44%);
  --api-surface: #12151f;
  --api-ease: cubic-bezier(.22, 1, .36, 1);
  overflow-x: clip;
}

/* 顶部原生 CSS 滚动阅读进度条（渐进增强） */
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .wqb-api::before {
      content: "";
      position: fixed;
      inset: 0 0 auto 0;
      z-index: 90;
      block-size: 2px;
      background: linear-gradient(90deg, var(--api-indigo), var(--api-mint) 62%, #d8f8f4);
      box-shadow: 0 0 12px rgb(125 226 216 / 55%);
      transform-origin: 0 50%;
      transform: scaleX(0);
      pointer-events: none;
      animation: api-scroll-progress linear both;
      animation-timeline: scroll(root block);
    }
  }
}

/* =========================================================
   HERO 开发者蓝图首屏 + 交互准备清单
   ========================================================= */
.wqb-api .wqb-hero {
  position: relative;
  isolation: isolate;
  padding-block: clamp(64px, 7.5vw, 108px) clamp(48px, 6vw, 84px);
}

.wqb-api .wqb-hero::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -12% -10% -6%;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 52% 48% at 76% 34%, rgb(125 148 242 / 14%), transparent 66%),
    radial-gradient(ellipse 40% 40% at 24% 62%, rgb(125 226 216 / 8%), transparent 66%),
    radial-gradient(rgb(176 192 255 / 12%) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 28px 28px;
  mask-image: linear-gradient(to bottom, #000 68%, transparent 100%);
}

.wqb-api .wqb-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--api-mint);
  letter-spacing: .12em;
}

.wqb-api .wqb-label::before {
  content: "";
  inline-size: 18px;
  block-size: 1px;
  background: linear-gradient(90deg, var(--api-mint), var(--api-indigo));
}

.wqb-api h1 em {
  color: var(--api-indigo-hi);
  background: linear-gradient(105deg, #e6ecff 10%, var(--api-indigo) 54%, var(--api-mint));
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* 按钮扫光与链接过渡 */
.wqb-api .wqb-cta {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: 4px;
  border-color: #d2dcff;
  background: linear-gradient(180deg, #ccd7ff, #b1c0ff);
  color: #0e1222;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 60%), 0 12px 28px -12px rgb(134 156 245 / 68%);
  transition: transform 280ms var(--api-ease), box-shadow 280ms var(--api-ease), border-color 280ms;
}

.wqb-api .wqb-cta::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(115deg, transparent 22%, rgb(255 255 255 / 72%) 50%, transparent 78%);
  transform: translateX(-115%);
  pointer-events: none;
}

.wqb-api .wqb-cta:hover {
  border-color: #ecf1ff;
  background: linear-gradient(180deg, #dde5ff, #c2ceff);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%), 0 16px 34px -10px rgb(156 176 255 / 82%);
}

.wqb-api .wqb-link {
  transition: color 240ms var(--api-ease), text-decoration-color 240ms var(--api-ease);
}

.wqb-api .wqb-link:hover {
  color: var(--api-mint);
}

/* 右侧接入流程控制台卡片 */
.wqb-api .wqb-api-stage {
  position: relative;
  border: 1px solid rgb(156 176 255 / 32%);
  border-radius: 10px;
  background:
    radial-gradient(ellipse at 82% 0%, rgb(125 226 216 / 10%), transparent 52%),
    radial-gradient(ellipse at 20% 100%, rgb(134 156 245 / 14%), transparent 60%),
    linear-gradient(180deg, #151a28, #0f121c);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 10%), 0 28px 72px -28px rgb(0 0 0 / 82%);
}

.wqb-api .wqb-api-top {
  border-bottom-color: rgb(156 176 255 / 22%);
}

.wqb-api .wqb-api-top strong {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
}

.wqb-api .wqb-api-top strong::before {
  content: "";
  inline-size: 7px;
  block-size: 7px;
  border-radius: 50%;
  background: var(--api-mint);
  box-shadow: 0 0 10px var(--api-mint);
}

.wqb-api .wqb-api-top span {
  padding: 3px 9px;
  border: 1px solid rgb(125 226 216 / 30%);
  border-radius: 999px;
  background: rgb(125 226 216 / 9%);
  color: var(--api-mint);
  font-size: 11.5px;
  font-weight: 600;
}

.wqb-api .wqb-api-stage details {
  border: 1px solid rgb(134 156 245 / 20%);
  border-radius: 6px;
  background: rgb(14 18 29 / 84%);
  transition: border-color 300ms var(--api-ease), background 300ms var(--api-ease), box-shadow 300ms var(--api-ease);
}

.wqb-api .wqb-api-stage details:hover {
  border-color: rgb(156 176 255 / 42%);
}

.wqb-api .wqb-api-stage details[open] {
  border-color: rgb(125 226 216 / 52%);
  background: linear-gradient(145deg, rgb(28 38 61 / 92%), rgb(18 23 38 / 95%));
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 8%), 0 14px 32px -18px rgb(125 226 216 / 35%);
}

.wqb-api .wqb-api-stage summary {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  list-style: none;
}

.wqb-api .wqb-api-stage summary::-webkit-details-marker { display: none; }

.wqb-api .wqb-api-stage summary::after {
  content: "+";
  flex: none;
  color: var(--api-indigo);
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  transition: transform 280ms var(--api-ease), color 280ms;
}

.wqb-api .wqb-api-stage details[open] summary::after {
  content: "−";
  color: var(--api-mint);
}

.wqb-api .wqb-api-stage details p {
  margin: 0 15px 14px;
  padding-top: 2px;
  color: #cfd6ea;
  font-size: 13.5px;
  line-height: 1.75;
}

/* =========================================================
   吸顶快速章节导航轨 (.wqapi-toc)
   ========================================================= */
.wqapi-toc-wrap {
  position: sticky;
  top: 72px;
  z-index: 25;
  border-block: 1px solid var(--api-line);
  background: rgb(13 14 18 / 84%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.wqapi-toc {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-block: 10px;
  scrollbar-width: none;
}
.wqapi-toc::-webkit-scrollbar { display: none; }

.wqapi-toc a {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--wqb-muted);
  font-size: 12.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  white-space: nowrap;
  transition: color 240ms var(--api-ease), background 240ms var(--api-ease), border-color 240ms var(--api-ease);
}

.wqapi-toc a:hover {
  color: var(--wqb-ink);
  background: rgb(255 255 255 / 5%);
}

.wqapi-toc a[aria-current="location"] {
  border-color: rgb(125 226 216 / 42%);
  background: rgb(125 226 216 / 11%);
  color: var(--api-mint);
}

/* =========================================================
   内容章节定位偏移 & 文档 2x2 核对网格
   ========================================================= */
.wqb-api .wqb-section {
  /* The shared 100px scroll padding also contributes to the anchor offset. */
  scroll-margin-top: 44px;
}

.wqb-api .wqb-reference {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px !important;
  border-block: 0;
}

.wqb-api .wqb-reference > div {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: 8px;
  padding: clamp(18px, 2.2vw, 26px);
  border: 1px solid var(--api-line);
  border-radius: 8px;
  background: linear-gradient(155deg, #141824, #0f1119);
  --api-mx: 50%;
  --api-my: 0%;
  transition: border-color 320ms var(--api-ease), transform 320ms var(--api-ease), box-shadow 320ms var(--api-ease);
}

.wqb-api .wqb-reference > div + div {
  border-top: 1px solid var(--api-line);
}

.wqb-api .wqb-reference > div::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(260px circle at var(--api-mx) var(--api-my), rgb(125 226 216 / 13%), transparent 68%);
  opacity: 0;
  transition: opacity 320ms var(--api-ease);
}

.wqb-api .wqb-reference > div:hover {
  border-color: var(--api-line-hi);
  box-shadow: 0 20px 44px -26px rgb(0 0 0 / 85%);
}

.wqb-api .wqb-reference > div:hover::before { opacity: 1; }

.wqb-api .wqb-reference dt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 16px;
}

.wqb-api .wqb-reference dt::after {
  content: attr(data-tag);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .1em;
  padding: 2px 7px;
  border: 1px solid rgb(156 176 255 / 30%);
  border-radius: 3px;
  background: rgb(156 176 255 / 9%);
  color: var(--api-indigo-hi);
}

.wqb-api .wqb-reference dd {
  font-size: 14px;
  line-height: 1.72;
}

/* =========================================================
   首条请求三阶段信号流水线 (.wqapi-pipeline)
   ========================================================= */
.wqapi-pipeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  list-style: none;
  margin: 22px 0 0;
  padding: 12px;
  border: 1px solid var(--api-line);
  border-radius: 8px;
  background: linear-gradient(180deg, #131723, #0e1018);
  overflow: hidden;
}

.wqapi-pipeline::before {
  content: "";
  position: absolute;
  inset: 50% 8% auto 8%;
  block-size: 1px;
  background: linear-gradient(90deg, transparent, rgb(156 176 255 / 45%) 25%, rgb(125 226 216 / 75%) 50%, rgb(156 176 255 / 45%) 75%, transparent);
  pointer-events: none;
}

.wqapi-pipeline::after {
  content: "";
  position: absolute;
  inset: calc(50% - 2px) auto auto 0;
  inline-size: 86px;
  block-size: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--api-mint), transparent);
  filter: blur(1px);
  opacity: 0;
  pointer-events: none;
}

.wqapi-pipeline li {
  position: relative;
  z-index: 1;
  padding: 14px 12px;
  border: 1px solid rgb(156 176 255 / 20%);
  border-radius: 6px;
  background: #101420ee;
  text-align: center;
  transition: border-color 280ms var(--api-ease), transform 280ms var(--api-ease);
}

.wqapi-pipeline li:nth-child(2) {
  border-color: rgb(125 226 216 / 48%);
  background: linear-gradient(155deg, #162433, #101724);
  box-shadow: 0 0 26px -10px rgb(125 226 216 / 55%);
}

.wqapi-pipeline strong {
  display: block;
  color: var(--wqb-ink);
  font-size: 13.5px;
  font-weight: 600;
}

.wqapi-pipeline li:nth-child(2) strong {
  color: var(--api-mint);
}

.wqapi-pipeline span {
  display: block;
  margin-top: 4px;
  color: var(--wqb-muted);
  font-size: 11.5px;
}

/* =========================================================
   常见问题 FAQ 手风琴微交互
   ========================================================= */
.wqb-api .wqb-faq details {
  padding: 16px 6px;
  transition: background 280ms var(--api-ease), border-color 280ms var(--api-ease);
}

.wqb-api .wqb-faq details[open] {
  background: linear-gradient(90deg, rgb(156 176 255 / 7%), transparent 85%);
  border-bottom-color: var(--api-line-hi);
}

.wqb-api .wqb-faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
}

.wqb-api .wqb-faq summary::-webkit-details-marker { display: none; }

.wqb-api .wqb-faq summary::after {
  content: "+";
  flex: none;
  color: var(--api-indigo);
  font-size: 19px;
  font-weight: 400;
  line-height: 1;
  transition: transform 280ms var(--api-ease), color 280ms;
}

.wqb-api .wqb-faq details[open] summary::after {
  transform: rotate(45deg);
  color: var(--api-mint);
}

.wqb-api .wqb-faq details p,
.wqb-api .wqb-faq details a {
  margin-left: 0;
}

.wqb-api .wqb-faq details a {
  margin-top: 8px;
}

/* =========================================================
   动效与入场（遵循 prefers-reduced-motion）
   ========================================================= */
@media (prefers-reduced-motion: no-preference) {
  .wqb-api .wqb-faq details[open] > :is(p, a) {
    animation: wqb-appear 280ms ease-out both;
  }

  .wqb-api .wqb-hero-copy > * {
    animation: api-rise 760ms var(--api-ease) both;
  }
  .wqb-api .wqb-hero-copy > *:nth-child(2) { animation-delay: 70ms; }
  .wqb-api .wqb-hero-copy > *:nth-child(3) { animation-delay: 140ms; }
  .wqb-api .wqb-hero-copy > *:nth-child(4) { animation-delay: 205ms; }
  .wqb-api .wqb-api-stage {
    animation: api-stage-in 860ms var(--api-ease) 110ms both;
  }

  .wqb-api .wqb-api-top strong::before {
    animation: api-pulse 2.6s ease-in-out infinite;
  }

  .wqapi-pipeline::after {
    animation: api-signal 3.4s var(--api-ease) infinite;
  }

  .wqb-api [data-api-reveal="pending"]:not(:focus-within) {
    opacity: 0;
    transform: translateY(22px);
    filter: blur(4px);
  }
  .wqb-api [data-api-reveal="visible"]:not(:focus-within) {
    animation: api-reveal 700ms var(--api-ease) calc(var(--api-stagger, 0) * 75ms) backwards;
  }
}

@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .wqb-api .wqb-cta:hover { transform: translateY(-2px); }
  .wqb-api .wqb-cta:hover::after { animation: api-shimmer 720ms var(--api-ease) both; }
  .wqb-api .wqb-reference > div:hover { transform: translateY(-3px); }
  .wqapi-pipeline li:hover { transform: translateY(-2px); border-color: var(--api-line-hi); }
}

@keyframes api-scroll-progress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes api-rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes api-stage-in {
  from { opacity: 0; transform: translateY(22px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes api-reveal {
  from { opacity: 0; transform: translateY(22px); filter: blur(4px); }
}
@keyframes api-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .42; transform: scale(.85); }
}
@keyframes api-shimmer {
  from { transform: translateX(-115%); }
  to { transform: translateX(115%); }
}
@keyframes api-signal {
  0% { opacity: 0; transform: translateX(-10%); }
  16% { opacity: .95; }
  84% { opacity: .95; }
  100% { opacity: 0; transform: translateX(640%); }
}

/* =========================================================
   响应式与高对比度无障碍降级
   ========================================================= */
@media (max-width: 720px) {
  .wqapi-toc-wrap { top: 68px; }
  .wqb-api .wqb-reference { grid-template-columns: minmax(0, 1fr); }
  .wqapi-pipeline { grid-template-columns: minmax(0, 1fr); }
  .wqapi-pipeline::before, .wqapi-pipeline::after { display: none; }
}

@media (forced-colors: active) {
  .wqb-api h1 em {
    background: transparent;
    color: CanvasText;
    -webkit-text-fill-color: currentColor;
  }
  .wqapi-toc a[aria-current="location"] {
    border: 2px solid Highlight;
    color: Highlight;
  }
}
