/* ============================================================================
   开机动画（Boot / Splash）
   ----------------------------------------------------------------------------
   结构：一张覆盖全屏的图，内部两层（各放一张不同的照片）+ 一个加载指示器。
   时间线：
     0.0s  淡入（图一 1.9 倍 → 1 倍，缓慢推近）
     1.3s  指示器扫描线划一遍
     1.5s  交叉淡化到图二（图二 1.12 → 1 倍，反向轻推）
     2.9s  整体淡出 + 轻微放大，露出网站内容
     3.6s  DOM 移除，不再占用任何资源

   两个设计要点：
   1. 每张图用自己的 img 元素 + object-fit: cover 独立缩放，所以两张照片宽高比
      不同也不会出现形变或位移；交叉淡化只是改 opacity，不会有跳变。
   2. 只用 transform 和 opacity 做动画（不碰 width/height/top/left），
      这样全程在 GPU 合成层，不会触发重排，掉帧概率最低。

   另见 public/boot.js —— 它负责控制时序与移除，本文件只描述视觉。
   ========================================================================== */

.boot {
  position: fixed;
  inset: 0;
  z-index: 9999;
  overflow: hidden;
  background: #05070c;
  /*
   * 淡出：整屏微微放大 + 轻微模糊 + 透明。
   * 加一点模糊是有意的——它让画面看起来像「镜头推过去」，比单纯的透明度变化
   * 更接近丝滑的观感；模糊值很小（8px），不会看不清内容，只是柔化边缘。
   */
  transition: opacity 0.72s cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 0.72s cubic-bezier(0.22, 0.61, 0.36, 1),
              filter 0.72s cubic-bezier(0.22, 0.61, 0.36, 1),
              visibility 0s linear 0.72s;
  will-change: opacity, transform, filter;
  /* 动画期间禁止滚动，避免背景内容跟着动 */
  touch-action: none;
}

.boot.is-done {
  opacity: 0;
  transform: scale(1.06);
  filter: blur(8px);
  visibility: hidden;
  pointer-events: none;
}

/* ------------------------------- 图层 ---------------------------------- */

.boot-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  will-change: opacity, transform;
}

/*
 * 图一：一边从 1.9 倍缓慢推近到 1 倍，一边在图二淡入的同时同步淡出。
 *
 * 这里是真正的「交叉淡化」——两边同时在变，中间态两张图各占约一半，
 * 而不是「图一不动 + 图二盖上去」。后者会让图一永不退场，最终画面
 * 变成两张图的永久叠加，看起来是脏的（实测发现过这个问题）。
 * 淡出与图二的淡入必须等长、同缓动，否则中间会有一瞬间的亮度跳变。
 *
 * 三个动画的分工：
 *   boot-in         0     → 0.42s   自身淡入，抹掉「黑底跳亮图」的硬边
 *   boot-push-1     0     → 4.9s    缓慢推近，全程都在动，所以过渡没有停顿感
 *   boot-fade-out-1 1.5s  → 3.0s    与图二交叉
 */
.boot-1 {
  opacity: 1;
  transform: scale(1.9);
  animation: boot-in 0.42s ease-out both,
             boot-push-1 4.9s cubic-bezier(0.16, 0.84, 0.44, 1) forwards,
             boot-fade-out-1 1.5s ease-in-out 1.5s forwards;
}

.boot-2 {
  transform: scale(1.12);
  animation: boot-fade-2 1.5s ease-in-out 1.5s forwards,
             boot-push-2 3.2s cubic-bezier(0.16, 0.84, 0.44, 1) 1.5s forwards;
}

/* 图一：从底色淡入，避免「黑块跳蓝天」的硬边 */
@keyframes boot-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.boot-layer img {
  width: 100%;
  height: 100%;
  /* 关键：cover 让两张不同宽高比的照片各自铺满，不会拉伸变形 */
  object-fit: cover;
  object-position: center;
  display: block;
  /* 避免拖拽图片 */
  -webkit-user-drag: none;
  user-select: none;
}

/* 图一：从 1.9 倍缓慢推近到 1 倍 */
@keyframes boot-push-1 {
  from { transform: scale(1.9); }
  to   { transform: scale(1); }
}

/* 图一：与图二的淡入同步淡出，形成交叉 */
@keyframes boot-fade-out-1 {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* 图二：淡入 */
@keyframes boot-fade-2 {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 图二：反向轻推，和推近形成对比，过渡更有层次 */
@keyframes boot-push-2 {
  from { transform: scale(1.12); }
  to   { transform: scale(1); }
}

/* ------------------------------ 暗角与遮罩 ------------------------------ */

/* 底部加一层渐变，让加载指示器在任何照片上都看得清 */
.boot-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 50%, transparent 40%, rgba(4, 6, 11, 0.55) 100%),
    linear-gradient(to top, rgba(4, 6, 11, 0.72) 0%, transparent 42%);
}

/* ------------------------------- 内容层 -------------------------------- */

.boot-content {
  position: absolute;
  inset: auto 0 clamp(44px, 9vh, 110px) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 0 24px;
  text-align: center;
  color: #f2f5fb;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
  animation: boot-rise 1.1s cubic-bezier(0.22, 0.61, 0.36, 1) 0.35s both;
}

@keyframes boot-rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.boot-title {
  margin: 0;
  font-size: clamp(21px, 3.4vw, 38px);
  font-weight: 650;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

.boot-sub {
  margin: -8px 0 0;
  font-size: clamp(12.5px, 1.5vw, 15px);
  letter-spacing: 0.22em;
  color: rgba(242, 245, 251, 0.72);
  font-weight: 400;
}

/* 加载指示器：一条细线里跑一道光，比转圈更安静 */
.boot-bar {
  position: relative;
  width: clamp(150px, 26vw, 260px);
  height: 2px;
  border-radius: 999px;
  background: rgba(242, 245, 251, 0.18);
  overflow: hidden;
}

.boot-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 25%,
    #ffffff 50%,
    rgba(255, 255, 255, 0.35) 75%,
    transparent 100%);
  transform: translateX(-100%);
  animation: boot-sweep 1.45s cubic-bezier(0.4, 0, 0.2, 1) 0.25s infinite;
}

@keyframes boot-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* 没有 JS 时也保证动画会退场（纯 CSS 兜底，见 boot.js 的说明） */
.boot:not(.is-ready) {
  animation: boot-auto-hide 0.7s ease 4.2s forwards;
}

@keyframes boot-auto-hide {
  to { opacity: 0; visibility: hidden; }
}

/* ---------------------------- 无障碍与降级 ----------------------------- */

/*
 * 用户开启了「减少动态效果」时：不推进、不扫描，只做一次很短的淡入淡出。
 * 这不是可选项——大幅度的画面推移会让部分人眩晕。
 */
@media (prefers-reduced-motion: reduce) {
  .boot,
  .boot-layer,
  .boot-content,
  .boot-bar::after {
    animation: none !important;
  }
  .boot-1 { opacity: 1; transform: none; }
  .boot-2 { opacity: 0; transform: none; }
  .boot { transition: opacity 0.3s ease; }
  .boot:not(.is-ready) { animation: none; }
}

/* 打印时不要这个遮罩 */
@media print {
  .boot { display: none !important; }
}
