/* 辉煌难铸主页：整屏卡片墙，卡片统一做成逆时针斜切的平行四边形并无缝密排。几何参数集中在 :root。 */
:root {
  --home-bg: #16161a;
  --home-ink: #f2f4f7;
  --home-accent: #4d7cff;

  /* 7 列 × 4 排 = 28 张，全部同尺寸。缩放与居中由 JS 的 fitWall() 按屏幕包围盒写入。 */
  --card-width: clamp(180px, 17vw, 300px);
  /* 卡片加宽：宽高比约 1.6:1。墙的缩放受高度限制，压低卡高、保持卡宽，左右两侧才会铺开。 */
  --card-height: calc(var(--card-width) * 0.62);

  /* 卡片裁成平行四边形：整片网格做 skewX，卡片随之变成平行四边形。
   * 取正值才是逆时针的观感（skewX 正角把上边缘向左推），与「逆时针 20 度」一致。 */
  --card-skew: 20deg;
  /* 平行四边形只是裁切外框：斜边水平收进量 = 卡高 × tan(skew)。图片与文字保持正向、不跟着斜。 */
  --card-slant: calc(var(--card-height) * 0.364);
  --card-gap: calc(var(--card-width) * 0.05);
  /* 相邻平行四边形的斜边互相咬合，所以列距比卡宽小一个 slant。 */
  --col-pitch: calc(var(--card-width) - var(--card-slant) + var(--card-gap));
  --row-pitch: calc(var(--card-height) + var(--card-gap) * 0.7);

  /* 为什么把 skew 加在整片网格而不是每张卡片上：
   * 平行四边形密铺平面的两组基向量是 (W, 0) 与 (H·tanθ, H)。
   * 对整片「宽 W、高 H 的矩形网格」施加这个剪切，正好把它映射成
   * 「边贴边的平行四边形网格」——变换是双双射的，所以缝隙与重叠同时为零，
   * 卡片也完全不用缩小。逐卡 skew 则会撑宽各自的包围盒、与邻卡压住。
   * 改角度只需改 --card-skew，铺法不用动。 */


  --card-radius: 12px;
  /* 标题占卡片 30% 的高度，居中显示 */
  --card-label-height: 30%;
  --card-font: calc(var(--card-width) * 0.185);

  --wall-scale: 1;
}

html,
body {
  height: 100%;
}

body.home-app {
  margin: 0;
  overflow: hidden;
  background: var(--home-bg);
  color: var(--home-ink);
  font-family: var(--maple-mono-cn-font);
  -webkit-font-smoothing: antialiased;
}

.home-stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* 卡片墙容器：墙本身正对屏幕 */
.home-wall-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.home-wall {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(7, var(--col-pitch));
  grid-template-rows: repeat(4, var(--row-pitch));
  transform-style: preserve-3d;
  /* 整片网格做 skewX：矩形网格被剪切成平行四边形网格，卡片随之变成平行四边形。
   * 剪切是双双射变换，所以相邻卡片精确边贴边——零缝隙、零重叠，卡片也不用缩小。
   * 缩放与居中位移由 home-wall.js 的 fitWall() 按实际屏幕包围盒写入，
   * 顺序上放在 skew 之前，保证缩放是各向同性的。 */
  transform:
    translate(-50%, -50%)
    translate(var(--wall-shift-x, 0px), var(--wall-shift-y, 0px))
    scale(var(--wall-scale, 1));
  will-change: transform;
}

/* ── 卡片 ───────────────────────────────────────────── */

/* 两层结构：
 * .home-card 外层只负责位置与动效（入场飞入、悬停放大、穿越放大），
 * .home-card-inner 内层负责把卡片裁成平行四边形并承担每行错位。
 * 这样 GSAP 写外层 transform 时不会把斜切冲掉。 */
.home-card {
  position: relative;
  width: var(--card-width);
  height: var(--card-height);
  transform-style: preserve-3d;
  will-change: transform, opacity;
}

.home-card.is-featured {
  cursor: pointer;
}

/* 入场动画结束后才启用过渡，否则会和 GSAP 的逐帧写入打架 */
.home-wall.is-interactive .home-card.is-featured {
  transition: transform 0.42s cubic-bezier(0.22, 0.8, 0.24, 1);
}

.home-card:not(.is-featured) {
  cursor: default;
}

/* fitWall() 量包围盒时短暂加上这个类：清掉外层卡片上的入场位移与悬停放大，
 * 让量到的是真实排布（内层的旋转不受影响）。必须在同一个同步任务里加、量、删，
 * 中间不会发生绘制，所以不会闪。 */
.home-wall.is-measuring .home-card {
  transform: none !important;
  transition: none !important;
}

/* 内层：圆角裁切与内容承载，并四周内缩一点留出细缝。
 * 缩进是唯一的视觉间隙来源——整片网格零缝隙，所以缝隙处处等宽。 */
.home-card-inner {
  position: absolute;
  inset: 1.25%;
  border-radius: var(--card-radius);
  background: #202027;
  overflow: hidden;
  transform-style: preserve-3d;
  will-change: transform;
  transition: box-shadow 0.42s ease;
}

.home-card-media {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
}

.home-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  /* 未加载完成前不占视觉，避免闪一下 */
  opacity: 0;
  transition: opacity 0.6s ease, filter 0.85s cubic-bezier(0.22, 0.7, 0.2, 1), transform 0.7s cubic-bezier(0.22, 0.7, 0.2, 1);
}

.home-card.is-loaded .home-card-media img {
  opacity: 1;
}

/* 卡片压暗层，用于“其余卡片渐暗成灰” */
.home-card-inner::after {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  background: var(--home-bg);
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.85s cubic-bezier(0.22, 0.7, 0.2, 1);
}

.home-card.is-dimmed .home-card-inner::after {
  opacity: 0.72;
}

.home-card.is-dimmed .home-card-media img {
  filter: grayscale(1) saturate(0) brightness(0.78) contrast(0.92);
}

/* ── 卡面标题：居中，占卡片 30% 高度，分三层做立体印刻 ── */

.home-card-label {
  position: absolute;
  top: 35%;
  left: 0;
  right: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  height: var(--card-label-height);
  pointer-events: none;
  transform-style: preserve-3d;
  /* 整片网格做了 skewX，卡片图与文字都会跟着斜。
   * 文字反向剪切抵消掉，让标题始终保持水平——斜的是卡片，不是字。 */
  transform: skewX(calc(var(--card-skew, 20deg) * -1));
}

/* 三层文字叠在同一个网格单元上。卡片有 overflow:hidden 会压平 3D，
 * 因此分层靠「缩放 + 偏移 + 模糊」做出前后纵深，而不是 translateZ。 */
.home-card-label > span {
  grid-area: 1 / 1;
  font-size: var(--card-font);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  line-height: 1;
  white-space: nowrap;
  will-change: transform, opacity, filter;
  transition: transform 0.42s cubic-bezier(0.22, 0.8, 0.24, 1), opacity 0.42s ease, filter 0.42s ease;
}

/* 最底层：贴在画面上的重影，负责“刻进卡片”的厚度 */
.home-card-label-shadow {
  color: rgba(4, 6, 12, 0.7);
  filter: blur(2.5px);
  transform: translate(2px, 4px) scale(1.06);
}

/* 中间层：偏冷的过渡层，悬浮时暴露出来 */
.home-card-label-mid {
  color: rgba(150, 186, 255, 0.45);
  filter: blur(0.6px);
  transform: translate(0.5px, 1px) scale(1.02);
}

/* 最上层：正面的字 */
.home-card-label-face {
  color: #ffffff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  transform: translate(0, 0) scale(1);
}

/* 标题背后的柔光，保证任何底图上都读得清 */
.home-card-label::before {
  position: absolute;
  inset: -30% -8%;
  z-index: -1;
  background: radial-gradient(ellipse at center, rgba(6, 8, 14, 0.5), rgba(6, 8, 14, 0.18) 52%, transparent 72%);
  content: "";
  pointer-events: none;
}

/* 卡片变暗时文字同步变暗 */
.home-card.is-dimmed .home-card-label-shadow,
.home-card.is-dimmed .home-card-label-mid,
.home-card.is-dimmed .home-card-label-face {
  opacity: 0.3;
}

/* ── 四张可访问卡片 ─────────────────────────────────── */

.home-card.is-featured {
  cursor: pointer;
}

/* 外层光晕画在内层卡片上：卡片的 overflow:hidden 会裁掉子元素的 box-shadow。 */
.home-card.is-lit .home-card-inner {
  box-shadow:
    0 0 0 1px rgba(126, 164, 255, 0.75),
    0 0 26px 4px rgba(77, 124, 255, 0.62),
    0 0 62px 14px rgba(77, 124, 255, 0.34),
    0 20px 46px rgba(0, 0, 0, 0.55);
}

/* 内描边与内侧辉光，叠出“被蓝光包住”的层次 */
.home-card-inner::before {
  position: absolute;
  inset: 0;
  z-index: 4;
  border: 2px solid #8fb4ff;
  border-radius: inherit;
  box-shadow:
    inset 0 0 22px rgba(143, 180, 255, 0.55),
    inset 0 0 4px rgba(220, 234, 255, 0.85);
  content: "";
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease, box-shadow 0.4s ease;
}

.home-card.is-featured.is-lit .home-card-inner::before {
  opacity: 1;
}

/* 入场结束后闪烁两下 */
.home-card.is-featured.is-lighting .home-card-inner::before {
  animation: home-card-flash 0.62s ease-in-out 2;
}

.home-card.is-featured.is-lighting .home-card-inner {
  animation: home-card-flash-glow 0.62s ease-in-out 2;
}

@keyframes home-card-flash {
  0% { opacity: 0; }
  32% { opacity: 1; }
  68% { opacity: 0.2; }
  100% { opacity: 1; }
}

@keyframes home-card-flash-glow {
  0% { box-shadow: 0 0 0 0 rgba(77, 124, 255, 0), 0 20px 46px rgba(0, 0, 0, 0.55); }
  32% { box-shadow: 0 0 34px 8px rgba(77, 124, 255, 0.8), 0 0 76px 20px rgba(77, 124, 255, 0.45), 0 20px 46px rgba(0, 0, 0, 0.55); }
  68% { box-shadow: 0 0 12px 2px rgba(77, 124, 255, 0.28), 0 20px 46px rgba(0, 0, 0, 0.55); }
  100% { box-shadow: 0 0 26px 4px rgba(77, 124, 255, 0.62), 0 0 62px 14px rgba(77, 124, 255, 0.34), 0 20px 46px rgba(0, 0, 0, 0.55); }
}

.home-card.is-featured {
  transition: transform 0.42s cubic-bezier(0.22, 0.8, 0.24, 1), box-shadow 0.42s ease;
}

/* 悬停抬起：卡片在原位放大一点，旋转角保持不变。 */
.home-card.is-featured.is-hovered,
.home-card.is-featured:focus-visible {
  z-index: 10;
  transform: scale(1.08);
}

.home-card.is-featured.is-hovered .home-card-inner,
.home-card.is-featured:focus-visible .home-card-inner {
  box-shadow:
    0 0 0 1px rgba(160, 190, 255, 0.9),
    0 0 40px 8px rgba(94, 140, 255, 0.75),
    0 0 92px 24px rgba(77, 124, 255, 0.42),
    0 34px 70px rgba(0, 0, 0, 0.62);
}

.home-card.is-featured.is-hovered .home-card-inner::before,
.home-card.is-featured:focus-visible .home-card-inner::before {
  box-shadow:
    inset 0 0 30px rgba(143, 180, 255, 0.7),
    inset 0 0 6px rgba(220, 234, 255, 1);
}

.home-card.is-featured.is-hovered .home-card-media img,
.home-card.is-featured:focus-visible .home-card-media img {
  transform: scale(1.06);
}

/* 悬停时三层文字大幅拉开，像被拆解分层 */
.home-card.is-featured.is-hovered .home-card-label-shadow,
.home-card.is-featured:focus-visible .home-card-label-shadow {
  opacity: 0.95;
  filter: blur(9px);
  transform: translate(7px, 15px) scale(1.2);
}

.home-card.is-featured.is-hovered .home-card-label-mid,
.home-card.is-featured:focus-visible .home-card-label-mid {
  opacity: 1;
  filter: blur(0.3px);
  transform: translate(3px, 6px) scale(1.1);
}

.home-card.is-featured.is-hovered .home-card-label-face,
.home-card.is-featured:focus-visible .home-card-label-face {
  transform: translate(-2px, -4px) scale(1.14);
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.6),
    0 0 26px rgba(143, 180, 255, 0.7),
    0 0 4px rgba(255, 255, 255, 0.5);
}

.home-card.is-featured:focus-visible {
  outline: none;
}

/* ── 顶部渐隐与标题 ─────────────────────────────────── */

/* 靠近标题的卡片被背景色吞掉，形成参考图的渐隐效果 */
.home-veil {
  position: absolute;
  inset: 0;
  z-index: 5;
  background:
    linear-gradient(to bottom, var(--home-bg) 0%, rgba(22, 22, 26, 0.92) 12%, rgba(22, 22, 26, 0.52) 30%, rgba(22, 22, 26, 0) 52%),
    radial-gradient(120% 70% at 50% 0%, rgba(22, 22, 26, 0.5), transparent 70%);
  pointer-events: none;
}

.home-heading {
  position: absolute;
  top: clamp(26px, 5.2vh, 62px);
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(10px, 1.6vh, 18px);
  pointer-events: none;
  text-align: center;
}

.home-title {
  margin: 0;
  color: var(--home-ink);
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  font-weight: 500;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  line-height: 1;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}

.home-hint {
  /* 默认无文字，仅用于「尚未开启」之类的临时提示；绝对定位，避免空行撑开标题与卡片墙的间距。 */
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 8px 0 0;
  color: rgba(198, 208, 224, 0.5);
  font-size: clamp(0.66rem, 0.9vw, 0.78rem);
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  transition: opacity 0.6s ease;
}

.home-hint.is-faded {
  opacity: 0;
}

/* ── 穿越光晕 ───────────────────────────────────────── */

.home-warp-glow {
  position: absolute;
  z-index: 9;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  margin: -30px 0 0 -30px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(180, 210, 255, 0.55) 0%, rgba(110, 156, 255, 0.42) 34%, rgba(77, 124, 255, 0.18) 54%, rgba(77, 124, 255, 0) 72%);
  filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

/* 穿越时承载被放大的那张图 */
.home-warp-card {
  position: fixed;
  z-index: 8;
  border-radius: var(--card-radius);
  overflow: hidden;
  pointer-events: none;
  will-change: transform, opacity;
  transform-origin: center center;
  box-shadow: 0 0 60px rgba(77, 124, 255, 0.55);
}

.home-warp-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 穿越时标题与渐隐层让位，其余卡片沉默消失（只留被点中的那张放大）。 */
.home-app.is-warping .home-veil,
.home-app.is-warping .home-heading {
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* 降级路径会给卡片写内联 opacity:1，这里必须用 !important 才能覆盖。 */
.home-wall.is-warping .home-card:not(.is-warp-target) {
  opacity: 0 !important;
  transition: opacity 0.34s ease;
}

/* 被点中的卡片在倾斜平面里直接放大，保持原有的斜角。 */
.home-wall.is-warping .home-card.is-warp-target {
  z-index: 30;
  transition: none;
}

/* 放大中的卡片：标题先淡去，只留画面，避免文字被拉得过大。 */
.home-wall.is-warping .home-card.is-warp-target .home-card-label {
  opacity: 0;
  transition: opacity 0.22s ease;
}

.home-wall.is-warping .home-card.is-warp-target .home-card-inner::after {
  opacity: 0;
  transition: opacity 0.22s ease;
}

/* 下线卡片标题下方的「已暂时下线」淡红小字，放在内层里随平行四边形一起裁切。 */
.home-card-offline {
  position: absolute;
  top: 68%;
  left: 0;
  right: 0;
  z-index: 3;
  color: rgba(255, 140, 140, 0.8);
  font-size: calc(var(--card-width) * 0.07);
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  pointer-events: none;
}

/* 金色 ID 与「已暂时下线」小字：入场动画结束、点亮序列开始后才淡入，一开始不显示。 */
.home-card-id,
.home-card-offline {
  opacity: 0;
  transition: opacity 0.8s ease;
}

.home-wall.is-interactive .home-card-id,
.home-wall.is-interactive .home-card-offline {
  opacity: 1;
  transition-delay: 0.9s;
}

/* 下线卡片：红色轮廓光晕，沿平行四边形外形发光；底图仍保持灰度，不恢复色彩。 */
.home-card.is-offline-lit {
  filter:
    drop-shadow(0 0 2px rgba(255, 150, 150, 0.95))
    drop-shadow(0 0 14px rgba(255, 64, 64, 0.7))
    drop-shadow(0 0 34px rgba(255, 64, 64, 0.4));
}

/* 卡面标题下方的金色 ID 小字，放在内层里随平行四边形一起裁切，不受变暗影响。 */
.home-card-id {
  position: absolute;
  top: 68%;
  left: 0;
  right: 0;
  z-index: 3;
  color: #f2c46a;
  font-size: calc(var(--card-width) * 0.075);
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
  white-space: nowrap;
  pointer-events: none;
}

.home-noscript {
  position: fixed;
  inset: auto 0 24px;
  z-index: 20;
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
}

.home-noscript a {
  color: var(--home-ink);
}

/* ── 平行四边形外框（覆盖前文的整墙 skew 方案）─────────────
 * 墙不再整体剪切：每张卡是正向矩形内容，用 clip-path 裁成平行四边形，
 * 图片与标题都不变形。clip-path 会裁掉自身阴影与边框，
 * 因此高亮光晕改由外层 .home-card 的 drop-shadow 承担（它跟随裁切后的轮廓）。 */
.home-card {
  justify-self: start;
}

/* 奇数排错位，形成参考图里的砖墙式错落 */
.home-card[data-row="1"],
.home-card[data-row="3"] {
  margin-left: calc(var(--col-pitch) * 0.07);
}

.home-card-inner {
  inset: 0;
  border-radius: 0;
  clip-path: polygon(var(--card-slant) 0, 100% 0, calc(100% - var(--card-slant)) 100%, 0 100%);
}

.home-card-label {
  transform: none;
}

.home-card-inner::before {
  display: none;
}

.home-card.is-lit .home-card-inner,
.home-card.is-featured.is-hovered .home-card-inner,
.home-card.is-featured:focus-visible .home-card-inner {
  box-shadow: none;
}

.home-card.is-featured.is-lighting .home-card-inner {
  animation: none;
}

.home-card.is-lit {
  filter:
    drop-shadow(0 0 2px rgba(159, 192, 255, 0.95))
    drop-shadow(0 0 14px rgba(77, 124, 255, 0.7))
    drop-shadow(0 0 34px rgba(77, 124, 255, 0.4));
}

.home-card.is-featured.is-hovered,
.home-card.is-featured:focus-visible {
  filter:
    drop-shadow(0 0 3px rgba(190, 212, 255, 1))
    drop-shadow(0 0 22px rgba(94, 140, 255, 0.85))
    drop-shadow(0 0 54px rgba(77, 124, 255, 0.5));
}

.home-card.is-featured.is-lighting {
  animation: home-card-flash-outline 0.62s ease-in-out 2;
}

.home-wall.is-interactive .home-card.is-featured {
  transition: transform 0.42s cubic-bezier(0.22, 0.8, 0.24, 1), filter 0.42s ease;
}

@keyframes home-card-flash-outline {
  0% { filter: drop-shadow(0 0 0 rgba(77, 124, 255, 0)); }
  32% { filter: drop-shadow(0 0 3px #bcd2ff) drop-shadow(0 0 26px rgba(77, 124, 255, 0.9)); }
  68% { filter: drop-shadow(0 0 6px rgba(77, 124, 255, 0.3)); }
  100% { filter: drop-shadow(0 0 2px rgba(159, 192, 255, 0.95)) drop-shadow(0 0 14px rgba(77, 124, 255, 0.7)) drop-shadow(0 0 34px rgba(77, 124, 255, 0.4)); }
}

/* 卡片已给标题让出位置，不再需要大面积渐隐，只留顶端一道轻柔的过渡。 */
.home-veil {
  background: linear-gradient(to bottom, var(--home-bg) 0%, rgba(22, 22, 26, 0) 14%);
}

@media (prefers-reduced-motion: reduce) {
  .home-card,
  .home-card-inner,
  .home-card-inner::after,
  .home-card-inner::before,
  .home-card-media img,
  .home-card-label > span,
  .home-veil,
  .home-heading {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}