/* ============================================================
   WORKS — Personal Engineering Archive v2
   S / A / B = 三种观看方式：
     S = Showcase   一次只看一个：大型编辑式案例（clip reveal + scale recovery）
     A = Selected   一次看几个：双栏精选（fade + stagger）
     B = Lab        快速浏览：档案索引（行高亮 + hover 预览）
   设计语言：沿用全站 米白/墨黑/暖棕/细线/留白（不推翻）
   ============================================================ */

/* 本站专用四级灰阶（比 --sub 略深，解决"整页像蒙了一层雾"） */
.works-page {
  --w-tertiary: #6A655C;
  --w-muted: #7F7A70;
  --w-stage: #ECE6DA;          /* S 级舞台衬底（日间） */
}
html.is-dark .works-page {
  --w-tertiary: #A9B4A2;
  --w-muted: #8B9A84;
  --w-stage: #1D231C;
}

/* ---------- 页面骨架 ---------- */
.works-main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 96px 48px 60px;
}

/* ---------- 顶部导航（保持 hub 结构，front-theme 注入主题按钮） ---------- */
.works-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 40px;
  background: var(--bg-soft, rgba(245, 241, 232, 0.94));
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.works-nav a {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--w-tertiary, #6A655C);
  transition: color .3s ease;
}
.works-nav a:hover { color: var(--accent); }
.works-logo { font: 16px var(--font-mono); color: var(--ink); }
.works-logo span { color: var(--accent); }

/* ---------- 键盘可达：全站只有鼠标 hover 不够 ---------- */
.works-page a:focus-visible,
.works-page button:focus-visible,
.works-page input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ============================================================
   页头 + 作品地图
   ============================================================ */
.works-head { padding: 64px 0 24px; }

.works-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--accent);
}
.works-title {
  font-family: var(--font-en);
  font-weight: 500;
  font-size: clamp(3rem, 8vw, 6.2rem);
  letter-spacing: -0.04em;
  line-height: 1.02;
  margin: 20px 0 22px;
}
.works-sub {
  font-family: var(--font-en);
  font-size: clamp(1rem, 1.8vw, 1.25rem);
  color: var(--ink);
  letter-spacing: 0.02em;
  max-width: 640px;
  line-height: 1.6;
}
.works-cn {
  color: var(--w-tertiary);
  font-size: 14px;
  margin-top: 10px;
  letter-spacing: 0.03em;
}

/* 档案状态行：WORKS / 2025 — 2026  +  N PROJECTS · N SIGNATURE */
.works-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-top: 30px;
}
.works-span {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--w-tertiary);
}
.works-span::before { content: ""; width: 44px; height: 1px; background: var(--accent); }
.works-stats {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 2px;
  color: var(--w-muted);
}

/* 作品地图：01 SIGNATURE / 02 SELECTED / 03 LAB（可点击跳转） */
.works-map {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 38px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.works-map li + li { border-left: 1px solid var(--line); }
.works-map a {
  display: block;
  padding: 20px 24px 22px;
  color: inherit;
  transition: color .35s ease;
}
.works-map li:first-child a { padding-left: 0; }
.works-map a:hover { color: var(--accent); }
.wm-top {
  display: flex;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--w-muted);
  transition: color .35s ease;
}
.works-map a:hover .wm-top,
.works-map a.on .wm-top { color: var(--accent); }
.wm-count {
  display: block;
  font-family: var(--font-en);
  font-weight: 500;
  font-size: clamp(1.4rem, 2.2vw, 1.9rem);
  letter-spacing: -0.01em;
  margin-top: 8px;
}
/* 数量单位：区分「分区序号」与「作品数量」，消除 02 SELECTED / 01 的误读 */
.wm-count em {
  font-family: var(--font-mono);
  font-size: 10px;
  font-style: normal;
  letter-spacing: 2px;
  color: var(--w-muted);
  margin-left: 9px;
  vertical-align: 3px;
}

/* ============================================================
   右侧滚动分区导航（桌面端极淡 01──02──03，自动高亮）
   ============================================================ */
.works-rail {
  display: none;
  position: fixed;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 40;
  flex-direction: column;
  gap: 20px;
}
@media (min-width: 1420px) {
  .works-rail { display: flex; }
}
.works-rail a {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--w-muted);
  transition: color .35s ease;
}
.works-rail .rail-num {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
}
.works-rail i {
  display: block;
  width: 22px;
  height: 1px;
  background: var(--line);
  transition: width .45s var(--ease-smooth), background .35s ease;
}
.works-rail a:hover { color: var(--accent); }
.works-rail a.on { color: var(--accent); }
.works-rail a.on i { width: 38px; background: var(--accent); }

/* ============================================================
   通用分区头
   ============================================================ */
.w-sec { padding: 118px 0 0; }
.w-sec-head {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 14px;
}
.w-sec-label {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--ink);
  white-space: nowrap;
}
.w-sec-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.w-sec-desc {
  font-size: 14px;
  color: var(--w-tertiary);
  letter-spacing: 0.02em;
  margin-bottom: 52px;
}
.w-empty {
  color: var(--w-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 2px;
  padding: 40px 0;
  border-top: 1px solid var(--line);
}

/* ============================================================
   01 / SIGNATURE —— 大型编辑式案例
   ============================================================ */
#sigBox { display: flex; flex-direction: column; gap: 118px; }

.sig { display: block; }
.sig-link { display: block; color: inherit; }

/* 舞台：图片进入"展示框架"（衬底 + 编号 + 年份），不是裸截图 */
.sig-stage {
  position: relative;
  overflow: hidden;
  height: clamp(440px, 62vh, 660px);
  background: var(--w-stage);
  border: 1px solid var(--line);
}
/* 视差层：上下各扩 14px，±8px 位移不露底 */
.sig-shift { position: absolute; inset: -14px 0; }
/* reveal 层：clip 窗口打开 + 缩放恢复 */
.sig-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: inset(10% 7% 10% 7%);
  opacity: 0;
  transition: clip-path 1s var(--ease-smooth), opacity .7s ease, transform .6s var(--ease-smooth);
}
.sig-frame img,
.sig-frame video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--pos, center);
  transform: scale(1.045);
  transition: transform 1.1s var(--ease-smooth);
}
/* 软件界面截图：contain，绝不为版式统一牺牲信息 */
.sig-stage.fit-contain .sig-frame { padding: clamp(18px, 3.6vw, 54px); }
.sig-stage.fit-contain .sig-frame img,
.sig-stage.fit-contain .sig-frame video { object-fit: contain; transform: scale(1.03); }

.sig-tag {
  position: absolute;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: #fff;
  background: rgba(23, 23, 23, 0.55);
  padding: 3px 10px;
  opacity: 0;
  transition: opacity .6s ease .45s;
}
.sig-tag-l { left: 14px; bottom: 12px; }
.sig-tag-r { right: 14px; bottom: 12px; }
.sig.in .sig-tag { opacity: 1; }

/* 进入：图片先 → 文字后（image → title → meta → cta） */
.sig.in .sig-frame { clip-path: inset(0); opacity: 1; }
.sig.in .sig-frame img,
.sig.in .sig-frame video { transform: scale(1); }
.sig.in .sig-stage.fit-contain .sig-frame img,
.sig.in .sig-stage.fit-contain .sig-frame video { transform: scale(1); }

/* hover：纸面/展柜被触碰的轻活感（不按按钮） */
.sig:hover .sig-frame { transform: scale(1.012); }
.sig:hover .sig-info { transform: translateX(4px); }
.sig:hover .sig-title { color: var(--accent); }
.sig:hover .sig-cta .arr { transform: translate(5px, -5px); }

.sig-info {
  padding-top: 30px;
  transition: transform .5s var(--ease-smooth);
}
.sig-title {
  font-family: var(--font-en);
  font-weight: 500;
  font-size: clamp(1.8rem, 4.2vw, 3.1rem);
  letter-spacing: -0.02em;
  line-height: 1.14;
  margin-bottom: 10px;
  transition: color .4s ease;
}
.sig-sub {
  font-size: 15.5px;
  color: var(--w-tertiary);
  line-height: 1.9;
  margin-bottom: 14px;
  max-width: 720px;
}
.sig-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 2px;
  color: var(--w-muted);
  margin-bottom: 24px;
}
.sig-meta .st-live { color: var(--accent); }

.sig-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--ink);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--ink);
  transition: color .35s ease, border-color .35s ease;
}
.sig-cta .arr { transition: transform .4s var(--ease-smooth); }
.sig:hover .sig-cta { color: var(--accent); border-color: var(--accent); }

/* 文字分级入场（图片完成 25% 后再出现） */
.sig-title, .sig-sub, .sig-meta, .sig-cta {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .8s var(--ease-smooth), transform .8s var(--ease-smooth);
}
.sig.in .sig-title { transition-delay: .26s; }
.sig.in .sig-sub   { transition-delay: .38s; }
.sig.in .sig-meta  { transition-delay: .5s; }
.sig.in .sig-cta   { transition-delay: .62s; }
.sig.in .sig-title, .sig.in .sig-sub, .sig.in .sig-meta, .sig.in .sig-cta {
  opacity: 1;
  transform: none;
}
/* hover 的 sig-info 位移与 .in 的文字 transform 分属不同元素，互不冲突 */

/* ============================================================
   02 / SELECTED —— 双栏精选
   ============================================================ */
.sel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 76px 48px;
}
.sel { display: block; color: inherit; }
.sel-link { display: block; color: inherit; }
/* 奇数个：最后一项横向铺满（杂志式收尾）——两列加在 <a> 上（article 的唯一子元素） */
.sel.wide { grid-column: 1 / -1; }
.sel.wide .sel-link {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 48px;
  align-items: center;
}
.sel.wide .sel-body { padding-top: 0; }

.sel-media {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  aspect-ratio: 4 / 3;
  background: var(--w-stage);
}
.sel.wide .sel-media { aspect-ratio: 16 / 10; }
.sel-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--pos, center);
  transition: transform 1s var(--ease-smooth);
}
.sel-media.fit-contain { padding: clamp(10px, 2vw, 26px); }
.sel-media.fit-contain img { object-fit: contain; }
.sel:hover .sel-media img { transform: scale(1.02); }

/* hover：右上角出现 VIEW → */
.sel-view {
  position: absolute;
  top: 12px;
  right: 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink);
  background: var(--bg-soft, var(--bg));
  border: 1px solid var(--line);
  padding: 4px 11px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .4s var(--ease-smooth), transform .4s var(--ease-smooth);
}
.sel:hover .sel-view { opacity: 1; transform: none; }

.sel-body {
  padding-top: 20px;
  transition: transform .45s var(--ease-smooth);
}
.sel:hover .sel-body { transform: translateY(-3px); }

.sel-meta {
  display: flex;
  align-items: baseline;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--w-muted);
  margin-bottom: 10px;
}
.sel-no { color: var(--accent); }
.sel-meta .st-live { color: var(--accent); }
.sel-title {
  font-family: var(--font-en);
  font-weight: 500;
  font-size: clamp(1.3rem, 2.4vw, 1.8rem);
  letter-spacing: -0.01em;
  line-height: 1.28;
  margin-bottom: 8px;
  transition: color .4s ease;
}
.sel:hover .sel-title { color: var(--accent); }
.sel-desc {
  font-size: 14px;
  color: var(--w-tertiary);
  line-height: 1.85;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sel-tags {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 2px;
  color: var(--w-muted);
}

/* ============================================================
   03 / LAB —— 档案索引（高密度 + hover 预览）
   ============================================================ */
.lab-list { border-top: 1px solid var(--line); }
.lab-row {
  position: relative;
  display: grid;
  grid-template-columns: 64px 1fr 260px 80px 26px;
  grid-template-rows: auto auto;
  gap: 0 22px;
  align-items: baseline;
  padding: 16px 8px 17px;
  border-bottom: 1px solid var(--line);
  color: inherit;
}
.lab-no { grid-column: 1; grid-row: 1; }
.lab-title { grid-column: 2; grid-row: 1; }
.lab-cats { grid-column: 3; grid-row: 1; }
.lab-year { grid-column: 4; grid-row: 1; }
.lab-arr { grid-column: 5; grid-row: 1; }
/* 一句话简介：标题行下方的通栏注脚（不挤压标题行） */
.lab-desc {
  grid-column: 2 / -1;
  grid-row: 2;
  min-width: 0;
  padding-top: 5px;
  font-size: 12.5px;
  color: var(--w-tertiary);
  line-height: 1.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .35s ease;
}
.lab-row:hover .lab-desc { color: var(--ink); }
/* 划线高亮：底部 accent 线自左展开 */
.lab-row::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .5s var(--ease-smooth);
}
.lab-row:hover::after { transform: scaleX(1); }

.lab-no {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--w-muted);
  transition: color .35s ease;
}
.lab-row:hover .lab-no { color: var(--accent); }
.lab-title {
  font-family: var(--font-en);
  font-weight: 500;
  font-size: 16.5px;
  letter-spacing: 0.01em;
  transition: color .35s ease;
}
.lab-row:hover .lab-title { color: var(--accent); }
.lab-cats {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 1.5px;
  color: var(--w-muted);
  text-align: right;
}
.lab-year {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--w-muted);
}
.lab-arr {
  font-family: var(--font-en);
  color: var(--w-muted);
  text-align: right;
  transition: transform .4s var(--ease-smooth), color .4s ease;
}
.lab-row:hover .lab-arr { transform: translateX(5px); color: var(--accent); }

/* 鼠标跟随预览（仅桌面 fine pointer；移动端不做） */
.lab-preview {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 264px;
  z-index: 60;
  pointer-events: none;
  opacity: 0;
  transition: opacity .35s ease;
}
@media (hover: hover) and (pointer: fine) and (min-width: 1200px) {
  .lab-preview { display: block; }
}
.lab-preview.on { opacity: 1; }
.lab-preview img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid var(--line);
  background: var(--w-stage);
}
.lab-preview span {
  display: block;
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--w-muted);
}

/* ============================================================
   PROJECT INDEX —— 只做索引/筛选，不重复展示作品
   ============================================================ */
.w-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.w-search {
  flex: 1 1 260px;
  min-width: 220px;
  height: 44px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 0 16px;
  font: 13px var(--font-mono);
  letter-spacing: 1px;
}
.w-search:focus { outline: none; border-color: var(--accent); }
.w-search::placeholder { color: var(--w-muted); }
.w-cats {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.w-cats::-webkit-scrollbar { display: none; }
.w-chip {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--w-tertiary);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: transparent;
  padding: 7px 16px;
  cursor: pointer;
  transition: color .3s ease, border-color .3s ease;
}
.w-chip:hover { color: var(--accent); border-color: var(--accent); }
.w-chip.on { color: var(--accent); border-color: var(--accent); }

.w-count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--w-muted);
  margin-top: 4px;
}
.w-idx-empty {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--w-tertiary);
  margin-top: 18px;
}

/* 筛选：隐藏不匹配的条目与空分区 */
.is-hidden { display: none !important; }

/* ============================================================
   滚动入场（分级：S 自带 .in；A/B 走 data-wr；均受动效开关控制）
   ============================================================ */
[data-wr] {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .7s var(--ease-smooth), transform .7s var(--ease-smooth);
  transition-delay: var(--d, 0ms);
}
[data-wr].in { opacity: 1; transform: none; }
/* 章节标题：更轻（8px） */
.w-sec-head[data-wr], .w-sec-desc[data-wr] {
  transform: translateY(10px);
  transition-duration: .5s;
}
/* B 级最轻：只做 opacity */
.lab-row[data-wr] { transform: none; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1024px) {
  .works-main { padding: 80px 36px 48px; }
  .sig-stage { height: clamp(400px, 56vh, 560px); }
  .sel-grid { gap: 64px 36px; }
  .lab-row { grid-template-columns: 48px 1fr 190px 70px 22px; gap: 0 18px; }
}

@media (max-width: 800px) {
  .works-nav { padding: 14px 20px; }
  .works-main { padding: 56px 20px 40px; }
  .works-head { padding-top: 40px; }
  .w-sec { padding-top: 82px; }
  .w-sec-desc { margin-bottom: 36px; }

  /* 作品地图改为纵向行 */
  .works-map { grid-template-columns: 1fr; }
  .works-map li + li { border-left: 0; border-top: 1px solid var(--line); }
  .works-map a { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 0; }
  .works-map li:first-child a { padding-left: 0; }
  .wm-count { margin-top: 0; }

  /* S：舞台改 4/3，natural 裁切 */
  .sig-stage { height: auto; aspect-ratio: 4 / 3; }
  #sigBox { gap: 84px; }
  .sig-stage.fit-contain .sig-frame { padding: 16px; }
  .sig-info { padding-top: 22px; }

  /* A：单列 */
  .sel-grid { grid-template-columns: 1fr; gap: 52px; }
  .sel.wide .sel-link { display: block; }
  .sel.wide .sel-media { aspect-ratio: 4 / 3; }
  .sel.wide .sel-body { padding-top: 20px; }

  /* B：收紧列（触控行高 ≥48px；简介缩到两行内） */
  .lab-row { grid-template-columns: 44px 1fr 24px; padding: 15px 4px 16px; }
  .lab-arr { grid-column: 3; }
  .lab-desc {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  .lab-cats, .lab-year { display: none; }
}

@media (max-width: 560px) {
  .works-title { font-size: clamp(2.6rem, 12vw, 3.6rem); }
  .works-meta { flex-direction: column; align-items: flex-start; }
}

/* ---------- 减少动效：与全站 data-motion 开关一致 ---------- */
@media (prefers-reduced-motion: reduce) {
  html:not([data-motion="on"]) [data-wr],
  html:not([data-motion="on"]) .sig-title, html:not([data-motion="on"]) .sig-sub,
  html:not([data-motion="on"]) .sig-meta, html:not([data-motion="on"]) .sig-cta {
    opacity: 1;
    transform: none;
    transition: none;
  }
  html:not([data-motion="on"]) .sig-frame { clip-path: none; opacity: 1; transition: none; }
  html:not([data-motion="on"]) .sig-frame img,
  html:not([data-motion="on"]) .sig-frame video,
  html:not([data-motion="on"]) .sel-media img { transform: none; transition: none; }
  html:not([data-motion="on"]) .sig-shift { transform: none !important; }
  html:not([data-motion="on"]) .lab-row::after { transition: none; }
}
