/* 손으로 뽑는 78장 타로(류진 시계방 · 윤슬 달빛) — 섞기·끊기·펼치기·고르기·뒤집기 (public/js/tarot-table.js?v=3fc7ec69)
 * Orun 기본 팔레트는 검정 패널·아이보리·황동(사이트 톤)이다. 색은 .tt 의 변수로만 쓴다 — 덱 그림 묶음(GATE.tarotArt)마다 .tt-<art> 가 변수를 덮는다(.tt-moon: 은·남색). 다섯 장 배열은 data-n="5".
 * 움직임은 transform·opacity 만 쓴다(60fps). prefers-reduced-motion 이면 회전·비행을 끈다. */
.tt {
  --tt-brass: #f0cf85; --tt-brass-d: #b8873a; --tt-teal: #141214; --tt-ink: rgba(255, 255, 255, .78); --tt-glow: 240, 207, 133; --tt-on: #121012;
  --tt-btn: linear-gradient(180deg, #f6dc9c, #d6a650); --tt-btn-shadow: 0 10px 30px rgba(214, 166, 80, .28); --tt-up: #f6f1e6; --tt-up-line: rgba(246, 241, 230, .4);
  --tt-bg-top: rgba(8, 7, 8, .72); --tt-bg-mid: rgba(8, 7, 8, .12); --tt-bg-bottom: rgba(4, 4, 5, .93); --tt-panel: rgba(20, 18, 20, .82);
  --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(var(--tt-glow), .1), transparent 70%), linear-gradient(180deg, var(--tt-bg-top), var(--tt-bg-mid) 34%, var(--tt-bg-bottom) 78%);
  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(var(--tt-glow), .14); }
.tt-steps li.on { color: var(--tt-on); background: var(--tt-brass); border-color: var(--tt-brass); }
.tt-steps li.done { color: var(--tt-brass); border-color: rgba(var(--tt-glow), .4); }
.tt-title { margin: 0; font: 700 clamp(22px, 6.2vw, 26px)/1.25 var(--g-serif); color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .9), 0 3px 18px rgba(0, 0, 0, .85); word-break: keep-all; }
.tt-note { margin: 6px auto 0; max-width: 340px; min-height: 20px; font: 600 13px/1.5 var(--g-sans); color: rgba(246, 241, 230, .82); text-shadow: 0 1px 2px rgba(0, 0, 0, .9), 0 2px 12px rgba(0, 0, 0, .8); 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: var(--tt-on); letter-spacing: -.01em;
  background: var(--tt-btn); box-shadow: var(--tt-btn-shadow), 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(var(--tt-glow), .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(var(--tt-glow), .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(var(--tt-glow), .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; }
/* keepFace (a guide talking behind the table): the deck, the fan and the turned cards sit at the
   bottom of the screen so the middle, where the guide's face is, stays clear. */
.tt.tt-keep-face .tt-table { align-items: flex-end; }
.tt.tt-keep-face.is-flip .tt-slots { align-items: flex-end; padding-top: 0; }
/* While choosing, the fan and the empty slots are smaller so they stay below the face on short phones. */
.tt.tt-keep-face .tt-table { min-height: 0; }
.tt.tt-keep-face .tt-fan { height: 168px; }
.tt.tt-keep-face .tt-fc { top: 24px; --tt-cw: 58px; --tt-ch: 91px; }
.tt.tt-keep-face.is-fan:not(.is-flip) .tt-slots { padding-top: 2px; }
.tt.tt-keep-face.is-fan:not(.is-flip) .tt-slot-card { width: 42px; height: 66px; }
.tt.tt-keep-face.is-fan:not(.is-flip) .tt-slot-card .tt-card { --tt-cw: 42px; --tt-ch: 66px; }
.tt.tt-keep-face.is-fan:not(.is-flip) .tt-slot b { margin-top: 2px; font-size: 11px; }
.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; }
/* The turned cards scale with the screen height so they stay below the face (about 93px wide on a 667px-tall phone). */
.tt.tt-keep-face.is-flip .tt-slot { max-width: min(132px, 14vh); }
.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: var(--tt-up); padding: 3px 7px; border-radius: 999px; border: 1px solid var(--tt-up-line); }
.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(var(--tt-glow), .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(var(--tt-glow), .2); } }

.tt-explain { display: none; margin: 4px 16px 6px; padding: 12px 14px; text-align: left; border-radius: 14px; background: var(--tt-panel); border: 1px solid rgba(var(--tt-glow), .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); } }

/* 다섯 장 배열(윤슬 관계 다섯 장) — 고르는 동안의 자리 칸을 줄이고, 뒤집을 땐 세 장 + 두 장 두 줄로 놓는다(390px 폭). */
.tt[data-n="5"] .tt-slots { gap: 6px; padding: 8px 8px 4px; }
.tt[data-n="5"] .tt-slot { width: 60px; }
.tt[data-n="5"] .tt-slot-card { width: 46px; height: 72px; }
.tt[data-n="5"] .tt-slot-card .tt-card { --tt-cw: 46px; --tt-ch: 72px; }
.tt[data-n="5"] .tt-slot b { font-size: 11px; white-space: nowrap; }
.tt[data-n="5"].is-flip .tt-slots { flex-wrap: wrap; row-gap: 12px; padding: 14px 10px 4px; }
.tt[data-n="5"].is-flip .tt-slot { width: calc((100% - 20px) / 3); max-width: 116px; }
.tt[data-n="5"].is-flip .tt-cap { min-height: 46px; }
.tt[data-n="5"].is-flip .tt-slot small { font-size: 10.5px; }
.tt[data-n="5"] .tt-explain b { flex-basis: 48px; }

/* 윤슬 달빛 덱 — 은·남색 */
.tt.tt-moon {
  --tt-brass: #dfe6f5; --tt-brass-d: #8f9bb3; --tt-teal: #0a1430; --tt-glow: 214, 225, 245; --tt-on: #0a1430;
  --tt-btn: linear-gradient(180deg, #f4f7fd, #b9c4db); --tt-btn-shadow: 0 10px 30px rgba(150, 170, 215, .3); --tt-up: #bfe0ff; --tt-up-line: rgba(191, 224, 255, .45);
  --tt-bg-top: rgba(7, 12, 32, .6); --tt-bg-mid: rgba(7, 12, 32, .2); --tt-bg-bottom: rgba(4, 7, 20, .92); --tt-panel: rgba(10, 20, 48, .8);
}

@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; }
}

/* ---- Orun head typography: Cinzel step labels, an italic Cormorant title in an ivory-to-brass
   fill with a small ornament under it, and a letter-spaced caption. Over a talking clip the
   shadows keep it legible without a box behind it. ---- */
.tt .tt-steps { gap: 0; margin-bottom: 14px; }
.tt .tt-steps li { position: relative; padding: 4px 9px 7px; border: 0; border-radius: 0; background: none;
  font: 600 9.5px/1 Cinzel, var(--g-serif); letter-spacing: .2em; text-transform: uppercase; color: rgba(246, 241, 230, .38);
  text-shadow: 0 1px 6px rgba(0, 0, 0, .9); }
.tt .tt-steps li + li::before { content: ""; position: absolute; left: -2px; top: 6px; width: 3px; height: 3px; border-radius: 50%; background: rgba(var(--tt-glow), .45); }
.tt .tt-steps li.done { color: rgba(var(--tt-glow), .75); background: none; }
.tt .tt-steps li.on { color: #f6f1e6; background: none; }
.tt .tt-steps li.on::after { content: ""; position: absolute; left: 22%; right: 22%; bottom: 0; height: 1.5px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--tt-brass), transparent); }
.tt .tt-title { display: inline-block; padding: 0 12px; font: italic 600 clamp(28px, 8.4vw, 34px)/1.08 var(--g-serif); letter-spacing: -.005em;
  background: linear-gradient(180deg, #fffaf0 30%, #e6c27a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .85)) drop-shadow(0 4px 16px rgba(0, 0, 0, .7)); }
.tt .tt-title::after { content: ""; display: block; width: 96px; height: 9px; margin: 9px auto 0;
  background: radial-gradient(circle, var(--tt-brass) 0 2.2px, transparent 2.8px) center / 9px 9px no-repeat,
    linear-gradient(90deg, transparent, rgba(var(--tt-glow), .8) 42%, transparent 42% 58%, rgba(var(--tt-glow), .8) 58%, transparent) center / 100% 1px no-repeat; }
.tt .tt-note { margin-top: 9px; font: 700 10.5px/1.5 var(--g-sans); letter-spacing: .16em; text-transform: uppercase; color: rgba(246, 241, 230, .84); }
.tt .tt-status { font: 700 10.5px/1.5 var(--g-sans); letter-spacing: .16em; text-transform: uppercase; text-shadow: 0 1px 6px rgba(0, 0, 0, .9); }
