/* 구독자 소개 페이지의 움직임 — index.html 의 body.motion 에만 걸린다(정책·계정 삭제 페이지는 styles.css 만 쓴다).
   첫 화면 장면: 감열지 명세서가 프린터에서 한 줄씩 인쇄되어 찢겨 나오고, 사흘 뒤 결제할 줄에 형광펜이 지나가고,
   운동 앱 줄이 지워지며 「해지」 도장이 찍히고, 지킨 돈이 한 번 튄다. 12초 한 바퀴. 스크립트 없이 CSS 로만 움직인다.
   종이 페이지라 떠다니는 빛은 쓰지 않는다 — 장식은 프린터 입구 하나뿐. */

:root:has(> body.motion), .motion { overflow-x: clip; }

/* 첫 화면 글: 제목 줄마다 → 소개 → 이용 조건 → 단추 */
.motion .hero h1 .line { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: .06em; }
.motion .hero h1 .line > span { display: inline-block; animation: subscribers-rise .9s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(.1s + var(--l) * .14s); }
.motion .hero-copy, .motion .hero-facts, .motion .hero .actions { animation: subscribers-fade .8s ease both; }
.motion .hero-copy { animation-delay: .4s; }
.motion .hero-facts { animation-delay: .55s; }
.motion .hero .actions { animation-delay: .7s; }
@keyframes subscribers-rise { from { transform: translateY(105%); } }
@keyframes subscribers-fade { from { opacity: 0; transform: translateY(14px); } }

/* ── 장면 ─────────────────────────────────────────────
   멈춘 모습(기본값)이 완성된 명세서다. 키프레임은 0% 에서 빈 상태로 시작해 차례로 채운다. */
.motion .receipt-wrap { --loop: 12s; position: relative; }

/* 프린터 입구 — 인쇄하는 동안만 보이고, 명세서를 찢고 나면 사라진다. 멈춘 모습에서는 숨는다 */
.motion .sub-printer {
  position: absolute; z-index: 1; top: -.55rem; left: -.6rem; right: -.6rem; height: 1.1rem; border-radius: 999px;
  background: var(--ink); box-shadow: inset 0 -.3rem 0 var(--ink-soft), 0 8px 14px -8px rgba(28, 27, 23, .45);
  opacity: 0; animation: subscribers-printer var(--loop) ease infinite;
}
.motion .sub-printer::after { content: ""; position: absolute; left: 6%; right: 6%; top: 45%; height: 2px; border-radius: 2px; background: var(--muted); }
@keyframes subscribers-printer { 0%, 26% { opacity: 1; transform: none; } 32%, 94% { opacity: 0; transform: translateY(-6px); } 100% { opacity: 1; transform: none; } }

/* 1) 인쇄 — 위에서부터 한 줄씩 나오고(곧게), 다 나오면 찢겨 비스듬히 놓인다 */
.motion .receipt { animation: subscribers-print var(--loop) infinite both; }
@keyframes subscribers-print {
  0% { clip-path: inset(-2rem -2rem 100% -2rem); transform: rotate(0deg) translateY(-.3rem); opacity: 1; animation-timing-function: linear; }
  22% { clip-path: inset(-2rem -2rem -3rem -2rem); transform: rotate(0deg) translateY(-.3rem); animation-timing-function: cubic-bezier(.3, 1.4, .5, 1); }
  28%, 92% { clip-path: inset(-2rem -2rem -3rem -2rem); transform: rotate(-1.5deg); opacity: 1; }
  97%, 100% { clip-path: inset(-2rem -2rem -3rem -2rem); transform: rotate(-1.5deg) translateY(.6rem); opacity: 0; }
}

/* 2) 결제 3일 전 — 사흘 뒤 결제할 줄에 형광펜이 왼쪽부터 지나간다 */
.motion .receipt-lines .soon { background-repeat: no-repeat; background-position: left center; animation: subscribers-marker var(--loop) ease-out infinite both; }
@keyframes subscribers-marker { 0%, 32% { background-size: 0% 100%; } 39%, 100% { background-size: 100% 100%; } }
.motion .receipt-lines .soon .when { animation: subscribers-ask var(--loop) ease infinite both; }
@keyframes subscribers-ask { 0%, 36% { color: var(--muted); font-weight: 400; } 40%, 100% { color: var(--ink-soft); font-weight: 700; } }

/* 3) 결제 전에 해지 — 운동 앱 줄이 흐려지며 그어지고, 도장이 찍힌다 */
.motion .receipt-lines .cancelled .name, .motion .receipt-lines .cancelled .amount { animation: subscribers-strike var(--loop) ease infinite both; }
@keyframes subscribers-strike {
  0%, 46% { color: var(--ink); text-decoration-color: transparent; }
  52%, 100% { color: var(--muted); text-decoration-color: var(--muted); }
}
.motion .receipt-lines .cancelled .when { animation: subscribers-when var(--loop) ease infinite both; }
@keyframes subscribers-when { 0%, 46% { opacity: 0; } 52%, 100% { opacity: 1; } }
.motion .stamp { animation: subscribers-stamp var(--loop) cubic-bezier(.2, 1.4, .4, 1) infinite both; }
@keyframes subscribers-stamp {
  0%, 53% { transform: rotate(-11deg) scale(1.8); opacity: 0; }
  57%, 100% { transform: rotate(-11deg) scale(1); opacity: .9; }
}

/* 4) 지킨 돈 — 도장이 찍히고 나면 아래 합계의 지킨 돈이 한 번 튄다 */
.motion .receipt-total .saved { display: inline-block; transform-origin: right center; animation: subscribers-saved var(--loop) ease infinite both; }
@keyframes subscribers-saved { 0%, 60% { transform: none; } 64% { transform: scale(1.3); } 69%, 100% { transform: none; } }

/* 아래 구역은 화면에 들어올 때 떠오른다 (스크롤 타임라인을 아는 브라우저만) */
@supports (animation-timeline: view()) {
  .motion main > .section { animation: subscribers-fade linear both; animation-timeline: view(); animation-range: entry 0% entry 40%; }
}

/* 동작 줄이기 — 움직임을 모두 멈추고 완성된 명세서(기본값)를 세운다 */
@media (prefers-reduced-motion: reduce) {
  .motion *, .motion *::before, .motion *::after { animation: none !important; }
  .motion .sub-printer { display: none; }
}
