/* ============================================================
   作品集 · 耿耿星河 — 2026 液态玻璃 / 暗色画廊风
   ------------------------------------------------------------
   · 零外部资源：底色、颗粒、海报全部由 CSS 生成，不耗图床流量
   · 视频仅点击后加载，源码中不出现真实地址（见 js/index.js）
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  color-scheme: light;
  --bg: #f4f1ea;
  --bg-soft: #ece7dc;
  --ink: #17181d;
  --ink-2: rgba(23, 24, 29, .68);
  --ink-3: rgba(23, 24, 29, .44);
  --glass: rgba(255, 255, 255, .58);
  --glass-2: rgba(255, 255, 255, .32);
  --stroke: rgba(23, 24, 29, .13);
  --stroke-2: rgba(23, 24, 29, .08);
  --accent: #5b4bff;
  --accent-2: #0b8f8f;
  --accent-3: #b5761f;
  --shadow: 0 24px 70px -24px rgba(30, 28, 45, .30);
  --shadow-sm: 0 12px 34px -16px rgba(30, 28, 45, .24);
  --radius: 24px;
  --radius-sm: 16px;
  --font-display: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --font-body: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, .8, .24, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07080c;
  --bg-soft: #0b0d13;
  --ink: #f2efe9;
  --ink-2: rgba(242, 239, 233, .68);
  --ink-3: rgba(242, 239, 233, .42);
  --glass: rgba(255, 255, 255, .055);
  --glass-2: rgba(255, 255, 255, .032);
  --stroke: rgba(255, 255, 255, .14);
  --stroke-2: rgba(255, 255, 255, .07);
  --accent: #a08dff;
  --accent-2: #58d5d6;
  --accent-3: #e9b872;
  --shadow: 0 28px 90px -26px rgba(0, 0, 0, .82);
  --shadow-sm: 0 14px 44px -20px rgba(0, 0, 0, .72);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: .01em;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .5s var(--ease), color .5s var(--ease);
}

body.is-locked {
  overflow: hidden;
  touch-action: none;
}

/* 触屏：去掉 300ms 延迟与双击缩放误触 */
a,
button,
.work { touch-action: manipulation; }

::selection { background: color-mix(in srgb, var(--accent) 36%, transparent); }

img,
svg,
video { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

h1, h2, h3, p, ul, figure { margin: 0; }
ul { padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- 极光背景 ---------- */
.aurora {
  position: fixed;
  inset: -18vmax;
  z-index: -2;
  pointer-events: none;
  filter: saturate(1.12);
}

.aurora i {
  position: absolute;
  width: 46vmax;
  height: 46vmax;
  border-radius: 50%;
  filter: blur(72px);
  opacity: .34;
  animation: drift 30s ease-in-out infinite alternate;
}

[data-theme="dark"] .aurora i { opacity: .5; }

.aurora .a1 {
  top: 4%;
  left: 8%;
  background: radial-gradient(circle at 40% 40%, var(--accent), transparent 66%);
}

.aurora .a2 {
  top: 32%;
  right: 2%;
  background: radial-gradient(circle at 60% 40%, var(--accent-2), transparent 66%);
  animation-duration: 38s;
  animation-delay: -8s;
}

.aurora .a3 {
  bottom: -8%;
  left: 26%;
  background: radial-gradient(circle at 50% 50%, var(--accent-3), transparent 66%);
  animation-duration: 44s;
  animation-delay: -16s;
  opacity: .24;
}

[data-theme="dark"] .aurora .a3 { opacity: .36; }

@keyframes drift {
  from { transform: translate3d(-4%, -3%, 0) scale(1); }
  to { transform: translate3d(6%, 5%, 0) scale(1.16); }
}

/* ---------- 胶片颗粒 ---------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .38;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  background-size: 150px 150px;
}

[data-theme="dark"] .grain { opacity: .5; mix-blend-mode: overlay; }

/* ---------- 玻璃 ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
}

@supports not ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
  .glass { background: var(--bg-soft); }
}

/* ---------- 顶部导航 ---------- */
.topnav {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  width: min(1080px, calc(100% - 24px));
}

.topnav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 10px 9px 18px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(22px) saturate(1.5);
  backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: var(--shadow-sm);
}

@supports not ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
  .topnav-inner { background: var(--bg-soft); }
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.brand svg { color: var(--accent-3); }

.mode-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  font-size: 13px;
  color: var(--ink-2);
  background: var(--glass-2);
  white-space: nowrap;
  transition: color .3s var(--ease), border-color .3s var(--ease), transform .3s var(--ease);
}

.mode-btn:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--stroke));
  transform: translateY(-1px);
}

/* ---------- 区块 ---------- */
main {
  padding-top: calc(74px + env(safe-area-inset-top, 0px));
}

.section {
  padding: clamp(26px, 4.5vw, 52px) clamp(20px, 6vw, 72px) clamp(72px, 10vw, 128px);
}

.section-head {
  max-width: 1180px;
  margin: 0 auto 44px;
  display: grid;
  gap: 12px;
}

.seal {
  justify-self: start;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--glass-2);
  font-size: 12px;
  letter-spacing: .18em;
  color: var(--ink-3);
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.6vw, 54px);
  line-height: 1.14;
  letter-spacing: .02em;
}

.section-head p {
  max-width: 36em;
  color: var(--ink-2);
  font-size: 15px;
}

/* ---------- 展映卡片（Bento） ---------- */
.bento {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(14px, 1.8vw, 22px);
}

.work {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  backdrop-filter: blur(16px) saturate(1.3);
  cursor: pointer;
  transition: transform .55s var(--ease), border-color .45s var(--ease), box-shadow .55s var(--ease);
}

@supports not ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
  .work { background: var(--bg-soft); }
}

.work:hover,
.work:focus-visible {
  transform: translateY(-5px);
  border-color: color-mix(in srgb, var(--accent) 48%, var(--stroke));
  box-shadow: var(--shadow);
}

.work:nth-child(1) { grid-column: span 4; }
.work:nth-child(2) { grid-column: span 2; }
.work:nth-child(3) { grid-column: span 2; }
.work:nth-child(4) { grid-column: span 4; }
.work:nth-child(5) { grid-column: span 3; }
.work:nth-child(6) { grid-column: span 3; }

/* 海报区：纯 CSS 渐变（不请求任何图片） */
.work-poster {
  position: relative;
  flex: 1;
  min-height: clamp(200px, 25vw, 330px);
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(95% 95% at 18% 12%, hsl(calc(210 + var(--i) * 26) 78% 60% / .52), transparent 62%),
    radial-gradient(85% 105% at 86% 88%, hsl(calc(276 + var(--i) * 17) 74% 55% / .46), transparent 64%),
    linear-gradient(156deg, hsl(calc(226 + var(--i) * 21) 34% 17%), hsl(calc(256 + var(--i) * 15) 40% 7%));
}

.work-poster::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, .52));
}

/* 真实视频预览帧（本地 webp，懒加载；渐变底作为加载前的占位） */
.work-thumb {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .9s var(--ease);
}

.work:hover .work-thumb,
.work:focus-visible .work-thumb { transform: scale(1.045); }

.work-sheen {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 255, 255, .16) 50%, transparent 62%);
  transform: translateX(-120%);
  transition: transform 1.05s var(--ease);
  pointer-events: none;
}

.work:hover .work-sheen { transform: translateX(120%); }

.work-num {
  position: absolute;
  right: 16px;
  bottom: 4px;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: clamp(52px, 6.4vw, 88px);
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, .22);
  opacity: .95;
  user-select: none;
}

/* 支持描边的浏览器用空心大字，老环境回退为半透明实心 */
@supports (-webkit-text-stroke: 1px rgba(255, 255, 255, .3)) {
  .work-num {
    color: transparent;
    -webkit-text-stroke: 1px rgba(255, 255, 255, .3);
  }
}

.work-play {
  position: relative;
  z-index: 3;
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .34);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: transform .45s var(--ease), background-color .45s var(--ease);
}

.work-play::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .34);
  animation: pulse 2.8s var(--ease) infinite;
  pointer-events: none;
}

.work:hover .work-play,
.work:focus-visible .work-play {
  transform: scale(1.09);
  background: rgba(255, 255, 255, .24);
}

@keyframes pulse {
  0% { transform: scale(1); opacity: .85; }
  70% { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

.work-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px 16px;
  border-top: 1px solid var(--stroke-2);
}

.work-meta { min-width: 0; }

.work-title {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .04em;
}

.work-desc {
  margin-top: 2px;
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.work-tag {
  flex: none;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
}

.noscript-tip {
  max-width: 1180px;
  margin: 22px auto 0;
  color: var(--ink-2);
}

/* ---------- 播放器 ---------- */
.player {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 40px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .38s var(--ease), visibility .38s var(--ease);
}

.player.is-open { opacity: 1; visibility: visible; }

.player-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 58%, transparent);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  backdrop-filter: blur(24px) saturate(1.2);
}

@supports not ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
  .player-backdrop { background: color-mix(in srgb, var(--bg) 92%, transparent); }
}

.player-stage {
  position: relative;
  width: min(1080px, 94vw);
  /* 按视口高度收敛，横屏手机/矮窗口也能完整放下播放器 */
  width: min(1080px, 94vw, calc((100svh - 208px) * 16 / 9));
  padding: 14px;
  display: grid;
  gap: 12px;
  border-radius: 26px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(26px) saturate(1.4);
  backdrop-filter: blur(26px) saturate(1.4);
  box-shadow: var(--shadow);
  transform: translateY(16px) scale(.985);
  transition: transform .5s var(--ease);
}

@supports not ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
  .player-stage { background: var(--bg-soft); }
}

.player.is-open .player-stage { transform: none; }

.player-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px 6px 0;
}

.player-index {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink-3);
  white-space: nowrap;
}

.player-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-close {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--glass-2);
  font-size: 13px;
  color: var(--ink-2);
  transition: color .3s var(--ease), border-color .3s var(--ease);
}

.player-close:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--stroke));
}

.player-frame {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16 / 9;
}

.player-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.player-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .38);
  opacity: 0;
  visibility: hidden;
  transition: opacity .28s var(--ease), visibility .28s var(--ease);
  pointer-events: none;
}

.player-loading.is-on { opacity: 1; visibility: visible; }

.player-loading span {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .22);
  border-top-color: #fff;
  animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.player-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
  padding: 0 6px 2px;
}

.player-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--glass-2);
  font-size: 13px;
  color: var(--ink-2);
  white-space: nowrap;
  transition: color .3s var(--ease), border-color .3s var(--ease), transform .3s var(--ease);
}

.player-nav:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--stroke));
  transform: translateY(-1px);
}

.player-desc {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 560px);
  padding: 12px 18px;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  color: var(--ink-2);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 16px);
  transition: opacity .38s var(--ease), transform .38s var(--ease), visibility .38s var(--ease);
}

@supports not ((-webkit-backdrop-filter: blur(4px)) or (backdrop-filter: blur(4px))) {
  .toast { background: var(--bg-soft); }
}

.toast.is-show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.toast-icon {
  flex: none;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
}

.toast-icon.is-err { background: #e05656; }
.toast-icon.is-ok { background: #2fae7d; }

/* ---------- 入场动画 ---------- */
.reveal-up {
  transition: opacity .85s var(--ease), transform .85s var(--ease);
  transition-delay: var(--d, 0ms);
}

.js-ready .reveal-up {
  opacity: 0;
  transform: translateY(22px);
}

.js-ready .reveal-up.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- 响应式 ---------- */

/* 平板：两列，首张与第四张通栏 */
@media (min-width: 641px) and (max-width: 1024px) {
  .bento { grid-template-columns: repeat(2, 1fr); }
  .work:nth-child(n) { grid-column: span 1; }
  .work:nth-child(1),
  .work:nth-child(4) { grid-column: span 2; }
  .work-poster { min-height: clamp(190px, 28vw, 280px); }
}

/* 手机：单列 + 紧凑导航 + 触屏与安全区适配 */
@media (max-width: 640px) {
  html { scroll-padding-top: 78px; }

  /* 顶部导航压缩 */
  .topnav { width: calc(100% - 16px); }
  .topnav-inner {
    padding: 7px 8px 7px 13px;
    gap: 6px;
  }
  .brand { font-size: 14px; letter-spacing: .05em; gap: 7px; }
  .brand svg { width: 15px; height: 15px; }
  .mode-btn { padding: 7px 11px; font-size: 12px; }

  /* 区块与卡片 */
  .section { padding-left: 16px; padding-right: 16px; }
  .section-head { margin-bottom: 30px; }
  .section-head h2 { font-size: clamp(26px, 8vw, 38px); }
  .bento { grid-template-columns: 1fr; gap: 14px; }
  .work:nth-child(n) { grid-column: auto; }
  .work-poster { flex: none; min-height: 0; aspect-ratio: 16 / 9; }
  .work-play { width: 56px; height: 56px; }
  .work-play::before { animation: none; opacity: .5; }
  .work-num { font-size: 46px; right: 12px; }
  .work-foot { padding: 13px 15px 14px; }
  .work-title { font-size: 17px; }

  /* 播放器：全宽、按视口高度收敛、底部按钮加大便于点按 */
  .player {
    padding: calc(8px + env(safe-area-inset-top, 0px)) 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .player-stage {
    width: min(100%, max(300px, calc((100svh - 176px) * 16 / 9)));
    padding: 10px;
    gap: 10px;
    border-radius: 20px;
  }
  .player-bar { gap: 10px; }
  .player-title { font-size: 15.5px; }
  .player-close { padding: 9px 15px; min-height: 40px; }
  .player-foot { flex-wrap: wrap; gap: 8px; }
  .player-nav { flex: 1; justify-content: center; min-height: 42px; padding: 9px 12px; }
  .player-desc { order: 3; flex-basis: 100%; text-align: center; }

  .toast { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); font-size: 13.5px; }

  /* 减负：缩小极光、弱化颗粒、卡片不做实时模糊 */
  .aurora i {
    width: 64vmax;
    height: 64vmax;
    filter: blur(52px);
    opacity: .26;
  }
  [data-theme="dark"] .aurora i { opacity: .4; }
  .grain { opacity: .24; background-size: 120px 120px; }
  [data-theme="dark"] .grain { opacity: .32; }
  .work {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* 触屏设备：去掉悬停位移，改按压反馈 */
@media (hover: none) {
  .work:hover,
  .work:focus-visible {
    transform: none;
    border-color: var(--stroke);
    box-shadow: none;
  }
  .work:hover .work-sheen,
  .work:focus-visible .work-sheen { transform: translateX(-120%); }
  .work:hover .work-play,
  .work:focus-visible .work-play {
    transform: none;
    background: rgba(255, 255, 255, .14);
  }
  .work:hover .work-thumb,
  .work:focus-visible .work-thumb { transform: none; }
  .work:active { transform: scale(.985); }
  .work:active .work-thumb { transform: scale(1.03); }
  .work:active .work-play {
    transform: scale(1.05);
    background: rgba(255, 255, 255, .22);
  }
  .mode-btn:active,
  .player-nav:active,
  .player-close:active { transform: scale(.97); }
}

/* ---------- 减弱动态效果 ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }

  .js-ready .reveal-up { opacity: 1; transform: none; }
  .aurora i { animation: none; }
}
