/* ============================================================
   InsVolc Studio — base.css
   设计令牌 / 排版 / 通用组件（详见 doc/design.md）
   ============================================================ */

/* ---------- 自托管字体（拉丁子集，仅 400 字重） ---------- */
/* 原先走 Google Fonts CDN，国内 fonts.googleapis.com 长期超时，字体实际从未生效；
   改为同源自托管后，跨域请求由 3 个（2 preconnect + 1 样式表）降为 0 */
@font-face {
  font-family: "Silkscreen";
  src: url("../fonts/silkscreen-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../fonts/jetbrains-mono-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg:        #0E0F13;
  --surface:   #16181F;
  --line:      #262932;
  --text:      #E8E9ED;
  --text-dim:  #9A9EAD;

  --acc-hanzi: #E34234;
  --acc-maze:  #2EC4B6;
  --acc-cal:   #F4A938;
  --acc-node:  #7C5CFF;

  --font-display: "Silkscreen", "Noto Sans SC", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI",
               "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;

  --step-display: clamp(2.25rem, 6vw, 3.5rem);
  --step-h2:      clamp(1.6rem, 3.5vw, 2.25rem);
  --step-h3:      1.5rem;
  --step-body:    1rem;
  --step-meta:    0.8rem;

  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: 6rem;

  --container: 72rem;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  scroll-behavior: smooth;
  /* 鼠标滚轮整页翻页 */
  scroll-snap-type: y mandatory;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--step-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
img, video, canvas { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }

/* ---------- 网格纹理基底（谜题网格母题） ---------- */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.18;
  pointer-events: none;
}

/* ---------- 排版 ---------- */
.display {
  font-family: var(--font-display);
  font-size: var(--step-display);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0.01em;
}
h2.section-title {
  font-size: var(--step-h2);
  font-weight: 700;
  line-height: 1.25;
}
h3 { font-size: var(--step-h3); line-height: 1.3; }

/* 等宽元信息标签：编号、日期、分类 */
.meta {
  font-family: var(--font-mono);
  font-size: var(--step-meta);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.meta--acc { color: var(--acc, var(--text)); }

.dim { color: var(--text-dim); }

/* ---------- 布局 ---------- */
.container {
  width: min(100% - 2.5rem, var(--container));
  margin-inline: auto;
}
.section { padding-block: var(--space-6); }
.section-head { margin-bottom: var(--space-4); }
.section-head .meta { display: block; margin-bottom: var(--space-1); }

/* ---------- 整页分区（翻页单位） ---------- */
.page {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-block: 5.5rem 3.5rem;
  scroll-snap-align: start;
  scroll-snap-stop: always;   /* 一次滚轮只翻一页 */
  border-bottom: 1px solid var(--line);
}
/* 末页：内容居中、页脚贴底 */
.page--last {
  justify-content: space-between;
  padding-block: 5.5rem 0;
}
.page--last > .container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ---------- 侧边页点导航 ---------- */
.page-dots {
  position: fixed;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  display: grid;
  gap: 0.85rem;
  justify-items: end;
}
.page-dot {
  position: relative;
  display: block;
  width: 10px;
  height: 10px;
  border: 1px solid var(--text-dim);
  border-radius: 50%;
  transition: background-color 180ms var(--ease-out),
              border-color 180ms var(--ease-out),
              transform 180ms var(--ease-out);
}
.page-dot:hover,
.page-dot.is-active {
  background: var(--acc, var(--text));
  border-color: var(--acc, var(--text));
}
.page-dot.is-active { transform: scale(1.35); }
.page-dot-label {
  position: absolute;
  right: calc(100% + 0.7rem);
  top: 50%;
  transform: translateY(-50%) translateX(6px);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--step-meta);
  letter-spacing: 0.08em;
  color: var(--text-dim);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
}
.page-dot:hover .page-dot-label,
.page-dot:focus-visible .page-dot-label {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.75em 1.5em;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  line-height: 1.2;
  transition: border-color 200ms var(--ease-out),
              transform 200ms var(--ease-out),
              background-color 200ms var(--ease-out);
}
.btn:hover {
  border-color: var(--acc, var(--text));
  transform: translateY(-2px);
}
.btn--primary {
  background: var(--acc, var(--text));
  border-color: var(--acc, var(--text));
  color: #0E0F13;
}
.btn--primary:hover { filter: brightness(1.1); }
.btn .arrow { font-family: var(--font-mono); }

/* ---------- 状态徽章 ---------- */
.badge {
  display: inline-block;
  padding: 0.25em 0.75em;
  border: 1px solid var(--acc, var(--line));
  font-family: var(--font-mono);
  font-size: var(--step-meta);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--acc, var(--text-dim));
}
.badge--soon { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* ---------- 页头 ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 4rem;
}
.logo {
  font-size: 1.05rem;      /* 仅作为下方 img 高度的基准：0.75em 即原文字字标的高度 */
  padding-block: 0.5rem;   /* 保持与原文字链接相当的可点击区域 */
}
.logo img { display: block; height: 0.75em; width: auto; }
.site-nav { display: flex; align-items: center; gap: var(--space-3); }
.site-nav a {
  font-size: 0.95rem;
  color: var(--text-dim);
  transition: color 160ms var(--ease-out);
}
.site-nav a:hover { color: var(--text); }
/* 语言切换是指向另一语言静态页的链接，故用 a.lang-toggle 提高优先级，
   避免被上面的 .site-nav a 字号规则覆盖 */
.site-nav a.lang-toggle {
  font-family: var(--font-mono);
  font-size: var(--step-meta);
  letter-spacing: 0.1em;
  padding: 0.5em 0.9em;
  border: 1px solid var(--line);
  color: var(--text);   /* 与原先的 button 外观一致，不被 .site-nav a 调暗 */
  transition: border-color 160ms var(--ease-out);
}
.site-nav a.lang-toggle:hover { border-color: var(--text); }

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: var(--space-4);
}
.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}
/* 版权 + 邮箱作为左侧一组，避免被 space-between 摊到中间 */
.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
/* 邮箱不用 .meta：其 uppercase 会把地址显示成全大写 */
.footer-email {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: var(--step-meta);
  letter-spacing: 0.02em;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 160ms var(--ease-out);
}
.footer-email:hover { color: var(--text); }
/* 信封标识：像素网格 + crispEdges，与站点像素风格一致 */
.footer-email__icon { flex: none; }

/* 页脚右侧：返回顶部 + 切换语言版本 */
.footer-alts {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* ---------- 滚动入场（fail-open：仅在 js 可用时隐藏） ---------- */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 500ms var(--ease-out), transform 500ms var(--ease-out);
}
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- 焦点可见性 ---------- */
:focus-visible {
  outline: 2px solid var(--acc, var(--acc-node));
  outline-offset: 3px;
}

/* ---------- 减少动态 ---------- */
@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;
  }
  .js .reveal { opacity: 1; transform: none; }
}

/* ---------- 移动端：保留整页吸附翻页 + 紧凑版式 ---------- */
/* 内容高于视口时，浏览器允许在该吸附区内部自由停留，
   不会把长页钉死在顶部，因此移动端可以保留吸附 */
@media (max-width: 900px) {
  .page { padding-block: 4.25rem 0.75rem; }
  .page--last { padding-block: 4.25rem 0; }
  /* 页点保留但缩小、贴近边缘，作为移动端的分页指示 */
  .page-dots { right: 0.55rem; gap: 0.7rem; }
  .page-dot { width: 8px; height: 8px; }
  .page-dot.is-active { transform: scale(1.3); }
}

/* ---------- 矮屏桌面窗口：照旧关闭吸附，回归自由滚动 ---------- */
@media (min-width: 901px) and (max-height: 700px) {
  html { scroll-snap-type: none; }
  .page {
    min-height: auto;
    padding-block: var(--space-6) var(--space-5);
  }
  .page--last { padding-block: var(--space-6) 0; }
}

@media (max-width: 640px) {
  .logo { font-size: 0.9rem; }        /* 收窄字标，避免顶栏导航折行 */
  .site-nav { gap: var(--space-1); }
  .site-nav a { font-size: 0.85rem; }
  .section { padding-block: var(--space-5); }
}
