/* =========================================================
   HNYZ · 个性化层
   ---------------------------------------------------------
   这一层不改动 style.css 的结构，只做三件事：
   1. 深色主题下组件级的覆盖（变量本身在 style.css，那边是所有页面的基础层）
   2. 动效：滚动渐显、卡片倾斜、首屏光晕、数字滚动
   3. 彩蛋：主题按钮、打字机标语、终端提示条、黑客模式

   所有动效都尊重 prefers-reduced-motion。
   ========================================================= */

/* ---------- 1. 深色主题变量 ---------- */

[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse 70% 42% at 50% -12%, rgba(91, 147, 255, 0.16), transparent 65%),
    linear-gradient(rgba(91, 147, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 147, 255, 0.045) 1px, transparent 1px);
}

/* 半透明白底的组件在深色下换成深面 */
[data-theme="dark"] .site-header {
  background: rgba(7, 15, 30, 0.86);
}

[data-theme="dark"] .site-header.is-scrolled {
  background: rgba(6, 13, 26, 0.94);
}

/* 关键修复：.section--soft 在 style.css 里是硬编码的浅蓝，
   深色模式下会变成一块灰白板，白字压在上面几乎看不清 */
[data-theme="dark"] .section--soft {
  background: rgba(9, 20, 38, 0.72);
}

[data-theme="dark"] .site-footer {
  background: rgba(8, 17, 33, 0.82);
}

[data-theme="dark"] .join-qr {
  background: var(--panel-2);
}

[data-theme="dark"] .skip-link {
  background: var(--panel);
}

[data-theme="dark"] .quick-card,
[data-theme="dark"] .do-card,
[data-theme="dark"] .agenda-card,
[data-theme="dark"] .wall-card,
[data-theme="dark"] .join-contact,
[data-theme="dark"] .member-profile {
  background: linear-gradient(180deg, #10203c 0%, #0b172c 100%);
}

[data-theme="dark"] .cover-tag,
[data-theme="dark"] .cover-badge {
  background: rgba(8, 18, 36, 0.82);
  color: var(--muted);
}

[data-theme="dark"] .member-chibi {
  background: var(--panel-2);
}

/* 次要按钮、联系卡标题栏、占位封面这类硬编码的浅底 */
[data-theme="dark"] .button--secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-soft);
}

[data-theme="dark"] .button--secondary:hover {
  background: var(--blue-soft);
}

[data-theme="dark"] .quick-path {
  background: rgba(16, 33, 64, 0.72);
}

[data-theme="dark"] .cover-placeholder {
  background:
    radial-gradient(circle at 78% 24%, rgba(91, 147, 255, 0.26), transparent 44%),
    radial-gradient(circle at 12% 88%, rgba(56, 189, 248, 0.16), transparent 44%),
    linear-gradient(135deg, #0d1c34 0%, #132a4c 52%, #0a1729 100%);
}

[data-theme="dark"] .cover-placeholder::before {
  background-image:
    linear-gradient(rgba(91, 147, 255, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 147, 255, 0.16) 1px, transparent 1px);
}

/* 校徽底板在深色下收暗，避免一块死白 */
[data-theme="dark"] .hnyz-pet__board {
  border-color: rgba(91, 147, 255, 0.45);
  background: radial-gradient(circle at 50% 38%, #1a2f52 0%, #12233f 52%, #0b172c 100%);
  box-shadow: 0 0 0 1px rgba(91, 147, 255, 0.18), 0 14px 32px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .hnyz-pet__badge,
[data-theme="dark"] .avatar-pet__img {
  opacity: 0.92;
}

[data-theme="dark"] .hnyz-pet__speech,
[data-theme="dark"] .hnyz-avatar__speech {
  background: rgba(11, 23, 44, 0.96);
  border-color: rgba(91, 147, 255, 0.55);
}

[data-theme="dark"] .hnyz-avatar__name {
  background: rgba(11, 23, 44, 0.9);
  border-color: rgba(91, 147, 255, 0.5);
}

[data-theme="dark"] img {
  /* 浅底插画在深色下略微压暗，避免刺眼 */
  filter: brightness(0.94) contrast(1.02);
}

[data-theme="dark"] .hnyz-pet__badge,
[data-theme="dark"] .hnyz-avatar__img,
[data-theme="dark"] .join-qr__img {
  filter: none;
}

/* ---------- 2. 主题切换按钮 ---------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* 让导航和操作区一起靠右，品牌留在左侧 */
.site-nav {
  margin-left: auto;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.35s ease,
    box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
  color: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
  transform: rotate(18deg);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.theme-toggle__icon {
  width: 17px;
  height: 17px;
}

/* 月亮 / 太阳雪碧图：显示 18px，源图每帧 54px，留 3 倍余量给高分屏 */
.theme-toggle__flip {
  display: block;
  width: 18px;
  height: 18px;
  background-image: url("../assets/moon-sun-sprite.png");
  background-repeat: no-repeat;
  background-position: 0 0;
  background-size: 1080px 18px;
  pointer-events: none;
}

html[data-style="minimal"] .theme-toggle__flip {
  filter: grayscale(1) contrast(1.1);
}

html[data-style="hacker"] .theme-toggle__flip {
  /* 蓝色 210° 转到荧光绿 120°，顺时针退回 90° */
  filter: hue-rotate(-90deg) saturate(1.45) brightness(1.06);
}

/* ---------- 2.5 主题切换：从按钮长出的圆 ---------- */
/* View Transitions 默认会交叉淡入淡出，这里关掉，只保留新界面的圆形遮罩。
   快照层要按视口尺寸铺满：浏览器默认会拿快照尺寸和容器尺寸对比，
   差一点点就把整页做一次等比缩放——看起来就是「切换时页面缩一下」。 */
::view-transition-group(root) {
  animation: none;
}

::view-transition-old(root) {
  animation: none;
  z-index: 1;
  mix-blend-mode: normal;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

::view-transition-new(root) {
  animation: none;
  z-index: 2;
  mix-blend-mode: normal;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

::view-transition-image-pair(root) {
  isolation: auto;
  width: 100%;
  height: 100%;
}

/* 转场的一瞬间先暂停持续动画和鼠标光晕，圆推得更顺 */
html.is-theme-swap .bg-icon,
html.is-theme-swap .bg-orbs__orb,
html.is-theme-swap .hnyz-ticker__track,
html.is-theme-swap .hnyz-sticker,
html.is-theme-swap .char-slot {
  animation-play-state: paused !important;
}

html.is-theme-swap .hynz-glow,
html.is-theme-swap .hnyz-glow {
  opacity: 0 !important;
  transition: none !important;
}

/* 图标切换：按钮只轻轻一收一放，光晕代替以前的放射线 */
.theme-toggle {
  position: relative;
}

.theme-toggle.is-switching {
  animation: themeBtnPop 0.34s cubic-bezier(0.22, 0.9, 0.28, 1);
  box-shadow:
    0 0 0 1px var(--blue),
    0 0 0 7px var(--blue-soft);
}

@keyframes themeBtnPop {
  0% { scale: 1; }
  32% { scale: 1.04; }
  100% { scale: 1; }
}

.theme-toggle.is-switching .theme-toggle__flip {
  animation: themeFlipPop 0.44s cubic-bezier(0.22, 0.9, 0.28, 1);
}

@keyframes themeFlipPop {
  0% { scale: 1; }
  46% { scale: 0.88; }
  100% { scale: 1; }
}

.theme-toggle__icon--moon,
[data-theme="dark"] .theme-toggle__icon--sun {
  display: none;
}

[data-theme="dark"] .theme-toggle__icon--moon {
  display: block;
}

/* ---------- 3. 滚动渐显 ---------- */
html.reveal-ready [data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s cubic-bezier(0.22, 0.61, 0.36, 1),
    transform 0.7s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: opacity, transform;
}

html.reveal-ready [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
  will-change: auto;
}

/* 卡片只做淡入，避免和 3D 倾斜的 transform 打架 */
html.reveal-ready .project-card[data-reveal] {
  transform: none;
}

/* ---------- 4. 项目卡片 3D 倾斜 ---------- */
.project-card.is-tilting {
  transition: transform 0.08s linear, border-color 0.3s ease, box-shadow 0.3s ease;
  transform-style: preserve-3d;
}

.project-card.is-tilting .project-cover {
  transform: translateZ(14px);
}

/* ---------- 5. 全站光标光晕 ---------- */
/* 一层覆盖整个视口的柔光，跟随鼠标移动；用 blend 模式让它在
   浅色下像投影灯、深色下像手电筒，而不是一块灰色蒙版 */
.hnyz-glow {
  position: fixed;
  left: 0;
  top: 0;
  /* 固定大小 + transform 平移：不用每帧重绘整屏渐变 */
  width: 900px;
  height: 900px;
  margin: -450px 0 0 -450px;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.55s ease;
  background: radial-gradient(
    circle closest-side,
    rgba(37, 99, 235, 0.2),
    transparent 66%
  );
  mix-blend-mode: multiply;
  transform: translate3d(-2000px, -2000px, 0);
  will-change: transform;
}

.hnyz-glow.is-on {
  opacity: 1;
}

[data-theme="dark"] .hnyz-glow {
  background: radial-gradient(
    circle closest-side,
    rgba(131, 176, 255, 0.26),
    transparent 66%
  );
  mix-blend-mode: screen;
}

/* ---------- 6. 打字机标语 ---------- */
.hero-rotator {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 1.9em;
  margin: 18px 0 0;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.01em;
}

.hero-rotator__prompt {
  color: var(--muted);
  opacity: 0.8;
}

.hero-rotator__caret {
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 1px;
  background: var(--blue);
  transform: translateY(2px);
  animation: hnyzCaret 1.05s steps(1, end) infinite;
}

@keyframes hnyzCaret {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

/* ---------- 7. 终端风格提示条 ---------- */
.hnyz-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 32px); /* fallback: 旧内核 */
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--blue);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-card);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.5;
  transform: translate(-50%, 18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

.hnyz-toast__prompt {
  color: var(--blue);
  font-weight: 700;
}

.hnyz-toast[data-tone="green"] {
  border-left-color: var(--green);
}

.hnyz-toast[data-tone="green"] .hnyz-toast__prompt {
  color: var(--green);
}

/* ---------- 8. 黑客模式 ---------- */
html[data-hacker="true"] {
  --blue: #22c55e;
  --blue-bright: #4ade80;
  --green: #f59e0b;
  --green-bright: #fbbf24;
  --blue-soft: rgba(34, 197, 94, 0.14);
  --green-soft: rgba(245, 158, 11, 0.14);
}

.hnyz-scanlines {
  position: fixed;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  z-index: 80;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(34, 197, 94, 0.09) 0px,
    rgba(34, 197, 94, 0.09) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hnyz-scanlines.is-on {
  opacity: 1;
}

/* 连点 Logo 的反馈 */
.brand.is-poked .brand-mark {
  animation: hnyzBrandPulse 0.6s ease;
}

@keyframes hnyzBrandPulse {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.18) rotate(-6deg);
    box-shadow: 0 0 0 6px var(--blue-soft);
  }
  100% {
    transform: scale(1);
  }
}

/* ---------- 9. 页脚访问次数 ---------- */
.footer-visits {
  display: block;
  margin-top: 6px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.66rem;
  opacity: 0.85;
}

/* ---------- 10. 减弱动效 ---------- */
@media (prefers-reduced-motion: reduce) {
  html.reveal-ready [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero-rotator__caret {
    animation: none;
  }

  .theme-toggle:hover {
    transform: none;
  }

  .hnyz-toast {
    transition: none;
  }
}

/* ---------- 11. 小屏适配 ---------- */
@media (max-width: 900px) {
  [data-theme="dark"] .site-nav {
    background: var(--panel);
    border-color: var(--border);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  }

  .theme-toggle {
    width: 32px;
    height: 32px;
  }

  .header-actions {
    gap: 8px;
  }
}

@media (max-width: 520px) {
  .hero-rotator {
    font-size: 0.78rem;
  }

  .hnyz-toast {
    bottom: 14px;
    font-size: 0.72rem;
  }
}

/* =========================================================
   12. 跑马灯（首屏下方的技术关键词带）
   ========================================================= */
.hnyz-ticker {
  position: relative;
  overflow: hidden;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.hnyz-ticker::before,
.hnyz-ticker::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 64px;
  z-index: 1;
  pointer-events: none;
}

.hnyz-ticker::before {
  left: 0;
  background: linear-gradient(90deg, var(--panel-2), transparent);
}

.hnyz-ticker::after {
  right: 0;
  background: linear-gradient(270deg, var(--panel-2), transparent);
}

.hnyz-ticker__track {
  display: flex;
  width: max-content;
  animation: hnyzTicker 34s linear infinite;
}

.hnyz-ticker:hover .hnyz-ticker__track {
  animation-play-state: paused;
}

.hnyz-ticker__group {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.hnyz-ticker__item {
  display: inline-flex;
  align-items: center;
  gap: 26px;
  padding-right: 26px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
}

.hnyz-ticker__item::after {
  content: "◆";
  color: var(--blue);
  font-size: 0.55rem;
  opacity: 0.55;
}

@keyframes hnyzTicker {
  from { transform: translateX(0); }
  to { transform: translateX(var(--shift, -50%)); }
}

/* =========================================================
   13. 手账感：胶带、便签、倾斜卡片
   ========================================================= */
.do-card {
  position: relative;
  overflow: visible;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

/* 卡片顶部的小胶带 */
.do-card::after {
  content: "";
  position: absolute;
  top: -9px;
  left: 24px;
  width: 62px;
  height: 18px;
  background: repeating-linear-gradient(
    90deg,
    rgba(37, 99, 235, 0.16) 0 6px,
    rgba(37, 99, 235, 0.09) 6px 12px
  );
  border-left: 1px dashed rgba(37, 99, 235, 0.32);
  border-right: 1px dashed rgba(37, 99, 235, 0.32);
  transform: rotate(-3.5deg);
  pointer-events: none;
}

.wall-card {
  position: relative;
}

.wall-card::before {
  content: "";
  position: absolute;
  top: -8px;
  right: 26px;
  width: 54px;
  height: 16px;
  background: repeating-linear-gradient(
    90deg,
    rgba(14, 165, 233, 0.2) 0 6px,
    rgba(14, 165, 233, 0.1) 6px 12px
  );
  transform: rotate(4deg);
  pointer-events: none;
}

@media (min-width: 901px) {
  /* 卡片轻微歪一点，hover 时摆正，像贴在墙上的手写卡片 */
  .do-card:nth-child(4n + 1) { transform: rotate(-0.8deg); }
  .do-card:nth-child(4n + 2) { transform: rotate(0.7deg); }
  .do-card:nth-child(4n + 3) { transform: rotate(0.5deg); }
  .do-card:nth-child(4n + 4) { transform: rotate(-0.6deg); }

  .do-card:hover {
    transform: rotate(0deg) translateY(-4px);
    box-shadow: var(--glow-blue);
  }

  .wall-card:nth-child(odd) { transform: rotate(-0.6deg); }
  .wall-card:nth-child(even) { transform: rotate(0.5deg); }

  .wall-card:hover {
    transform: rotate(0deg) translateY(-3px);
  }
}

/* 引言改成一张便签 */
.about-quote {
  transform: rotate(-0.8deg);
  box-shadow: 5px 6px 0 rgba(37, 99, 235, 0.07);
}

[data-theme="dark"] .about-quote {
  box-shadow: 5px 6px 0 rgba(91, 147, 255, 0.08);
}

/* 主按钮做出一点实体厚度 */
.button--primary {
  box-shadow: 0 4px 0 rgba(29, 78, 216, 0.55);
}

.button--primary:hover {
  box-shadow: 0 5px 0 rgba(29, 78, 216, 0.6);
  transform: translateY(-1px);
}

.button--primary:active {
  box-shadow: 0 2px 0 rgba(29, 78, 216, 0.55);
  transform: translateY(2px);
}

/* =========================================================
   14. 首屏关键词贴纸
   ========================================================= */
.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--blue);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 0 rgba(37, 99, 235, 0.08);
}

.hero-tag:nth-child(1) { rotate: -2deg; }
.hero-tag:nth-child(2) { rotate: 1.5deg; }
.hero-tag:nth-child(3) { rotate: -1deg; }
.hero-tag:nth-child(4) { rotate: 2deg; }

/* =========================================================
   15. 个人页贴纸墙
   ========================================================= */
.member-profile__sprites {
  display: grid;
  grid-template-columns: repeat(3, 88px);
  gap: 0;
  align-items: end;
  margin-right: 6px;
}

.member-chibi {
  width: 100px;
  height: 92px;
  border-radius: 0;
  background: transparent;
  object-fit: contain;
  box-shadow: none;
  transform: none;
  filter: drop-shadow(0 8px 12px rgba(30, 64, 175, 0.2));
  animation: hnyzStickerFloat 4.4s ease-in-out infinite;
}

.member-chibi--a { --sticker-rot: -7deg; animation-delay: 0s; }
.member-chibi--b { --sticker-rot: 6deg; animation-delay: -1.1s; }
.member-chibi--c { --sticker-rot: 4deg; animation-delay: -2.2s; }
.member-chibi--d { --sticker-rot: -5deg; animation-delay: -3.3s; }

.member-chibi {
  rotate: var(--sticker-rot, 0deg);
}

@keyframes hnyzStickerFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* =========================================================
   16. 小屏：关掉倾斜和贴纸，避免晃动与占位
   ========================================================= */
@media (max-width: 900px) {
  .hnyz-glow {
    display: none;
  }

  .do-card,
  .wall-card,
  .about-quote {
    transform: none;
    box-shadow: none;
  }

  .do-card::after,
  .wall-card::before {
    display: none;
  }

}

@media (max-width: 720px) {
  /* 横幅改成竖排：文字在上，贴纸一行四张在下 */
  .member-profile {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .member-profile__sprites {
    grid-template-columns: repeat(3, 72px);
    gap: 0;
    margin: 2px 0 0;
  }

  .member-chibi {
    width: 72px;
    height: 66px;
  }
}

@media (max-width: 520px) {
  .hnyz-ticker__item {
    font-size: 0.64rem;
    letter-spacing: 0.14em;
  }

  .hero-tags {
    gap: 6px;
  }

  .hero-tag {
    font-size: 0.62rem;
    padding: 4px 9px;
  }

}

/* 减少动效时停掉跑马灯和贴纸浮动 */
@media (prefers-reduced-motion: reduce) {
  .hnyz-ticker__track {
    animation: none;
  }

  .member-chibi {
    animation: none;
  }

  .hnyz-glow {
    display: none;
  }
}

/* =========================================================
   17. 更丰富的背景层
   ---------------------------------------------------------
   - body 上多两层柔光 + 一层点阵，比纯网格更有层次
   - .bg-orbs 是 fixed 的三团模糊光斑，缓慢漂移
   - main / footer 抬到 z-index 1，保证内容在光斑之上
   ========================================================= */
body {
  background-image:
    radial-gradient(ellipse 58% 38% at 88% 6%, rgba(56, 189, 248, 0.1), transparent 62%),
    radial-gradient(ellipse 52% 36% at 4% 72%, rgba(37, 99, 235, 0.09), transparent 66%),
    radial-gradient(ellipse 70% 42% at 50% -12%, rgba(37, 99, 235, 0.12), transparent 65%),
    linear-gradient(rgba(37, 99, 235, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.035) 1px, transparent 1px);
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(ellipse 58% 38% at 88% 6%, rgba(56, 189, 248, 0.14), transparent 62%),
    radial-gradient(ellipse 52% 36% at 4% 72%, rgba(91, 147, 255, 0.12), transparent 66%),
    radial-gradient(ellipse 70% 42% at 50% -12%, rgba(91, 147, 255, 0.16), transparent 65%),
    linear-gradient(rgba(91, 147, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 147, 255, 0.05) 1px, transparent 1px);
}

.bg-orbs {
  position: fixed;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-orbs__orb {
  position: absolute;
  border-radius: 50%;
  /* 径向渐变本身就是柔边，不用 filter: blur——
     大尺寸模糊层在部分 GPU 上会出现棋盘格伪影 */
}

.bg-orbs__orb--a {
  top: -180px;
  right: -140px;
  width: 560px;
  height: 560px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.3), transparent 68%);
}

.bg-orbs__orb--b {
  bottom: -240px;
  left: -200px;
  width: 640px;
  height: 640px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.26), transparent 70%);
}

.bg-orbs__orb--c {
  top: 36%;
  left: 54%;
  width: 440px;
  height: 440px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.16), transparent 70%);
}

.bg-orbs__dots {
  position: absolute;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  background-image: radial-gradient(rgba(37, 99, 235, 0.18) 1px, transparent 1.2px);
  background-size: 26px 26px;
  opacity: 0.45;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 72%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 72%);
}

[data-theme="dark"] .bg-orbs__orb--a {
  background: radial-gradient(circle, rgba(56, 189, 248, 0.28), transparent 68%);
}

[data-theme="dark"] .bg-orbs__orb--b {
  background: radial-gradient(circle, rgba(91, 147, 255, 0.24), transparent 70%);
}

[data-theme="dark"] .bg-orbs__dots {
  background-image: radial-gradient(rgba(147, 197, 253, 0.2) 1px, transparent 1.2px);
  opacity: 0.35;
}

main,
.site-footer {
  position: relative;
  z-index: 1;
}

/* =========================================================
   18. 图集
   ========================================================= */
.gallery-board {
  position: relative;
  margin-top: 28px;
  padding: 26px 24px 24px;
  overflow: hidden;
  border: 1px solid rgba(91, 147, 255, 0.3);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 86% 4%, rgba(37, 99, 235, 0.32), transparent 44%),
    linear-gradient(158deg, #0a1a31 0%, #102746 58%, #081426 100%);
  box-shadow: 0 24px 60px rgba(12, 30, 60, 0.28);
}

.gallery-board::before {
  content: "";
  position: absolute;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  background-image:
    linear-gradient(rgba(147, 197, 253, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(147, 197, 253, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

.gallery-grid {
  position: relative;
  /* 瀑布流：梗图长宽比差异很大，用列布局让每张按原比例显示 */
  column-count: 4;
  column-gap: 20px;
}

.gallery-item {
  margin: 0 0 20px;
  padding: 9px 9px 6px;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(3, 10, 22, 0.4);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1),
    box-shadow 0.3s ease;
}

.gallery-item:hover,
.gallery-item:focus-within {
  transform: rotate(0deg) translateY(-6px);
  box-shadow: 0 20px 38px rgba(3, 10, 22, 0.5);
}

.gallery-item__button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.gallery-item__button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--ratio, 4 / 5);
  /* 壁纸是 4:5 铺满，梗图是透明底的贴纸，用 contain 留白更自然 */
  object-fit: contain;
  background: #f5f9ff;
}

.gallery-item__caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 2px 4px;
  color: #2b466c;
  font-family: var(--mono);
  font-size: 0.62rem;
}

.gallery-item__title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-item__tag {
  flex-shrink: 0;
  color: #2563eb;
}

.gallery-empty {
  grid-column: 1 / -1;
  margin: 0;
  color: #93aac9;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.gallery-note {
  margin-top: 14px;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 0.68rem;
}

.gallery-note code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--panel-2);
  color: var(--text-soft);
}

/* ---------- 灯箱 ---------- */
.hnyz-lightbox {
  position: fixed;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  z-index: 120;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 46px 28px;
  background: rgba(3, 9, 18, 0.88);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.hnyz-lightbox[hidden] {
  display: none;
}

.lightbox-figure {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin: 0;
  min-width: 0;
}

.lightbox-image {
  max-width: 100%;
  max-height: 74vh;
  border-radius: 6px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  object-fit: contain;
}

.lightbox-caption {
  color: #cfe2ff;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.lightbox-close {
  position: fixed;
  top: 18px;
  right: 22px;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  border-radius: 50%;
  background: rgba(9, 20, 38, 0.8);
  color: #dbeafe;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.lightbox-nav {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(147, 197, 253, 0.35);
  border-radius: 50%;
  background: rgba(9, 20, 38, 0.8);
  color: #dbeafe;
  font-size: 17px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  border-color: rgba(147, 197, 253, 0.75);
  background: rgba(37, 99, 235, 0.45);
}

.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
  outline: 2px solid #93c5fd;
  outline-offset: 3px;
}

body.is-lightbox-open {
  overflow: hidden;
}

/* =========================================================
   19. 图集/背景的小屏与减少动效
   ========================================================= */
@media (max-width: 900px) {
  .gallery-board {
    padding: 18px 14px 16px;
  }

  .gallery-grid {
    column-count: 2;
    column-gap: 14px;
  }

  .gallery-item {
    margin-bottom: 14px;
  }

  .gallery-item {
    transform: none;
    padding: 7px 7px 4px;
  }

  .gallery-item:hover {
    transform: translateY(-3px);
  }

  .hnyz-lightbox {
    grid-template-columns: 1fr;
    padding: 56px 16px 16px;
  }

  .lightbox-nav {
    position: fixed;
    bottom: 18px;
    width: 46px;
    height: 46px;
  }

  .lightbox-nav--prev { left: 18px; }
  .lightbox-nav--next { right: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-item {
    transition: none;
  }
}

/* =========================================================
   20. 图集页：筛选条与首页入口
   ========================================================= */
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 20px;
}

.gallery-filter {
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.68rem;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.gallery-filter:hover {
  color: var(--blue);
  border-color: var(--blue);
}

.gallery-filter.is-active {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.gallery-filter:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* 首页资源墙下的细条入口 */
.gallery-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding: 12px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text-soft);
  font-family: var(--mono);
  font-size: 0.74rem;
  text-decoration: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.gallery-entry:hover {
  border-color: var(--blue);
  box-shadow: var(--glow-blue);
  transform: translateY(-2px);
}

.gallery-entry__index {
  color: var(--blue);
  font-size: 0.7rem;
}

.gallery-entry__label {
  color: var(--text);
  font-weight: 700;
}

.gallery-entry__desc {
  flex: 1;
  min-width: 0;
  color: var(--dim);
  font-size: 0.68rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-entry__arrow {
  color: var(--blue);
}

@media (max-width: 520px) {
  .gallery-entry__desc {
    display: none;
  }
}

/* =========================================================
   21. 背景图标阵列（校徽 / Arduino / token，灰度小图标）
   ========================================================= */
.bg-icons {
  position: fixed;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-icon {
  position: absolute;
  width: var(--s, 34px);
  height: var(--s, 34px);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0;
  transform: rotate(var(--rot, 0deg));
  /* 像气泡一样持续往上飘：淡入 → 上升 → 淡出 → 从原点重来 */
  animation: bgIconRise var(--dur, 18s) linear var(--delay, 0s) infinite;
}

[data-theme="dark"] .bg-icon {
  /* 灰度图标在深色背景上反过来才看得见 */
  filter: invert(1);
  opacity: calc(var(--o, 0.06) * 0.9);
}

@keyframes bgIconRise {
  0% {
    transform: translate3d(0, 0, 0) rotate(var(--rot, 0deg)) scale(0.92);
    opacity: 0;
  }
  12% {
    opacity: var(--o, 0.15);
  }
  78% {
    opacity: var(--o, 0.15);
  }
  100% {
    transform: translate3d(var(--dx, 18px), -260px, 0) rotate(calc(var(--rot, 0deg) + 12deg)) scale(1.06);
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .bg-icons {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-icon {
    animation: none;
  }
}

/* 页面最下方的图集入口 */
.gallery-entry-row {
  padding: 0 0 56px;
}

.gallery-entry-row .gallery-entry {
  margin-top: 0;
}

@media (max-width: 520px) {
  .gallery-entry-row {
    padding-bottom: 40px;
  }
}

/* =========================================================
   22. 开屏
   ---------------------------------------------------------
   盖住首帧，等脚本把页面定位到「关于」后再淡出，
   避免看到滑动过程。
   ========================================================= */
.boot {
  position: fixed;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 70% 50% at 50% 28%, rgba(37, 99, 235, 0.14), transparent 62%),
    var(--bg);
  transition: opacity 0.45s ease;
}

.boot.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.boot__inner {
  display: grid;
  justify-items: center;
  gap: 10px;
  animation: bootIn 0.55s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

.boot__mark {
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: 0.12em;
  color: var(--blue);
}

.boot__brand {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--text);
}

.boot__line {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

@keyframes bootIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .boot,
  .boot__inner {
    animation: none;
    transition: none;
  }
}

/* =========================================================
   音效开关（头部，和主题按钮同尺寸）
   ========================================================= */
.sound-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.sound-toggle:hover {
  color: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-soft);
}

.sound-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.sound-toggle__icon {
  width: 18px;
  height: 18px;
}

.sound-toggle__icon--off {
  display: none;
}

.sound-toggle.is-muted .sound-toggle__icon--on {
  display: none;
}

.sound-toggle.is-muted .sound-toggle__icon--off {
  display: block;
}

.sound-toggle.is-muted {
  color: var(--dim);
}

@media (max-width: 900px) {
  .sound-toggle {
    width: 32px;
    height: 32px;
  }

  .sound-toggle__icon {
    width: 17px;
    height: 17px;
  }
}

/* ---------- 点击反馈 ---------- */
.click-fx {
  position: fixed;
  top: 0; /* fallback: 旧内核 */
  right: 0; /* fallback: 旧内核 */
  bottom: 0; /* fallback: 旧内核 */
  left: 0; /* fallback: 旧内核 */
  inset: 0;
  z-index: 9990;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* 按下时整体缩一点，给手指一个“按到了”的反馈 */
.button:active,
.nav-cta:active,
.theme-toggle:active,
.sound-toggle:active,
.filter-chip:active,
.copy-btn:active {
  scale: 0.96;
}

/* ---------- 导航下划线滑入 ---------- */
.nav-list a {
  position: relative;
}

.nav-list a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -4px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
  pointer-events: none;
}

.nav-list a:hover::after,
.nav-list a:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left center;
}

@media (max-width: 900px) {
  .nav-list a::after {
    bottom: 6px;
  }
}
