/* 류진의 시계방 타로 — 섞기·끊기·펼치기·고르기·뒤집기 (public/js/tarot-table.js?v=c49e27df)
 * 움직임은 transform·opacity 만 쓴다(60fps). prefers-reduced-motion 이면 회전·비행을 끈다. */
.tt {
  --tt-brass: #f0cf85; --tt-brass-d: #b8873a; --tt-teal: #0c1d22; --tt-ink: rgba(255, 255, 255, .78);
  --tt-cw: 70px; --tt-ch: 110px;
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: stretch;
  padding: calc(env(safe-area-inset-top, 0px) + 60px) 0 calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: radial-gradient(90% 46% at 50% 40%, rgba(240, 207, 133, .1), transparent 70%), linear-gradient(180deg, rgba(6, 16, 19, .62), rgba(3, 9, 11, .9) 72%);
  overflow-x: hidden; overflow-y: auto; scrollbar-width: none; text-align: center; color: #fff;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.tt::-webkit-scrollbar { display: none; }
.tt-head { padding: 0 20px; }
.tt-steps { display: flex; justify-content: center; gap: 6px; margin: 0 0 12px; padding: 0; list-style: none; }
.tt-steps li { font: 700 11px/1 var(--g-sans); color: rgba(255, 255, 255, .38); padding: 6px 10px; border-radius: 999px; border: 1px solid rgba(240, 207, 133, .14); }
.tt-steps li.on { color: #10181a; background: var(--tt-brass); border-color: var(--tt-brass); }
.tt-steps li.done { color: var(--tt-brass); border-color: rgba(240, 207, 133, .4); }
.tt-title { margin: 0; font: 700 clamp(21px, 6.2vw, 27px)/1.32 var(--g-serif); color: #fff; text-shadow: 0 3px 20px rgba(0, 0, 0, .8); word-break: keep-all; }
.tt-note { margin: 8px auto 0; max-width: 340px; min-height: 20px; font: 13.5px/1.6 var(--g-sans); color: rgba(255, 255, 255, .66); word-break: keep-all; }

.tt-table { position: relative; flex: 1 0 auto; min-height: 230px; display: flex; align-items: center; justify-content: center; }
.tt-foot { padding: 6px 20px 0; }
.tt-status { margin: 0 0 10px; min-height: 18px; font: 600 13px/1.4 var(--g-sans); color: var(--tt-brass); }
.tt-btn {
  width: 100%; max-width: 360px; min-height: 54px; border: 0; border-radius: 14px; cursor: pointer;
  font: 800 16px/1 var(--g-sans); color: #10181a; letter-spacing: -.01em;
  background: linear-gradient(180deg, #f6dc9c, #d6a650); box-shadow: 0 10px 30px rgba(214, 166, 80, .28), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.tt-btn[hidden] { display: none; }
.tt-btn:disabled { opacity: .55; }

/* 카드 한 장 — 뒷면과 앞면을 3D 로 뒤집는다. 역방향은 앞면 그림만 180도 돌린다. */
.tt-card { position: relative; width: var(--tt-cw); height: var(--tt-ch); perspective: 900px; }
.tt-inner { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .7, .2, 1); }
.tt-back, .tt-face { position: absolute; inset: 0; border-radius: 9px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; box-shadow: 0 8px 22px rgba(0, 0, 0, .55); }
.tt-back { background: var(--tt-teal) center/cover no-repeat; }
.tt-face { transform: rotateY(180deg); background: var(--tt-teal); }
.tt-face img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s ease .55s; }
.tt-card.is-open .tt-inner { transform: rotateY(180deg); }
.tt-card.is-open.is-rev .tt-face img { transform: rotate(180deg); }

/* 1) 섞기 */
.tt-stack { position: relative; width: 210px; height: 210px; border: 0; padding: 0; background: none; cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent; border-radius: 50%; }
.tt-stack:focus-visible { outline: 2px solid var(--tt-brass); outline-offset: 4px; }
.tt-stack .tt-sh { position: absolute; left: 50%; top: 50%; --tt-cw: 92px; --tt-ch: 144px; will-change: transform; transition: transform .35s ease; }
.tt-stack.is-hold .tt-sh { transition: none; }
.tt-stack.is-hold { cursor: grabbing; }
.tt-ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); pointer-events: none; }
.tt-ring circle { fill: none; stroke: rgba(240, 207, 133, .14); stroke-width: 3; }
.tt-ring .tt-ring-v { stroke: var(--tt-brass); stroke-linecap: round; transition: stroke-dashoffset .08s linear; filter: drop-shadow(0 0 6px rgba(240, 207, 133, .6)); }
.tt-stack.is-done .tt-ring { opacity: 0; transition: opacity .4s; }

/* 2) 끊기 */
.tt-piles { display: flex; gap: 14px; align-items: flex-end; justify-content: center; }
.tt-pile { position: relative; width: 84px; height: 150px; border: 0; padding: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
  transform: translateX(calc((1 - var(--d)) * 98px)); transition: transform .55s cubic-bezier(.2, .8, .2, 1) calc(var(--d) * 60ms), opacity .4s; }
.tt-piles.is-split .tt-pile { transform: none; }
.tt-pile .tt-pc { position: absolute; left: 0; top: 0; --tt-cw: 84px; --tt-ch: 132px; }
.tt-pile .tt-pc:nth-child(2) { transform: translate(1px, -2px); }
.tt-pile .tt-pc:nth-child(3) { transform: translate(2px, -4px); }
.tt-pile .tt-pc:nth-child(4) { transform: translate(3px, -6px); }
.tt-pile .tt-pc:nth-child(5) { transform: translate(4px, -8px); }
.tt-pile .tt-pc:nth-child(6) { transform: translate(5px, -10px); }
.tt-pile .tt-pc:nth-child(7) { transform: translate(6px, -12px); }
.tt-pile span { position: absolute; left: 0; right: 0; bottom: 0; font: 700 12px/1 var(--g-sans); color: rgba(255, 255, 255, .55); }
.tt-pile:focus-visible { outline: 2px solid var(--tt-brass); outline-offset: 6px; border-radius: 10px; }
.tt-piles.is-chosen .tt-pile:not(.is-pick) { opacity: .25; transform: translateY(16px); }
.tt-pile.is-pick { transform: translateY(-26px) scale(1.06); }

/* 3) 펼치기·고르기 — 가로로 밀리는 부채꼴. 칸 위치는 --k(순번)로, 휘는 각도는 스크롤에 맞춰 JS 가 매긴다. */
.tt-fan { position: relative; width: 100%; height: 220px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; opacity: 0; transition: opacity .45s; }
.tt-fan::-webkit-scrollbar { display: none; }
.tt.is-fan-in .tt-fan { opacity: 1; }
.tt-track { position: relative; height: 100%; width: calc((var(--n) - 1) * 24px + 100%); }
.tt-fc { position: absolute; top: 34px; left: calc(50% - (var(--n) - 1) * 12px - var(--tt-cw) / 2 + var(--k) * 24px); width: var(--tt-cw); height: var(--tt-ch);
  border: 0; padding: 0; background: none; cursor: pointer; transform-origin: 50% 160%; will-change: transform; -webkit-tap-highlight-color: transparent; }
.tt-fc span { position: absolute; inset: 0; border-radius: 8px; background: var(--tt-teal) center/cover no-repeat; box-shadow: -4px 4px 12px rgba(0, 0, 0, .55); transition: transform .18s ease, box-shadow .18s; }
.tt-fc:hover span, .tt-fc:focus-visible span { transform: translateY(-14px); box-shadow: 0 0 0 2px var(--tt-brass), 0 10px 22px rgba(0, 0, 0, .6); }
.tt-fc.is-gone { visibility: hidden; pointer-events: none; }

/* 자리 칸 — 고르는 동안엔 아래에 작게, 뒤집을 땐 크게 */
.tt-slots { display: none; justify-content: center; gap: 10px; padding: 8px 14px 4px; }
.tt.is-fan .tt-slots, .tt.is-flip .tt-slots { display: flex; }
.tt-slot { flex: 0 0 auto; width: 74px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tt-slot-card { width: 58px; height: 91px; border-radius: 8px; border: 1px dashed rgba(240, 207, 133, .4); display: flex; align-items: center; justify-content: center; }
.tt-slot.is-filled .tt-slot-card { border-color: transparent; }
.tt-slot-card .tt-card { --tt-cw: 58px; --tt-ch: 91px; }
.tt-slot b { font: 800 12px/1.2 var(--g-sans); color: var(--tt-brass); margin-top: 4px; }
.tt-slot small { display: none; font: 11px/1.35 var(--g-sans); color: rgba(255, 255, 255, .5); word-break: keep-all; }
.tt-cap { display: none; }

.tt.is-flip .tt-table { display: none; }
.tt.is-flip .tt-slots { flex: 1 0 auto; align-items: flex-start; padding-top: 18px; gap: 8px; }
.tt.is-flip .tt-slot { width: calc((100% - 16px) / 3); max-width: 132px; }
.tt.is-flip .tt-slot-card { width: 100%; height: auto; aspect-ratio: 2 / 3; border: 0; }
.tt.is-flip .tt-slot-card .tt-card { --tt-cw: 100%; --tt-ch: 100%; width: 100%; height: 100%; cursor: pointer; }
.tt.is-flip .tt-slot small { display: block; }
.tt.is-flip .tt-cap { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 52px; margin-top: 4px; }
.tt-cap strong { font: 700 14px/1.25 var(--g-serif); color: #fff; word-break: keep-all; }
.tt-cap em { font: 800 10.5px/1 var(--g-sans); font-style: normal; color: #9fe3ee; padding: 3px 7px; border-radius: 999px; border: 1px solid rgba(159, 227, 238, .45); }
.tt-cap em.rev { color: #ffcf8a; border-color: rgba(255, 207, 138, .55); }
.tt-cap span { font: 12px/1.35 var(--g-sans); color: rgba(255, 255, 255, .7); word-break: keep-all; }
.tt-slot.is-next .tt-card:not(.is-open) .tt-back { box-shadow: 0 0 0 2px var(--tt-brass), 0 0 26px rgba(240, 207, 133, .55); animation: ttPulse 1.6s ease-in-out infinite; }
@keyframes ttPulse { 50% { box-shadow: 0 0 0 2px var(--tt-brass), 0 0 8px rgba(240, 207, 133, .2); } }

.tt-explain { display: none; margin: 4px 16px 6px; padding: 12px 14px; text-align: left; border-radius: 14px; background: rgba(12, 29, 34, .78); border: 1px solid rgba(240, 207, 133, .2); }
.tt.is-explain .tt-explain { display: block; animation: ttRise .5s ease both; }
.tt-explain p { margin: 0; padding: 7px 0; display: flex; gap: 10px; font: 13.5px/1.55 var(--g-sans); color: var(--tt-ink); word-break: keep-all; border-top: 1px solid rgba(255, 255, 255, .06); }
.tt-explain p:first-child { border-top: 0; }
.tt-explain b { flex: 0 0 34px; color: var(--tt-brass); font-weight: 800; }
.tt-explain strong { color: #fff; }
@keyframes ttRise { from { opacity: 0; transform: translateY(10px); } }

@media (max-height: 700px) {
  .tt { padding-top: calc(env(safe-area-inset-top, 0px) + 52px); }
  .tt-steps { margin-bottom: 8px; }
  .tt-table { min-height: 200px; }
  .tt-fan { height: 196px; }
  .tt-fc { top: 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .tt-inner, .tt-face img, .tt-pile, .tt-fan, .tt-stack .tt-sh, .tt-fc span { transition: none !important; }
  .tt-slot.is-next .tt-card:not(.is-open) .tt-back, .tt.is-explain .tt-explain { animation: none !important; }
}
