/* ============================================================
   伟德主页 · 共享样式 /assets/site.css
   结构：重置 → 变量 → 基础排版 → 头部 → 按钮 → 布局工具
        → 通用组件 → 页脚 → 返回顶部 → 响应式与动效降级
   ============================================================ */

/* ---------- 01 重置 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 104px;
}

body,
h1, h2, h3, h4, p, ul, ol, figure, blockquote, dl, dd {
  margin: 0;
}

ul, ol { padding: 0; }

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

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 02 变量 ---------- */
:root {
  --c-abyss: #0B1B2B;
  --c-navy: #122A40;
  --c-steel: #8FA6B8;
  --c-mist: #C7D3DC;
  --c-sand: #E8DFD2;
  --c-paper: #F6F2EA;
  --c-orange: #FF6B35;
  --c-amber: #FFB27A;
  --c-cyan: #2FD4C4;
  --c-ink: #07131F;
  --c-light: #EDF3F7;

  --line: rgba(143, 166, 184, 0.26);
  --line-strong: rgba(143, 166, 184, 0.46);
  --line-soft: rgba(143, 166, 184, 0.12);
  --line-dark: rgba(7, 19, 31, 0.14);

  --dur: 200ms;
  --dur-fast: 150ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --font-sans: 'HarmonyOS Sans SC', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;

  --shell: 1240px;
  --gutter: clamp(18px, 4vw, 40px);
  --cut: 16px;
  --radius: 10px;
}

/* ---------- 03 基础排版 ---------- */
body {
  min-height: 100vh;
  background-color: var(--c-abyss);
  background-image: repeating-linear-gradient(
    90deg,
    rgba(143, 166, 184, 0.045) 0 1px,
    transparent 1px 96px
  );
  color: var(--c-light);
  font-family: var(--font-sans);
  font-size: clamp(15px, 0.3vw + 14px, 16.5px);
  font-weight: 400;
  line-height: 1.75;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

h1, h2, h3, h4 {
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.012em;
}

strong { font-weight: 700; }

:where(a, button, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--c-cyan);
  outline-offset: 3px;
  border-radius: 4px;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.82em;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--c-steel);
}

/* ---------- 04 跳转链接 ---------- */
.skip-link {
  position: fixed;
  top: -120px;
  left: 16px;
  z-index: 300;
  padding: 12px 20px;
  background: var(--c-sand);
  color: var(--c-ink);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 10px 10px;
  box-shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.9);
  transition: top var(--dur) var(--ease);
}

.skip-link:focus,
.skip-link:focus-visible {
  top: 0;
}

/* ---------- 05 头部 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  padding: 14px var(--gutter) 0;
  background: linear-gradient(180deg, rgba(11, 27, 43, 0.94) 0%, rgba(11, 27, 43, 0) 100%);
}

.header-shell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding: 9px 9px 9px 18px;
  background: rgba(18, 42, 64, 0.88);
  border: 1px solid var(--line);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  box-shadow: 0 22px 46px -30px rgba(0, 0, 0, 0.95),
              inset 0 1px 0 rgba(199, 211, 220, 0.07);
}

/* 品牌 */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  text-decoration: none;
  color: var(--c-light);
}

.brand__mark {
  position: relative;
  display: block;
  flex: none;
  width: 22px;
  height: 22px;
  background: linear-gradient(140deg, var(--c-cyan) 0%, var(--c-orange) 100%);
  clip-path: polygon(0 0, 100% 0, 100% 62%, 62% 100%, 0 100%);
  transition: transform var(--dur) var(--ease);
}

.brand:hover .brand__mark { transform: rotate(-6deg); }

.brand__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.15;
}

.brand__name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.brand__meta {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--c-steel);
  text-transform: uppercase;
}

/* 移动导航按钮 */
.nav-toggle {
  display: none;
  margin-left: auto;
  align-items: center;
  gap: 9px;
  padding: 9px 15px 9px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(11, 27, 43, 0.5);
  color: var(--c-light);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.nav-toggle:hover { border-color: var(--c-cyan); color: var(--c-cyan); }

.nav-toggle__bars {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  width: 15px;
}

.nav-toggle__bars span {
  display: block;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transition: transform var(--dur) var(--ease), opacity var(--dur-fast) var(--ease);
}

.site-header[data-open] .nav-toggle__bars span:nth-child(1) { transform: translateY(4.5px) rotate(45deg); }
.site-header[data-open] .nav-toggle__bars span:nth-child(2) { opacity: 0; }
.site-header[data-open] .nav-toggle__bars span:nth-child(3) { transform: translateY(-4.5px) rotate(-45deg); }

/* 主导航 */
.site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.site-nav__list {
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  list-style: none;
}

.site-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--c-mist);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.site-nav__link::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 4px;
  height: 1px;
  background: var(--c-cyan);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--dur) var(--ease);
}

.site-nav__link:hover { color: var(--c-light); }
.site-nav__link:hover::after { transform: scaleX(1); }

.site-nav__link[aria-current="page"] {
  color: var(--c-light);
  background: rgba(255, 107, 53, 0.13);
}

.site-nav__link[aria-current="page"]::before {
  content: "";
  display: block;
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-orange);
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.18);
}

.site-nav__link[aria-current="page"]::after { transform: scaleX(0); }

.site-nav__tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 8px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.link-quiet {
  position: relative;
  font-size: 13px;
  font-weight: 500;
  color: var(--c-steel);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}

.link-quiet:hover { color: var(--c-cyan); }

/* 阅读刻度 */
.scroll-gauge {
  position: absolute;
  left: 36px;
  right: 36px;
  bottom: 5px;
  height: 1px;
  border-radius: 1px;
  background: rgba(143, 166, 184, 0.16);
  overflow: hidden;
  pointer-events: none;
}

.scroll-gauge > span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--c-cyan) 0%, var(--c-orange) 100%);
  transition: width 120ms linear;
}

/* ---------- 06 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease),
              color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform var(--dur) var(--ease);
}

.btn--accent {
  background: var(--c-orange);
  color: #160802;
}

.btn--accent:hover {
  background: #ff8352;
  transform: translateY(-1px);
}

.btn--ghost {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--c-light);
}

.btn--ghost:hover {
  border-color: var(--c-cyan);
  color: var(--c-cyan);
}

/* ---------- 07 布局工具 ---------- */
.wrap {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: clamp(44px, 7vw, 92px);
}

.grid12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 28px);
}

.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

/* ---------- 08 通用组件 ---------- */
.prose {
  max-width: 38em;
}

.prose p {
  max-width: 34em;
  margin-bottom: 1.1em;
}

.prose p:last-child { margin-bottom: 0; }

.prose h2 {
  margin: 2em 0 0.7em;
  font-size: clamp(1.3rem, 2vw, 1.7rem);
  font-weight: 800;
}

.prose h3 {
  margin: 1.6em 0 0.5em;
  font-size: 1.1rem;
  font-weight: 700;
}

.prose ul,
.prose ol {
  margin-bottom: 1.2em;
  padding-left: 1.3em;
}

.prose li { margin-bottom: 0.45em; }

.prose a {
  color: var(--c-cyan);
  text-decoration: none;
  border-bottom: 1px solid rgba(47, 212, 196, 0.42);
  transition: border-color var(--dur) var(--ease);
}

.prose a:hover { border-bottom-color: var(--c-cyan); }

.panel {
  position: relative;
  padding: clamp(18px, 2.4vw, 28px);
  background: var(--c-navy);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cut-tr {
  clip-path: polygon(
    0 0,
    calc(100% - var(--cut)) 0,
    100% var(--cut),
    100% 100%,
    0 100%
  );
}

.rule {
  height: 1px;
  border: 0;
  margin: clamp(24px, 4vw, 48px) 0;
  background: var(--line);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--c-mist);
  text-transform: uppercase;
}

.tag--accent {
  border-color: rgba(255, 107, 53, 0.5);
  color: var(--c-orange);
}

.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--c-steel);
}

.crumbs a {
  color: var(--c-steel);
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}

.crumbs a:hover { color: var(--c-cyan); }

.crumbs__sep {
  color: rgba(143, 166, 184, 0.45);
}

.crumbs [aria-current="page"] { color: var(--c-mist); }

/* 图片容器基础规则（页面阶段填充 <img>） */
.figure {
  position: relative;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--c-navy);
}

.figure__media {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  background-color: var(--c-navy);
  background-image:
    repeating-linear-gradient(90deg, rgba(143, 166, 184, 0.14) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(0deg, rgba(143, 166, 184, 0.14) 0 1px, transparent 1px 42px),
    linear-gradient(135deg, rgba(143, 166, 184, 0.12) 0%, rgba(11, 27, 43, 0.55) 100%);
}

.figure__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.86) contrast(1.04);
}

.figure--wide .figure__media { aspect-ratio: 16 / 9; }
.figure--tall .figure__media { aspect-ratio: 4 / 5; }
.figure--square .figure__media { aspect-ratio: 1 / 1; }

.figure__caption {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--c-steel);
}

/* ---------- 09 页脚 ---------- */
.site-footer {
  position: relative;
  margin-top: clamp(64px, 9vw, 120px);
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, var(--c-abyss) 0%, #081522 100%);
  color: var(--c-mist);
}

.site-footer::before {
  content: "";
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 6px;
  background-image: repeating-linear-gradient(
    90deg,
    var(--line-strong) 0 1px,
    transparent 1px 16px
  );
  opacity: 0.55;
  pointer-events: none;
}

.footer-shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding: clamp(44px, 6vw, 76px) var(--gutter) clamp(24px, 3vw, 36px);
}

.footer-top {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, minmax(0, 1fr));
  gap: clamp(28px, 4vw, 56px);
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: flex-start;
}

.brand--footer .brand__name { font-size: 18px; }
.brand--footer .brand__meta { color: var(--c-steel); }

.footer-revision {
  max-width: 30em;
  padding-left: 12px;
  border-left: 2px solid var(--c-amber);
  font-size: 13px;
  line-height: 1.72;
  color: var(--c-mist);
}

.footer-col__title {
  margin-bottom: 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--c-steel);
  text-transform: uppercase;
}

.footer-col__list {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin: 0;
  list-style: none;
}

.link-footer {
  position: relative;
  display: inline-block;
  padding-bottom: 2px;
  color: var(--c-light);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}

.link-footer::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--dur) var(--ease);
}

.link-footer:hover { color: var(--c-cyan); }
.link-footer:hover::after { transform: scaleX(1); }

.link-footer--mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--c-mist);
  word-break: break-all;
}

.link-footer--old { color: var(--c-mist); }

/* 悬停批注条 */
[data-tip] { position: relative; }

[data-tip]::before {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 9px);
  z-index: 20;
  padding: 7px 11px;
  border-radius: 7px;
  background: var(--c-sand);
  color: var(--c-ink);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}

[data-tip]:hover::before,
[data-tip]:focus-visible::before {
  opacity: 1;
  transform: translateY(0);
}

.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
  margin-top: clamp(32px, 4vw, 56px);
  padding-top: 18px;
  border-top: 1px dashed var(--line);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--c-steel);
}

.footer-bottom__item { display: inline-block; }

/* ---------- 10 返回顶部 ---------- */
.to-top {
  position: fixed;
  right: clamp(16px, 3vw, 30px);
  bottom: clamp(16px, 3vw, 30px);
  z-index: 70;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(18, 42, 64, 0.9);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--c-light);
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease),
              transform var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}

.to-top[data-show] {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.to-top:hover {
  border-color: var(--c-orange);
  color: var(--c-orange);
}

/* ---------- 11 响应式 ---------- */
@media (max-width: 1180px) {
  .site-nav__tools .link-quiet { display: none; }
}

@media (max-width: 1040px) {
  .nav-toggle { display: inline-flex; }

  .site-nav {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 0;
    max-height: calc(100dvh - 130px);
    overflow-y: auto;
    padding: 14px;
    background: rgba(18, 42, 64, 0.98);
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    box-shadow: 0 34px 64px -34px rgba(0, 0, 0, 0.95);
  }

  .site-header[data-open] .site-nav { display: flex; }

  .site-nav__list {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    width: 100%;
  }

  .site-nav__link {
    justify-content: flex-start;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 15px;
    white-space: normal;
  }

  .site-nav__link::after { left: 14px; right: 14px; bottom: 7px; }

  .site-nav__tools {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin: 12px 0 0;
    padding: 14px 0 0;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .site-nav__tools .link-quiet {
    display: block;
    padding: 4px 2px;
  }

  .site-nav__tools .btn { width: 100%; padding-block: 13px; }

  .scroll-gauge { left: 24px; right: 24px; }

  .footer-top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 1024px) {
  .col-4, .col-5, .col-6, .col-7, .col-8 { grid-column: span 6; }
  .header-shell { gap: 12px; }
}

@media (max-width: 720px) {
  html { scroll-padding-top: 92px; }

  .site-header { padding-top: 10px; }

  .header-shell {
    padding: 7px 7px 7px 14px;
    border-radius: 20px;
  }

  .brand__meta { display: none; }

  .scroll-gauge { left: 18px; right: 18px; bottom: 3px; }

  .footer-top { grid-template-columns: minmax(0, 1fr); gap: 32px; }

  .footer-bottom { flex-direction: column; gap: 8px; }

  .footer-revision { max-width: none; }
}

@media (max-width: 640px) {
  .col-4, .col-5, .col-6, .col-7, .col-8, .col-12 { grid-column: span 1; }
  .grid12 { gap: 16px; }
  .figure--tall .figure__media { aspect-ratio: 3 / 4; }
}

@media (hover: none) {
  [data-tip]::before { display: none; }
}

/* ---------- 12 动效降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  .brand:hover .brand__mark { transform: none; }
  .btn--accent:hover { transform: none; }
  .to-top { transform: none; }
}
