/* =============================================
   上海普陀 H5 - Canvas 序列帧动画
   ============================================= */

/* CSS 变量 */
:root {
  --cream: #f5f0e6;
  --gold: #c9a86c;
  --text-dark: #333;
  --transition-duration: 0.5s;
}

/* 基础重置 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* =============================================
   加载界面
   ============================================= */
#loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--cream);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease-out, visibility 0.5s;
}

#loading.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(201, 168, 108, 0.3);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 14px;
  color: var(--text-dark);
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.loading-progress {
  font-size: 24px;
  font-weight: 600;
  color: var(--gold);
}

/* =============================================
   主应用容器
   ============================================= */
#app {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.pages-container {
  width: 100%;
  height: 100%;
  position: relative;
}

/* =============================================
   页面样式
   ============================================= */
.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-duration) ease-out,
              transform var(--transition-duration) ease-out,
              visibility var(--transition-duration);
  will-change: opacity, transform;
  background: var(--cream);
}

.page.active {
  opacity: 1;
  visibility: visible;
  z-index: 10;
}

.page.prev {
  transform: translateY(-100%);
}

.page.next {
  transform: translateY(100%);
}

/* Canvas 样式 */
.page canvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* =============================================
   叠加层样式
   ============================================= */
.overlay-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 15;
}

.overlay-layer img {
  width: 100%;
  height: 100%;
  object-fit: fill;  /* 铺满整个屏幕 */
}

/* 卡片层动画 */
.overlay-card.show {
  visibility: visible;
  animation: fadeInScale 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* 文字层动画 - 向上浮出 */
.overlay-text.show {
  visibility: visible;
  animation: floatUpFadeIn 2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 0.3s;
}

/* 重置动画状态 - 用于重播 */
.overlay-card.hide,
.overlay-text.hide {
  opacity: 0;
  visibility: hidden;
  animation: none;
}

/* 淡入缩放动画 */
@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* 向上浮出淡入动画 */
@keyframes floatUpFadeIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* =============================================
   滑动提示
   ============================================= */
.swipe-hint {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 1px;
  opacity: 0;
  animation: fadeInHint 0.5s ease-out forwards;
  animation-delay: 4s;
  z-index: 20;
}

.swipe-hint.swipe-hint-up {
  top: 40px;
  bottom: auto;
  flex-direction: column-reverse;
}

.swipe-hint.swipe-hint-end {
  opacity: 0;
  animation: fadeInHint 0.5s ease-out forwards;
  animation-delay: 4s;
}

.swipe-hint.swipe-hint-end span {
  margin-bottom: 0;
  font-size: 13px;
  color: rgba(201, 168, 108, 0.8);
}

.swipe-hint span {
  margin-bottom: 8px;
}

.swipe-hint-up span {
  margin-bottom: 0;
  margin-top: 8px;
}

@keyframes fadeInHint {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.arrow-down {
  width: 12px;
  height: 12px;
  border-right: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  transform: rotate(45deg);
  animation: bounceDown 1.5s ease-in-out infinite;
}

.arrow-up {
  width: 12px;
  height: 12px;
  border-left: 2px solid var(--gold);
  border-top: 2px solid var(--gold);
  transform: rotate(45deg);
  animation: bounceUp 1.5s ease-in-out infinite;
}

@keyframes bounceDown {
  0%, 100% { transform: rotate(45deg) translateY(0); }
  50% { transform: rotate(45deg) translateY(5px); }
}

@keyframes bounceUp {
  0%, 100% { transform: rotate(45deg) translateY(0); }
  50% { transform: rotate(45deg) translateY(-5px); }
}

/* =============================================
   页面过渡动画
   ============================================= */
.page.slide-out-up {
  animation: slideOutUp var(--transition-duration) ease-out forwards;
}

.page.slide-in-up {
  animation: slideInUp var(--transition-duration) ease-out forwards;
}

.page.slide-out-down {
  animation: slideOutDown var(--transition-duration) ease-out forwards;
}

.page.slide-in-down {
  animation: slideInDown var(--transition-duration) ease-out forwards;
}

@keyframes slideOutUp {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-30%);
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideOutDown {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(30%);
  }
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-30%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================
   横屏提示
   ============================================= */
@media screen and (orientation: landscape) and (max-height: 500px) {
  body::before {
    content: "请竖屏浏览";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    z-index: 99999;
    letter-spacing: 2px;
  }
}

/* =============================================
   安全区域适配（iPhone X 等）
   ============================================= */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .swipe-hint {
    bottom: calc(40px + env(safe-area-inset-bottom));
  }
  
  .swipe-hint.swipe-hint-up {
    top: calc(40px + env(safe-area-inset-top));
  }
}
