/* 所有尺寸按视口宽度等比缩放：桌面以 1500px 设计稿为基准，手机以 430px 为基准 */
:root {
  --u: calc(100vw / 1500);
  --pad-x: calc(80 * var(--u));
  --pad-y: calc(40 * var(--u));
  --bg: #000;
  --ink: #fff;
  --line: rgba(255, 255, 255, .16);
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: dark;
}
@media (max-width: 720px) {
  :root { --u: calc(100vw / 430); --pad-x: calc(40 * var(--u)); --pad-y: calc(25 * var(--u)); }
}

* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: max(13px, calc(14 * var(--u)));
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h2, p, ul, dl, dd { margin: 0; padding: 0; }
ul { list-style: none; }
img { display: block; width: 100%; height: 100%; object-fit: cover; -webkit-user-drag: none; }
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; border-radius: 2px; }

.label { font-size: max(11px, calc(10 * var(--u))); line-height: 1.4; font-weight: 500; text-transform: uppercase; }
.dim { opacity: .6; }

/* 加载动画 */
.loader {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  display: flex; align-items: center; justify-content: center; gap: calc(8 * var(--u));
  transition: opacity .5s var(--ease);
}
.loader i {
  width: calc(50 * var(--u)); height: max(3px, calc(5 * var(--u))); border-radius: 2rem; background: var(--ink);
  transform-origin: left; animation: bar .9s var(--ease) both;
}
.loader i:nth-child(2) { animation-delay: .12s; }
.loader i:nth-child(3) { animation-delay: .24s; }
@keyframes bar { from { transform: scaleX(0); opacity: .2; } }
.ready .loader { opacity: 0; }

/* 画廊 */
.stage {
  position: fixed; inset: 0; overflow: hidden;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  transition: opacity .7s var(--ease), filter .7s var(--ease), visibility .7s;
}
.stage.dragging { cursor: grabbing; }
/* WebGL 开启时，卡片画面由画布绘制，DOM 里的图只保留占位和点击 */
.gl { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gl-on .item { background: transparent; overflow: visible; }
.gl-on .stage .media { opacity: 0 !important; }
.gl-on .cap .title { opacity: 0; } /* 标题由 WebGL 画在卡片上 */
.track {
  position: absolute; left: 0; right: 0; top: 50%;
  height: min(43.5svh, calc(550 * var(--u))); transform: translateY(-50%);
}
.stage.vertical .track { top: 0; height: 100%; transform: none; left: calc(20 * var(--u)); right: calc(20 * var(--u)); }
.item {
  position: absolute; top: 0; left: 0; display: block; overflow: hidden;
  border-radius: calc(20 * var(--u)); background: #111;
  will-change: transform; cursor: pointer;
}
.stage.vertical .item { border-radius: calc(15 * var(--u)); }
.stage.dragging .item { cursor: grabbing; }
.media { width: 100%; height: 100%; transition: opacity .6s var(--ease); }
.media > * {
  transition: transform 1.4s var(--ease);
  animation: enter 1.4s var(--ease) backwards;
  animation-delay: calc(var(--i, 0) * 80ms);
}
@keyframes enter { from { opacity: 0; transform: scale(1.4); } }
.cap {
  position: absolute; left: calc(20 * var(--u)); right: calc(20 * var(--u)); bottom: calc(10 * var(--u));
  display: flex; align-items: flex-end; justify-content: space-between; pointer-events: none;
}
.stage.vertical .cap { left: calc(10 * var(--u)); right: calc(10 * var(--u)); }
.cap .title {
  white-space: nowrap; font-size: max(14px, calc(18 * var(--u))); letter-spacing: -.05em;
  text-shadow: 0 0 12px rgba(0, 0, 0, .35);
}
.go {
  display: inline-flex; align-items: center; justify-content: center;
  width: max(22px, calc(25 * var(--u))); height: max(22px, calc(25 * var(--u)));
  border-radius: 50%; background: #000; color: #fff; font-size: max(11px, calc(11 * var(--u))); line-height: 1;
  transform: scale(0); transition: transform .5s var(--ease);
}
@media (hover: hover) {
  .stage:not(.dragging) .track:hover .item:not(:hover) .media { opacity: .45; }
  .stage:not(.dragging) .item:hover .media > * { transform: scale(1.06); }
  .stage:not(.dragging) .item:hover .go { transform: none; }
}
.item:focus-visible .go { transform: none; }
.item:focus-visible { outline-offset: -1px; border-radius: calc(20 * var(--u)); }
.empty { position: absolute; inset: 0; display: grid; place-items: center; opacity: .6; }

/* 占位渐变图（没有图片时显示） */
.art { position: relative; width: 100%; height: 100%; }
.art::after {
  content: ""; position: absolute; inset: 0; opacity: .4; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* 索引视图：居中的一片作品名称，用圆点隔开 */
.index {
  position: fixed; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: max(70px, 12svh) 0;
  opacity: 0; visibility: hidden;
  transition: opacity .7s var(--ease), filter .7s var(--ease), visibility .7s;
}
.index-list {
  margin: 0 auto; min-height: 100%; max-width: calc(900 * var(--u)); padding: 0 calc(20 * var(--u));
  display: flex; flex-wrap: wrap; align-content: center; align-items: center; justify-content: center;
  gap: calc(6 * var(--u)) calc(24 * var(--u));
}
.name { position: relative; display: flex; }
.name a {
  white-space: nowrap; font-size: max(18px, calc(30 * var(--u))); line-height: 1.15; letter-spacing: -.05em;
  transition: opacity .5s var(--ease);
}
.name .dot {
  position: absolute; left: 100%; top: 50%; margin-left: calc(12 * var(--u)); transform: translate(-50%, -50%);
  font-size: max(6px, calc(8 * var(--u))); line-height: 1; pointer-events: none;
}
@media (max-width: 720px) { .index-list { max-width: calc(420 * var(--u)); } }
@media (hover: hover) {
  .index-list:hover .name a:not(:hover) { opacity: .3; }
}
.peek {
  position: fixed; left: 0; top: 0; z-index: 2; pointer-events: none;
  width: calc(300 * var(--u)); aspect-ratio: 16 / 10; overflow: hidden; border-radius: calc(15 * var(--u));
  opacity: 0; transition: opacity .4s var(--ease);
}
.peek.on { opacity: 1; }
@media (hover: none) { .peek { display: none; } }
.view-index .index { opacity: 1; visibility: visible; }
.view-index .stage { opacity: 0; visibility: hidden; }

/* 四角小字 */
.ui { position: fixed; inset: 0; z-index: 30; pointer-events: none; }
.ui > * {
  position: absolute; pointer-events: auto; transition: opacity .3s ease-out;
  /* 加宽的粗体：系统字体没有宽体字重，用横向拉伸模拟 */
  font-weight: 800; letter-spacing: .1em; transform: scaleX(1.32);
}
.ui > *::before, .views a::before { content: ""; position: absolute; inset: -15px; }
.ui > button:hover, .tl:hover { opacity: .6; }
.tl { top: var(--pad-y); left: var(--pad-x); transform-origin: left center; }
.tr { top: var(--pad-y); right: var(--pad-x); transform-origin: right center; }
.bl { bottom: var(--pad-y); left: var(--pad-x); transform-origin: left center; }
.br { bottom: var(--pad-y); right: var(--pad-x); transform-origin: right center; }
.ui button { text-transform: inherit; font-weight: inherit; }
.views { display: flex; gap: calc(5 * var(--u)); }
.views::before { display: none; }
.views { align-items: baseline; }
.views a { position: relative; opacity: .5; font-weight: 500; transition: opacity .5s ease-out; }
.views a[aria-current="page"] { font-weight: 800; }
.views a:hover, .views a[aria-current="page"] { opacity: 1; }

/* 简介 / 联系浮层 */
.panel {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 80px calc(20 * var(--u)); text-align: center;
  opacity: 0; visibility: hidden;
  transition: opacity .7s var(--ease), visibility .7s;
}
.panel-inner { display: flex; flex-direction: column; align-items: center; transform: translateY(12px); transition: transform 1s var(--ease); }
.lead { max-width: calc(450 * var(--u)); letter-spacing: -.02em; }
@media (max-width: 720px) { .lead { max-width: calc(350 * var(--u)); } }
.lead p + p { margin-top: .8em; }
.panel .label, .mail { margin-top: calc(30 * var(--u)); }
.mail { font-size: max(20px, calc(34 * var(--u))); letter-spacing: -.05em; transition: opacity .3s ease-out; overflow-wrap: anywhere; }
.links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: calc(8 * var(--u)) calc(20 * var(--u)); }
.links a { transition: opacity .3s ease-out; }
.links a:hover, .mail:hover { opacity: .6; }
[data-panel="profile"] #panel-profile, [data-panel="contact"] #panel-contact { opacity: 1; visibility: visible; }
[data-panel="profile"] #panel-profile .panel-inner, [data-panel="contact"] #panel-contact .panel-inner { transform: none; }
body[data-panel] .stage, body[data-panel] .index { opacity: .12; filter: blur(10px); pointer-events: none; }
body[data-panel].view-index .stage { opacity: 0; }
body[data-panel] .views { opacity: 0; pointer-events: none; }
[data-panel="profile"] .br, [data-panel="contact"] .tr { opacity: 0; pointer-events: none; }

/* 作品详情：白色面板 */
.detail { position: fixed; inset: 0; z-index: 35; background: #000; overflow: hidden; }
.detail[hidden] { display: none; }
.sheet {
  position: absolute; top: calc(20 * var(--u)); bottom: calc(20 * var(--u)); left: calc(50 * var(--u)); right: calc(50 * var(--u));
  display: flex; align-items: flex-start; gap: calc(100 * var(--u));
  padding: calc(40 * var(--u)) calc(120 * var(--u)) 0 calc(40 * var(--u));
  overflow: hidden; border-radius: calc(20 * var(--u)); background: #fff; color: #000;
}
.sheet ::selection { background: #000; color: #fff; }
.sheet :focus-visible { outline-color: #000; }
.sheet-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.sheet-text h2 { font-size: max(30px, calc(45 * var(--u))); font-weight: 400; line-height: 1.1; letter-spacing: -.05em; white-space: nowrap; }
.desc { margin-top: calc(20 * var(--u)); max-width: calc(400 * var(--u)); font-size: max(14px, calc(16 * var(--u))); letter-spacing: -.035em; }
.pills { margin-top: calc(45 * var(--u)); display: flex; align-items: flex-start; gap: calc(12 * var(--u)); }
.pills > div { display: flex; flex-wrap: wrap; gap: calc(2 * var(--u)); }
.pill {
  display: inline-flex; align-items: center; height: 2em; padding: 0 1.25em; border-radius: 999px;
  background: #eee; color: #000; white-space: nowrap; font-size: max(13px, calc(14 * var(--u)));
}
.pill .label { line-height: 1; }
.pill.dark { flex: none; aspect-ratio: 1; justify-content: center; padding: 0; background: #000; color: #fff; transition: transform .5s var(--ease); }
.pill.dark:hover { transform: scale(1.1); }
.sheet-shots {
  flex: none; width: calc(700 * var(--u)); height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  display: flex; flex-direction: column; align-items: center; gap: calc(60 * var(--u)); padding-bottom: calc(40 * var(--u));
}
.sheet-shots::-webkit-scrollbar { display: none; }
.shot { flex: none; width: 100%; overflow: hidden; background: #eee; }
.shot img { height: auto; }
.close { position: absolute; top: calc(30 * var(--u)); right: calc(30 * var(--u)); width: max(36px, calc(45 * var(--u))); height: max(36px, calc(45 * var(--u))); }
.related {
  position: absolute; inset: calc(100 * var(--u)); border-radius: calc(20 * var(--u)); background: #fff; opacity: .3; cursor: pointer;
  transition: opacity .5s var(--ease), translate .7s var(--ease);
}
.related.prev { transform: translateX(calc(-100% - 75 * var(--u))); }
.related.next { transform: translateX(calc(100% + 75 * var(--u))); }
.related::before { content: ""; position: absolute; inset: 0 calc(-25 * var(--u)); }
@media (hover: hover) {
  .related:hover { opacity: .55; }
  .related.prev:hover { translate: calc(8 * var(--u)) 0; }
  .related.next:hover { translate: calc(-8 * var(--u)) 0; }
}
/* 卡片图片飞向详情页首图时用的临时层 */
.flight { position: fixed; z-index: 50; overflow: hidden; pointer-events: none; }

@media (max-width: 720px) {
  .sheet {
    top: calc(15 * var(--u)); bottom: calc(15 * var(--u)); left: calc(20 * var(--u)); right: calc(20 * var(--u));
    flex-direction: column; align-items: stretch; gap: calc(40 * var(--u)); padding: 0 calc(10 * var(--u));
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; border-radius: calc(15 * var(--u));
  }
  .sheet::-webkit-scrollbar { display: none; }
  .sheet-text { flex: none; padding: calc(40 * var(--u)) calc(15 * var(--u)) 0; }
  .sheet-text h2 { font-size: calc(35 * var(--u)); white-space: normal; }
  .desc { max-width: none; }
  .pills { margin-top: calc(30 * var(--u)); }
  .pills > div { gap: calc(4 * var(--u)); }
  .sheet-shots { width: 100%; height: auto; overflow: visible; gap: calc(30 * var(--u)); padding-bottom: calc(80 * var(--u)); }
  .close { position: fixed; top: auto; bottom: calc(30 * var(--u)); right: calc(35 * var(--u)); width: calc(40 * var(--u)); height: calc(40 * var(--u)); }
  .related { border-radius: calc(15 * var(--u)); }
  .related.prev { transform: translateX(calc(-100% - 90 * var(--u))); }
  .related.next { transform: translateX(calc(100% + 90 * var(--u))); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
