/* 절취선에서 뜯기는 티켓. 같은 그림을 위아래 두 조각으로 겹쳐 두고, 다 그어지면 아래 조각이 화면 밖으로 나간다 */
.tearbox .art { position: relative; width: 343px; max-width: 100%; height: 430px; }
.tearbox .half { position: absolute; inset: 0; transition: transform .6s cubic-bezier(.3, 1.25, .5, 1), opacity .4s ease; }
.tearbox .half svg { display: block; }
.tearbox .half.top { clip-path: inset(0 0 262px 0); }
.tearbox .half.bottom { clip-path: inset(168px 0 0 0); transform-origin: var(--ox, 0%) 168px; }
/* 종이 찢기: 그은 데까지만 손끝을 축으로 접혀 처진다. 긋지 않은 쪽은 제자리에 붙어 있다 */
.tearbox .half.flap { clip-path: inset(168px calc(100% - var(--cut)) 0 0); transform-origin: var(--cut) 168px; transform: rotate(var(--ang)); transition: transform .22s cubic-bezier(.3, 1.4, .5, 1); }
.tearbox .art.flap-left .half.bottom { clip-path: inset(168px 0 0 var(--cut)); }
.tearbox .art.flap-right .half.bottom { clip-path: inset(168px calc(100% - var(--cut)) 0 0); }
.tearbox .art.flap-right .half.flap { clip-path: inset(168px 0 0 var(--cut)); }
/* 뜯긴 아래 조각은 그대로 미끄러져 화면 밖으로 나가고, 위 조각은 남는다. 다 나간 뒤에는 제자리에서 숨겨 두어 페이지가 길어지지 않는다 */
.tearbox .art.torn .half.bottom { animation: tear-out-bottom .8s cubic-bezier(.5, 0, .9, .5) forwards; }
@keyframes tear-out-bottom { 0% { transform: rotate(var(--from, 0deg)); } 99.9% { transform: translateY(110vh) rotate(var(--rot, 1.4deg)); visibility: visible; } 100% { transform: none; visibility: hidden; } }
/* 남은 위 조각은 아래로 내려가 창 밑에 놓인다. 놓이는 자리와 각도는 정해진 범위 안에서 그때그때 다르다(--sx, --sy, --sr) */
.tearbox .half.top { transform-origin: 50% 84px; }
.tearbox .art.torn .half.top { translate: var(--sx, 0px) calc(var(--drop, 262px) + var(--sy, 0px)); transform: rotate(var(--sr, 0deg)); transition: translate .75s cubic-bezier(.3, 1.15, .4, 1) .12s, filter .9s ease; }
.tearbox .half.top { transition: translate .6s cubic-bezier(.3, 1.25, .5, 1), transform .2s ease-out, filter .9s ease; }
/* 돌아올 때는 아래에서 다시 들어와 붙는다 */
.tearbox .art.back .half.bottom { animation: tear-in-bottom .7s cubic-bezier(.2, .9, .3, 1); }
@keyframes tear-in-bottom { from { transform: translateY(110vh); } }
.tearbox.tearing { touch-action: none; cursor: crosshair; }
/* 긋는 동안의 효과. 카드 밖으로 튀는 것까지 그리도록 카드보다 넓게 깐다 */
.spark { position: absolute; left: -70px; top: -70px; z-index: 3; pointer-events: none; }
/* 접힌 자리: 처진 조각에 접힌 선과 그늘을 넣어 종이가 꺾인 것으로 읽히게 한다 */
.tearbox .half.flap::after {
  content: ""; position: absolute; top: 168px; bottom: 0; left: 0; width: var(--cut); pointer-events: none;
  background: linear-gradient(to left, rgba(10, 14, 28, .08), rgba(10, 14, 28, .03) 26px, rgba(10, 14, 28, 0) 90px), linear-gradient(to bottom, rgba(10, 14, 28, .05), rgba(10, 14, 28, 0) 10px);
}
.tearbox .half.flap::before {
  content: ""; position: absolute; z-index: 1; top: 168px; bottom: 0; left: calc(var(--cut) - 1px); width: 1px; pointer-events: none;
  background: rgba(255, 255, 255, .22); box-shadow: -1px 0 0 rgba(10, 14, 28, .07);
}
.tearbox .art.flap-right .half.flap::after {
  left: var(--cut); right: 0; width: auto;
  background: linear-gradient(to right, rgba(10, 14, 28, .08), rgba(10, 14, 28, .03) 26px, rgba(10, 14, 28, 0) 90px), linear-gradient(to bottom, rgba(10, 14, 28, .05), rgba(10, 14, 28, 0) 10px);
}
.tearbox .art.flap-right .half.flap::before { left: var(--cut); box-shadow: 1px 0 0 rgba(10, 14, 28, .07); }
/* 붙어 있는 쪽에도 접힌 선 바로 옆에 옅은 그늘이 진다 */
.tearbox .art.flap-left .half.bottom::after, .tearbox .art.flap-right .half.bottom::after {
  content: ""; position: absolute; top: 168px; bottom: 0; left: var(--cut); width: 18px; pointer-events: none;
  background: linear-gradient(to right, rgba(10, 14, 28, .05), rgba(10, 14, 28, 0));
}
.tearbox .art.flap-right .half.bottom::after { left: calc(var(--cut) - 18px); background: linear-gradient(to left, rgba(10, 14, 28, .05), rgba(10, 14, 28, 0)); }
/* 날아가는 카드: 화면 위에 따로 띄워 움직인다 */
.flyer { position: fixed; z-index: 50; pointer-events: none; }
.flyer .face { position: absolute; inset: 0; }
.flyer svg { display: block; width: 100%; height: 100%; }
