/* 产品集（入口页）
   设计依据：docs/02-设计规范.md，修改令牌时同步更新规范。
   站点 CSP 只允许本文件作为样式来源：页面里没有内联样式，也没有脚本，所有状态与动效都在这里实现。
   分类筛选规则由 scripts/lib/styles.js 在构建时追加到本文件末尾。
   分段顺序：令牌 → 基础 → 布局 → 组件 → 首屏 → 项目 → 关于与页脚 → 动效 → 响应式 → 深色模式 */

/* == 令牌 == */
:root {
  color-scheme: light dark;

  --bg: #F4F2EE;
  --bg-raised: #FBFAF8;
  --ink: #141413;
  --ink-2: #3B3A37;
  --ink-3: #8A867F;
  --muted: #6A6761;
  --line: #DDD9D1;
  --line-strong: #C7C2B8;
  --seal: #B5301C;
  --header-bg: rgb(244 242 238 / 82%);

  --stage-bg: #0D0E10;
  --stage-ink: #F2F1EE;
  --stage-muted: #9C9A95;
  --stage-line: rgb(255 255 255 / 10%);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --font-seal: "Songti SC", "STSong", "SimSun", serif;

  --fs-display-1: clamp(36px, 8vw, 116px);
  --fs-heading: clamp(28px, 3.2vw, 44px);
  --fs-title: clamp(21px, 1.8vw, 25px);
  --fs-lead: clamp(17px, 1.45vw, 21px);

  --container: 1280px;
  --gutter: clamp(20px, 5vw, 56px);
  --gap: clamp(16px, 2vw, 28px);
  --section-y: clamp(96px, 12vw, 160px);

  --radius-card: 18px;

  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
  --shadow-hover: 0 30px 60px -30px rgb(20 20 19 / 30%);
}

/* 项目色调：封面面板底色、强调色、网格线与光晕 */
.tint--blue { --tint-bg: #E6ECF8; --tint-ink: #2D5BD3; --tint-grid: rgb(45 91 211 / 11%); --tint-spot: rgb(59 108 236 / 34%); }
.tint--indigo { --tint-bg: #E8E7F6; --tint-ink: #4B46B8; --tint-grid: rgb(75 70 184 / 11%); --tint-spot: rgb(98 92 230 / 34%); }
.tint--teal { --tint-bg: #E2F0EE; --tint-ink: #176B62; --tint-grid: rgb(23 107 98 / 11%); --tint-spot: rgb(32 160 146 / 30%); }
.tint--slate { --tint-bg: #E7E9ED; --tint-ink: #3B4656; --tint-grid: rgb(59 70 86 / 10%); --tint-spot: rgb(120 136 160 / 30%); }
.tint--amber { --tint-bg: #F5ECDD; --tint-ink: #9A5B0E; --tint-grid: rgb(154 91 14 / 11%); --tint-spot: rgb(224 150 60 / 30%); }
.tint--vermilion { --tint-bg: #F6E6E1; --tint-ink: #B5301C; --tint-grid: rgb(181 48 28 / 10%); --tint-spot: rgb(220 80 56 / 30%); }

/* == 基础 == */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.8 var(--font-sans);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p, ol, ul, figure { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
ol, ul { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
strong { font-weight: 600; }
time, .label { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 6px; }
.stage :focus-visible,
.site-footer :focus-visible { outline-color: var(--stage-ink); }
::selection { background: var(--seal); color: #fff; }

.icon {
  width: 1em;
  height: 1em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s var(--ease);
}

.label {
  font: 500 12px/1.4 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

/* 标题与标语按词组断行：中文只在标点和空格处换行，放不下时才强制断开 */
.card__title,
.card__tagline,
.section-head__title,
.principles h3 {
  word-break: keep-all;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
}
.skip-link:focus { top: 12px; }

/* == 布局 == */
.container { width: min(var(--container), 100% - 2 * var(--gutter)); margin-inline: auto; }
.section { padding-block: var(--section-y); }

.section-head { margin-bottom: clamp(36px, 4.5vw, 64px); }
.section-head__title {
  font-size: var(--fs-heading);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
}
.section-head__count { margin-left: 14px; color: var(--muted); font: 500 15px/1 var(--font-mono); letter-spacing: 0.06em; vertical-align: 0.9em; }

/* == 组件 == */

/* 印章：朱砂底、白色宋体单字，内缩细框模拟印框 */
.seal {
  display: inline-grid;
  place-items: center;
  flex: none;
  aspect-ratio: 1;
  border-radius: 7px;
  background: var(--seal);
  color: #fff;
  font-family: var(--font-seal);
  font-weight: 700;
  line-height: 1;
  box-shadow: inset 0 0 0 3px var(--seal), inset 0 0 0 4px rgb(255 255 255 / 55%);
}
.seal--sm { width: 34px; font-size: 20px; }
.seal--md { width: 44px; font-size: 26px; border-radius: 9px; }
.seal--lg {
  width: 72px;
  font-size: 42px;
  border-radius: 13px;
  box-shadow: inset 0 0 0 5px var(--seal), inset 0 0 0 6.5px rgb(255 255 255 / 55%);
}

/* 页眉 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(150%) blur(16px);
  backdrop-filter: saturate(150%) blur(16px);
}
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 24px; height: 72px; }
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand__name { font-size: 17px; font-weight: 600; letter-spacing: 0.04em; }
.site-nav { display: flex; align-items: center; gap: 36px; font-size: 15px; }
.site-nav a { position: relative; padding-block: 6px; color: var(--ink-2); transition: color 0.24s var(--ease); }
.site-nav a::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:hover::after { transform: scaleX(1); }

/* 按钮 */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: background-color 0.24s var(--ease), border-color 0.24s var(--ease), color 0.24s var(--ease);
}
.button .icon { font-size: 17px; }
.button--primary { background: var(--ink); color: var(--bg); }
.button--primary:hover { background: var(--ink-2); }
.button--secondary { border-color: var(--line-strong); color: var(--ink); }
.button--secondary:hover { border-color: var(--ink); }
.stage .button--secondary { border-color: rgb(255 255 255 / 24%); color: var(--stage-ink); }
.stage .button--secondary:hover { border-color: rgb(255 255 255 / 64%); }

/* 状态与标记：只有筹备中的项目显示状态，已上线的卡片本身就是链接 */
.status { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; line-height: 1.4; }
.status::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; line-height: 1.5; }
.badge--draft { background: var(--seal); color: #fff; }

/* 封面面板：项目色调底 + 向四周淡出的细网格 + 中心柔光 */
.cover { position: relative; isolation: isolate; overflow: hidden; background: var(--tint-bg); }
.cover::before,
.cover::after { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.cover::before {
  background-image:
    linear-gradient(var(--tint-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--tint-grid) 1px, transparent 1px);
  background-position: center;
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(ellipse 62% 62% at 50% 50%, #000 25%, transparent 100%);
  mask-image: radial-gradient(ellipse 62% 62% at 50% 50%, #000 25%, transparent 100%);
}
.cover::after { background: radial-gradient(ellipse 40% 50% at 50% 50%, rgb(255 255 255 / 75%), transparent 72%); }
.cover--icon,
.cover--text { display: grid; place-items: center; }
.cover__icon {
  width: clamp(96px, 30%, 150px);
  filter: drop-shadow(0 22px 30px rgb(15 20 30 / 24%));
  transition: transform 0.5s var(--ease);
}
.cover__text {
  padding: 0.16em 0.22em 0.2em;
  border: 3px solid currentColor;
  border-radius: 0.16em;
  color: var(--tint-ink);
  font: 700 clamp(48px, 6vw, 84px)/1 var(--font-seal);
  letter-spacing: 0.04em;
}
.cover__shot {
  position: absolute;
  top: 13%;
  left: 9%;
  width: 104%;
  max-width: none;
  border: 1px solid rgb(0 0 0 / 10%);
  border-radius: 10px;
  box-shadow: 0 30px 60px -24px rgb(0 0 0 / 40%);
  transition: transform 0.5s var(--ease);
}

/* == 首屏 == */
.hero { padding-block: clamp(48px, 7vw, 104px) clamp(72px, 9vw, 120px); }
.hero__title {
  font-size: var(--fs-display-1);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.hero__title > span { display: block; }
.hero__title > span:first-child { color: var(--ink-3); }
.hero__body {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-items: end;
  margin-top: clamp(40px, 5vw, 80px);
}
.hero__lead { grid-column: 1 / span 7; max-width: 32em; color: var(--ink-2); font-size: var(--fs-lead); line-height: 1.85; }
.hero__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px; grid-column: 8 / -1; }

/* == 项目 == */
.projects { padding-top: 0; }
.projects .section-head { padding-top: clamp(56px, 6vw, 88px); border-top: 1px solid var(--line); }

/* 分类筛选：点分类跳到对应锚点，:target 隐藏其他分类（规则由构建脚本按分类生成） */
.projects__anchor { display: block; scroll-margin-top: 96px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: clamp(28px, 3vw, 40px); }
.filters__item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.24s var(--ease), border-color 0.24s var(--ease), color 0.24s var(--ease);
}
.filters__item span { font: 500 11px/1 var(--font-mono); opacity: 0.7; }
.filters__item:hover { border-color: var(--ink); color: var(--ink); }
.filters__item--all { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.projects__anchor:target ~ .filters .filters__item--all { border-color: var(--line-strong); background: transparent; color: var(--ink-2); }
.projects__anchor:target ~ .project-grid > .slot { display: none; }

.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(20px, 2.2vw, 32px); }
.project-grid > li { display: flex; }
.project-grid > li > * { flex: 1; }
.projects__empty { color: var(--muted); }

/* 项目卡：已上线的整张卡片链接到项目官网；筹备中的卡片不可点击 */
.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--bg-raised);
  transition: transform 0.4s var(--ease), box-shadow 0.4s var(--ease), border-color 0.4s var(--ease);
}
.card__cover { aspect-ratio: 16 / 10; border-bottom: 1px solid var(--line); }
.card__body { display: flex; flex: 1; flex-direction: column; padding: 24px 26px 22px; }
.card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.card__title { display: flex; align-items: center; gap: 12px; margin-top: 16px; font-size: var(--fs-title); font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.card__icon { width: 34px; height: 34px; flex: none; }
.card__tagline {
  display: -webkit-box;
  margin-top: 10px;
  overflow: hidden;
  color: var(--ink-2);
  font-size: 15px;
  line-height: 1.75;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
/* 底栏靠 margin-top: auto 贴底，同一行卡片的「访问官网」对齐；最小间距放在底栏前一个元素上。 */
.card__body > :nth-last-child(2) { margin-bottom: 24px; }
.card__cta { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.card__cta .icon { font-size: 16px; }
a.card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-hover); }
.card--upcoming { border-style: dashed; background: transparent; }
.card--upcoming .card__cover { filter: saturate(0.4); opacity: 0.8; }

/* 空展位：补齐网格最后一行（每行几列就最多补几个，见响应式段） */
.slot__frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 320px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-card);
  color: var(--muted);
}
.slot__frame .icon { margin-bottom: 6px; color: var(--line-strong); font-size: 28px; stroke-width: 1.25; }
.slot__text { font-size: 15px; }

/* == 关于与页脚（深色收尾）== */
.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--stage-bg);
  color: var(--stage-ink);
}
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(ellipse 45% 55% at 12% 0%, var(--tint-spot), transparent 70%);
  pointer-events: none;
}
.stage .label { color: var(--stage-muted); }

.about__grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
.about__head { grid-column: 1 / span 4; }
.about__name { display: flex; align-items: center; gap: 20px; font-size: var(--fs-heading); font-weight: 600; letter-spacing: 0.04em; }
.about__role { margin-top: 16px; color: var(--stage-muted); font-size: 15px; }
.about__text { grid-column: 6 / -1; }
.about__text p { max-width: 680px; color: var(--stage-muted); line-height: 1.9; }
.about__text p:first-child { color: var(--stage-ink); font-size: var(--fs-lead); line-height: 1.85; }
.about__text p + p { margin-top: 20px; }
.contact { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.principles__label { margin-top: clamp(72px, 9vw, 120px); }
.principles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); margin-top: 20px; }
.principles > li { padding-top: 22px; border-top: 1px solid var(--stage-line); }
.principles h3 { font-size: 19px; font-weight: 600; line-height: 1.45; }
.principles p { margin-top: 10px; color: var(--stage-muted); font-size: 15px; line-height: 1.85; }

.site-footer { padding-block: 40px; border-top: 1px solid var(--stage-line); background: var(--stage-bg); color: var(--stage-muted); font-size: 13px; }
.site-footer__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px 40px; }
.site-footer__brand { display: flex; align-items: center; gap: 14px; }
.site-footer__brand strong { color: var(--stage-ink); font-size: 15px; letter-spacing: 0.04em; }
.site-footer__meta { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.site-footer a:hover { color: var(--stage-ink); }

/* == 动效（只在用户未要求减少动态效果时启用）== */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  @keyframes rise {
    from { opacity: 0; translate: 0 18px; }
    to { opacity: 1; translate: 0 0; }
  }

  .hero__title > span,
  .hero__body { animation: rise 1s var(--ease) both; }
  .hero__title > span:nth-child(2) { animation-delay: 0.08s; }
  .hero__body { animation-delay: 0.18s; }

  /* 滚动进入时淡入：不支持的浏览器直接显示 */
  @supports (animation-timeline: view()) {
    .project-grid > li,
    .principles > li {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 40%;
    }
  }

  @media (hover: hover) {
    a.card:hover { transform: translateY(-4px); }
    a.card:hover .cover__icon { transform: translateY(-4px) scale(1.04); }
    a.card:hover .cover__shot { transform: translate(-6px, -6px); }
    a.card:hover .card__cta .icon,
    .button:hover .icon--arrow-up-right { transform: translate(2px, -2px); }
    .button:hover .icon--arrow-down { transform: translateY(3px); }
  }
}

/* == 响应式 == */

/* 空展位只补齐最后一行：落在新一行行首的展位及其后的展位隐藏 */
@media (min-width: 1200px) {
  .project-grid > .slot:nth-child(3n + 1),
  .project-grid > .slot:nth-child(3n + 1) ~ .slot { display: none; }
}

@media (max-width: 1199px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-grid > .slot:nth-child(2n + 1),
  .project-grid > .slot:nth-child(2n + 1) ~ .slot { display: none; }
  .hero__lead,
  .hero__actions { grid-column: 1 / -1; }
  .hero__actions { justify-content: flex-start; }
  .about__head,
  .about__text { grid-column: 1 / -1; }
  .about__text { margin-top: 32px; }
}

@media (max-width: 899px) {
  .principles { grid-template-columns: minmax(0, 1fr); gap: 32px; }
}

@media (max-width: 639px) {
  .site-header__inner { height: 60px; }
  .hero__actions .button { flex: 1 1 auto; }
  .button { min-height: 52px; }
  .project-grid { grid-template-columns: minmax(0, 1fr); }
  .project-grid > .slot { display: none; }
  .card__body { padding: 20px 20px 18px; }
  .about__name { gap: 16px; }
  .seal--lg { width: 60px; font-size: 34px; }
  .site-footer__inner { flex-direction: column; align-items: flex-start; }
}

/* == 深色模式（跟随系统）== */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E0E0D;
    --bg-raised: #161615;
    --ink: #EEECE7;
    --ink-2: #C9C6BF;
    --ink-3: #77736C;
    --muted: #95918A;
    --line: #2A2926;
    --line-strong: #3A3935;
    --seal: #C0402A;
    --header-bg: rgb(14 14 13 / 78%);
    --stage-bg: #141518;
    --shadow-hover: 0 30px 60px -30px rgb(0 0 0 / 80%);
  }
  .tint--blue { --tint-bg: #131C2E; --tint-ink: #8FB0FF; --tint-grid: rgb(143 176 255 / 8%); }
  .tint--indigo { --tint-bg: #1A1930; --tint-ink: #AAA6FF; --tint-grid: rgb(170 166 255 / 8%); }
  .tint--teal { --tint-bg: #0F2826; --tint-ink: #6FD3C5; --tint-grid: rgb(111 211 197 / 8%); }
  .tint--slate { --tint-bg: #1A1D23; --tint-ink: #A8B3C4; --tint-grid: rgb(168 179 196 / 7%); }
  .tint--amber { --tint-bg: #2B2010; --tint-ink: #F0B866; --tint-grid: rgb(240 184 102 / 8%); }
  .tint--vermilion { --tint-bg: #2E1510; --tint-ink: #F08B74; --tint-grid: rgb(240 139 116 / 8%); }

  .stage { border-top: 1px solid var(--stage-line); }
  .button--primary:hover { background: #fff; }
  .cover::after { background: radial-gradient(ellipse 40% 50% at 50% 50%, var(--tint-spot), transparent 72%); }
  .cover__icon { filter: drop-shadow(0 22px 30px rgb(0 0 0 / 55%)); }
  .cover__shot { border-color: rgb(255 255 255 / 10%); }
}
