/* ============================================================
   海底考古文物复原探索 —— 样式表
   纯原生 CSS，无框架
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #030a14;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: #fff;
  user-select: none;
}

/* ===== 主场景容器 ===== */
#underwater-scene {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  /* 海底背景图作为底图 */
  background: url("./assets/bg_seabed.jpg") center/cover no-repeat;
}

/* 给场景叠一层深海蓝调，让整体偏暗 */
#underwater-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(2,12,28,0.55) 0%, rgba(3,18,38,0.75) 60%, rgba(2,10,22,0.9) 100%);
  pointer-events: none;
  z-index: 1;
}

/* ===== 长图卷动层 ===== */
.long-scroll {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  /* 宽度由 JS 动态设定（足够放下 7 件瓷器 + 间距） */
  width: 5200px;
  z-index: 2;
  transition: transform 0.15s linear;
  will-change: transform;
}

/* 海底地面延伸（横向平铺背景图的下半部分） */
.seabed-floor {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 70%;
  background:
    url("./assets/bg_seabed.jpg") bottom center / auto 100% repeat-x,
    linear-gradient(180deg, transparent 0%, rgba(5,20,35,0.4) 50%, rgba(3,12,24,0.85) 100%);
  opacity: 0.55;
  filter: brightness(0.7) saturate(0.8);
}

/* ===== 埋藏的瓷器（散布在长图中） ===== */
.relic {
  position: absolute;
  bottom: 12%;
  width: 220px;
  height: 280px;
  z-index: 3;
  transform-style: preserve-3d;
}

.relic img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  /* 埋藏状态：偏暗、偏冷、带泥沙模糊 */
  filter: brightness(0.45) contrast(0.8) saturate(0.5) blur(1.2px) sepia(0.3);
  transition: filter 0.4s ease;
}

/* 埋藏时覆盖一层泥沙质感 */
.relic.buried::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 80%, rgba(120,110,80,0.55) 0%, rgba(60,55,40,0.35) 45%, transparent 70%),
    radial-gradient(circle at 30% 60%, rgba(80,75,55,0.4), transparent 60%);
  mix-blend-mode: multiply;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

/* 被手电照到时的瓷器（变亮、变清晰） */
.relic.lit img {
  filter: brightness(1.1) contrast(1.05) saturate(1.1) blur(0px) sepia(0);
}
.relic.lit::after { opacity: 0; }

/* 被拾起的瓷器（从长图中消失） */
.relic.picked { opacity: 0; pointer-events: none; }

/* ===== 浮动泥沙粒子 ===== */
.sand-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(180,200,210,0.5) 1px, transparent 1px),
    radial-gradient(circle, rgba(150,170,185,0.35) 1px, transparent 1px),
    radial-gradient(circle, rgba(200,215,225,0.25) 1px, transparent 1px);
  background-size: 120px 120px, 200px 200px, 320px 320px;
  background-position: 0 0, 40px 60px, 80px 120px;
  animation: sandDrift 18s linear infinite;
  opacity: 0.6;
}

@keyframes sandDrift {
  0%   { background-position: 0 0, 40px 60px, 80px 120px; }
  100% { background-position: 600px -300px, 640px -240px, 560px -180px; }
}

/* ===== 水下光斑 ===== */
.light-spots {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    radial-gradient(ellipse 200px 120px at 20% 30%, rgba(120,180,220,0.12), transparent 70%),
    radial-gradient(ellipse 160px 90px at 70% 20%, rgba(140,200,230,0.10), transparent 70%),
    radial-gradient(ellipse 240px 140px at 50% 10%, rgba(100,160,200,0.08), transparent 70%);
  animation: lightSway 12s ease-in-out infinite alternate;
}

@keyframes lightSway {
  0%   { transform: translate(0,0) scale(1); opacity: 0.8; }
  50%  { transform: translate(30px,-15px) scale(1.05); opacity: 1; }
  100% { transform: translate(-20px,10px) scale(0.98); opacity: 0.7; }
}

/* ===== 手电筒聚光遮罩 ===== */
.flashlight {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  /* 由 JS 通过 --fx / --fy 控制聚光中心 */
  background: radial-gradient(
    circle 180px at var(--fx, 50%) var(--fy, 50%),
    rgba(0,0,0,0) 0%,
    rgba(0,10,25,0.25) 120px,
    rgba(0,8,20,0.82) 260px,
    rgba(0,5,15,0.96) 420px
  );
  transition: background 0.08s linear;
}

/* ===== 3D 展示舞台 ===== */
.display-stage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(500px, 90vw);
  height: min(500px, 72vh);
  max-width: 90vw;
  max-height: 72vh;
  z-index: 20;
  perspective: 1200px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.display-stage.active { opacity: 1; }

.relic-3d {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
}

.relic-3d-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  /* 由 JS 控制 rotateY 实现竖直轴旋转展示 */
  transform: rotateY(var(--ry, 0deg));
  transition: transform 0.1s linear;
}

#relic-3d-img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  opacity: 0.6;
  /* 修复前：破碎状态滤镜 */
  filter: brightness(0.5) contrast(0.7) saturate(0.4) blur(3px) grayscale(0.6);
  transition: filter 1.6s ease;
}

/* 修复完成状态：清晰明亮 */
.relic-3d.repaired #relic-3d-img {
  filter: brightness(1.15) contrast(1.1) saturate(1.2) blur(0px) grayscale(0);
}

/* 破碎裂纹遮罩 */
.crack-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 98%;
  height: 98%;
  max-width: 100%;
  max-height: 100%;
  pointer-events: none;
  background:
    /* 裂纹用线性渐变模拟 */
    linear-gradient(115deg, transparent 48%, rgba(20,20,20,0.85) 49%, rgba(20,20,20,0.85) 50%, transparent 51%),
    linear-gradient(75deg, transparent 60%, rgba(20,20,20,0.8) 61%, rgba(20,20,20,0.8) 62%, transparent 63%),
    linear-gradient(140deg, transparent 30%, rgba(20,20,20,0.7) 31%, rgba(20,20,20,0.7) 32%, transparent 33%),
    linear-gradient(30deg, transparent 75%, rgba(20,20,20,0.7) 76%, rgba(20,20,20,0.7) 77%, transparent 78%);
  background-size: 100% 100%;
  opacity: 0.9;
  transition: opacity 1.6s ease;
}
.relic-3d.repaired .crack-overlay { opacity: 0; }

/* 修复光晕 */
.repair-glow {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,220,140,0.5) 0%, rgba(255,200,100,0.2) 40%, transparent 70%);
  opacity: 0;
  pointer-events: none;
}
.relic-3d.repairing .repair-glow {
  animation: glowPulse 1.6s ease-in-out;
}
@keyframes glowPulse {
  0%   { opacity: 0; transform: scale(0.6); }
  40%  { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0; transform: scale(1.3); }
}

/* 舞台提示文字 */
.stage-hint {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  color: rgba(220,230,240,0.85);
  text-shadow: 0 0 8px rgba(0,0,0,0.8);
  letter-spacing: 2px;
  white-space: nowrap;
}

/* ===== 文物信息卡片 ===== */
.info-card {
  position: absolute;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%) translateY(120%);
  width: min(680px, 90vw);
  max-height: 38vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(8,24,48,0.96), rgba(6,18,38,0.97));
  /* 深蓝色外框 */
  border: 2px solid #1e4a7a;
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(30,90,150,0.5), inset 0 0 20px rgba(20,60,110,0.4);
  padding: 18px 26px;
  z-index: 30;
  opacity: 0;
  transition: transform 0.1s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.1s ease;
}
.info-card.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.card-inner { padding-right: 10px; }

/* 名字介绍：土黄色加粗 */
.card-body {
  font-size: 14px;
  line-height: 1.85;
  color: #f2f2f2;
}
.card-body p { margin-bottom: 4px; }
.card-body .label { color: #d9b15a; font-weight: 600; margin-right: 6px; }

/* ===== 摄像头面板（左上角） ===== */
.cam-panel {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 160px;
  height: 120px;
  z-index: 40;
  border: 1px solid rgba(120,180,220,0.4);
  border-radius: 6px;
  overflow: hidden;
  background: #000;
}
.cam-video, .cam-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* 镜像翻转，符合直觉 */
  transform: scaleX(-1);
}
.cam-canvas { z-index: 2; }
.cam-status {
  position: absolute;
  bottom: 2px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: #9fd0ee;
  background: rgba(0,0,0,0.5);
  padding: 2px 0;
  z-index: 3;
}

/* ===== 左下角标题 ===== */
.scene-title {
  position: absolute;
  left: 20px;
  bottom: 50px;
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 8px;
  color: rgba(220,230,240,0.85);
  z-index: 25;
  text-shadow: 0 0 10px rgba(0,0,0,0.8);
}

/* ===== 底部操作提示 ===== */
.bottom-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(200,215,230,0.7);
  z-index: 25;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  white-space: nowrap;
}

/* ===== 启动遮罩 ===== */
.start-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  background:
    linear-gradient(180deg, rgba(2,12,28,0.52), rgba(3,18,38,0.78)),
    url("./assets/bg_seabed.jpg") center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}
.start-overlay.hide { opacity: 0; pointer-events: none; }

.start-box {
  text-align: center;
  padding: 40px 60px;
  border: 1px solid rgba(80,140,200,0.4);
  border-radius: 12px;
  background: rgba(6,18,38,0.6);
  box-shadow: 0 0 40px rgba(30,90,150,0.3);
}
.start-box h1 {
  font-size: 26px;
  font-weight: 600;
  color: #d9b15a;
  margin-bottom: 14px;
  letter-spacing: 4px;
}
.start-box p {
  font-size: 14px;
  color: #c8d8e8;
  margin-bottom: 6px;
}
.start-box p.sub {
  font-size: 12px;
  color: #8aa8c4;
  margin-bottom: 24px;
}
.start-box button {
  padding: 10px 36px;
  font-size: 15px;
  color: #fff;
  background: linear-gradient(180deg, #2a6aa8, #1a4a78);
  border: 1px solid #4a8ac8;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 4px;
  transition: all 0.2s;
}
.start-box button:hover {
  background: linear-gradient(180deg, #3a7ab8, #2a5a88);
  box-shadow: 0 0 16px rgba(80,150,220,0.6);
}
