/* ============================================================
   FOLIO© — motion study
   复刻目标：暗色画布 + 全屏 WebGL 画廊 + 字母级文字动效
   ============================================================ */

:root {
  --bg: #0a0a0a;
  --fg: #fafafa;
  --fg-dim: #8a8a8a;
  --accent: #2effc7;
  --font: "Neue Haas Grotesk", "Helvetica Neue", Helvetica, "Inter", Arial, sans-serif;
  --ease-out: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-inout: cubic-bezier(0.77, 0, 0.175, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;              /* 虚拟滚动，不用原生滚动条 */
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body { cursor: none; }           /* 使用自定义光标 */
@media (pointer: coarse) {
  body { cursor: auto; }
  .cursor { display: none; }
}

button { font-family: inherit; background: none; border: 0; color: inherit; cursor: none; }
a { color: inherit; text-decoration: none; cursor: none; }

/* ---------- WebGL 画布 ---------- */
#webgl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- 顶/底渐变遮罩（对应原站 uFillColor 渐变 shader） ---------- */
.fade {
  position: fixed;
  left: 0; right: 0;
  height: 18vh;
  pointer-events: none;
  z-index: 3;
}
.fade-top    { top: 0;    background: linear-gradient(to bottom, var(--bg) 0%, transparent 100%); }
.fade-bottom { bottom: 0; background: linear-gradient(to top,   var(--bg) 0%, transparent 100%); }

/* ---------- UI 入场（loader 结束后统一 stagger 淡入） ---------- */
.ui-reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}
body.is-ready .ui-reveal { opacity: 1; transform: translateY(0); }

/* ---------- 顶栏 ---------- */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  z-index: 10;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.logo { display: flex; align-items: baseline; gap: 4px; font-weight: 700; }
.logo-tag { font-size: 10px; color: var(--fg-dim); font-weight: 400; }

.portfolio-home-link {
  position: fixed;
  z-index: 120;
  top: 17px;
  left: 128px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(250, 250, 250, 0.2);
  border-radius: 99px;
  background: rgba(10, 10, 10, 0.38);
  color: var(--fg-dim);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.13em;
  backdrop-filter: blur(10px);
  transition:
    color 0.35s var(--ease-out),
    border-color 0.35s var(--ease-out),
    background 0.35s var(--ease-out);
}

.portfolio-home-link:hover {
  border-color: rgba(46, 255, 199, 0.62);
  background: rgba(10, 10, 10, 0.72);
  color: var(--fg);
}

/* 视图切换（list / grid 胶囊开关） */
.view-switch {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(250, 250, 250, 0.18);
  border-radius: 99px;
}
.switch-opt {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  transition: color 0.4s var(--ease-out), background 0.4s var(--ease-out);
}
.switch-opt .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  transform: scale(0);
  transition: transform 0.4s var(--ease-out);
}
.switch-opt.is-active {
  color: var(--bg);
  background: var(--fg);
}
.switch-opt.is-active .dot { transform: scale(1); background: var(--accent); }

/* ---------- 字母拆分（hover 翻转 & 入场） ---------- */
.split-letter {
  display: inline-block;
  position: relative;
  overflow: hidden;
  vertical-align: top;
}
.split-letter .l {
  display: inline-block;
  transition: transform 0.5s var(--ease-out);
  transition-delay: var(--d, 0s);
}
.split-letter .l::after {
  content: attr(data-char);
  position: absolute;
  left: 0; top: 100%;
  color: var(--accent);
}
[data-split-hover]:hover .split-letter .l,
a:hover .split-letter .l,
button:hover .split-letter .l {
  transform: translateY(-100%);
}

.menu-btn { font-size: 13px; font-weight: 600; letter-spacing: 0.14em; padding: 8px 2px; }

/* ---------- 项目标题 ---------- */
.project-info {
  position: fixed;
  left: 28px;
  bottom: 96px;
  z-index: 5;
  pointer-events: none;
}
.project-title {
  font-size: clamp(40px, 7vw, 96px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  text-transform: uppercase;
  min-height: 1em;
}
/* 标题字母：JS 控制入出场 */
.project-title .t-line { display: block; overflow: hidden; }
.project-title .t-char {
  display: inline-block;
  transform: translateY(115%);
  transition: transform 0.7s var(--ease-out);
  transition-delay: var(--d, 0s);
  will-change: transform;
}
.project-title.is-in .t-char { transform: translateY(0); }
.project-title.is-out .t-char { transform: translateY(-115%); }

.project-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 14px;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.8s var(--ease-out) 0.2s, transform 0.8s var(--ease-out) 0.2s;
}
body.is-ready .project-meta { opacity: 1; transform: none; }
.meta-index { color: var(--fg); }
.meta-year { margin-left: 16px; }

/* 网格模式隐藏标题 */
body.mode-grid .project-info { opacity: 0; transition: opacity 0.5s var(--ease-out); }
.project-info { transition: opacity 0.5s var(--ease-out); }

/* ---------- Showreel 跑马灯胶囊 ---------- */
.showreel {
  position: fixed;
  left: 28px;
  bottom: 26px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0;
  height: 44px;
  border: 1px solid rgba(250, 250, 250, 0.18);
  border-radius: 99px;
  overflow: hidden;
  width: 210px;
  transition: border-color 0.4s var(--ease-out),
              opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}
.showreel:hover { border-color: var(--accent); }
.showreel-thumb {
  flex: 0 0 62px;
  height: 100%;
  background:
    radial-gradient(circle at 30% 40%, var(--accent), transparent 60%),
    radial-gradient(circle at 70% 70%, #7a5cff, transparent 55%),
    #151515;
  border-radius: 99px 0 0 99px;
}
.marquee {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);
}
.marquee-inner {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--fg-dim);
  animation: marquee 9s linear infinite;
}
.showreel:hover .marquee-inner { color: var(--fg); }
@keyframes marquee {
  to { transform: translateX(-50%); }
}

/* ---------- 声音开关 ---------- */
.sound-btn {
  position: fixed;
  right: 28px;
  bottom: 26px;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 44px;
  width: 44px;
  padding: 15px 12px;
  border: 1px solid rgba(250, 250, 250, 0.18);
  border-radius: 99px;
  transition: border-color 0.4s var(--ease-out),
              opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
}
.sound-btn:hover { border-color: var(--accent); }
.sound-btn .bar {
  flex: 1;
  background: var(--fg);
  height: 100%;
  transform-origin: bottom;
  animation: eq 0.9s ease-in-out infinite alternate;
}
.sound-btn .bar:nth-child(1) { animation-delay: -0.1s; }
.sound-btn .bar:nth-child(2) { animation-delay: -0.4s; }
.sound-btn .bar:nth-child(3) { animation-delay: -0.7s; }
.sound-btn .bar:nth-child(4) { animation-delay: -0.25s; }
.sound-btn.is-muted .bar {
  animation: none;
  transform: scaleY(0.18);
  transition: transform 0.4s var(--ease-out);
}
@keyframes eq {
  from { transform: scaleY(0.25); }
  to   { transform: scaleY(1); }
}

/* ---------- 滚动提示 ---------- */
.scroll-hint {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--fg-dim);
  animation: hint 2s ease-in-out infinite;
  pointer-events: none;
}
body.has-scrolled .scroll-hint { opacity: 0 !important; transition: opacity 0.6s; }
@keyframes hint {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* ---------- 菜单浮层 ---------- */
.menu-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #111111;
  clip-path: inset(0 0 100% 0);
  transition: clip-path 0.9s var(--ease-inout);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 28px;
  visibility: hidden;
}
.menu-overlay.is-open {
  clip-path: inset(0 0 0% 0);
  visibility: visible;
}
.menu-overlay.is-closing {
  visibility: visible;
  clip-path: inset(100% 0 0 0);
}

.menu-close {
  position: absolute;
  top: 22px;
  right: 28px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.menu-links { display: flex; flex-direction: column; gap: 4px; }
.menu-link {
  display: flex;
  align-items: baseline;
  gap: 18px;
  width: fit-content;
  overflow: hidden;
}
.menu-link-text {
  display: inline-block;
  font-size: clamp(44px, 8vw, 110px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-transform: uppercase;
  transform: translateY(115%) rotate(3deg);
  transition: transform 0.9s var(--ease-out), color 0.4s;
  transition-delay: var(--d, 0s);
  will-change: transform;
}
.menu-overlay.is-open .menu-link-text { transform: translateY(0) rotate(0); }
.menu-link:hover .menu-link-text { color: var(--accent); }
.menu-link-num {
  font-size: 12px;
  color: var(--fg-dim);
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
  transition-delay: calc(var(--d, 0s) + 0.3s);
}
.menu-overlay.is-open .menu-link-num { opacity: 1; }

.menu-footer {
  position: absolute;
  bottom: 26px;
  left: 28px;
  right: 28px;
  display: flex;
  gap: 28px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.7s var(--ease-out) 0.55s, transform 0.7s var(--ease-out) 0.55s;
}
.menu-overlay.is-open .menu-footer { opacity: 1; transform: none; }

/* 社交链接：双层文字上滑 */
.social-link {
  overflow: hidden;
  display: block;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  height: 1.4em;          /* 只露出一层，hover 上滑露出第二层 */
  line-height: 1.4;
}
.social-inner {
  display: flex;
  flex-direction: column;
  transition: transform 0.45s var(--ease-out);
}
.social-inner span { display: block; height: 1.4em; }
.social-inner span:nth-child(2) { color: var(--accent); }
.social-link:hover .social-inner { transform: translateY(-50%); }

/* ---------- 加载器 ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 26px;
  transition: clip-path 1s var(--ease-inout);
  clip-path: inset(0);
}
.loader.is-done { clip-path: inset(0 0 100% 0); pointer-events: none; }
.is-embedded .loader { display: none; }

.loader-top {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--fg-dim);
}
.loader-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
}
.loader-count {
  font-size: clamp(70px, 14vw, 180px);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.loader-count::after { content: "%"; font-size: 0.35em; vertical-align: super; color: var(--fg-dim); }

.loader-status,
.loader-bottom {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--fg-dim);
  text-transform: uppercase;
}

.loader-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.loader-status span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 16px rgba(46, 255, 199, 0.72);
  animation: loaderPulse 1.1s ease-in-out infinite alternate;
}

@keyframes loaderPulse {
  from { opacity: 0.32; transform: scale(0.72); }
  to { opacity: 1; transform: scale(1.15); }
}

/* ---------- 自定义光标 ---------- */
.cursor {
  position: fixed;
  top: 0; left: 0;
  z-index: 200;
  pointer-events: none;
  will-change: transform;
}
.cursor-dot {
  width: 10px; height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.35s var(--ease-out), background 0.3s;
}
.cursor.is-hover .cursor-dot { transform: scale(3.2); background: rgba(46, 255, 199, 0.35); }
.cursor.is-down .cursor-dot { transform: scale(0.6); }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .header { padding: 16px 18px; }
  .portfolio-home-link { top: 12px; left: 112px; min-height: 32px; }
  .project-info { left: 18px; bottom: 88px; }
  .showreel { left: 18px; width: 160px; }
  .sound-btn { right: 18px; }
  .view-switch { display: none; }
}
