/* ===== 梁平剪纸非遗 H5 样式 ===== */
:root {
  --red: #C94C4C;
  --green: #7BA088;
  --yellow: #F5E6C8;
  --gold: #D4AF37;
  --pink: #F5D5D5;
  --bg: #FAF7F2;
  --text: #4A4039;
  --text-light: #8A7B6F;
  --shadow: rgba(201, 76, 76, 0.12);
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Serif SC', 'PingFang SC', 'Microsoft YaHei', serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.7;
}

/* ===== 页面系统 ===== */
.page {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.page.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

.page.page-exit {
  opacity: 0;
  transform: translateY(-20px) rotateX(5deg);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.page-inner {
  position: relative;
  z-index: 2;
  flex: 1;
  padding: calc(56px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.scroll-page {
  padding-bottom: calc(40px + var(--safe-bottom));
}

.page-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--bg) 0%, #F5F0E8 50%, var(--pink) 100%);
  opacity: 0.6;
  z-index: 0;
}

.bamboo-bg {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(123, 160, 136, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 30%, rgba(245, 230, 200, 0.3) 0%, transparent 40%),
    linear-gradient(180deg, var(--bg) 0%, #F0EBE3 100%);
  opacity: 1;
}

.share-bg {
  background: linear-gradient(180deg, var(--bg) 0%, rgba(201, 76, 76, 0.06) 100%);
}

/* ===== 全局导航 ===== */
.global-nav {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 12px;
  z-index: 100;
  display: flex;
  gap: 8px;
  transition: opacity 0.3s;
}

.global-nav.hidden {
  opacity: 0;
  pointer-events: none;
}

.nav-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px var(--shadow);
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.2s;
}

.nav-btn:active {
  transform: scale(0.92);
}

/* ===== 按钮 ===== */
.btn-primary {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 16px auto 0;
  padding: 14px 24px;
  border: none;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--red), #B03E3E);
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(201, 76, 76, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-outline {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 12px auto;
  padding: 12px 24px;
  border: 1.5px solid var(--red);
  border-radius: 28px;
  background: transparent;
  color: var(--red);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-outline:active {
  background: rgba(201, 76, 76, 0.08);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  border: none;
  background: none;
  color: var(--text-light);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 12px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--red);
  border-radius: 50%;
  background: #fff;
  color: var(--red);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-row .btn-primary,
.btn-row .btn-outline {
  flex: 1;
  min-width: 120px;
  max-width: 160px;
}

/* ===== 加载开篇页 ===== */
#page-loader {
  background: var(--bg);
  align-items: center;
  justify-content: center;
}

.loader-content {
  position: relative;
  z-index: 3;
  text-align: center;
  padding: 24px;
  max-width: 360px;
}

.loader-tag {
  font-size: 12px;
  color: var(--text-light);
  letter-spacing: 3px;
  margin-bottom: 24px;
  animation: fadeUp 0.8s ease forwards;
}

.loader-title {
  font-size: clamp(18px, 5vw, 24px);
  font-weight: 700;
  color: var(--red);
  line-height: 1.6;
  margin-bottom: 16px;
}

.loader-title .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(16px);
  animation: charReveal 0.5s ease forwards;
}

.loader-sub {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 32px;
  animation: fadeUp 1s ease 0.5s forwards;
  opacity: 0;
}

.reveal-text {
  animation: fadeUp 1s ease forwards;
}

.loader-bar-wrap {
  width: 200px;
  height: 3px;
  background: rgba(201, 76, 76, 0.15);
  border-radius: 2px;
  margin: 0 auto 28px;
  overflow: hidden;
}

.loader-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--red), var(--gold));
  border-radius: 2px;
  transition: width 0.3s ease;
}

#btn-enter {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.5s, transform 0.5s;
}

#btn-enter.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* 水晶球 */
.crystal-orb {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.8), rgba(245,213,213,0.3) 50%, rgba(212,175,55,0.1) 100%);
  box-shadow: inset 0 0 30px rgba(255,255,255,0.5), 0 0 40px rgba(245,213,213,0.4);
  animation: orbBreath 4s ease-in-out infinite;
  z-index: 1;
}

.crystal-orb::after {
  content: '';
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(123,160,136,0.15), transparent);
}

/* 金箔 */
.gold-dust {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, var(--gold) 100%, transparent),
    radial-gradient(1px 1px at 30% 60%, var(--gold) 100%, transparent),
    radial-gradient(1px 1px at 50% 10%, var(--gold) 100%, transparent),
    radial-gradient(1px 1px at 70% 40%, var(--gold) 100%, transparent),
    radial-gradient(1px 1px at 90% 70%, var(--gold) 100%, transparent),
    radial-gradient(1px 1px at 20% 80%, var(--gold) 100%, transparent),
    radial-gradient(1px 1px at 60% 90%, var(--gold) 100%, transparent);
  opacity: 0.4;
  animation: goldTwinkle 3s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

/* 飘落粒子 */
.particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.particle {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  background: var(--red);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
  animation: fall linear infinite;
}

/* ===== 导览首页 ===== */
.home-header {
  text-align: center;
  margin-bottom: 28px;
}

.section-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--red);
  line-height: 1.4;
}

.section-title small {
  font-size: 16px;
  font-weight: 400;
  color: var(--green);
}

.section-desc {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-light);
  letter-spacing: 4px;
}

.nav-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.nav-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  padding: 16px 18px;
  border: none;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px var(--shadow);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: slideUp 0.6s ease backwards;
  border-left: 3px solid var(--red);
}

.nav-card:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px var(--shadow);
}

.nav-card-num {
  font-size: 11px;
  color: var(--gold);
  font-weight: 600;
  width: 100%;
}

.nav-card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.nav-card-sub {
  font-size: 12px;
  color: var(--text-light);
  flex: 1;
}

.nav-card-arrow {
  color: var(--red);
  font-size: 18px;
}

/* ===== 通用页面标题 ===== */
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--red);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}

.sub-title {
  font-size: 16px;
  color: var(--green);
  margin: 20px 0 12px;
  text-align: center;
}

.intro-text, .closing-text {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 20px;
}

.closing-text {
  margin-top: 24px;
  font-style: italic;
  color: var(--green);
}

/* ===== 剪纸溯源 ===== */
.scroll-paper {
  background: rgba(255, 255, 255, 0.8);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 4px 24px var(--shadow);
  border: 1px solid rgba(201, 76, 76, 0.1);
}

.scroll-paper p {
  margin-bottom: 14px;
  font-size: 14px;
  text-indent: 2em;
  color: var(--text);
}

.origin-illus {
  text-align: center;
  margin: 16px 0;
}

.paper-cut-svg {
  width: 160px;
  height: 160px;
  animation: gentleFloat 4s ease-in-out infinite;
}

.symbols-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.symbol-card {
  flex: 1;
  text-align: center;
  padding: 14px 8px;
  background: linear-gradient(180deg, #fff, var(--yellow));
  border-radius: 12px;
  border: 1px solid rgba(123, 160, 136, 0.2);
}

.symbol-emoji {
  font-size: 28px;
  display: block;
  margin-bottom: 6px;
}

.symbol-card strong {
  display: block;
  font-size: 14px;
  color: var(--red);
  margin-bottom: 2px;
}

.symbol-card span:last-child {
  font-size: 11px;
  color: var(--text-light);
}

/* ===== 匠心工序 ===== */
.process-steps {
  position: relative;
  min-height: 280px;
  margin-bottom: 20px;
}

.process-step {
  display: none;
  text-align: center;
  padding: 24px 16px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px var(--shadow);
  animation: fadeIn 0.4s ease;
}

.process-step.active {
  display: block;
}

.step-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.step-num {
  font-size: 12px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.process-step h3 {
  font-size: 22px;
  color: var(--red);
  margin-bottom: 12px;
}

.process-step p {
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.8;
}

.process-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.process-dots {
  display: flex;
  gap: 8px;
}

.process-dots .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--red);
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s;
}

.process-dots .dot.active {
  background: var(--red);
}

/* ===== 二十四节气长卷 ===== */
.solar-page {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.solar-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 12px;
  transition: opacity 0.5s;
  animation: pulse 2s ease infinite;
}

.solar-track {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding: 8px 4px 20px;
  flex: 1;
  scrollbar-width: none;
  cursor: grab;
}

.solar-track::-webkit-scrollbar {
  display: none;
}

.solar-track:active {
  cursor: grabbing;
}

.solar-card {
  flex: 0 0 200px;
  scroll-snap-align: center;
}

.solar-card-inner {
  height: 260px;
  padding: 20px 16px;
  background: linear-gradient(160deg, #fff 0%, var(--yellow) 100%);
  border-radius: var(--radius);
  border: 1px solid rgba(201, 76, 76, 0.15);
  box-shadow: 0 4px 16px var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s;
}

.solar-card-inner:hover {
  transform: translateY(-4px);
}

.solar-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.solar-card h3 {
  font-size: 20px;
  color: var(--red);
  margin-bottom: 10px;
}

.solar-card p {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.6;
}

.solar-deco {
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(123, 160, 136, 0.1);
}

/* ===== 互动工坊 ===== */
.workshop-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: rgba(255,255,255,0.6);
  border-radius: 24px;
  padding: 4px;
}

.workshop-tab {
  flex: 1;
  padding: 10px 4px;
  border: none;
  border-radius: 20px;
  background: transparent;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.workshop-tab.active {
  background: var(--red);
  color: #fff;
  box-shadow: 0 2px 8px rgba(201, 76, 76, 0.3);
}

.workshop-panel {
  display: none;
}

.workshop-panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 12px;
}

.color-picker {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}

.color-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.color-btn.active {
  border-color: var(--text);
  transform: scale(1.15);
}

canvas {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto 16px;
  border-radius: 12px;
  box-shadow: 0 4px 16px var(--shadow);
  touch-action: none;
  background: #fff;
}

.carve-progress-wrap {
  margin-bottom: 12px;
  text-align: center;
}

.carve-progress-bg {
  height: 6px;
  background: rgba(201, 76, 76, 0.15);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.carve-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--red), var(--gold));
  border-radius: 3px;
  transition: width 0.3s;
}

#carve-status {
  font-size: 12px;
  color: var(--text-light);
}

.complete-badge {
  display: none;
  text-align: center;
  padding: 10px;
  background: rgba(123, 160, 136, 0.15);
  color: var(--green);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
}

.complete-badge.show {
  display: block;
  animation: fadeIn 0.5s ease;
}

/* 拼图 */
.puzzle-board {
  position: relative;
  width: 100%;
  max-width: 300px;
  height: 220px;
  margin: 0 auto 16px;
  background: rgba(255,255,255,0.9);
  border-radius: var(--radius);
  border: 2px dashed rgba(201, 76, 76, 0.3);
  box-shadow: inset 0 0 20px rgba(201, 76, 76, 0.05);
}

.puzzle-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: rgba(201, 76, 76, 0.3);
  letter-spacing: 4px;
}

.puzzle-slot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 70px;
  height: 70px;
  border: 2px dashed var(--green);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(123, 160, 136, 0.08);
}

.puzzle-slot.filled {
  border-style: solid;
  background: rgba(255,255,255,0.9);
}

.slot-outline {
  font-size: 11px;
  color: var(--green);
}

.puzzle-tray {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.puzzle-piece {
  width: 72px;
  padding: 10px 6px;
  background: #fff;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 4px 12px var(--shadow);
  cursor: grab;
  border: 1.5px solid var(--pink);
  user-select: none;
}

.puzzle-piece span {
  font-size: 28px;
  display: block;
}

.puzzle-piece small {
  font-size: 11px;
  color: var(--text-light);
}

.puzzle-piece.dragging {
  opacity: 0.85;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

/* ===== 文创赏集 ===== */
.products-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.product-card {
  padding: 18px 14px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 4px 12px var(--shadow);
  border-top: 2px solid var(--gold);
  transition: transform 0.2s;
}

.product-card:active {
  transform: scale(0.97);
}

.product-emoji {
  font-size: 32px;
  display: block;
  margin-bottom: 8px;
}

.product-card h4 {
  font-size: 14px;
  color: var(--red);
  margin-bottom: 4px;
}

.product-card p {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.5;
}

.products-grid .product-card:last-child {
  grid-column: 1 / -1;
  max-width: 200px;
  margin: 0 auto;
  width: 100%;
}

/* ===== 分享页 ===== */
.share-main {
  font-size: 24px;
}

.share-sub {
  text-align: center;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.share-quote {
  text-align: center;
  font-size: 15px;
  color: var(--green);
  font-style: italic;
  margin-bottom: 20px;
  min-height: 24px;
  transition: opacity 0.3s;
}

.share-preview {
  display: none;
  text-align: center;
  margin-bottom: 16px;
}

.share-preview.show {
  display: block;
  animation: fadeIn 0.5s ease;
}

#share-canvas {
  max-width: 260px;
  border: 2px solid var(--red);
  border-radius: 8px;
}

.page-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 32px;
  letter-spacing: 2px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: calc(40px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 24px;
  background: rgba(74, 64, 57, 0.9);
  color: #fff;
  border-radius: 20px;
  font-size: 13px;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== 动画 ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes charReveal {
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 0.6; }
  100% { transform: translateY(100vh) rotate(360deg); opacity: 0; }
}

@keyframes orbBreath {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.8; }
  50% { transform: translateX(-50%) scale(1.05); opacity: 1; }
}

@keyframes goldTwinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

@keyframes gentleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== 响应式 ===== */
@media (min-width: 414px) {
  .page-inner {
    padding-left: 28px;
    padding-right: 28px;
  }

  .nav-grid {
    gap: 14px;
  }

  .solar-card {
    flex: 0 0 220px;
  }
}

@media (max-height: 600px) {
  .crystal-orb {
    width: 100px;
    height: 100px;
    top: 10%;
  }

  .loader-content {
    padding: 16px;
  }
}
