/* 官网共用主题：颜色、字体、页头、页脚与按钮。
   颜色取自应用的 Quiet Precision（src/index.css）：浅色纸面、石墨文字、细描边；品牌的紫粉渐变只留在标志上。
   跟随系统切换暗色。各页面在自己的样式表之前引入本文件，页面样式只引用这里的变量，不另写一套颜色。 */

:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-subtle: #f7f7f5;
  --surface: #ffffff;
  --surface-muted: #f3f3f1;
  --surface-hover: #ececea;
  --surface-active: #e5e5e2;
  --stroke: #e9e9e6;
  --stroke-soft: #efefec;
  --stroke-strong: #d6d6d2;
  --text: #1b1b1a;
  --text-secondary: #52524e;
  --text-muted: #6f6f6a;
  --text-faint: #a2a29c;
  --star: #1b1b1a;
  --star-hover: #33332f;
  --on-star: #ffffff;
  --focus: #3d4bef;
  --focus-ring: rgba(61, 75, 239, 0.24);
  --attn: #b26b00;
  --attn-soft: #fcf5e8;
  --attn-border: #eed3a3;
  --run: #2f6fde;
  --done: #2e7d4f;
  --danger: #b42318;
  --code-bg: #f3f3f1;
  --key-shadow: 0 1px 0 rgba(16, 16, 24, 0.04), 0 1px 3px rgba(16, 16, 24, 0.05);
  --sh-1: 0 1px 0 rgba(19, 22, 27, 0.03), 0 1px 3px rgba(19, 22, 27, 0.06);
  --sh-2: 0 12px 32px -16px rgba(16, 16, 24, 0.18);
  --sh-shot: 0 1px 2px rgba(16, 16, 24, 0.06), 0 24px 64px -28px rgba(16, 16, 24, 0.28);
  --brand-gradient: linear-gradient(135deg, #8b5cf6 0%, #a855f7 45%, #ec4899 100%);

  --font-sans: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', 'PingFang SC',
    'Microsoft YaHei UI', 'Noto Sans CJK SC', 'Microsoft YaHei', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Consolas, Menlo, 'DejaVu Sans Mono',
    'Liberation Mono', monospace;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --shell: 1120px;
  --header-height: 60px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #1e1e1d;
    --bg-subtle: #171716;
    --surface: #262625;
    --surface-muted: #272726;
    --surface-hover: #2d2d2b;
    --surface-active: #343432;
    --stroke: #2f2f2d;
    --stroke-soft: #292928;
    --stroke-strong: #444441;
    --text: #ededea;
    --text-secondary: #b4b4ae;
    --text-muted: #94948e;
    --text-faint: #62625d;
    --star: #ededea;
    --star-hover: #ffffff;
    --on-star: #1b1b1a;
    --focus: #8d95ff;
    --focus-ring: rgba(141, 149, 255, 0.3);
    --attn: #f5b866;
    --attn-soft: rgba(245, 184, 102, 0.09);
    --attn-border: rgba(245, 184, 102, 0.34);
    --run: #7aa7ff;
    --done: #6cc28f;
    --danger: #ff9c8d;
    --code-bg: #272726;
    --key-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 1px 2px rgba(0, 0, 0, 0.5);
    --sh-1: 0 1px 0 rgba(0, 0, 0, 0.35);
    --sh-2: 0 16px 40px -16px rgba(0, 0, 0, 0.7);
    --sh-shot: 0 1px 2px rgba(0, 0, 0, 0.4), 0 28px 72px -28px rgba(0, 0, 0, 0.8);
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img,
video {
  max-width: 100%;
}

a {
  color: inherit;
}

code,
kbd,
pre {
  font-family: var(--font-mono);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection {
  background: var(--focus-ring);
}

.shell {
  width: min(100% - 32px, var(--shell));
  margin-inline: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--star);
  color: var(--on-star);
  text-decoration: none;
  transform: translateY(-160%);
  transition: transform 160ms var(--ease);
}

.skip-link:focus {
  transform: none;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 160ms var(--ease),
    border-color 160ms var(--ease),
    color 160ms var(--ease);
}

.btn-primary {
  background: var(--star);
  color: var(--on-star);
  box-shadow: var(--sh-1);
}

.btn-primary:hover {
  background: var(--star-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--stroke-strong);
  color: var(--text);
  box-shadow: var(--key-shadow);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-sm {
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
}

.btn-lg {
  min-height: 48px;
  padding: 0 20px;
  font-size: 16px;
}

.text-link {
  color: var(--text);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--stroke-strong);
  text-underline-offset: 3px;
  transition: text-decoration-color 160ms var(--ease);
}

.text-link:hover {
  text-decoration-color: currentColor;
}

/* ---------- 页头 ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  border-bottom: 1px solid transparent;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  transition: border-color 200ms var(--ease);
}

/* 不支持 color-mix 的旧浏览器退回实心底色。 */
@supports not (background: color-mix(in srgb, red 50%, transparent)) {
  .site-header {
    background: var(--bg);
  }
}

.site-header.is-scrolled,
.site-header[data-static-border] {
  border-bottom-color: var(--stroke);
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
}

/* 教程页是全宽双栏：页头与其内容区同宽，品牌与左侧导航对齐。 */
.site-header-inner.is-wide {
  width: min(1180px, calc(100% - 48px));
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: -0.01em;
}

.site-brand img {
  display: block;
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-right: auto;
}

.site-nav a {
  padding: 6px 10px;
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-size: 14px;
  text-decoration: none;
  transition:
    background-color 160ms var(--ease),
    color 160ms var(--ease);
}

.site-nav a:hover,
.site-nav a[aria-current='page'] {
  color: var(--text);
  background: var(--surface-hover);
}

.site-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 窄屏：主导航收进菜单（details 无脚本也能用）。 */
.site-menu {
  position: relative;
  display: none;
}

.site-menu > summary {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--stroke-strong);
  border-radius: var(--r-md);
  color: var(--text);
  list-style: none;
  cursor: pointer;
}

.site-menu > summary::-webkit-details-marker {
  display: none;
}

.site-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  min-width: 200px;
  padding: 6px;
  border: 1px solid var(--stroke);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-2);
}

.site-menu-panel a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--r-sm);
  color: var(--text);
  text-decoration: none;
}

.site-menu-panel a:hover {
  background: var(--surface-hover);
}

@media (max-width: 860px) {
  .site-nav {
    display: none;
  }

  .site-menu {
    display: block;
  }

  .site-header-inner {
    justify-content: space-between;
    gap: 12px;
  }

  .site-header-actions {
    margin-left: auto;
  }
}

/* ---------- 页脚 ---------- */

.site-footer {
  margin-top: 96px;
  border-top: 1px solid var(--stroke);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: 14px;
}

.site-footer-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px 48px;
  padding: 40px 0 48px;
}

.site-footer-brand p {
  max-width: 320px;
  margin: 10px 0 0;
}

.site-footer-links {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, auto));
  gap: 8px 40px;
}

.site-footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
}

.site-footer-links a:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.site-footer-extra {
  grid-column: 1 / -1;
  margin: 0;
  padding-top: 20px;
  border-top: 1px solid var(--stroke);
}

.site-footer-extra a {
  color: var(--text-secondary);
}

@media (max-width: 720px) {
  .site-footer {
    margin-top: 64px;
  }

  .site-footer-inner {
    grid-template-columns: 1fr;
  }

  .site-footer-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-footer-links a {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
  }
}

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
