/* Image Collage 404 v1.0.0 */
/* ==========================================================================
   Image Collage 404
   52 个固定百分比槽位 + 数据驱动图片
   ========================================================================== */

:root {
  --page-bg: #f7f7f7;
  --text: #252525;
  --muted: #8a8a8a;
  --card-radius: 7px;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--muted);
  font-family: "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  text-align: center;
}

.page {
  min-height: 100vh;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(36px, 6vw, 84px) clamp(14px, 3vw, 32px) 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.message-404 {
  position: relative;
  z-index: 5;
}

.message-404 h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(30px, 3vw, 46px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.message-404 p {
  max-width: 620px;
  margin: 14px auto 0;
  font-size: clamp(15px, 1.35vw, 18px);
  line-height: 1.5;
  text-wrap: balance;
}

/* ------------------------------ 404 舞台 ------------------------------ */

.collage-404 {
  position: relative;
  width: min(1080px, 94vw);
  aspect-ratio: 2.44 / 1;
  margin: clamp(30px, 4vw, 50px) auto 28px;
  perspective: 500px;
  transform-style: preserve-3d;
  isolation: isolate;
}

.collage-ghost {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #111;
  font-size: clamp(180px, 28vw, 420px);
  font-weight: 800;
  line-height: .78;
  letter-spacing: -.09em;
  opacity: .055;
  transition: opacity .75s ease;
  user-select: none;
  pointer-events: none;
}

.collage-404.is-ready .collage-ghost {
  opacity: 0;
}

.collage-404-images {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.collage-404-images a {
  position: absolute;
  width: 7%;
  display: block;
  border-radius: var(--card-radius);
  outline: 0;
  transform-style: preserve-3d;
  transition:
    transform .75s cubic-bezier(.2, .8, .2, 1),
    opacity .35s ease;
  will-change: transform;
}

.collage-404-images a:focus-visible {
  z-index: 20;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(0, 0, 0, .75);
}

.collage-404-images img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
  border-radius: inherit;
  opacity: 0;
  filter: grayscale(1);
  transform: scale(.95);
  box-shadow:
    0 5px 18px rgba(0, 0, 0, .09),
    0 0 0 1px rgba(0, 0, 0, .035);
  transition:
    opacity .55s ease,
    filter .9s ease,
    transform .2s ease,
    box-shadow .2s ease;
}

.collage-404-images a.loaded img {
  opacity: 1;
  filter: grayscale(0);
  transform: scale(1);
}

.collage-404-images a.introduced {
  transition-duration: .15s;
}

@media (hover: hover) and (pointer: fine) {
  .collage-404-images a:hover {
    z-index: 10;
  }

  .collage-404-images a:hover img {
    transform: scale(1.36);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
  }
}

/* ------------------------------ 52 个 404 槽位 ------------------------------ */
/*
   这一版回到“原网站原理”：
   使用更多、更小的卡片来拼出清晰的 404 轮廓。
   图片允许重复排列，优先保证数字骨架。
*/

/* 左侧 4：1 - 17 */
.collage-404 a:nth-child(1){left:19%;top:18%}
.collage-404 a:nth-child(2){left:15%;top:25%}
.collage-404 a:nth-child(3){left:12%;top:32%}
.collage-404 a:nth-child(4){left:8%;top:39%}
.collage-404 a:nth-child(5){left:4%;top:47%}
.collage-404 a:nth-child(6){left:1%;top:55%}
.collage-404 a:nth-child(7){left:-2%;top:62%}
.collage-404 a:nth-child(8){left:5%;top:62%}
.collage-404 a:nth-child(9){left:12%;top:62%}
.collage-404 a:nth-child(10){left:19%;top:62%}
.collage-404 a:nth-child(11){left:25.5%;top:62%}
.collage-404 a:nth-child(12){left:19%;top:27%}
.collage-404 a:nth-child(13){left:19%;top:35.5%}
.collage-404 a:nth-child(14){left:19%;top:43.5%}
.collage-404 a:nth-child(15){left:19%;top:53%}
.collage-404 a:nth-child(16){left:19%;top:70%}
.collage-404 a:nth-child(17){left:19%;top:79%}

/* 中间 0：18 - 35 */
.collage-404 a:nth-child(18){left:41%;top:20%}
.collage-404 a:nth-child(19){left:38%;top:26%}
.collage-404 a:nth-child(20){left:36%;top:34%}
.collage-404 a:nth-child(21){left:35%;top:43%}
.collage-404 a:nth-child(22){left:35%;top:52%}
.collage-404 a:nth-child(23){left:35.5%;top:61%}
.collage-404 a:nth-child(24){left:37%;top:69%}
.collage-404 a:nth-child(25){left:41%;top:76%}
.collage-404 a:nth-child(26){left:47%;top:79%}
.collage-404 a:nth-child(27){left:52%;top:76%}
.collage-404 a:nth-child(28){left:55.5%;top:69%}
.collage-404 a:nth-child(29){left:57%;top:61%}
.collage-404 a:nth-child(30){left:58%;top:52%}
.collage-404 a:nth-child(31){left:58%;top:43%}
.collage-404 a:nth-child(32){left:57%;top:34%}
.collage-404 a:nth-child(33){left:55%;top:26%}
.collage-404 a:nth-child(34){left:52%;top:20%}
.collage-404 a:nth-child(35){left:47%;top:18%}

/* 右侧 4：36 - 52 */
.collage-404 a:nth-child(36){left:88%;top:18%}
.collage-404 a:nth-child(37){left:84%;top:25%}
.collage-404 a:nth-child(38){left:81%;top:32%}
.collage-404 a:nth-child(39){left:77%;top:39%}
.collage-404 a:nth-child(40){left:73%;top:47%}
.collage-404 a:nth-child(41){left:70%;top:55%}
.collage-404 a:nth-child(42){left:67%;top:62%}
.collage-404 a:nth-child(43){left:74%;top:62%}
.collage-404 a:nth-child(44){left:81%;top:62%}
.collage-404 a:nth-child(45){left:88%;top:62%}
.collage-404 a:nth-child(46){left:94.5%;top:62%}
.collage-404 a:nth-child(47){left:88%;top:27%}
.collage-404 a:nth-child(48){left:88%;top:35.5%}
.collage-404 a:nth-child(49){left:88%;top:43.5%}
.collage-404 a:nth-child(50){left:88%;top:53%}
.collage-404 a:nth-child(51){left:88%;top:70%}
.collage-404 a:nth-child(52){left:88%;top:79%}

/* ------------------------------ 返回首页 ------------------------------ */

.back-home {
  margin: 4px 0 0;
}

.back-home a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 22px;
  border: 1px solid rgba(0, 0, 0, .12);
  border-radius: 999px;
  color: #555;
  background: #fff;
  text-decoration: none;
  font-size: 14px;
  transition:
    transform .18s ease,
    border-color .18s ease,
    color .18s ease,
    box-shadow .18s ease;
}

.back-home a:hover {
  color: #222;
  border-color: rgba(0, 0, 0, .25);
  transform: translateY(-1px);
  box-shadow: 0 7px 20px rgba(0, 0, 0, .08);
}

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

@media (max-width: 760px) {
  .page {
    min-height: 100svh;
    padding: 30px 10px 24px;
  }

  .message-404 h1 {
    font-size: clamp(28px, 8vw, 38px);
  }

  .message-404 p {
    max-width: 410px;
    font-size: 14px;
  }

  .collage-404 {
    width: 99vw;
    margin-top: 34px;
    margin-bottom: 24px;
  }

  .collage-404-images a {
    width: 7.5%;
    border-radius: 4px;
  }

  .collage-ghost {
    font-size: 47vw;
  }
}

@media (max-width: 420px) {
  .collage-404 {
    width: 98vw;
    margin-top: 38px;
  }

  .collage-404-images a {
    width: 8%;
  }

  .back-home a {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
  }
}
