@import url('https://fonts.googleapis.com/css2?family=Lexend+Mega:wght@100..900&family=Public+Sans:wght@100..900&display=swap');

/* ========================================
   CSS 变量 & 基础重置
======================================== */
:root {
  --c-bg: #1f1f1f;
  --c-bg-2: #2a2a2a;
  --c-bg-3: #333333;
  --c-surface: #242424;
  --c-white: #ffffff;
  --c-off-white: #f5f5f5;
  --c-accent: #ffffff;
  --c-text: #f5f5f5;
  --c-text-muted: #aaaaaa;
  --c-border: rgba(255,255,255,0.10);
  --c-slash: rgba(255,255,255,0.06);

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.40);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.55);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.65);
  --shadow-xl: 0 32px 80px rgba(0,0,0,0.75);

  --radius-card: 4px;
  --radius-pill: 999px;

  --font-head: 'Lexend Mega', 'Public Sans', system-ui, sans-serif;
  --font-body: 'Public Sans', system-ui, sans-serif;

  --topbar-h: 64px;
  --anchor-h: 44px;
  --sticky-offset: calc(var(--topbar-h) + var(--anchor-h));
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  background: var(--c-bg);
  color: var(--c-text);
}

body, .dark-body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  background: var(--c-bg);
  color: var(--c-text);
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

ul {
  list-style: none;
}

/* ========================================
   scroll-margin-top for anchored sections
======================================== */
div[id] {
  scroll-margin-top: var(--sticky-offset);
}

/* ========================================
   SITE WRAPPER
======================================== */
.site-wrapper {
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* ========================================
   TOPBAR (aside > nav > ul > li > a)
======================================== */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  z-index: 100;
  background: rgba(31,31,31,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-md);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  text-decoration: none;
}

.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
}

.brand-name {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1rem;
  color: var(--c-white);
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.main-nav {
  flex: 1;
  overflow: hidden;
}

.main-nav ul {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav ul::-webkit-scrollbar {
  display: none;
}

.main-nav ul li a.nav-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  min-height: 40px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--c-text-muted);
  white-space: nowrap;
  border: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.main-nav ul li a.nav-pill:hover,
.main-nav ul li a.nav-pill:focus-visible {
  color: var(--c-white);
  border-color: var(--c-border);
  background: rgba(255,255,255,0.06);
  outline: none;
}

/* 搜索框 */
.nav-search {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.search-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--c-white);
  outline: none;
  width: 160px;
  transition: border-color 0.2s, width 0.3s;
  font-family: var(--font-body);
  min-height: 40px;
}

.search-input::placeholder {
  color: var(--c-text-muted);
}

.search-input:focus {
  border-color: rgba(255,255,255,0.3);
  width: 200px;
}

.search-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-pill);
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-white);
  transition: background 0.2s;
}

.search-btn:hover {
  background: rgba(255,255,255,0.14);
}

/* 汉堡按钮（仅移动端显示） */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  cursor: pointer;
  flex-shrink: 0;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--c-white);
  border-radius: 2px;
  transition: transform 0.2s;
}

/* 移动端菜单 */
.mobile-nav {
  background: rgba(31,31,31,0.97);
  border-top: 1px solid var(--c-border);
  padding: 12px 24px 20px;
}

.mobile-nav ul {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-nav ul li a.nav-pill {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  min-height: 48px;
  border-radius: var(--radius-card);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--c-text);
  border: 1px solid var(--c-border);
  transition: background 0.2s;
}

.mobile-nav ul li a.nav-pill:hover {
  background: rgba(255,255,255,0.06);
}

/* ========================================
   STICKY ANCHOR BAR
======================================== */
.sticky-anchor-bar {
  position: sticky;
  top: var(--topbar-h);
  z-index: 90;
  background: rgba(26,26,26,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
}

.anchor-bar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--anchor-h);
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.anchor-bar-inner::-webkit-scrollbar {
  display: none;
}

.anchor-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  min-height: 32px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-text-muted);
  white-space: nowrap;
  border: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  font-family: var(--font-body);
}

.anchor-pill:hover,
.anchor-pill:focus-visible {
  color: var(--c-white);
  border-color: var(--c-border);
  background: rgba(255,255,255,0.07);
  outline: none;
}

/* ========================================
   HERO
======================================== */
.hero-wrap {
  position: relative;
  width: 100%;
  height: 45vh;
  min-height: 300px;
  max-height: 520px;
  margin-top: var(--topbar-h);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.hero-media {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.hero-bg-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.04);
  will-change: transform;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(31,31,31,0.82) 40%, rgba(31,31,31,0.45) 100%);
  z-index: 2;
}

/* 斜切色带 */
.hero-slash {
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 80px;
  background: var(--c-bg);
  clip-path: polygon(0 60%, 100% 0, 100% 100%, 0 100%);
  z-index: 3;
}

/* 三维层叠装饰卡 */
.hero-depth-card {
  position: absolute;
  border-radius: var(--radius-card);
  border: 1px solid var(--c-border);
  z-index: 2;
  pointer-events: none;
}

.hero-depth-card--1 {
  width: 120px;
  height: 80px;
  right: 12%;
  top: 20%;
  background: rgba(255,255,255,0.04);
  box-shadow: var(--shadow-lg);
  transform: rotate(-6deg) translateZ(0);
  backdrop-filter: blur(4px);
}

.hero-depth-card--2 {
  width: 80px;
  height: 54px;
  right: 8%;
  top: 38%;
  background: rgba(255,255,255,0.03);
  box-shadow: var(--shadow-md);
  transform: rotate(3deg) translateZ(0);
}

.hero-depth-card--3 {
  width: 60px;
  height: 40px;
  right: 16%;
  top: 52%;
  background: rgba(255,255,255,0.02);
  box-shadow: var(--shadow-sm);
  transform: rotate(-2deg) translateZ(0);
}

.hero-content {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 0 24px;
  max-width: 780px;
}

.hero-eyebrow {
  margin-bottom: 12px;
}

.hero-eyebrow small {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  background: rgba(255,255,255,0.08);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--c-border);
}

.hero-h1 {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  font-weight: 900;
  color: var(--c-white);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
}

.hero-desc {
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  color: var(--c-text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  padding: 12px 28px;
  min-height: 48px;
  background: var(--c-white);
  color: var(--c-bg);
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  transition: transform 0.2s, box-shadow 0.2s;
}

.hero-cta:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* ========================================
   PAGE MAIN — content-section (main > div > figure/aside 交错)
======================================== */
.page-main {
  position: relative;
  z-index: 3;
  max-width: 1280px;
  margin: 0 auto;
  padding: 60px 24px 40px;
}

.content-section {
  display: grid;
  grid-template-columns: 1fr 280px;
  grid-template-rows: auto 1fr;
  gap: 32px 40px;
  position: relative;
}

/* figure 作为装饰层叠元素（div 直接子） */
.content-figure {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
  position: relative;
  height: 8px;
  margin-bottom: -20px;
}

.figure-deco {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--c-white), transparent);
  border-radius: 2px;
  opacity: 0.15;
}

/* 正文区 */
.content-body {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  min-width: 0;
}

/* aside 在内容右侧（div 直接子） */
.content-aside {
  grid-column: 2 / 3;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ========================================
   SECTION EYEBROW + HEADING
======================================== */
.section-eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: 8px;
}

.section-heading {
  font-family: var(--font-head);
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 800;
  color: var(--c-white);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--c-border);
}

/* ========================================
   PROSE CONTENT（page.content 注入区）
======================================== */
.prose-content {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--c-text);
}

.prose-content h1,
.prose-content h2,
.prose-content h3,
.prose-content h4 {
  font-family: var(--font-head);
  font-weight: 800;
  color: var(--c-white);
  letter-spacing: -0.03em;
  line-height: 1.25;
  margin-top: 2em;
  margin-bottom: 0.6em;
}

.prose-content h1 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); }
.prose-content h2 { font-size: clamp(1.2rem, 2.5vw, 1.7rem); border-bottom: 1px solid var(--c-border); padding-bottom: 8px; }
.prose-content h3 { font-size: clamp(1rem, 2vw, 1.3rem); }
.prose-content h4 { font-size: 1rem; }

.prose-content p {
  margin-bottom: 1.2em;
}

.prose-content ul,
.prose-content ol {
  margin: 0.8em 0 1.2em 1.4em;
  list-style: disc;
}

.prose-content ol {
  list-style: decimal;
}

.prose-content li {
  margin-bottom: 0.5em;
}

.prose-content a {
  color: var(--c-white);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.2s;
}

.prose-content a:hover {
  opacity: 0.75;
}

.prose-content blockquote {
  border-left: 3px solid rgba(255,255,255,0.2);
  margin: 1.5em 0;
  padding: 12px 20px;
  color: var(--c-text-muted);
  font-style: italic;
  background: rgba(255,255,255,0.03);
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
}

.prose-content code {
  background: rgba(255,255,255,0.08);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: ui-monospace, monospace;
}

.prose-content pre {
  background: rgba(255,255,255,0.05);
  padding: 16px;
  border-radius: var(--radius-card);
  overflow-x: auto;
  margin: 1.2em 0;
}

.prose-content pre code {
  background: none;
  padding: 0;
}

.prose-content img {
  border-radius: var(--radius-card);
  margin: 1.5em 0;
  box-shadow: var(--shadow-md);
}

.prose-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.9rem;
}

.prose-content th,
.prose-content td {
  padding: 10px 14px;
  border: 1px solid var(--c-border);
  text-align: left;
}

.prose-content th {
  background: rgba(255,255,255,0.05);
  font-weight: 700;
}

/* div 区块分隔（prose-content 内的 div[id] 区块） */
.prose-content div {
  margin-bottom: 3.5em;
  padding-top: 1em;
  border-top: 1px solid var(--c-border);
}

.prose-content div:first-child {
  border-top: none;
  padding-top: 0;
}

/* ========================================
   ASIDE CARDS（内容右侧）
======================================== */
.aside-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-card);
  padding: 20px;
  position: relative;
  /* 底部强调线 */
  border-bottom: 3px solid rgba(255,255,255,0.18);
  transition: transform 0.25s, box-shadow 0.25s;
}

.aside-card:hover {
  transform: translateY(-3px);
}

.elevation-md {
  box-shadow: var(--shadow-md);
}

.elevation-lg {
  box-shadow: var(--shadow-lg);
}

.aside-card--accent {
  background: linear-gradient(145deg, #2c2c2c, #242424);
  border-color: rgba(255,255,255,0.14);
  border-bottom-color: var(--c-white);
}

.aside-eyebrow {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: 8px;
}

.aside-title {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 800;
  color: var(--c-white);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.aside-tips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.aside-tips li {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  padding-left: 12px;
  position: relative;
  line-height: 1.5;
}

.aside-tips li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}

.aside-text {
  font-size: 0.88rem;
  color: var(--c-text-muted);
  line-height: 1.6;
}

/* ========================================
   ELEVATION 工具类
======================================== */
.elevation-sm { box-shadow: var(--shadow-sm); }
.elevation-xl { box-shadow: var(--shadow-xl); }

/* ========================================
   REVEAL SCROLL ANIMATION
======================================== */
.reveal-section {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal-section.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================
   FOOTER (footer 极简: p + small)
======================================== */
.site-footer {
  position: relative;
  z-index: 3;
  background: var(--c-bg);
  border-top: 1px solid var(--c-border);
  padding: 48px 24px 32px;
  text-align: center;
}

.footer-brand {
  font-family: var(--font-head);
  font-size: clamp(2.5rem, 8vw, 5rem);
  font-weight: 900;
  color: rgba(255,255,255,0.06);
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 20px;
  user-select: none;
}

.footer-copy {
  display: block;
  font-size: 0.8rem;
  color: var(--c-text-muted);
  line-height: 1.6;
}

/* ========================================
   RESPONSIVE
======================================== */
@media (max-width: 1024px) {
  .content-section {
    grid-template-columns: 1fr 240px;
  }
}

@media (max-width: 768px) {
  :root {
    --topbar-h: 60px;
  }

  .main-nav,
  .nav-search {
    display: none;
  }

  .nav-toggle {
    display: flex;
  }

  .topbar {
    height: auto;
    min-height: var(--topbar-h);
  }

  .topbar-inner {
    height: var(--topbar-h);
    padding: 0 16px;
  }

  .topbar.nav-open {
    height: auto;
  }

  .mobile-nav[hidden] {
    display: none;
  }

  .mobile-nav:not([hidden]) {
    display: block;
  }

  .sticky-anchor-bar {
    top: var(--topbar-h);
  }

  .hero-wrap {
    height: 42vh;
    margin-top: var(--topbar-h);
  }

  .hero-h1 {
    font-size: clamp(1.5rem, 6vw, 2.2rem);
  }

  .hero-depth-card {
    display: none;
  }

  .page-main {
    padding: 40px 16px 32px;
  }

  .content-section {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .content-figure {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
  }

  .content-body {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
  }

  .content-aside {
    grid-column: 1 / 2;
    grid-row: 3 / 4;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .aside-card {
    flex: 1 1 240px;
  }

  .anchor-bar-inner {
    gap: 2px;
  }

  .anchor-pill {
    font-size: 0.72rem;
    padding: 5px 10px;
  }
}

@media (max-width: 480px) {
  .hero-wrap {
    height: 48vh;
  }

  .hero-content {
    padding: 0 16px;
  }

  .hero-desc {
    display: none;
  }

  .content-aside {
    flex-direction: column;
  }

  .footer-brand {
    font-size: 2.2rem;
  }
}

/* ========================================
   prefers-reduced-motion
======================================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal-section {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero-bg-img {
    transform: none;
  }

  .hero-cta,
  .aside-card {
    transition: none;
  }
}
