/*
 * 首頁開團專區（views/partials/group-buy-zone.ejs、/js/group-buy-zone.js）
 * 深藍底、金色細線與大字；右側三欄商品在固定高度的視窗裡，捲動時以不同速度、相反方向移動
 * 進場動畫只在 JS 加上 .gbz-js 後才隱藏內容，JS 沒有載入時內容照常顯示
 */
.gbz {
  --gbz-bg: #0d1628;
  --gbz-ink: #f6f1e3;
  --gbz-muted: rgba(246, 241, 227, 0.62);
  --gbz-gold: var(--accent, #d4af37);
  --gbz-line: rgba(212, 175, 55, 0.28);
  position: relative;
  overflow: hidden;
  color: var(--gbz-ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(212, 175, 55, 0.14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(64, 98, 168, 0.28), transparent 65%),
    linear-gradient(180deg, var(--gbz-bg) 0%, #142039 55%, var(--gbz-bg) 100%);
  border-bottom: 1px solid var(--gbz-line);
  isolation: isolate;
}

/* ---------- 背景：游標光暈、大字、金線 ---------- */
.gbz-bg { position: absolute; inset: 0; pointer-events: none; z-index: -1; }
.gbz-glow {
  position: absolute; inset: 0;
  background: radial-gradient(520px circle at var(--mx, 72%) var(--my, 42%), rgba(212, 175, 55, 0.13), transparent 62%);
  transition: background 0.2s linear;
}
/* 細微的雜訊紋理，讓深色底不死板 */
.gbz-bg::after {
  content: ''; position: absolute; inset: 0; opacity: 0.07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.gbz-giant {
  position: absolute; left: 0; top: 50%;
  display: flex; gap: 0.35em; white-space: nowrap;
  font-size: clamp(5.5rem, 15vw, 15rem); line-height: 1;
  transform: translate3d(-8%, -50%, 0);
  will-change: transform;
}
.gbz-giant span { flex: none; }
.gbz-giant .is-serif { font-family: var(--font-serif); font-style: italic; font-weight: 500; color: rgba(246, 241, 227, 0.045); letter-spacing: -0.02em; }
.gbz-giant .is-outline { font-family: var(--font-sans); font-weight: 800; text-transform: uppercase; letter-spacing: -0.03em; color: transparent; -webkit-text-stroke: 1px rgba(212, 175, 55, 0.2); }
.gbz-rule { position: absolute; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.55) 30%, rgba(212, 175, 55, 0.55) 70%, transparent); transform-origin: left center; }
.gbz-rule--top { top: 28px; }
.gbz-rule--bottom { bottom: 64px; transform-origin: right center; }

/* ---------- 版面 ---------- */
.gbz-inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(32px, 5vw, 80px);
  align-items: center;
  padding-top: clamp(64px, 8vw, 112px);
  padding-bottom: clamp(88px, 9vw, 128px);
}
.gbz-copy { position: relative; z-index: 2; max-width: 520px; }

.gbz-kicker { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 16px; margin: 0 0 22px; }
.gbz-live {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 10px; border: 1px solid rgba(212, 175, 55, 0.6);
  color: var(--gbz-gold); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.28em; text-transform: uppercase;
}
.gbz-live i { width: 7px; height: 7px; border-radius: 50%; background: var(--gbz-gold); animation: gbzPulse 1.8s ease-out infinite; }
.is-upcoming .gbz-live i { background: transparent; border: 1px solid var(--gbz-gold); animation: none; }
.gbz-kicker-tc { font-size: 0.82rem; letter-spacing: 0.24em; color: var(--gbz-muted); }

.gbz-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(2.1rem, 4.4vw, 3.9rem);
  line-height: 1.12;
  letter-spacing: 0.03em;
  color: #fff;
  overflow-wrap: anywhere;
}
.gbz-mask { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: 0.06em; }
.gbz-mask > span { display: inline-block; }
.gbz-title::after {
  content: ''; display: block; width: 56px; height: 1px; margin-top: 24px;
  background: var(--gbz-gold); transform-origin: left center;
}
.gbz-tagline { margin: 22px 0 0; max-width: 440px; font-size: 0.95rem; line-height: 1.9; color: var(--gbz-muted); }

/* 倒數 */
.gbz-clock { margin: 34px 0 0; }
.gbz-clock-cap { display: block; margin-bottom: 10px; font-size: 0.7rem; letter-spacing: 0.3em; color: var(--gbz-muted); }
.gbz-clock-cells { display: flex; align-items: flex-start; gap: clamp(8px, 1.4vw, 16px); }
.gbz-clock-cells > div { display: flex; flex-direction: column; align-items: center; min-width: clamp(52px, 5.6vw, 76px); padding: 12px 6px 10px; border: 1px solid rgba(212, 175, 55, 0.32); background: rgba(13, 22, 40, 0.55); backdrop-filter: blur(4px); }
.gbz-clock-cells b { display: block; font-family: var(--font-serif); font-weight: 500; font-size: clamp(1.7rem, 3vw, 2.6rem); line-height: 1; color: var(--gbz-gold); font-variant-numeric: tabular-nums; }
.gbz-clock-cells b.is-tick { animation: gbzTick 0.45s var(--ease, ease); }
.gbz-clock-cells small { margin-top: 8px; font-size: 0.58rem; letter-spacing: 0.24em; text-transform: uppercase; color: var(--gbz-muted); }
.gbz-clock-cells > i { align-self: center; margin-top: -14px; font-style: normal; font-family: var(--font-serif); font-size: 1.4rem; color: rgba(212, 175, 55, 0.55); }
.gbz-clock-ended { display: none; margin-top: 10px; font-size: 0.86rem; color: #f3c9a0; }
.gbz-copy.is-ended .gbz-clock-cells { opacity: 0.4; }
.gbz-copy.is-ended .gbz-clock-ended { display: block; }

.gbz-meta { margin: 16px 0 0; font-size: 0.8rem; letter-spacing: 0.08em; color: var(--gbz-muted); }
.gbz-meta span { margin: 0 4px; }

/* 按鈕 */
.gbz-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.gbz-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 24px; overflow: hidden;
  font: inherit; font-size: 0.84rem; font-weight: 600; letter-spacing: 0.14em; text-decoration: none;
  border: 1px solid var(--gbz-gold); cursor: pointer;
  transition: color 0.4s var(--ease, ease), background-color 0.4s var(--ease, ease), border-color 0.4s;
}
.gbz-btn > * { position: relative; z-index: 1; }
.gbz-btn::before {
  content: ''; position: absolute; inset: 0; z-index: 0;
  transform: scaleX(0); transform-origin: right center;
  transition: transform 0.5s var(--ease, ease);
}
.gbz-btn:hover::before, .gbz-btn:focus-visible::before { transform: scaleX(1); transform-origin: left center; }
.gbz-btn--gold { background: var(--gbz-gold); color: var(--gbz-bg); }
.gbz-btn--gold::before { background: #fff; }
.gbz-btn--gold svg { transition: transform 0.4s var(--ease, ease); }
.gbz-btn--gold:hover svg { transform: translateX(4px); }
.gbz-btn--ghost { background: transparent; color: var(--gbz-gold); }
.gbz-btn--ghost::before { background: rgba(212, 175, 55, 0.14); }
.gbz-btn.is-on { background: transparent; color: var(--gbz-ink); border-color: rgba(246, 241, 227, 0.45); }
.gbz-btn.is-on::before { background: rgba(246, 241, 227, 0.08); }
.gbz-btn:disabled { cursor: progress; opacity: 0.7; }
.gbz-btn:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

/* 同時進行中的其他團、下一團 */
.gbz-more { list-style: none; margin: 30px 0 0; padding: 0; border-top: 1px solid rgba(246, 241, 227, 0.14); }
.gbz-more li { display: flex; align-items: baseline; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(246, 241, 227, 0.1); font-size: 0.85rem; }
.gbz-more-tag { flex: none; font-size: 0.66rem; letter-spacing: 0.18em; color: var(--gbz-gold); }
.gbz-more-tag.is-next { color: var(--gbz-muted); }
.gbz-more-name { flex: 1; min-width: 0; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gbz-more-time { flex: none; font-size: 0.78rem; color: var(--gbz-muted); font-variant-numeric: tabular-nums; }

/* ---------- 商品：三欄視差 ---------- */
.gbz-stage {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(14px, 1.6vw, 24px);
  align-items: start;
  height: clamp(560px, 74vh, 780px);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 9%, #000 91%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 9%, #000 91%, transparent 100%);
}
.gbz-stage--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.gbz-stage--1 { grid-template-columns: minmax(0, 0.7fr); justify-content: center; }
.gbz-col { display: flex; flex-direction: column; gap: clamp(14px, 1.6vw, 24px); will-change: transform; }
.gbz-col:nth-child(2) { padding-top: 96px; }
.gbz-col:nth-child(3) { padding-top: 40px; }
.gbz-stage--1 .gbz-col, .gbz-stage--2 .gbz-col { padding-top: 40px; }

.gbz-card { display: block; color: var(--gbz-ink); text-decoration: none; }
.gbz-card-img {
  position: relative; display: block; overflow: hidden;
  aspect-ratio: 4 / 5; background: rgba(246, 241, 227, 0.05);
}
.gbz-card-img img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transform: scale(1.02);
  transition: transform 1.4s var(--ease, ease), filter 0.6s;
}
.gbz-card:hover .gbz-card-img img, .gbz-card:focus-visible .gbz-card-img img { transform: scale(1.08); }
.gbz-card.is-out .gbz-card-img img { filter: grayscale(0.6) brightness(0.7); }
/* 滑過時內縮的金色細框 */
.gbz-card-img::after {
  content: ''; position: absolute; inset: 8px; pointer-events: none;
  border: 1px solid rgba(212, 175, 55, 0);
  transition: inset 0.6s var(--ease, ease), border-color 0.6s;
}
.gbz-card:hover .gbz-card-img::after, .gbz-card:focus-visible .gbz-card-img::after { inset: 14px; border-color: rgba(212, 175, 55, 0.85); }
.gbz-card-img::before {
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(180deg, rgba(13, 22, 40, 0) 55%, rgba(13, 22, 40, 0.55));
}
.gbz-card-tag {
  position: absolute; left: 12px; top: 12px; z-index: 2;
  padding: 4px 8px; background: rgba(13, 22, 40, 0.82); color: var(--gbz-gold);
  font-size: 0.64rem; font-weight: 600; letter-spacing: 0.14em;
  border: 1px solid rgba(212, 175, 55, 0.5);
}
.gbz-card-no {
  position: absolute; right: 12px; bottom: 10px; z-index: 2;
  font-family: var(--font-serif); font-style: italic; font-size: 0.8rem; color: rgba(255, 255, 255, 0.78);
}
.gbz-card-body { display: flex; flex-direction: column; gap: 4px; padding: 12px 2px 0; }
.gbz-card-name {
  font-size: 0.86rem; line-height: 1.55; color: var(--gbz-ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gbz-card:hover .gbz-card-name { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(212, 175, 55, 0.7); }
.gbz-card-price { font-family: var(--font-serif); font-size: 0.98rem; color: var(--gbz-gold); }
.gbz-card-price s { margin-left: 4px; font-size: 0.78rem; color: var(--gbz-muted); }
.gbz-card:focus-visible { outline: 2px solid var(--gbz-gold); outline-offset: 4px; }

/* ---------- 底部跑馬燈 ---------- */
.gbz-ticker {
  position: absolute; left: 0; right: 0; bottom: 0;
  overflow: hidden; white-space: nowrap;
  border-top: 1px solid var(--gbz-line);
  background: rgba(13, 22, 40, 0.7);
  padding: 14px 0;
}
.gbz-ticker-track { display: inline-flex; animation: gbzTicker 38s linear infinite; }
.gbz-ticker:hover .gbz-ticker-track { animation-play-state: paused; }
.gbz-ticker-set { display: inline-flex; align-items: center; flex: none; }
.gbz-ticker-set > span { padding: 0 18px; font-size: 0.76rem; letter-spacing: 0.32em; text-transform: uppercase; color: var(--gbz-muted); }
.gbz-ticker-set > span:nth-child(4n + 1) { color: var(--gbz-gold); }
.gbz-star { width: 9px; height: 9px; fill: var(--gbz-gold); flex: none; }

/* ---------- 進場動畫（JS 載入後才隱藏，捲到時出現） ---------- */
.gbz-js .gbz-mask > span { transform: translateY(108%); }
.gbz-js .gbz-title::after, .gbz-js .gbz-rule { transform: scaleX(0); }
.gbz-js .gbz-kicker, .gbz-js .gbz-tagline, .gbz-js .gbz-clock, .gbz-js .gbz-meta, .gbz-js .gbz-cta, .gbz-js .gbz-more { opacity: 0; transform: translateY(18px); }
.gbz-js .gbz-card { opacity: 0; transform: translateY(46px); }
.gbz-js.is-in .gbz-mask > span { transform: none; transition: transform 1.1s var(--ease, ease) 0.15s; }
.gbz-js.is-in .gbz-title::after { transform: scaleX(1); transition: transform 1s var(--ease, ease) 0.7s; }
.gbz-js.is-in .gbz-rule { transform: scaleX(1); transition: transform 1.8s var(--ease, ease) 0.1s; }
.gbz-js.is-in .gbz-kicker, .gbz-js.is-in .gbz-tagline, .gbz-js.is-in .gbz-clock, .gbz-js.is-in .gbz-meta, .gbz-js.is-in .gbz-cta, .gbz-js.is-in .gbz-more {
  opacity: 1; transform: none; transition: opacity 0.9s var(--ease, ease), transform 0.9s var(--ease, ease);
}
.gbz-js.is-in .gbz-kicker { transition-delay: 0.05s; }
.gbz-js.is-in .gbz-tagline { transition-delay: 0.45s; }
.gbz-js.is-in .gbz-clock { transition-delay: 0.6s; }
.gbz-js.is-in .gbz-meta { transition-delay: 0.7s; }
.gbz-js.is-in .gbz-cta { transition-delay: 0.8s; }
.gbz-js.is-in .gbz-more { transition-delay: 0.9s; }
.gbz-js.is-in .gbz-card {
  opacity: 1; transform: none;
  transition: opacity 0.9s var(--ease, ease), transform 1.1s var(--ease, ease);
  transition-delay: calc(0.25s + var(--i, 0) * 0.07s);
}

@keyframes gbzPulse {
  0% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.75); }
  70% { box-shadow: 0 0 0 9px rgba(212, 175, 55, 0); }
  100% { box-shadow: 0 0 0 0 rgba(212, 175, 55, 0); }
}
@keyframes gbzTick {
  0% { transform: translateY(-35%); opacity: 0.2; }
  100% { transform: none; opacity: 1; }
}
@keyframes gbzTicker {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-50%, 0, 0); }
}

/* ---------- 平板：上下排列 ---------- */
@media (max-width: 1024px) {
  .gbz-inner { grid-template-columns: minmax(0, 1fr); }
  .gbz-copy { max-width: 640px; }
  .gbz-stage { height: clamp(460px, 62vh, 620px); }
}

/* ---------- 手機：商品改成左右滑動 ---------- */
@media (max-width: 760px) {
  .gbz-inner { gap: 36px; padding-top: 56px; padding-bottom: 92px; }
  .gbz-title { font-size: clamp(1.9rem, 8.4vw, 2.6rem); }
  .gbz-tagline { font-size: 0.9rem; }
  .gbz-clock-cells > div { min-width: 0; flex: 1; padding: 10px 4px 8px; }
  .gbz-clock-cells > i { margin-top: -12px; font-size: 1.1rem; }
  .gbz-cta { flex-direction: column; }
  .gbz-btn { width: 100%; }
  /* 手機：大字放在團名上方的空白處，描邊更淡，不干擾介紹文字 */
  .gbz-giant { font-size: clamp(4.5rem, 26vw, 8rem); top: 9%; }
  .gbz-giant .is-outline { -webkit-text-stroke-color: rgba(212, 175, 55, 0.12); }
  .gbz-stage {
    display: flex; gap: 12px; height: auto;
    margin: 0 -20px; padding: 0 20px 6px;
    overflow-x: auto; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scroll-padding: 0 20px;
    -webkit-mask-image: none; mask-image: none;
    scrollbar-width: none;
  }
  .gbz-stage::-webkit-scrollbar { display: none; }
  .gbz-col { display: contents; }
  .gbz-card { flex: 0 0 64%; scroll-snap-align: start; order: var(--i, 0); }
  .gbz-ticker { padding: 11px 0; }
  .gbz-rule--bottom { bottom: 50px; }
}

/* ---------- 減少動態效果：全部靜止 ---------- */
@media (prefers-reduced-motion: reduce) {
  .gbz-live i { animation: none; }
  .gbz-ticker-track { animation: none; }
  .gbz-clock-cells b.is-tick { animation: none; }
  .gbz-card-img img, .gbz-card-img::after, .gbz-btn::before { transition: none; }
  .gbz-stage { overflow-y: auto; }
}

/* ---------- 本團優惠（折扣、滿額贈、加購） ----------
 * 只用 CSS：沒有模糊濾鏡、沒有捲動計算；滑過只改邊框與位移（只有滑鼠裝置）
 */
.gbz-offers { grid-column: 1 / -1; position: relative; z-index: 2; margin-top: clamp(8px, 2vw, 24px); }
.gbz-offers-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid rgba(246, 241, 227, 0.14); }
.gbz-offers-kicker { margin: 0; font-size: 0.66rem; letter-spacing: 0.32em; text-transform: uppercase; color: var(--gbz-gold); }
.gbz-offers-title { margin: 0; font-family: var(--font-serif); font-size: clamp(1.3rem, 2.2vw, 1.7rem); font-weight: 700; letter-spacing: 0.06em; color: #fff; }
.gbz-offers-note { margin-left: auto; font-size: 0.76rem; letter-spacing: 0.08em; color: var(--gbz-muted); }
.gbz-offers-rail { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1024px) { .gbz-offers-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.gbz-offer {
  position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0;
  padding: 18px 18px 16px;
  background: linear-gradient(160deg, rgba(246, 241, 227, 0.06), rgba(246, 241, 227, 0.015));
  border: 1px solid rgba(212, 175, 55, 0.26);
  transition: border-color 0.4s var(--ease, ease), transform 0.4s var(--ease, ease);
}
/* 上緣金線：滑過時畫出 */
.gbz-offer::before {
  content: ''; position: absolute; left: -1px; right: -1px; top: -1px; height: 2px;
  background: var(--gbz-gold); transform: scaleX(0.18); transform-origin: left center;
  transition: transform 0.5s var(--ease, ease);
}
@media (hover: hover) {
  .gbz-offer:hover { border-color: rgba(212, 175, 55, 0.7); transform: translateY(-3px); }
  .gbz-offer:hover::before { transform: scaleX(1); }
}
.gbz-offer-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; min-height: 28px; }
.gbz-offer-kind { display: inline-flex; align-items: center; gap: 6px; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.22em; color: var(--gbz-gold); }
.gbz-offer.is-gift .gbz-offer-kind { color: #f3c9a0; }
.gbz-offer.is-addon .gbz-offer-kind { color: #b9c8ee; }
.gbz-offer-img { flex: none; width: 44px; height: 44px; object-fit: cover; border: 1px solid rgba(212, 175, 55, 0.35); background: rgba(246, 241, 227, 0.06); }
.gbz-offer-headline { margin: 4px 0 0; line-height: 1.25; color: var(--gbz-ink); }
.gbz-offer-headline span { font-size: 0.9rem; letter-spacing: 0.04em; }
.gbz-offer-headline b { font-family: var(--font-serif); font-weight: 600; font-size: clamp(1.45rem, 2.2vw, 1.75rem); color: var(--gbz-gold); letter-spacing: 0.02em; }
.gbz-offer-title { margin: 0; font-size: 0.86rem; line-height: 1.55; color: #fff; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gbz-offer-meta { margin: auto 0 0; padding-top: 8px; font-size: 0.72rem; line-height: 1.6; color: var(--gbz-muted); }

/* 進場：跟著專區一起淡入（.gbz-js 才隱藏） */
.gbz-js .gbz-offers-head, .gbz-js .gbz-offer { opacity: 0; transform: translateY(18px); }
.gbz-js.is-in .gbz-offers-head { opacity: 1; transform: none; transition: opacity 0.8s var(--ease, ease) 0.5s, transform 0.8s var(--ease, ease) 0.5s; }
.gbz-js.is-in .gbz-offer {
  opacity: 1; transform: none;
  transition: opacity 0.8s var(--ease, ease), transform 0.8s var(--ease, ease), border-color 0.4s var(--ease, ease);
  transition-delay: calc(0.6s + var(--i, 0) * 0.07s), calc(0.6s + var(--i, 0) * 0.07s), 0s;
}

/* 手機：左右滑動 */
@media (max-width: 760px) {
  .gbz-offers-note { margin-left: 0; width: 100%; }
  .gbz-offers-rail {
    display: flex; gap: 10px; margin: 0 -20px; padding: 0 20px 4px;
    overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding: 0 20px;
    scrollbar-width: none;
  }
  .gbz-offers-rail::-webkit-scrollbar { display: none; }
  .gbz-offer { flex: 0 0 74%; scroll-snap-align: start; }
}

@media (prefers-reduced-motion: reduce) {
  .gbz-offer, .gbz-offer::before { transition: none; }
}
