/* =========================================================================
 * foil_core.css —— 闪卡预览的舞台 / 卡片壳样式
 * 编辑页（/admin/foilcard.html）、公开预览工具（/tools/foilcard_lab/）
 * 与画廊端「闪卡模式」共用。只负责外壳（尺寸、圆角、白边、投影、倾斜容器），
 * 画面本身由 foil_core.js 渲染。
 * ========================================================================= */

.foil-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1500px;
  perspective-origin: 50% 45%;
}

.foil-shell {
  position: relative;
  background: #FFFEF9;
  border: 1px solid #D4CFC5;
  border-radius: var(--foil-radius, 0px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .10), 0 12px 28px rgba(0, 0, 0, .12);
  overflow: hidden;
  will-change: transform;
  transition: transform .16s cubic-bezier(.22, .61, .36, 1);
  transform-style: preserve-3d;
}

/* 关闭「倾斜跟随鼠标」时保持平面 */
.foil-shell.is-flat { transform: none !important; }

/* 关闭卡片壳：只剩画面本身 */
.foil-shell.no-shell {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.foil-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #101010;
}

.foil-fallback {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.foil-note {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 6px 10px;
  background: rgba(251, 234, 229, .95);
  border-top: 1px solid #E6C4B8;
  color: #8B0000;
  font: 12px/1.7 'SimSun', serif;
  letter-spacing: .5px;
}

/* =========================================================================
 * 触摸交互（编辑页 / 将来画廊端共用；由 FoilCore.createInteraction 自动挂上）
 *
 * touch-action: none 告诉浏览器「这块区域内的触摸手势归渲染层，别拿去滚页面」。
 * 只作用在这个元素上，页面其它区域照常滚动。
 * ========================================================================= */
.foil-zone {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: crosshair;
}

.foil-zone.is-gesturing { cursor: grabbing; }

/* 拖动 / 陀螺仪期间不要倾斜过渡，否则手感发黏 */
.foil-dragging .foil-shell { transition: none; }

/* =========================================================================
 * 沉浸模式（双击预览区进入 / 再双击退出；编辑页与将来画廊端共用）
 *
 * 结构：.foil-imm-back 半透明黑遮罩铺满屏幕 → .is-immersive 的卡片浮在它上面
 *      （position: fixed + translate 居中，宽度收缩到卡片自身大小，所以卡片
 *        以外的地方点得到遮罩）。卡片排多大由调用方按 immersiveBox() 决定。
 * ========================================================================= */
html.foil-immersive,
body.foil-immersive { overflow: hidden; }

.foil-imm-back {
  position: fixed;
  inset: 0;
  z-index: 9990;
  background: rgba(0, 0, 0, .62);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.foil-imm-hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 9992;
  padding: 0 12px;
  /* 文字与按钮同一行居中；一行放不下（手机窄屏）时按钮自动落到下一行 */
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  text-align: center;
  color: rgba(255, 255, 255, .80);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
  font: 12px/1.6 'SimSun', serif;
  letter-spacing: 1px;
  pointer-events: none;   /* 提示条本身不吃点击（否则会挡住卡片）；只有按钮例外 */
}

/* 提示文字：允许在行内换行（min-width:0 才能收缩到容器宽度） */
.foil-imm-hint-text { min-width: 0; }

/* 提示条上的动作按钮（如「重新授权」）：默认藏着，由 foil_view 按状态显示 */
.foil-imm-hint-act {
  flex: 0 0 auto;
  pointer-events: auto;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 6px 14px;
  min-height: 32px;                       /* 手指够点得着 */
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 999px;
  background: rgba(20, 20, 20, .45);
  color: rgba(255, 255, 255, .94);
  font: 12px/1.35 'SimSun', serif;
  letter-spacing: .5px;
  cursor: pointer;
  touch-action: manipulation;             /* 去掉双击缩放的等待 */
  -webkit-tap-highlight-color: transparent;
}

.foil-imm-hint-act[hidden] { display: none; }
.foil-imm-hint-act:active { background: rgba(255, 255, 255, .22); }
.foil-imm-hint-act:disabled { opacity: .55; cursor: default; }

/* 浮起来的卡片本体：固定在视口中心，尺寸随内容收缩（父级链上不能有 transform，否则定位会跑偏） */
.is-immersive {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 9991;
}

.is-immersive .foil-shell {
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .45);
}
