/* ==========================================================================
   299792458.com — 全站唯一样式表
   视觉方向：深空暗色科技风 · 严谨排版 · 克制的发光细节
   契约：本文件定义所有页面级通用类，内容页直接引用，不另写样式表。
   ========================================================================== */

/* --------------------------------------------------------------------------
   0. 设计变量
   -------------------------------------------------------------------------- */
:root {
  --bg: #050810;                 /* 近黑深空底色 */
  --bg-card: #0b1220;            /* 卡片底色 */
  --bg-card-hover: #0f1a30;      /* 卡片悬停底色 */
  --text: #e8eef7;               /* 主文字 */
  --text-dim: #8fa3bd;           /* 次要文字 */
  --accent: #4dd8ff;             /* 青蓝主强调色（切伦科夫蓝） */
  --accent2: #ffd166;            /* 暖金次强调色（钠灯黄，对比用） */
  --border: #1c2740;             /* 分隔线 / 描边 */
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, "SF Mono",
          Menlo, "Liberation Mono", "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --header-h: 60px;
  --content-w: 1080px;
  --article-w: 720px;
}

/* --------------------------------------------------------------------------
   1. 基础重置与全局底色
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  background-color: var(--bg);
  /* 深空氛围：顶部冷光晕 + 细网格装饰（纯 CSS 渐变实现） */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(77, 216, 255, 0.09), transparent 65%),
    linear-gradient(rgba(77, 216, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 216, 255, 0.035) 1px, transparent 1px);
  background-size: 100% 100%, 48px 48px, 48px 48px;
  background-attachment: fixed;
}

::selection {
  background: rgba(77, 216, 255, 0.35);
  color: #ffffff;
}

a { color: var(--accent); }
a:hover { color: #8ce6ff; }

a:focus-visible,
button:focus-visible,
input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

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

pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 48px 0;
}

/* 通用内容分区容器 */
.section {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 80px 24px;
}

.section-title {
  font-size: clamp(1.5rem, 3.5vw, 2.1rem);
  font-weight: 700;
  margin: 0 0 12px;
  letter-spacing: 0.02em;
}

.section-title::before {
  content: "// ";
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 400;
}

.section-lede {
  color: var(--text-dim);
  margin: 0 0 40px;
  max-width: 560px;
}

/* --------------------------------------------------------------------------
   2. 粘性页首 .site-header（站名 + .site-nav + .lang-switch）
   移动端折叠：纯 CSS checkbox 技巧
   约定结构：<input type="checkbox" id="nav-toggle" class="nav-toggle">
            <label for="nav-toggle" class="nav-toggle-label">…</label>
            <nav class="site-nav">…</nav> 三者为 .site-header 内兄弟元素
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--header-h);
  padding: 0 24px;
  background: rgba(5, 8, 16, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-logo {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.site-logo:hover { color: #ffffff; }

.site-logo .unit {
  color: var(--accent);
  font-size: 0.72em;
  font-weight: 400;
  margin-left: 4px;
}

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

.site-nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.92rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.site-nav a:hover {
  color: var(--text);
  background: rgba(77, 216, 255, 0.08);
}

.site-nav a.current {
  color: var(--accent);
  background: rgba(77, 216, 255, 0.12);
}

/* 语言切换 */
.lang-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  flex: none;
}

.lang-switch button {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  padding: 5px 12px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.lang-switch button:hover { color: var(--text); }

.lang-switch button.active {
  background: var(--accent);
  color: #04121c;
  font-weight: 700;
}

/* checkbox 折叠机制（桌面端隐藏开关） */
.nav-toggle { display: none; }

.nav-toggle-label {
  display: none;
  cursor: pointer;
  padding: 8px 4px;
  margin-left: auto;
}

.nav-toggle-label span,
.nav-toggle-label span::before,
.nav-toggle-label span::after {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
  position: relative;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-toggle-label span::before,
.nav-toggle-label span::after {
  content: "";
  position: absolute;
  left: 0;
}

.nav-toggle-label span::before { top: -6px; }
.nav-toggle-label span::after  { top: 6px; }

/* --------------------------------------------------------------------------
   3. 首屏 .hero（canvas.starfield 绝对定位铺满）
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  overflow: hidden;
  padding: calc(var(--header-h) + 48px) 24px 72px;
}

.hero canvas.starfield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hero > :not(canvas) { position: relative; z-index: 1; }

.hero-kicker {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.82rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  margin: 0 0 18px;
}

.hero-number {
  margin: 0;
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(2.6rem, 9.5vw, 6.8rem);
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: #ffffff;
  text-shadow:
    0 0 14px rgba(77, 216, 255, 0.55),
    0 0 52px rgba(77, 216, 255, 0.28);
  animation: hero-glow 4.5s ease-in-out infinite alternate;
}

.hero-number .sep { color: rgba(232, 238, 247, 0.35); }

@keyframes hero-glow {
  from {
    text-shadow:
      0 0 10px rgba(77, 216, 255, 0.4),
      0 0 40px rgba(77, 216, 255, 0.18);
  }
  to {
    text-shadow:
      0 0 18px rgba(77, 216, 255, 0.7),
      0 0 72px rgba(77, 216, 255, 0.36);
  }
}

.hero-sub {
  margin: 18px 0 0;
  color: var(--text-dim);
  font-size: clamp(0.95rem, 2.4vw, 1.3rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.hero-unit {
  margin-top: 10px;
  font-family: var(--mono);
  color: var(--accent);
  font-size: clamp(0.85rem, 2vw, 1.05rem);
  letter-spacing: 0.12em;
}

.hero-more {
  margin-top: 56px;
  color: var(--text-dim);
  font-size: 1.4rem;
  text-decoration: none;
  animation: hero-bob 2.2s ease-in-out infinite;
}

@keyframes hero-bob {
  0%, 100% { transform: translateY(0);    opacity: 0.55; }
  50%      { transform: translateY(7px);  opacity: 1; }
}

/* --------------------------------------------------------------------------
   4. 话题卡片网格 .topic-grid / .topic-card
   -------------------------------------------------------------------------- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.topic-card {
  position: relative;
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 24px;
  text-decoration: none;
  color: var(--text);
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease,
              box-shadow 0.25s ease, background-color 0.25s ease;
}

/* 顶部扫光线 */
.topic-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.topic-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  border-color: rgba(77, 216, 255, 0.55);
  box-shadow:
    0 0 0 1px rgba(77, 216, 255, 0.25),
    0 12px 44px rgba(77, 216, 255, 0.12);
}

.topic-card:hover::before { opacity: 1; }

.topic-card .card-index {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.25em;
}

.topic-card h3 {
  margin: 12px 0 10px;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.topic-card p {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.65;
}

.topic-card .card-arrow {
  display: inline-block;
  margin-top: 18px;
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.85rem;
  transition: transform 0.25s ease;
}

.topic-card:hover .card-arrow { transform: translateX(6px); }

/* --------------------------------------------------------------------------
   5. 正文 .article（max-width 720px 居中）
   -------------------------------------------------------------------------- */
.article {
  max-width: var(--article-w);
  margin: 0 auto;
  padding: 64px 24px 96px;
}

.article h1 {
  font-size: clamp(1.8rem, 4.5vw, 2.5rem);
  line-height: 1.3;
  margin: 0 0 12px;
  letter-spacing: 0.02em;
}

.article .article-meta {
  font-family: var(--mono);
  color: var(--text-dim);
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.article h2 {
  font-size: 1.45rem;
  line-height: 1.4;
  margin: 56px 0 18px;
  padding-left: 14px;
  border-left: 3px solid var(--accent);
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.article h3 {
  font-size: 1.15rem;
  margin: 40px 0 12px;
  color: #cfeaff;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.article p { margin: 0 0 18px; }

.article ul, .article ol { margin: 0 0 18px; padding-left: 24px; }
.article li { margin-bottom: 6px; }

.article a { text-decoration: none; border-bottom: 1px dashed rgba(77, 216, 255, 0.5); }
.article a:hover { border-bottom-style: solid; }

.article blockquote {
  margin: 28px 0;
  padding: 4px 0 4px 20px;
  border-left: 2px solid var(--accent2);
  color: var(--text-dim);
  font-style: italic;
}

.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 0.92rem;
}

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

.article th {
  background: var(--bg-card);
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
}

/* --------------------------------------------------------------------------
   6. 公式块 .formula（等宽 · 卡片底 · 居中 · 左高亮边线）
   -------------------------------------------------------------------------- */
.formula {
  font-family: var(--mono);
  font-size: 1.05rem;
  letter-spacing: 0.03em;
  color: #d7f4ff;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 20px 24px;
  margin: 28px 0;
  text-align: center;
  overflow-x: auto;
}

.formula sup, .formula sub { font-size: 0.65em; }

.formula .formula-label {
  display: block;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
}

/* --------------------------------------------------------------------------
   7. 图容器 .diagram 与图注 .figure-caption
   -------------------------------------------------------------------------- */
.diagram {
  margin: 36px 0;
  text-align: center;
}

.diagram svg {
  width: 100%;
  height: auto;
  max-width: 640px;
}

/* SVG 内文字默认填充色（SVG 内请用 class 或 fill="currentColor" 继承） */
.diagram text {
  fill: var(--text);
  font-family: var(--sans);
  font-size: 14px;
}

.diagram text.svg-accent { fill: var(--accent); }
.diagram text.svg-dim    { fill: var(--text-dim); font-size: 12px; }
.diagram text.svg-mono   { font-family: var(--mono); }

.figure-caption {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 12px auto 0;
  max-width: 560px;
}

.figure-caption::before {
  content: "▍";
  color: var(--accent);
  margin-right: 6px;
}

/* --------------------------------------------------------------------------
   8. 要点提示框 .highlight-box
   -------------------------------------------------------------------------- */
.highlight-box {
  background: rgba(77, 216, 255, 0.06);
  border: 1px solid rgba(77, 216, 255, 0.35);
  border-radius: 10px;
  padding: 20px 24px;
  margin: 28px 0;
}

.highlight-box > :first-child { margin-top: 0; }
.highlight-box > :last-child  { margin-bottom: 0; }

.highlight-box .box-title {
  display: block;
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.highlight-box.warm {
  background: rgba(255, 209, 102, 0.05);
  border-color: rgba(255, 209, 102, 0.35);
}

.highlight-box.warm .box-title { color: var(--accent2); }

/* --------------------------------------------------------------------------
   9. 时间轴 .timeline（测量史）
   -------------------------------------------------------------------------- */
.timeline {
  list-style: none;
  margin: 36px 0;
  padding: 0 0 0 28px;
  border-left: 1px solid var(--border);
}

.timeline li {
  position: relative;
  padding: 0 0 30px 22px;
}

.timeline li:last-child { padding-bottom: 0; }

.timeline li::before {
  content: "";
  position: absolute;
  left: -33px;
  top: 7px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(77, 216, 255, 0.8);
}

.timeline .year {
  display: block;
  font-family: var(--mono);
  color: var(--accent2);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}

.timeline .event {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}

.timeline .event small {
  display: block;
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   10. 小字注释 .footnote
   -------------------------------------------------------------------------- */
.footnote {
  font-size: 0.8rem;
  line-height: 1.7;
  color: var(--text-dim);
  border-top: 1px dashed var(--border);
  margin-top: 52px;
  padding-top: 18px;
}

.footnote ol { padding-left: 20px; margin: 8px 0 0; }

sup a {
  text-decoration: none;
  color: var(--accent);
  font-family: var(--mono);
}

/* --------------------------------------------------------------------------
   11. 回到顶部 .back-top（ui.js 负责切换 .visible）
   -------------------------------------------------------------------------- */
.back-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.9);
  color: var(--accent);
  font-size: 1.05rem;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease,
              visibility 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.back-top.visible {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.back-top:hover {
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(77, 216, 255, 0.35);
}

/* --------------------------------------------------------------------------
   12. 页脚 .site-footer
   -------------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 44px 24px 52px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.9;
}

.site-footer .footer-number {
  display: block;
  font-family: var(--mono);
  color: var(--accent);
  letter-spacing: 0.15em;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.site-footer a {
  color: var(--text-dim);
  text-decoration: underline;
  text-decoration-color: rgba(77, 216, 255, 0.4);
  text-underline-offset: 3px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}
.site-footer a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

/* --------------------------------------------------------------------------
   13. 响应式：≤768px 单列
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .section { padding: 56px 20px; }

  /* 移动端导航折叠（checkbox 技巧） */
  .nav-toggle-label { display: block; }

  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin-left: 0;
    padding: 12px 16px 16px;
    background: rgba(5, 8, 16, 0.97);
    border-bottom: 1px solid var(--border);
  }

  .nav-toggle:checked ~ .site-nav { display: flex; }

  .nav-toggle:checked ~ .nav-toggle-label span { background: transparent; }
  .nav-toggle:checked ~ .nav-toggle-label span::before { transform: translateY(6px) rotate(45deg); }
  .nav-toggle:checked ~ .nav-toggle-label span::after  { transform: translateY(-6px) rotate(-45deg); }

  .site-nav a { padding: 10px 12px; }

  .hero { min-height: 88vh; padding-bottom: 56px; }
  .hero-sub { letter-spacing: 0.18em; }

  .article { padding: 44px 20px 72px; }
  .article h2 { margin-top: 44px; }

  .formula { font-size: 0.92rem; padding: 16px; }

  .back-top { right: 16px; bottom: 16px; }
}

/* --------------------------------------------------------------------------
   14. prefers-reduced-motion：关闭 CSS 动画
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

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