/* AI 廣告參考：直式短片卡片輪播（#reel） */

:root[data-tone="reel-coffee"] { --tone-a: #9fd3f2; --tone-b: #c98a4b; }
:root[data-tone="reel-tea"] { --tone-a: #b9d39a; --tone-b: #e2bf7c; }
:root[data-tone="reel-noodle"] { --tone-a: #ff9f63; --tone-b: #b8432f; }
:root[data-tone="reel-serum"] { --tone-a: #f2b8c6; --tone-b: #e6cfa8; }
:root[data-tone="reel-earbuds"] { --tone-a: #a78bfa; --tone-b: #22d3ee; }
:root[data-tone="reel-inn"] { --tone-a: #ffb27a; --tone-b: #7cc4e8; }

main > section.reel { padding-bottom: 96px; overflow: hidden; }

.reel-stage { position: relative; }
.reel-stage::before {
  content: "";
  position: absolute;
  inset: 0 45% 10% 0;
  z-index: -1;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--tone-a) 22%, transparent), transparent);
  pointer-events: none;
}

.reel-track {
  --cw: clamp(232px, 23vw, 318px);
  --gap: clamp(14px, 2.2vw, 32px);
  /* The playing card lines up with the page content; the queue runs off to the right */
  --pad: max(24px, calc((100% - var(--max)) / 2));
  position: relative;
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  overflow-y: hidden;
  padding: 26px calc(100% - var(--pad) - var(--cw)) 18px var(--pad);
  scroll-padding-inline-start: var(--pad);
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--pad), #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--pad), #000 90%, transparent);
}
.reel-track::-webkit-scrollbar { display: none; }
.reel-track:focus-visible { outline: none; }

.reel-card {
  --d: 0;
  --cd: 0;
  --ad: 0;
  --dur: 7.5s;
  position: relative;
  z-index: var(--z, 1);
  flex: 0 0 var(--cw);
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  scroll-snap-align: start;
  opacity: var(--op, 1);
  transform: perspective(1300px) translateX(var(--tx, 0px)) translateZ(calc(var(--ad) * -70px)) rotateY(calc(var(--cd) * -18deg));
  transform-origin: 0% 46%;
}
.reel-card:focus-visible { outline: none; }
.reel-card:focus-visible .reel-frame { box-shadow: 0 0 0 2px var(--tone-a), 0 30px 60px -24px rgba(0, 0, 0, .8); }

.reel-frame {
  position: relative;
  display: block;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border-radius: 22px;
  background: #16120f;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .08), 0 34px 70px -28px rgba(0, 0, 0, .85);
  container-type: inline-size;
  isolation: isolate;
}
.reel-frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.04);
  transform-origin: var(--kb-o, 50% 62%);
}
.reel-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  background: #0b0a09;
  opacity: calc(var(--ad) * .3);
  pointer-events: none;
}

.reel-ui {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  color: #fff;
  pointer-events: none;
}
.reel-ui::before,
.reel-ui::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  pointer-events: none;
}
.reel-ui::before { top: 0; height: 30%; background: linear-gradient(rgba(0, 0, 0, var(--scrim-top, .34)), transparent); }
.reel-ui::after { bottom: 0; height: 30%; background: linear-gradient(transparent, rgba(0, 0, 0, .5)); }
.reel-ui > * { position: absolute; z-index: 1; }

.reel-bar {
  opacity: 0;
  transition: opacity .4s;
  top: 3.6cqw;
  left: 4.4cqw;
  right: 4.4cqw;
  display: block;
  height: 3px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, .26);
}
.reel-bar i {
  display: block;
  height: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
}
.reel-chip,
.reel-ai {
  top: 7.6cqw;
  display: block;
  padding: .3em .9em;
  border-radius: 999px;
  background: rgba(12, 10, 9, .4);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: max(10px, 3.6cqw);
  line-height: 1.5;
  letter-spacing: .06em;
  white-space: nowrap;
}
.reel-chip { left: 4.4cqw; }
.reel-ai { right: 4.4cqw; color: rgba(255, 255, 255, .86); }

/* Headline: each line rises in when the card starts playing (no clipping box, so the shadow stays soft) */
.reel-title {
  top: 20%;
  left: 8cqw;
  right: 8cqw;
  display: block;
  font-family: var(--font-serif);
  font-size: 10.6cqw;
  font-weight: 700;
  line-height: 1.24;
  letter-spacing: .04em;
  text-shadow: 0 2px 20px rgba(0, 0, 0, .3);
}
.reel-title .ln { display: block; }
.reel-title .ln > span { display: inline-block; }
.js .reel-title .ln > span { opacity: 0; transform: translateY(.55em); }

/* Burned-in subtitles: two lines take turns */
.reel-subs {
  left: 6cqw;
  right: 6cqw;
  bottom: 8cqw;
  display: block;
  height: 2.2em;
  font-size: max(11px, 4.6cqw);
  text-align: center;
}
.reel-subs span {
  position: absolute;
  inset: auto 0 0;
  display: block;
  font-weight: 500;
  letter-spacing: .06em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .7), 0 0 14px rgba(0, 0, 0, .45);
}
.js .reel-subs span { opacity: 0; }
html:not(.js) .reel-subs span + span { display: none; }

/* Caption under each frame */
.reel-meta {
  display: block;
  margin-top: 16px;
  padding-inline: 4px;
  opacity: calc(1 - var(--ad) * .55);
}
.reel-name {
  display: block;
  font-family: var(--font-serif);
  font-size: 1.04rem;
  font-weight: 600;
  line-height: 1.4;
}
.reel-fmt {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: .04em;
}
.reel-shots {
  display: block;
  margin-top: 8px;
  color: var(--faint);
  font-size: .76rem;
  line-height: 1.6;
  opacity: 0;
  transition: opacity .5s var(--ease);
}
.reel-card.is-active .reel-shots,
.reel-card.is-active .reel-bar { opacity: 1; }

/* Playing: Ken Burns push-in, progress bar, headline, subtitles */
.reel-card.is-active .reel-frame img { animation: reel-kb var(--dur) linear both; will-change: transform; }
.reel-card.is-active .reel-bar i { animation: reel-bar var(--dur) linear both; }
.reel-card.is-active .reel-title .ln > span { animation: reel-line 1.1s var(--ease) both; animation-delay: calc(.3s + var(--i, 0) * .16s); }
.reel-card.is-active .reel-subs span:first-child { animation: reel-sub-a var(--dur) linear both; }
.reel-card.is-active .reel-subs span + span { animation: reel-sub-b var(--dur) linear both; }
.reel:not(.is-playing) .reel-card.is-active .reel-frame img,
.reel:not(.is-playing) .reel-card.is-active .reel-bar i,
.reel:not(.is-playing) .reel-card.is-active .reel-title .ln > span,
.reel:not(.is-playing) .reel-card.is-active .reel-subs span { animation-play-state: paused; }

@keyframes reel-kb {
  from { transform: scale(1.04) translate3d(0, 0, 0); }
  to { transform: scale(var(--kb-s, 1.15)) translate3d(var(--kb-x, 0%), var(--kb-y, -1.5%), 0); }
}
@keyframes reel-bar { to { transform: scaleX(1); } }
@keyframes reel-line { to { opacity: 1; transform: none; } }
@keyframes reel-sub-a {
  0%, 16% { opacity: 0; transform: translateY(6px); }
  20%, 52% { opacity: 1; transform: none; }
  55%, 100% { opacity: 0; transform: none; }
}
@keyframes reel-sub-b {
  0%, 55% { opacity: 0; transform: translateY(6px); }
  59%, 95% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: none; }
}

/* Per-ad art direction */
.reel-card[data-id="coffee"],
.reel-card[data-id="tea"],
.reel-card[data-id="serum"],
.reel-card[data-id="inn"] { --scrim-top: .14; }
.reel-card[data-id="coffee"] .reel-title { color: #12304a; text-shadow: 0 0 22px rgba(255, 255, 255, .45); }
.reel-card[data-id="tea"] .reel-title {
  top: 12%;
  color: #24302a;
  text-shadow: 0 0 18px rgba(255, 255, 255, .5);
  left: auto;
  right: 9cqw;
  writing-mode: vertical-rl;
  font-size: 11.5cqw;
  letter-spacing: .16em;
}
.js .reel-card[data-id="tea"] .reel-title .ln > span { transform: translateY(-.55em); }
.reel-card[data-id="noodle"] .reel-title { top: 13%; color: #fff4e6; font-size: 11.4cqw; }
.reel-card[data-id="serum"] .reel-title { top: 15%; color: #5b4148; font-weight: 600; text-shadow: none; text-align: center; }
.reel-card[data-id="earbuds"] .reel-title { top: 14%; font-family: var(--font-sans); font-weight: 700; font-size: 10cqw; letter-spacing: .02em; }
.reel-card[data-id="inn"] .reel-title { top: 15%; color: #22304a; font-weight: 600; text-align: center; text-shadow: 0 0 22px rgba(255, 255, 255, .5); }

/* Controls */
.reel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
  flex-wrap: wrap;
}
.reel-aside {
  display: flex;
  align-items: center;
  gap: 14px 24px;
  flex-wrap: wrap;
}
.reel-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.reel-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(255, 255, 255, .02);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .25s, color .25s, transform .25s var(--ease);
}
.reel-btn:hover { border-color: var(--tone-a); color: var(--tone-a); }
.reel-btn:active { transform: scale(.94); }
.reel-count {
  min-width: 64px;
  color: var(--faint);
  font-family: var(--font-display);
  font-size: .84rem;
  letter-spacing: .12em;
  text-align: center;
}
.reel-count b { color: var(--ink); font-weight: 700; }
.reel-controls .demo-toggle { margin-left: 6px; }
.reel-note {
  max-width: 460px;
  color: var(--faint);
  font-size: .82rem;
}

@media (max-width: 720px) {
  main > section.reel { padding-bottom: 72px; }
  .reel-track {
    --cw: min(64vw, 300px);
    --gap: 14px;
    padding-top: 18px;
  }
  .reel-track { --pad: 16px; }
  .reel-card { transform: perspective(1000px) translateX(var(--tx, 0px)) translateZ(calc(var(--ad) * -50px)) rotateY(calc(var(--cd) * -12deg)); }
  .reel-foot { flex-direction: column-reverse; align-items: stretch; }
  .reel-controls { justify-content: center; }
}
