/* ==========================================================================
   小满券仓（coupon.zangeng.com）· 优惠券展示专用样式
   复用 tokens.css / main.css 的设计令牌；本文件只放优惠券页独有组件。
   ========================================================================== */

:root {
  /* 京东红，仅用于券面价格与「券」徽标，避免污染全站品牌色 */
  --coupon-red: #e4393c;
  --coupon-red-soft: rgba(228, 57, 60, 0.1);
}

/* ---------------------------------- 工具栏（榜单切换 + 搜索） ---------------------------------- */
.cp-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.cp-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.cp-tab {
  border: 0;
  background: transparent;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: background .15s ease, color .15s ease;
}
.cp-tab:hover { color: var(--text); }
.cp-tab.is-active { background: var(--accent); color: #fff; }
.cp-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 平台筛选（JS 动态注入 .cp-toolbar；数据带 platform 后才显示，京东/淘宝混合期可见） */
.cp-plat {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.cp-plat[hidden] { display: none; }
.cp-plat-chip {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: inherit;
  transition: background .15s ease, color .15s ease;
}
.cp-plat-chip:hover { color: var(--text); }
.cp-plat-chip.is-active { background: var(--accent); color: #fff; }
.cp-plat-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 排序下拉（C8） */
.cp-sort { display: inline-flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.875rem; }
.cp-sort select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}
.cp-sort select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.cp-search { display: flex; gap: 8px; }
.cp-search input {
  width: 260px;
  max-width: 60vw;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
}
.cp-search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.cp-search button {
  height: 42px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease;
}
.cp-search button:hover { background: var(--accent-strong); }

/* ---------------------------------- 优惠券网格 ---------------------------------- */
.cp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
}
.cp-card {
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
/* 平台色描边（京东红 / 淘宝橙） */
.cp-card[data-plat="jd"] { border-color: rgba(228, 57, 60, .45); }
.cp-card[data-plat="taobao"] { border-color: rgba(255, 119, 0, .45); }
.cp-card[data-plat="pdd"] { border-color: rgba(226, 33, 32, .42); }
.cp-card[data-plat="douyin"] { border-color: rgba(17, 17, 17, .42); }
/* 悬停放大 + 强阴影（仅精确指针设备，避免触屏点击后 :hover 卡住导致放大/位移冲突） */
@media (hover: hover) {
  .cp-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-strong);
  }
  .cp-card[data-plat="jd"]:hover { border-color: var(--coupon-red); }
  .cp-card[data-plat="taobao"]:hover { border-color: #ff7700; }
.cp-card[data-plat="pdd"]:hover { border-color: #e22120; }
.cp-card[data-plat="douyin"]:hover { border-color: #111; }
}
/* 无可点链接的券卡降级（防 featured 死卡）：置灰、取消 hover 位移 */
.cp-card.is-dead { opacity: .55; cursor: not-allowed; }
.cp-card.is-dead:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--border); }
.cp-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface-2);
}
.cp-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  padding: 12px 12px 0;
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
}
.cp-price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 10px 12px 14px;
}
/* 立减大角标：渐变红 pill，放大加粗，一眼可见力度 */
.cp-off {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ff6a3d, #e4393c);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.3;
  letter-spacing: .01em;
  box-shadow: 0 4px 14px rgba(228, 57, 60, .32);
}
.cp-final {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 600;
}
.cp-final::before { content: "到手 "; color: var(--text-soft); font-weight: 400; }

/* 超值 / 火爆 飘带（按券面额力度），置于右上星标左侧 */
/* 价格走势 sparkline（M7） */
.cp-spark { vertical-align: middle; margin-left: 6px; }

.cp-hot {
  position: absolute;
  top: 8px;
  right: 80px;
  z-index: 2;
  padding: 2px 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffb03a, #ff7a00);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: .03em;
  box-shadow: 0 3px 10px rgba(255, 122, 0, .35);
}
.cp-hot--fire {
  background: linear-gradient(135deg, #ff5a5f, #e4393c);
  box-shadow: 0 3px 10px rgba(228, 57, 60, .35);
}

/* 限时倒计时（couponEndTime 24h 内）：红色脉冲，实时刷新 */
.cp-countdown {
  align-self: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(228, 57, 60, .12);
  color: #e4393c;
  font-size: 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  animation: cp-pulse 1.1s ease-in-out infinite;
}
.cp-countdown.is-ended { background: var(--surface-2); color: var(--text-soft); animation: none; }
@keyframes cp-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(228, 57, 60, .35); }
  50% { box-shadow: 0 0 0 4px rgba(228, 57, 60, 0); }
}

/* 今日新增小徽标（createTime 24h 内） */
.cp-fresh {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--coupon-red);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}

/* 即将失效小徽标（couponEndTime 3 天内，行内贴在手价旁，避免与 cp-fresh / 星标争位） */
.cp-expire {
  align-self: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  animation: cp-pulse 1.6s ease-in-out infinite;
}

/* 热门品类 chip 行（首页券区上方） */
.cp-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 22px;
}
.cp-cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}
.cp-cat-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------- 状态 / 加载更多 ---------------------------------- */
.cp-state {
  padding: 24px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9375rem;
}
.cp-state .cp-retry { margin-top: 14px; }
/* 后端不可达、用构建快照兜底时：灰化券卡 + 状态区警示（快照券可能已失效，提示用户核对） */
.cp-grid.is-stale .cp-card { opacity: .6; filter: grayscale(.5); transition: opacity .2s ease, filter .2s ease; }
.cp-grid.is-stale .cp-card:hover { transform: none; box-shadow: var(--shadow-sm); border-color: var(--border); }
.cp-grid.is-stale .cp-card.is-dead { opacity: .4; }
.cp-state.is-fallback {
  color: #b45309;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}
.cp-more-wrap { text-align: center; margin-top: 18px; }
.cp-more-wrap .btn[hidden] { display: none; }

.cp-note {
  margin-top: 14px;
  color: var(--text-soft);
  font-size: 0.8125rem;
}

@media (max-width: 720px) {
  .cp-toolbar { flex-direction: column; align-items: stretch; }
  .cp-search { width: 100%; }
  .cp-search input { flex: 1; max-width: none; width: auto; }
  .cp-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
}

/* ---------------------------------- 券卡单元（收藏星标包裹层） ---------------------------------- */
/* 星标按钮不能嵌在 <a> 内（非法嵌套），改用 .cp-cell 包裹层承载绝对定位 */
.cp-cell { position: relative; display: flex; flex-direction: column; }
.cp-cell .cp-card { flex: 1; }
.cp-star {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  font-size: 0.9375rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, transform .15s ease;
}
.cp-star:hover { transform: scale(1.12); background: rgba(0, 0, 0, 0.6); }
.cp-star:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cp-star.is-on { background: var(--coupon-red); }

/* ---------------------------------- 骨架屏加载态 ---------------------------------- */
.cp-skeleton {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  padding-bottom: 14px;
}
.cp-sk-img { width: 100%; aspect-ratio: 1 / 1; background: var(--surface-2); }
.cp-sk-line {
  height: 14px;
  margin: 12px 12px 0;
  border-radius: 6px;
  background: var(--surface-2);
}
.cp-sk-line.is-short { width: 55%; height: 12px; margin-top: 8px; }
.cp-skeleton .cp-sk-img,
.cp-skeleton .cp-sk-line {
  animation: cp-sk-shimmer 1.2s ease-in-out infinite;
}
@keyframes cp-sk-shimmer { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  .cp-skeleton .cp-sk-img, .cp-skeleton .cp-sk-line { animation: none; }
  .cp-star, .cp-star:hover { transform: none; }
  .cp-countdown, .cp-expire { animation: none; }
}

/* ---------------------------------- 搜索历史 / 热门词 chip ---------------------------------- */
.cp-his {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.cp-his[hidden] { display: none; }
.cp-his-label { color: var(--text-soft); font-size: 0.8125rem; }
.cp-his-chip {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  padding: 4px 12px;
  font-size: 0.8125rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color .15s ease, color .15s ease;
}
.cp-his-chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.cp-his-clear {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.8125rem;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
}
.cp-his-clear:hover { color: var(--coupon-red); }

/* ---------------------------------- 收藏 / 最近看过页 ---------------------------------- */
.cp-fav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.cp-fav-count { color: var(--text-muted); font-size: 0.9375rem; }
.cp-card-actions {
  display: flex;
  gap: 8px;
  padding: 0 12px 12px;
}
.cp-mini-btn {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text-muted);
  padding: 6px 0;
  font-size: 0.8125rem;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: border-color .15s ease, color .15s ease;
}
.cp-mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.cp-mini-btn.is-danger:hover { border-color: var(--coupon-red); color: var(--coupon-red); }
.cp-empty {
  padding: 42px 0;
  text-align: center;
  color: var(--text-muted);
}
.cp-empty .btn { margin-top: 16px; }

/* ---------------------------------- 凑单计算器 ---------------------------------- */
.cal-wrap { display: grid; grid-template-columns: 1.2fr .8fr; gap: 24px; align-items: start; }
.cal-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px;
}
.cal-panel h3 { margin: 0 0 12px; font-size: 1.0625rem; }
.cal-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.cal-row.is-head { color: var(--text-soft); font-size: 0.8125rem; margin-bottom: 6px; }
.cal-input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
}
.cal-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cal-del {
  border: 0; background: transparent; color: var(--text-soft);
  font-size: 1rem; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
}
.cal-del:hover { color: var(--coupon-red); }
.cal-add { margin-top: 4px; }
.cal-check { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.cal-result-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9375rem;
  color: var(--text-muted);
}
.cal-result-line:last-child { border-bottom: 0; }
.cal-result-line strong { color: var(--text); }
.cal-total strong { color: var(--coupon-red); font-size: 1.375rem; }
.cal-save strong { color: var(--accent); }
.cal-warn { margin-top: 12px; font-size: 0.8125rem; color: var(--text-soft); }
.cal-tips { margin-top: 14px; font-size: 0.8125rem; color: var(--text-soft); line-height: 1.7; }
@media (max-width: 860px) {
  .cal-wrap { grid-template-columns: 1fr; }
}

/* ---------------------------------- 大促日历 ---------------------------------- */
.hol-next {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  margin-bottom: 24px;
  font-size: 0.9375rem;
}
.hol-next strong { color: var(--accent); }
.hol-list { list-style: none; margin: 0; padding: 0; }
.hol-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.hol-item.is-next { background: var(--accent-soft); border-radius: var(--radius); padding-left: 14px; padding-right: 14px; }
.hol-date { font-weight: 800; color: var(--coupon-red); font-size: 1.0625rem; }
.hol-count { margin-left: 8px; font-weight: 400; color: var(--text-soft); font-size: 0.8125rem; }
.hol-name { margin: 0 0 6px; font-size: 1.0625rem; }
.hol-desc { margin: 0; color: var(--text-muted); font-size: 0.9375rem; line-height: 1.7; }
.hol-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--coupon-red-soft);
  color: var(--coupon-red);
  font-size: 0.75rem;
  font-weight: 700;
  vertical-align: 2px;
}
@media (max-width: 720px) {
  .hol-item { grid-template-columns: 1fr; gap: 6px; }
}

/* ---------------------------------- 猜你喜欢（M1） ---------------------------------- */
.cp-rec-section[hidden] { display: none; }
.cp-rec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.cp-rec-head h2 { font-size: 1.25rem; margin: 0; }
.cp-rec-dismiss {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.8125rem;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.cp-rec-dismiss:hover { color: var(--coupon-red); border-color: var(--coupon-red); }

/* 分享按钮（M4）：星标左侧，火爆飘带再左侧（right:80px） */
.cp-share {
  position: absolute;
  top: 8px;
  right: 44px;
  z-index: 2;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.42);
  color: #fff;
  font-size: 0.9375rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, transform .15s ease;
}
.cp-share:hover { transform: scale(1.12); background: rgba(0, 0, 0, 0.6); }
.cp-share:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 降价提醒按钮（M2）：价格行内联胶囊 */
.cp-alert {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.cp-alert.is-on { background: var(--coupon-red); border-color: var(--coupon-red); color: #fff; }
.cp-alert:hover { color: var(--coupon-red); border-color: var(--coupon-red); }
.cp-alert.is-on:hover { color: #fff; }
.cp-expire.is-hot { background: var(--coupon-red); color: #fff; }

/* ---------------------------------- 回到顶部 ---------------------------------- */
.cp-back-top {
  position: fixed;
  right: 18px;
  bottom: 22px;
  z-index: 50;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 1.125rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: opacity .15s ease, transform .15s ease;
}
.cp-back-top[hidden] { display: none; }
.cp-back-top:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }
