/* ============================================================
   H5 引导落地页 · 样式表（自建版，可整体替换为原版 vendor.css）
   结构约定：每个 .main 是一屏，加 .is-active 显示，.is-past 表示已翻过

   说明：
   - 全站内容横向居中，内容不足一屏时整组垂直居中
   - 标题 / 说明文字的字号由后台「外观」控制（--title-scale）
   - 页面底色由后台「外观」控制（--page-bg 等变量由 template.html 注入）
   ============================================================ */

:root {
  --app-w: 480px;

  /* 标题与说明文字的字号倍率，后台可选 0.9 / 1 / 1.16 */
  --title-scale: 1;

  /* 背景配色：由后台写入，默认值与后台「原色」一致 */
  --page-bg: #f6f7fb;
  --page-bg-2: #ecedf1;
  --glow: #ffe7e0;

  --bg: var(--page-bg);
  --card: #ffffff;
  --surface: #ffffff;
  --image-bg: #f0f2f8;
  --ink: #1c2030;
  --muted: #7b8196;
  --line: #e8eaf3;
  --primary: #ff5f6d;
  --primary-2: #ff8a5b;
  --primary-soft: rgba(255, 95, 109, 0.12);
  --shadow: 0 18px 40px rgba(28, 32, 48, 0.10);
  --radius: 20px;
}

/* 深色底时自动切换（后台按背景色亮度写入 data-theme="dark"） */
html[data-theme="dark"] {
  --card: rgba(255, 255, 255, 0.07);
  --surface: rgba(255, 255, 255, 0.09);
  --image-bg: rgba(255, 255, 255, 0.05);
  --ink: #eef1f8;
  --muted: #a7afc4;
  --line: rgba(255, 255, 255, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background:
    radial-gradient(900px 520px at 50% -8%, var(--glow) 0%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, var(--page-bg) 0%, var(--page-bg-2) 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------
   1. 屏（每一页）· 全站居中
   ------------------------------------------------------------ */
.main {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: var(--app-w);
  margin: 0 auto;
  padding: 36px 24px calc(28px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;      /* 内容横向居中 */
  text-align: center;       /* 文字居中对齐 */
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  opacity: 0;
  transform: translateY(28px);
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.46s cubic-bezier(0.22, 0.61, 0.36, 1);
  will-change: opacity, transform;
}

.main > * { width: 100%; }

/* 内容不多时上下留白均分，整组垂直居中；内容超高时自动退化为从顶部开始，不会裁切 */
.main > :first-child { margin-top: auto; }
.main > :last-child { margin-bottom: auto; }

.main.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.main.is-past {
  opacity: 0;
  transform: translateY(-28px);
}

/* 桌面端：中间像一张手机屏，两侧留白 */
@media (min-width: 560px) {
  .main {
    inset: auto 0 auto 0;
    top: 50%;
    height: min(880px, 100dvh);
    min-height: 0;
    transform: translateY(calc(-50% + 28px));
    border-radius: 28px;
    box-shadow: 0 40px 80px rgba(28, 32, 48, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: var(--page-bg);
  }
  .main.is-active { transform: translateY(-50%); }
  .main.is-past   { transform: translateY(calc(-50% - 28px)); }
}

/* ------------------------------------------------------------
   2. 标题区（统一居中，字号跟随后台设置）
   ------------------------------------------------------------ */
.header { text-align: center; }

.header h1,
.header h2,
.header h3 {
  margin: 0 0 10px;
  font-weight: 800;
  letter-spacing: -0.4px;
  line-height: 1.28;
}

.header h1 { font-size: calc(1.875rem * var(--title-scale)); }
.header h2 { font-size: calc(1.625rem * var(--title-scale)); }
.header h3 { font-size: calc(1.3125rem * var(--title-scale)); }

.header p {
  margin: 0;
  color: var(--muted);
  font-size: calc(0.90625rem * var(--title-scale));
  line-height: 1.65;
}

.header--question { text-align: center; }

.header--question h3 { font-size: calc(1.25rem * var(--title-scale)); }

/* ------------------------------------------------------------
   3. 图片区
   ------------------------------------------------------------ */
.image-block {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 22px 0;
}

.image-block > img {
  display: block;
  width: 100%;
  max-height: 100%;
  object-fit: cover;
  border-radius: 24px;
  box-shadow: var(--shadow);
}

/* 第 1 页的四图拼贴 */
.collage-block {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.collage__image {
  border-radius: 18px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 12px 26px rgba(28, 32, 48, 0.10);
  aspect-ratio: 1 / 1;
}

.collage__image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.collage__image:nth-child(1) { transform: rotate(-1.2deg); }
.collage__image:nth-child(4) { transform: rotate(1.2deg); }

/* ------------------------------------------------------------
   4. 按钮
   ------------------------------------------------------------ */
.buttons-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.buttons-block--start { margin-top: auto; }

.button {
  position: relative;
  display: block;
  width: 100%;
  padding: 16px 20px;
  border: 0;
  border-radius: 16px;
  font-family: inherit;
  font-size: 1.03125rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-2), var(--primary));
  box-shadow: 0 14px 28px rgba(255, 95, 109, 0.30);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.14s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.button:active { transform: scale(0.975); box-shadow: 0 8px 18px rgba(255, 95, 109, 0.28); }

.button:disabled,
.button[disabled] {
  cursor: not-allowed;
  color: #a9aec0;
  background: #e6e8f1;
  box-shadow: none;
}

.button--no {
  color: var(--ink);
  background: var(--card);
  border: 1.5px solid var(--line);
  box-shadow: 0 8px 20px rgba(28, 32, 48, 0.06);
}

.button--no:active { box-shadow: 0 4px 12px rgba(28, 32, 48, 0.08); }

.button--skip {
  padding: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
}

.button--skip:active { color: var(--muted); background: rgba(28, 32, 48, 0.04); }

.buttons-block--grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

/* 问题卡片：图片下方浮起的一块 */
.buttons-block--question {
  margin-top: -34px;
  padding: 22px 20px 20px;
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 -12px 40px rgba(28, 32, 48, 0.10);
  position: relative;
  z-index: 2;
}

/* ------------------------------------------------------------
   5. 选择项
   ------------------------------------------------------------ */
.choose-block {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.choose-line {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* 第 7 / 8 屏只有一项的那一行：居中，不靠左 */
.choose-line > .choose-item:only-child {
  grid-column: 1 / -1;
  justify-self: center;
  width: calc(50% - 6px);
}

.choose-item {
  position: relative;
  display: flex;
  flex-direction: column;
  padding-bottom: 12px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.14s ease;
}

.choose-item:active { transform: scale(0.985); }

.choose-item.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.choose-item.is-selected::after {
  content: "✓";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 4px 10px rgba(255, 95, 109, 0.4);
}

.choose__image {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--image-bg);
}

/* 第 7、8 页用扁一点的图，保证五六个选项 + 按钮能在一屏里放完 */
.choose-item-1 .choose__image,
.choose-item-2 .choose__image {
  aspect-ratio: 4 / 3;
}

.choose-item > p {
  margin: 10px 8px 0;
  text-align: center;
  font-size: 0.90625rem;
  font-weight: 600;
}

/* 第 10 页：横条选项 + 大图 */
.choose__image--big {
  display: block;
  width: 100%;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.choose-item-4 {
  flex-direction: row;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.choose-item-4 > p {
  margin: 0;
  font-size: 0.96875rem;
}

/* ------------------------------------------------------------
   6. 最后一屏
   ------------------------------------------------------------ */
.main.page-11 {
  padding: 0;
  justify-content: flex-end;
  overflow: hidden;
}

/* 整组已经靠底部，不再参与垂直居中 */
.main.page-11 > .buttons-block { margin-top: 0; margin-bottom: 0; }

.page-11 .background {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.background-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.page-11::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg,
    rgba(12, 14, 24, 0) 0%,
    rgba(12, 14, 24, 0.20) 38%,
    rgba(12, 14, 24, 0.72) 72%,
    rgba(12, 14, 24, 0.88) 100%);
}

.page-11 .buttons-block {
  position: relative;
  z-index: 2;
  margin: 0;
  padding: 0 24px calc(34px + env(safe-area-inset-bottom));
}

.page-11 .header--final h2 {
  color: #fff;
  font-size: calc(1.625rem * var(--title-scale));
}

.page-11 .header--final p {
  color: rgba(255, 255, 255, 0.82);
  font-size: calc(0.90625rem * var(--title-scale));
  margin-bottom: 18px;
}

.page-11 .header--final b {
  color: #fff;
  font-size: calc(1.0625rem * var(--title-scale));
}

.palma {
  display: block;
  width: 52px;
  margin: 0 auto 14px;
}

#installButton {
  background: linear-gradient(135deg, #fff 0%, #ffe9e5 100%);
  color: var(--primary);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.32);
}

/* ------------------------------------------------------------
   7. 深色底细节修正
   ------------------------------------------------------------ */
html[data-theme="dark"] .button--no {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] .button:disabled,
html[data-theme="dark"] .button[disabled] {
  color: rgba(255, 255, 255, 0.38);
  background: rgba(255, 255, 255, 0.10);
}

html[data-theme="dark"] .buttons-block--question {
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .main {
  border-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .button--skip:active { background: rgba(255, 255, 255, 0.06); }

/* ------------------------------------------------------------
   8. 小屏适配
   ------------------------------------------------------------ */
@media (max-width: 360px) {
  .main { padding-left: 18px; padding-right: 18px; }
  .header h1 { font-size: calc(1.625rem * var(--title-scale)); }
  .header h2 { font-size: calc(1.4375rem * var(--title-scale)); }
  .button { font-size: 0.96875rem; padding: 15px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .main { transition: none; }
  .button { transition: none; }
}
