/*
 * 谷仓：谷柜 / 痛包、晒图预览、动画的样式。
 * 三种板子背景（.bg-bag / .bg-shelf / .bg-cork）要和 js/share.js 里 drawBoardBg 画出来的样子对应。
 */

/* ---------- 首页上的谷柜一排 ---------- */
.cabs { margin: 12px 18px 0; }
.cabs-head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.cabs-head small { font-size: 11px; color: var(--soft); }
.cabs-row { display: flex; gap: 10px; margin-top: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.cabs-row::-webkit-scrollbar { display: none; }
.cab-card { position: relative; flex: 0 0 auto; width: 96px; height: 108px; border-radius: 16px; border: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; padding: 8px 10px; text-align: left; color: #4a3040; overflow: hidden; }
.cab-card b { font-size: 12px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: rgba(255,255,255,.85); border-radius: 6px; padding: 0 4px; }
.cab-card small { font-size: 10px; background: rgba(255,255,255,.75); border-radius: 6px; padding: 0 4px; margin-top: 2px; }
.cab-card.add { background: var(--card); border: 2px dashed var(--soft); color: var(--soft); align-items: center; justify-content: center; font-size: 26px; }
.cab-card.add small { background: none; }

/* ---------- 三种板子背景 ---------- */
.bg-bag { background-color: #ffe3ea; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.5) 0 2px, transparent 2px 10px); box-shadow: inset 0 0 0 10px #ffe3ea, inset 0 0 0 13px #f39ab0; }
.bg-shelf { box-shadow: inset 0 0 0 10px #b98a5e; background-image:
  linear-gradient(to bottom, transparent calc(25% - 8px), rgba(255,255,255,.8) calc(25% - 8px) 25%, rgba(120,90,60,.18) 25% calc(25% + 5px), transparent calc(25% + 5px)),
  linear-gradient(to bottom, transparent calc(50% - 8px), rgba(255,255,255,.8) calc(50% - 8px) 50%, rgba(120,90,60,.18) 50% calc(50% + 5px), transparent calc(50% + 5px)),
  linear-gradient(to bottom, transparent calc(75% - 8px), rgba(255,255,255,.8) calc(75% - 8px) 75%, rgba(120,90,60,.18) 75% calc(75% + 5px), transparent calc(75% + 5px)),
  linear-gradient(#f3ece4, #e6dace); }
.bg-cork { background-color: #c99a63; background-image: radial-gradient(rgba(120,80,40,.28) 1.2px, transparent 1.6px), radial-gradient(rgba(255,230,190,.3) 1px, transparent 1.4px);
  background-size: 9px 9px, 13px 13px; background-position: 0 0, 4px 6px; box-shadow: inset 0 0 0 10px #8d6038; }
.bg-bag.cab-card { box-shadow: inset 0 0 0 5px #ffe3ea, inset 0 0 0 7px #f39ab0; }
.bg-shelf.cab-card { box-shadow: inset 0 0 0 6px #b98a5e; }
.bg-cork.cab-card { box-shadow: inset 0 0 0 6px #8d6038; }

/* ---------- 谷柜编辑器（全屏） ---------- */
.shelf-shell { position: absolute; inset: 0; z-index: 25; background: var(--bg); background-image: var(--paper, none); background-size: var(--paper-size, auto); }
.shelf-editor { display: flex; flex-direction: column; height: 100%; padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px calc(env(safe-area-inset-bottom, 0px) + 12px); }
.shelf-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shelf-name { border: 0; background: none; font-size: 17px; font-weight: 800; font-family: var(--title-font, inherit); max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.small { flex: 0 0 auto; padding: 6px 14px; font-size: 13px; }
.board-wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; margin-top: 10px; }
/* 宽高比 8:9，和晒图（js/share.js 的 BOARD 960×1080）一样，摆的样子才对得上 */
.board { position: relative; width: min(100%, calc((100vh - 300px) * 8 / 9)); aspect-ratio: 8 / 9; border-radius: 22px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.board-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0; color: rgba(80,50,60,.6); font-size: 14px; }
.piece { position: absolute; aspect-ratio: 1; cursor: grab; touch-action: none; }
.piece .piece-art { width: 100%; height: 100%; border-radius: 10%; border: 4px solid #fff; box-shadow: 0 6px 14px rgba(60,30,40,.28); }
.piece.round .piece-art { border-radius: 50%; }
.piece .piece-art .shape { transform: scale(.8); }
.piece.on .piece-art { outline: 3px dashed var(--accent); outline-offset: 4px; }
.shelf-tools { margin-top: 10px; }
.tool-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.tool-row .btn { flex: 0 0 auto; padding: 7px 14px; font-size: 13px; }
.piece-tools button { flex: 1; min-width: 0; padding: 6px 0; border-radius: 10px; border: var(--chip-border, 1px solid rgba(0,0,0,.1)); background: var(--card); font-size: 12px; }
.piece-tools .danger, .link.danger { color: #d64545; }
.shelf-tools > .link.danger { display: block; margin: 6px auto 0; font-size: 12px; }
.pick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pick-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: 12px; border: 0; background: var(--card); font-size: 11px; }
.pick-item .art.small { width: 64px; height: 64px; }
.pick-item span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 晒图预览 ---------- */
.share-img { display: block; width: 100%; border-radius: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.15); -webkit-touch-callout: default; }
.share-row { display: flex; gap: 8px; margin: 12px 18px 0; }
.share-row .btn { font-size: 13px; padding: 9px 6px; }

/* ---------- 钱飞进去 ---------- */
.fly-note { position: absolute; z-index: 40; width: 54px; height: 26px; border-radius: 2px; background-size: cover; pointer-events: none; box-shadow: 1px 2px 4px rgba(0,0,0,.25); }
.fly-note.coin { width: 22px; height: 22px; border-radius: 50%; }

/* ---------- 开箱仪式 ---------- */
.unbox { position: absolute; inset: 0; z-index: 45; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(40, 25, 30, .55); animation: unbox-fade .25s ease-out; }
.unbox-box { position: relative; width: 150px; height: 150px; animation: unbox-shake .5s ease-in-out 2; }
.unbox-body { position: absolute; left: 0; right: 0; bottom: 0; height: 104px; border-radius: 8px; background: linear-gradient(#e7b47c, #c98d52); box-shadow: inset 0 -10px 0 rgba(0,0,0,.08); }
.unbox-body::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 22px; margin-left: -11px; background: #ff8fab; }
.unbox-lid { position: absolute; left: -8px; right: -8px; top: 30px; height: 30px; border-radius: 6px; background: linear-gradient(#f0c08a, #d79a5c); transform-origin: 0 100%; animation: unbox-lid .6s 1s cubic-bezier(.3,1.6,.5,1) both; z-index: 2; }
.unbox-lid::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 22px; margin-left: -11px; background: #ff6f91; }
.unbox-item { position: absolute; left: 50%; bottom: 40px; width: 90px; height: 90px; margin-left: -45px; transform: translateY(40px) scale(.3); opacity: 0; animation: unbox-pop .6s 1.25s cubic-bezier(.3,1.7,.5,1) both; z-index: 1; }
.unbox-item .art.small { width: 90px; height: 90px; border-radius: 18px; border: 4px solid #fff; box-shadow: 0 6px 16px rgba(0,0,0,.3); }
.unbox-confetti { position: absolute; left: 50%; top: 40%; z-index: 3; }
.unbox-confetti i { position: absolute; width: 9px; height: 14px; border-radius: 2px; background: var(--c); opacity: 0; animation: unbox-confetti .9s calc(1.15s + var(--t)) ease-out both; }
.unbox-text { margin: 26px 0 0; color: #fff; font-size: 18px; text-align: center; opacity: 0; animation: unbox-fade .4s 1.5s both; }
.unbox-text b { display: block; font-size: 15px; margin-top: 4px; }
@keyframes unbox-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes unbox-shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes unbox-lid { to { transform: translate(-30px, -60px) rotate(-35deg); } }
@keyframes unbox-pop { to { transform: translateY(-70px) scale(1); opacity: 1; } }
@keyframes unbox-confetti {
  0% { transform: rotate(var(--a)) translateY(0) rotate(0); opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) rotate(540deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .unbox, .unbox * { animation: none !important; } }
