/* 샌드박스 탭(#/sandbox) — 카드 갤러리와 티티.
 *
 * 2026-10-11 다시 그렸다. 설계 판단은 docs/superpowers/specs/2026-10-11-sandbox-tab-ui-design.md.
 *
 * 색·간격·글자 크기는 사이트 토큰(design.css 의 var(--…))만 쓴다 — 다크 모드와 브랜드가 사이트와
 * 한 곳에서 바뀌어야 하기 때문이다. 여기서 새로 정하는 것은 탁구 소품의 색(공·탁구대·라켓 손잡이)
 * 뿐이고, 그것도 탁구 화면(tt/play/kit.css)의 값을 그대로 옮겼다.
 *
 * 움직임은 transform·opacity 만 쓴다(레이아웃 속성을 움직이면 저사양 폰에서 끊긴다).
 * prefers-reduced-motion 이면 맨 아래에서 전부 멈춘다 — 공이 튀지 않아도 뜻은 글이 전한다.
 */
.sbPage {
  word-break: keep-all; overflow-wrap: anywhere;  /* 한국어는 어절 단위로 줄을 바꾼다(「치울 / 게요」 방지) */
  --sb-ink: #2a2326;
  --sb-ball: #fffaf2;
  --sb-spring: cubic-bezier(.34, 1.56, .64, 1);
  --sb-table: #26201f;
  --sb-dot: color-mix(in srgb, var(--accent) 12%, transparent);
  --sb-art: color-mix(in srgb, var(--accent) 6%, var(--surface-2));
}
[data-theme="dark"] .sbPage { --sb-table: #3b3234; --sb-dot: color-mix(in srgb, var(--accent) 22%, transparent); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .sbPage {
    --sb-table: #3b3234; --sb-dot: color-mix(in srgb, var(--accent) 22%, transparent);
  }
}

/* ── 머리 ── */
.sbHero {
  display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: var(--sp-7); align-items: center;
  padding: var(--sp-7); margin-bottom: var(--sp-7); border-radius: 24px;
  border: 1px solid var(--border);
  background: radial-gradient(circle at 12px 12px, var(--sb-dot) 2.5px, transparent 3px) 0 0 / 26px 26px,
              linear-gradient(135deg, var(--accent-bg), var(--surface) 70%);
}
.sbEyebrow {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 var(--sp-2);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--accent-text); letter-spacing: .02em;
}
.sbHero h1 { margin: 0 0 var(--sp-3); font-size: var(--fs-4xl); line-height: var(--lh-tight); letter-spacing: var(--ls-tight); }
.sbLead { margin: 0 0 var(--sp-5); max-width: 40em; color: var(--dim); font-size: var(--fs-lg); line-height: var(--lh-base); }
.sbFacts { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3); }
.sbFacts li {
  display: flex; gap: 10px; align-items: flex-start; padding: var(--sp-3) var(--sp-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
}
.sbFacts li > .ic { flex: none; margin-top: 2px; color: var(--accent-text); }
.sbFacts b { display: block; font-size: var(--fs-md); margin-bottom: 2px; }
.sbFacts span { display: block; font-size: var(--fs-sm); color: var(--dim); line-height: var(--lh-snug); }

.sbHeroArt { position: relative; display: grid; justify-items: center; align-content: end; min-height: 230px; }
.sbBubble {
  position: relative; margin: 0 0 var(--sp-3); padding: 10px 14px; max-width: 220px;
  background: var(--surface); border: 2px solid var(--border-2); border-radius: 18px;
  font-size: var(--fs-sm); font-weight: var(--fw-semibold); line-height: var(--lh-snug); text-align: center;
}
.sbBubble::after {
  content: ""; position: absolute; left: 50%; bottom: -9px; width: 14px; height: 14px; margin-left: -7px;
  background: inherit; border-right: 2px solid var(--border-2); border-bottom: 2px solid var(--border-2);
  transform: rotate(45deg);
}
.sbHeroBall { position: absolute; right: 18px; bottom: 34px; }
.sbHeroBall i {
  display: block; width: 18px; height: 18px; border-radius: 50%;
  background: var(--sb-ball); border: 2.5px solid var(--sb-ink);
  animation: sbHop 1.1s var(--sb-spring) infinite;
}

/* 티티 */
.sbPongi { width: 132px; line-height: 0; }
.sbPongi.sm { width: 96px; }
.sbPongi.xs { width: 48px; flex: none; }
.sbPongiSvg { display: block; width: 100%; height: auto; overflow: visible; }
.sbPongiSvg .ln { fill: none; stroke: #2a2326; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.sbPongiBody, .sbPongiShadow { transform-box: fill-box; transform-origin: 50% 100%; }
.sbHeroArt .sbPongiBody { animation: sbBob 2.4s ease-in-out infinite; }
.sbPongiSvg .eye { transform-box: fill-box; transform-origin: 50% 50%; animation: sbBlink 4.2s infinite; }

/* ── 상태 띠(이어하기·상한) ── */
.sbLive {
  display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); margin-bottom: var(--sp-6);
  border-radius: var(--r-xl); border: 2px solid var(--accent); background: var(--accent-bg); color: var(--text);
}
.sbLive.warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: var(--warn-bg); }
.sbLiveIc { flex: none; color: var(--warn); line-height: 0; }
.sbLiveText { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 10px; row-gap: 2px; }
.sbLiveText b { flex-basis: 100%; font-size: var(--fs-base); }
.sbLiveText > span { font-weight: var(--fw-semibold); }
.sbLiveLeft { color: var(--dim); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.sbLiveText small { flex-basis: 100%; color: var(--dim); font-size: var(--fs-sm); line-height: var(--lh-snug); }
.sbLive .btn { flex: none; }

/* ── 갤러리 ── */
.sbHead { display: flex; align-items: baseline; gap: var(--sp-3); margin: 0 0 var(--sp-4); }
.sbHead h2 { margin: 0; font-size: var(--fs-xl); }
.sbCount {
  display: inline-block; padding: 2px 10px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--dim); font-size: var(--fs-sm); font-weight: var(--fw-semibold);
}
.sbGrid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); }

.sbCard2 {
  position: relative; display: flex; flex-direction: column; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: transform .3s var(--sb-spring), box-shadow var(--t) var(--ease), border-color var(--t) var(--ease);
}
.sbCard2:hover, .sbCard2:focus-within {
  transform: translateY(-5px); border-color: var(--border-2); box-shadow: var(--shadow-lg);
}
.sbCard2.isLive { border: 2px solid var(--accent); }

.sbArt {
  height: 120px; border-bottom: 1px solid var(--border);
  background: radial-gradient(circle at 9px 9px, var(--sb-dot) 1.6px, transparent 2px) 0 0 / 18px 18px, var(--sb-art);
}
.sbArtSvg { display: block; width: 100%; height: 100%; }
.sbTable { fill: var(--sb-table); }
.sbTableLine { stroke: var(--sb-ball); stroke-width: 1.5; opacity: .7; }
.sbNet { fill: var(--sb-ball); stroke: var(--sb-ink); stroke-width: 2; }
.sbArc { fill: none; stroke: var(--accent-text); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 2 9; opacity: .55; }
.sbBallShadow { fill: var(--sb-ink); opacity: .18; transform-box: fill-box; transform-origin: 50% 50%; }
.sbPaddle { transform-box: fill-box; transform-origin: 50% 85%; transform: rotate(-14deg); transition: transform .45s var(--sb-spring); }
.sbBall { transform-box: fill-box; transform-origin: 50% 100%; }
.sbCard2:hover .sbPaddle, .sbCard2:focus-within .sbPaddle { transform: rotate(4deg); }
.sbCard2:hover .sbBall, .sbCard2:focus-within .sbBall { animation: sbBallHop .9s var(--sb-spring) infinite; }
.sbCard2:hover .sbBallShadow, .sbCard2:focus-within .sbBallShadow { animation: sbShadow .9s var(--sb-spring) infinite; }

.sbLiveTag {
  position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-full); background: var(--accent); color: var(--on-accent);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
.sbLiveTag i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: sbPulse 1.6s ease-in-out infinite; }

.sbBody { display: flex; flex-direction: column; gap: var(--sp-3); flex: 1; padding: var(--sp-4) var(--sp-5) var(--sp-5); }
.sbTitle { margin: 0; font-size: var(--fs-lg); line-height: var(--lh-snug); }
.sbBlurb { margin: 0; color: var(--dim); font-size: var(--fs-md); line-height: var(--lh-base); }
.sbTags { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.sbTags li {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding: 3px 9px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--border);
  color: var(--dim); font-size: var(--fs-xs); font-family: var(--font-mono);
}
.sbTags .sbMore { font-family: var(--font-sans); font-weight: var(--fw-bold); color: var(--accent-fg); background: var(--accent-bg); border-color: transparent; }
.sbMeta {
  list-style: none; margin: auto 0 0; padding: var(--sp-3) 0 0; border-top: 1px dashed var(--border-2);
  display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--dimmer); font-size: var(--fs-sm);
}
.sbMeta li { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.sbMeta li.left { color: var(--accent-text); font-weight: var(--fw-bold); }
.sbFoot { display: flex; justify-content: flex-end; }

/* 「열기」 — 공처럼 눌렸다 튄다. ::after 가 카드 전체를 덮어 어디를 눌러도 이 링크다. */
.sbOpen {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 18px;
  border-radius: var(--r-full); background: var(--accent); color: var(--on-accent);
  font-weight: var(--fw-bold); font-size: var(--fs-md); text-decoration: none;
  box-shadow: 0 3px 0 var(--accent-hover);
  transition: transform .25s var(--sb-spring), box-shadow .25s var(--sb-spring);
}
.sbOpen::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.sbOpen:hover { color: var(--on-accent); }
.sbCard2:hover .sbOpen { transform: translateY(-2px); }
.sbOpen:active { transform: translateY(3px) scale(.97); box-shadow: 0 0 0 var(--accent-hover); }
.sbOpen:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.sbOpen:focus-visible::after { outline: none; }
.sbOpen.resume { background: var(--ok-fill); box-shadow: 0 3px 0 color-mix(in srgb, var(--ok-fill) 70%, #000); }
.sbOpenBall { display: none; width: 14px; height: 18px; align-items: flex-end; }
.sbOpenBall i { display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--sb-ball); border: 2px solid var(--sb-ink); }
.isOpening .sbOpenBall { display: inline-flex; }
.isOpening .sbOpenBall i { animation: sbBallHop .45s var(--sb-spring) infinite; }
.isOpening .sbOpen > .ic { display: none; }
.isOpening { transform: translateY(-5px) scale(.99); }

/* ── 로그인 전 — 흐린 미리보기 위에 문 하나 ── */
.sbGuest { position: relative; }
.sbBlur { filter: blur(5px) saturate(.85); opacity: .7; pointer-events: none; user-select: none; max-height: 640px; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.sbGate {
  position: absolute; top: 56px; left: 50%; transform: translateX(-50%); width: min(440px, calc(100% - 32px));
  display: grid; justify-items: center; gap: var(--sp-3); text-align: center;
  padding: var(--sp-6) var(--sp-6) var(--sp-7); border-radius: 24px;
  background: var(--surface); border: 2px solid var(--border-2); box-shadow: var(--shadow-lg);
}
.sbGate h2, .sbState h2 { margin: 0; font-size: var(--fs-2xl); line-height: var(--lh-tight); }
.sbGate p, .sbState p { margin: 0; color: var(--dim); line-height: var(--lh-base); }

/* ── 오류·빈 목록 ── */
.sbState {
  display: grid; justify-items: center; gap: var(--sp-3); text-align: center; max-width: 520px; margin: 0 auto;
  padding: var(--sp-8) var(--sp-6); border-radius: 24px; border: 2px dashed var(--border-2); background: var(--surface);
}
.sbStateWhy { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--err) !important; }

/* ── 환경을 만드는 동안(runTerminal 로딩 카드) — 탁구대 위에서 공이 튄다 ── */
.sbRally {
  position: relative; flex: none; width: 46px; height: 40px;
  background: linear-gradient(var(--accent), var(--accent)) 50% 100% / 3px 12px no-repeat;
  border-bottom: 4px solid #26201f; border-radius: 2px;
}
.sbRally i {
  position: absolute; left: 0; bottom: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: #fffaf2; border: 2px solid #2a2326;
  animation: sbRallyX 1.3s linear infinite alternate, sbRallyY .65s ease-in infinite alternate;
}

@keyframes sbBob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
@keyframes sbBlink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes sbHop { 0%, 100% { transform: translateY(0) scale(1.1, .9); } 50% { transform: translateY(-34px); } }
@keyframes sbBallHop { 0%, 100% { transform: translateY(0) scale(1.08, .9); } 50% { transform: translateY(-20px); } }
@keyframes sbShadow { 0%, 100% { transform: scale(1); opacity: .18; } 50% { transform: scale(.55); opacity: .08; } }
@keyframes sbPulse { 50% { opacity: .35; } }
@keyframes sbRallyX { from { transform: translateX(0); } to { transform: translateX(30px); } }
@keyframes sbRallyY { from { bottom: 22px; } to { bottom: 2px; } }

/* ── 좁은 화면 ── */
@media (max-width: 900px) {
  .sbHero { grid-template-columns: 1fr; padding: var(--sp-6) var(--sp-5); gap: var(--sp-4); }
  .sbHeroArt { display: none; }
  .sbFacts { grid-template-columns: 1fr; gap: var(--sp-2); }
  .sbFacts li { padding: 10px var(--sp-3); }
}
@media (max-width: 560px) {
  .sbHero { margin-bottom: var(--sp-5); border-radius: 20px; }
  .sbHero h1 { font-size: var(--fs-3xl); }
  .sbLead { font-size: var(--fs-base); }
  .sbLive { flex-wrap: wrap; }
  .sbLive .btn { width: 100%; }
  .sbGate { position: relative; top: auto; left: auto; transform: none; width: 100%; margin-bottom: var(--sp-4); order: -1; }
  .sbGuest { display: flex; flex-direction: column; }
  .sbBlur { max-height: 420px; }
}

/* 움직임을 줄이라고 한 사람에게는 전부 멈춘다. 들림·눌림도 위치를 바꾸므로 함께 끈다. */
@media (prefers-reduced-motion: reduce) {
  .sbPage *, .sbPage *::before, .sbPage *::after, .sbRally i { animation: none !important; transition: none !important; }
  .sbCard2:hover, .sbCard2:focus-within, .isOpening, .sbCard2:hover .sbOpen { transform: none; }
  .sbCard2:hover .sbPaddle, .sbCard2:focus-within .sbPaddle { transform: rotate(-14deg); }
  .sbRally i { left: 17px; }
}
