:root {
  color-scheme: dark;
  --ink: #070605;
  --paper: #fff8ea;
  --muted: rgba(255, 248, 234, 0.7);
  --line: rgba(255, 214, 160, 0.24);
  --ember: #d98532;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Microsoft YaHei", sans-serif;
}

body {
  min-height: 100vh;
}

.site-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 18%, rgba(170, 92, 24, 0.22), transparent 30%),
    #020201;
}

.hero-image,
#particle-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-image {
  object-fit: cover;
  object-position: center;
  opacity: 0;
  filter: saturate(1.04) contrast(1.04);
  transform: scale(1.025);
  transition:
    opacity 900ms ease,
    transform 1200ms ease;
  z-index: 0;
}

body.image-settled .hero-image {
  opacity: 0.84;
  transform: scale(1);
}

.site-shell::before {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.68), transparent 34%, rgba(0, 0, 0, 0.26)),
    linear-gradient(0deg, rgba(0, 0, 0, 0.52), transparent 42%);
}

.site-shell::after {
  position: absolute;
  inset: 24px;
  z-index: 3;
  pointer-events: none;
  content: "";
  border: 1px solid var(--line);
  opacity: 0;
  transition: opacity 900ms ease 1100ms;
}

body.image-settled .site-shell::after {
  opacity: 1;
}

#particle-stage {
  display: block;
  z-index: 1;
}

.identity {
  position: absolute;
  left: clamp(28px, 7vw, 112px);
  bottom: clamp(42px, 10vh, 112px);
  z-index: 4;
  max-width: min(620px, calc(100vw - 56px));
  color: var(--paper);
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 850ms ease 1250ms,
    transform 850ms ease 1250ms;
}

body.image-settled .identity {
  opacity: 1;
  transform: translateY(0);
}

.kicker {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family:
    "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
  font-size: 7rem;
  font-weight: 500;
  line-height: 0.96;
  letter-spacing: 0;
  text-wrap: balance;
  text-shadow: 0 16px 54px rgba(0, 0, 0, 0.58);
}

.subtitle {
  max-width: 420px;
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.8;
}

@media (max-width: 1100px) {
  h1 {
    font-size: 5.7rem;
  }
}

@media (max-width: 720px) {
  .site-shell {
    background:
      radial-gradient(circle at 74% 20%, rgba(170, 92, 24, 0.18), transparent 36%),
      #020201;
  }

  .hero-image {
    object-position: 56% center;
  }

  .site-shell::before {
    background:
      linear-gradient(90deg, rgba(0, 0, 0, 0.72), transparent 58%),
      linear-gradient(0deg, rgba(0, 0, 0, 0.68), transparent 48%);
  }

  .site-shell::after {
    inset: 14px;
  }

  .identity {
    left: 26px;
    right: 26px;
    bottom: 46px;
    max-width: none;
  }

  .subtitle {
    max-width: 300px;
    margin-top: 18px;
    font-size: 1rem;
  }

  h1 {
    font-size: 3.45rem;
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-image,
  .identity,
  .site-shell::after {
    transition: none;
  }
}

/* ═══════════════════════════════════════════
   API Docs Section
   ═══════════════════════════════════════════ */

.api-docs {
  position: relative;
  z-index: 5;
  padding: 64px 28px 80px;
  background:
    linear-gradient(180deg, rgba(2, 2, 1, 0.94), rgba(7, 6, 5, 1) 20%);
  border-top: 1px solid var(--line);
}

.docs-container {
  max-width: 740px;
  margin: 0 auto;
  color: var(--paper);
}

.docs-container h2 {
  margin: 0 0 8px;
  font-family: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;
  font-size: 2.2rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.docs-intro {
  margin: 0 0 36px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.docs-note {
  margin: 4px 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

.docs-container h3 {
  margin: 40px 0 12px;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ember);
}

.docs-container h4 {
  margin: 20px 0 8px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Route explanation */
.route-explain {
  margin: 0 0 10px;
}

.route-explain > p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.route-table {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.85rem;
}

.route-row {
  display: grid;
  grid-template-columns: 200px 100px 1fr;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255, 214, 160, 0.08);
}

.route-row:last-child {
  border-bottom: none;
}

.route-header {
  background: rgba(255, 214, 160, 0.06);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.route-row code {
  font-family: "JetBrains Mono", "Cascadia Code", "Fira Code", monospace;
  font-size: 0.82rem;
  color: var(--ember);
}

/* Code blocks */
.code-block {
  margin: 8px 0 24px;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.65;
}

.code-block code {
  font-family: "JetBrains Mono", "Cascadia Code", "Fira Code", monospace;
  color: #e8d5b0;
  white-space: pre;
}

/* Model tags */
.model-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 16px;
}

.model-tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--muted);
}

.model-tag.highlight {
  border-color: var(--ember);
  color: var(--ember);
}

/* Footer */
.docs-footer {
  margin: 48px 0 0;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 214, 160, 0.1);
  font-size: 0.78rem;
  color: rgba(255, 248, 234, 0.32);
}

.docs-footer a {
  color: var(--ember);
  text-decoration: none;
}

.docs-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  .api-docs {
    padding: 40px 16px 60px;
  }

  .docs-container h2 {
    font-size: 1.6rem;
  }

  .route-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .route-header {
    display: none;
  }

  .route-row span::before {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 2px;
  }

  .route-row span:nth-child(1)::before { content: "路径"; }
  .route-row span:nth-child(2)::before { content: "协议"; }
  .route-row span:nth-child(3)::before { content: "处理方式"; }

  .code-block {
    padding: 12px 14px;
    font-size: 0.74rem;
  }
}

/* ==============================================
   Top Navigation
   ============================================== */

.top-nav {
  position: absolute;
  top: 28px;
  right: clamp(28px, 7vw, 56px);
  z-index: 5;
  display: flex;
  gap: 16px;
  align-items: center;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 850ms ease 1600ms, transform 850ms ease 1600ms;
}

body.image-settled .top-nav {
  opacity: 1;
  transform: translateY(0);
}

.nav-link {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 6px 16px;
  border-radius: 100px;
  transition: color 200ms ease, background 200ms ease;
}

.nav-link:hover {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link-primary {
  color: var(--ember);
  border: 1px solid rgba(217, 133, 50, 0.4);
}

.nav-link-primary:hover {
  background: rgba(217, 133, 50, 0.12);
  color: var(--ember);
}

/* ==============================================
   Scroll Hint
   ============================================== */

.scroll-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 850ms ease 2000ms;
  pointer-events: none;
}

body.image-settled .scroll-hint {
  opacity: 1;
}

.scroll-hint.hidden {
  opacity: 0 !important;
  transition: opacity 300ms ease;
}

.scroll-arrow {
  color: var(--muted);
  animation: bounce 2s ease-in-out infinite;
}

.scroll-text {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

/* ==============================================
   Responsive adjustments
   ============================================== */

@media (max-width: 720px) {
  .top-nav {
    top: 16px;
    right: 16px;
    gap: 10px;
  }

  .nav-link {
    font-size: 0.78rem;
    padding: 5px 12px;
  }
}
