/* ─────────────────────────────────────────────────────────────
   官網 hero 以外的動態（2026-09-30；hero 自 2026-10-01 起在 hero.css／hero.js）
   ② 03「一場比賽怎麼走完」：一支手機、三個步驟、畫面依序切換
   ③ 動態：流程自動播放（捲動相關的動態都在 rhythm.css，原生 scroll-driven）

   原則：
   - 只動 transform／opacity（不觸發排版 ⇒ 不會跳版、手機 Safari 也順）
   - 所有動態都包在 prefers-reduced-motion: no-preference 裡；要求減少動態 ⇒ 靜止、立即切換
   - 捲動顯現的「先藏」只在 html.motion 時成立（index.html 的內嵌腳本加、2.5 秒保險會拿掉）
     ⇒ motion.js 沒載入、被擋、或出錯，內容照樣看得到
   - 不綁架捲動：沒有 scroll-snap 劫持、沒有 preventDefault、沒有固定捲動速度
   ───────────────────────────────────────────────────────────── */

/* ② 流程 ------------------------------------------------------- */
.flow-stage {
  margin-top: var(--space-5);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 320px);
  gap: clamp(32px, 6vw, 96px);
  align-items: center;
}
.flow-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.flow-step {
  position: relative;
  overflow: hidden;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 18px;
  align-items: start;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--duration), border-color var(--duration), box-shadow var(--duration);
}
.flow-step:hover { background: var(--surface); }
.flow-step:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.flow-step[aria-current="step"] {
  background: var(--surface);
  border-color: var(--ink);
  box-shadow: 0 14px 30px -24px rgba(46, 49, 56, .6);
}
.flow-num { font: 400 13px/1.9 var(--mono); color: var(--muted); letter-spacing: .06em; }
.flow-text { display: flex; flex-direction: column; gap: 4px; }
.flow-text strong { font-size: 18px; line-height: 1.5; }
.flow-text small { font-size: 14px; line-height: 1.6; color: var(--muted); }
.flow-soon {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 9px;
  border-radius: var(--pill);
  background: var(--club-tint);
  font: 400 11px/1.8 var(--mono);
  font-style: normal;
  letter-spacing: .06em;
  vertical-align: 2px;
}
.flow-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
}
.flow-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--mustard);
  transform: scaleX(0);
  transform-origin: left center;
}
.flow-phone {
  position: relative;
  width: 100%;
  max-width: 320px;
  justify-self: center;
  aspect-ratio: 603 / 1000; /* 只露出畫面上段：重點都在上面，整支太高 */
  padding: 8px;
  border-radius: 38px;
  background: var(--ink);
  box-shadow: 0 34px 70px -34px rgba(46, 49, 56, .75);
}
.flow-frame {
  position: absolute;
  inset: 8px;
  margin: 0;
  overflow: hidden;
  border-radius: 30px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .55s var(--ease), visibility 0s linear .55s;
}
.flow-frame.is-active {
  opacity: 1;
  visibility: visible;
  transition: opacity .55s var(--ease), visibility 0s;
}
.flow-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}
.flow-note {
  margin: var(--space-4) 0 0;
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
  max-width: 60ch;
}
/* 沒有 JS：三張並排、全部看得到（沒有切換可言） */
html:not(.js) .flow-phone {
  aspect-ratio: auto;
  max-width: none;
  padding: 0;
  background: none;
  box-shadow: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
html:not(.js) .flow-frame { position: static; opacity: 1; visibility: visible; border-radius: 18px; }
html:not(.js) .flow-frame img { height: auto; }

@media (max-width: 900px) {
  .flow-stage { grid-template-columns: 1fr; gap: var(--space-3); }
  .flow-steps { flex-direction: row; gap: 8px; }
  .flow-steps li { flex: 1 1 0; min-width: 0; }
  .flow-step { grid-template-columns: 1fr; padding: 12px 12px 14px; gap: 2px; height: 100%; }
  .flow-text strong { font-size: 14px; }
  .flow-text small { display: none; }
  .flow-soon { display: block; width: fit-content; margin: 4px 0 0; }
  .flow-phone { max-width: min(78vw, 300px); }
}

/* ③ 動態 ------------------------------------------------------- */
@keyframes sbalt-bar {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: no-preference) {
  /* (c) 流程自動播放：進度條跑完 ⇒ motion.js 換下一步（animationend） */
  .motion .flow-stage.is-playing .flow-step[aria-current="step"] .flow-bar::after {
    animation: sbalt-bar var(--flow-ms, 3800ms) linear forwards;
  }
  .motion .flow-stage.is-paused .flow-step[aria-current="step"] .flow-bar::after {
    animation-play-state: paused;
  }
  .flow-frame img { transition: transform 1.2s var(--ease); transform: scale(1.03); }
  .flow-frame.is-active img { transform: none; }
}
