/* ============================================================
   联通套餐对比小助手
   设计：暖色渐变底 + 彩色光斑 + 磨砂玻璃卡片 + 卡通扁平图标
   ============================================================ */

:root {
  --red: #e60012;            /* 中国联通红 */
  --red-deep: #c10010;
  --red-soft: #ff5c4d;
  --orange: #f0740a;
  --green: #0ba36f;
  --green-bg: rgba(16, 185, 129, .14);
  --warn-bg: rgba(240, 116, 10, .14);
  --ink: #3a2b28;            /* 主文字：暖褐黑 */
  --ink-2: #8a7570;          /* 次级文字 */
  --card-bg: rgba(255, 255, 255, .58);
  --card-border: rgba(255, 255, 255, .8);
  --card-shadow: 0 24px 60px -22px rgba(230, 0, 18, .22);
  --radius: 26px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "PingFang SC", "HarmonyOS Sans SC",
               "MiSans", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background: linear-gradient(175deg, #fff7ef 0%, #ffeee6 38%, #fff4e2 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 背景层：光斑 + 泡泡画布 ---------- */

.bg-blobs, #bubble-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#bubble-canvas { z-index: 1; }

.bg-blobs { z-index: 0; overflow: hidden; }

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: .55;
  animation: blob-drift 26s ease-in-out infinite alternate;
}
.blob-1 { width: 55vmin; height: 55vmin; background: #ffb59d; top: -12%; left: -10%; }
.blob-2 { width: 46vmin; height: 46vmin; background: #ffd9a3; top: 22%; right: -14%; animation-duration: 32s; animation-delay: -8s; }
.blob-3 { width: 50vmin; height: 50vmin; background: #ff9d9d; bottom: -18%; left: 16%; animation-duration: 29s; animation-delay: -15s; }
.blob-4 { width: 34vmin; height: 34vmin; background: #ffe3b8; bottom: 12%; right: 10%; animation-duration: 36s; animation-delay: -4s; }

@keyframes blob-drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vmin, -4vmin) scale(1.15); }
}

/* ---------- 版式 ---------- */

.wrap {
  position: relative;
  z-index: 2;
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 44px) clamp(14px, 3vw, 28px) 40px;
}

/* ---------- 头部 ---------- */

.hero { text-align: center; margin-bottom: clamp(20px, 4vw, 34px); }

.hero-badge {
  display: block;
  margin: 0 auto 6px;
  animation: pig-bob 3.2s ease-in-out infinite;
  filter: drop-shadow(0 10px 18px rgba(230, 0, 18, .25));
}
@keyframes pig-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-9px) rotate(3deg); }
}

.hero h1 {
  margin: 0;
  font-size: clamp(26px, 5.4vw, 42px);
  font-weight: 900;
  letter-spacing: .02em;
  background: linear-gradient(120deg, var(--red) 20%, #ff7a45 80%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: clamp(14px, 2.6vw, 17px);
}

.inline-ico { vertical-align: -3px; }

/* ---------- 磨砂玻璃卡片 ---------- */

.card {
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  -webkit-backdrop-filter: blur(22px) saturate(1.6);
  backdrop-filter: blur(22px) saturate(1.6);
  padding: clamp(18px, 3.4vw, 26px);
  margin-bottom: clamp(16px, 3vw, 24px);
  opacity: 0;
  transform: translateY(26px);
  animation: card-in .6s cubic-bezier(.2, .7, .3, 1.1) forwards;
}
.card-old    { animation-delay: .05s; }
.card-unicom { animation-delay: .16s; }
.card-result { animation-delay: .27s; }

@keyframes card-in {
  to { opacity: 1; transform: none; }
}

.card-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 16px;
  font-size: 19px;
  font-weight: 800;
}

.card-old    .card-title::after,
.card-unicom .card-title::after,
.card-result .card-title::after {
  content: "";
  flex: 1;
  height: 2px;
  border-radius: 2px;
  margin-left: 4px;
  opacity: .35;
}
.card-old    .card-title::after { background: linear-gradient(90deg, #f4a261, transparent); }
.card-unicom .card-title::after { background: linear-gradient(90deg, var(--red-soft), transparent); }
.card-result .card-title::after { background: linear-gradient(90deg, #2ec48f, transparent); }

.card-unicom { border-top: 4px solid rgba(230, 0, 18, .55); }
.card-result { border-top: 4px solid rgba(16, 185, 129, .5); }

/* ---------- 输入区 ---------- */

.fields {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, .78);
  border: 2px solid rgba(255, 255, 255, .9);
  border-radius: 18px;
  padding: 10px 12px 8px;
  cursor: text;
  transition: border-color .18s, box-shadow .18s, transform .18s;
}
.field:focus-within {
  border-color: var(--red-soft);
  box-shadow: 0 0 0 4px rgba(230, 0, 18, .12);
  transform: translateY(-2px);
}

.f-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 600;
  margin-bottom: 4px;
}

.field input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 21px;
  font-weight: 800;
  color: var(--ink);
  padding: 0;
  min-width: 0;
}

.f-unit {
  align-self: flex-end;
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 600;
  margin-top: -16px;
  pointer-events: none;
}

/* 隐藏 number 输入框的上下箭头 */
.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* ---------- 档位下拉框 ---------- */

.plan-pick {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.pp-label { font-size: 14px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }

#plan-select {
  flex: 1;
  min-width: 0;            /* 关键：允许收缩到比选项文字窄，不撑破卡片 */
  max-width: 100%;
  text-overflow: ellipsis; /* 显示不全的档位名以省略号收尾 */
  overflow: hidden;
  font: inherit;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--red-deep);
  padding: 11px 38px 11px 14px;
  border-radius: 14px;
  border: 2px solid rgba(230, 0, 18, .28);
  background: rgba(255, 255, 255, .85)
              url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23e60012' stroke-width='2.2' stroke-linecap='round' fill='none'/%3E%3C/svg%3E")
              no-repeat right 14px center;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color .18s, box-shadow .18s;
}
#plan-select:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(230, 0, 18, .12);
}

/* ---------- 赠品 / 备注展示 ---------- */

.plan-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(230, 0, 18, .07);
  border: 1.5px dashed rgba(230, 0, 18, .35);
  font-size: 14px;
  line-height: 1.7;
  color: var(--red-deep);
  font-weight: 600;
}
.plan-note .note-line { display: block; }

/* ---------- 结果区 ---------- */

.result-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.result-head .card-title { margin-bottom: 0; flex: 1; }
.result-head .card-title::after { display: none; }

.reset-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  background: rgba(255, 255, 255, .75);
  border: 2px solid rgba(138, 117, 112, .25);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  transition: all .18s;
}
.reset-btn:hover { color: var(--red); border-color: var(--red-soft); transform: translateY(-1px); }

.export-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(120deg, var(--red) 30%, #ff5a3c 100%);
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: 0 8px 18px -8px rgba(230, 0, 18, .55);
  transition: transform .18s, box-shadow .18s;
}
.export-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 22px -8px rgba(230, 0, 18, .6); }
.export-btn:disabled { opacity: .6; cursor: wait; }

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: rgba(255, 255, 255, .72);
  border: 1.5px solid rgba(255, 255, 255, .9);
  border-radius: 20px;
  padding: 16px 8px 12px;
  transition: transform .18s, box-shadow .18s;
}
.tile:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -14px rgba(230, 0, 18, .3); }

.t-ico { margin-bottom: 6px; }

.t-label { font-size: 13px; color: var(--ink-2); font-weight: 700; }

.t-value { margin-top: 3px; }

.t-num {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 900;
  letter-spacing: -.01em;
  color: var(--green);
}
.t-unit { font-size: 13px; font-weight: 700; color: var(--ink-2); margin-left: 3px; }

.tile--bad .t-num { color: var(--orange); }
.tile--flat .t-num { color: var(--ink-2); }

.t-badge {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  border-radius: 999px;
  padding: 3px 10px;
  background: var(--green-bg);
  color: var(--green);
}
.t-badge--up { background: var(--warn-bg); color: var(--orange); }

/* 数字变化时弹一下 */
.t-num.pop { animation: num-pop .35s cubic-bezier(.2, .8, .3, 1.4); }
@keyframes num-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.summary {
  margin: 16px 2px 0;
  font-size: clamp(14.5px, 2.8vw, 16.5px);
  font-weight: 700;
  line-height: 1.8;
  color: var(--ink);
  text-align: center;
  min-height: 1.8em;
}

/* 计算结果固定尾句：单独一行，联通红突出 */
.summary .slogan {
  display: block;
  margin-top: 6px;
  color: var(--red);
}

/* ---------- 导出图片分享弹层 ---------- */

.share-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(30, 14, 10, .58);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.share-modal[hidden] { display: none; }

.share-box { text-align: center; max-width: 94vw; }

.share-box img {
  max-width: min(80vw, 430px);
  max-height: 70vh;
  border-radius: 18px;
  box-shadow: 0 30px 80px -18px rgba(0, 0, 0, .55);
}

.share-tip { color: #fff; margin: 14px 0 2px; font-weight: 700; font-size: 15px; }

.share-actions { display: flex; gap: 12px; justify-content: center; margin-top: 10px; }

.share-btn {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  border-radius: 999px;
  padding: 9px 22px;
  cursor: pointer;
  border: none;
}
.share-btn.share-send {
  color: #fff;
  background: linear-gradient(120deg, var(--red) 30%, #ff5a3c 100%);
  box-shadow: 0 8px 18px -8px rgba(230, 0, 18, .6);
}
.share-btn.share-close {
  color: #fff;
  background: rgba(255, 255, 255, .16);
  border: 1.5px solid rgba(255, 255, 255, .45);
}

/* ---------- 页脚 ---------- */

.foot {
  text-align: center;
  color: var(--ink-2);
  font-size: 12.5px;
  opacity: .8;
  margin-top: 10px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 680px) {
  .fields { grid-template-columns: repeat(2, 1fr); }
  .tiles  { grid-template-columns: repeat(2, 1fr); }
  .plan-pick { flex-direction: column; align-items: stretch; gap: 6px; }
  .pp-label { text-align: center; }
}

/* ---------- 宽屏三栏：电脑 / 平板（含平板竖屏）/ 手机横屏 ---------- */
/* 手机竖屏两个条件都不命中，维持上面的上中下堆叠，一行 JS 都不用改 */
@media (min-width: 760px), (orientation: landscape) and (min-width: 600px) {
  .wrap { max-width: 1280px; }

  .cols {
    display: grid;
    /* 老套餐 / 联通 / 结果，结果栏稍宽让大数字舒展；minmax(0,…) 防内容撑爆栏宽 */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.12fr);
    gap: clamp(14px, 2vw, 24px);
    align-items: start;
    margin-bottom: clamp(16px, 3vw, 24px);
  }

  /* 三栏后每张卡变窄：字段和结果块改成 2×2，按钮允许换行，数字略缩防溢出 */
  .cols .card { margin-bottom: 0; }
  .cols .fields { grid-template-columns: repeat(2, 1fr); }
  .cols .tiles  { grid-template-columns: repeat(2, 1fr); }
  /* 栏变窄后“选择档位”改为上下排列，让下拉框占满整栏宽度，减少省略号出现 */
  .cols .plan-pick { flex-direction: column; align-items: stretch; gap: 6px; }
  .cols .pp-label { text-align: center; }
  .cols .t-num  { font-size: clamp(19px, 2.4vw, 28px); }
  .cols .result-head { flex-wrap: wrap; }
  .cols .reset-btn,
  .cols .export-btn { padding: 7px 12px; font-size: 13px; }
}

/* ---------- 减少动态效果（无障碍） ---------- */

@media (prefers-reduced-motion: reduce) {
  .blob, .hero-badge { animation: none; }
  .card { animation-duration: .01s; }
  .t-num.pop { animation: none; }
  * { transition: none !important; }
}
