/* ==========================================================================
   翻牌屏（split-flap / flip board）
   --------------------------------------------------------------------------
   参考：Aceternity「Text Flipping Board」的机场翻牌屏效果。
   实现：纯 CSS 3D + 少量 JS，无依赖；支持 reduced-motion 降级。
   用法见 templates/portal/index.html：
     <h1 class="ap-title ap-title--flip" data-flip="第一行|第二行">…原文…</h1>
   ========================================================================== */

.ap-title--flip {
  /* 逐字翻牌时不要把整块撑得抖动 */
  line-height: 1.18;
  /* 14 个字 + 瓦片内边距，比原来的纯文字更占宽，字号要略收；
     但手机端不能小于 40px（原来是 44px 起），否则标题会显得"缩水" */
  font-size: clamp(40px, 8.2vw, 96px);
  letter-spacing: 0;
  /* ⚠ .ap-title 原样式是「渐变文字 + text-fill 透明」，
     套上翻牌瓦片后每个字都会变成透明 → 看不见。
     这里必须把渐变裁切和透明填充全部还原。 */
  background: none !important;
  -webkit-background-clip: border-box !important;
  background-clip: border-box !important;
  -webkit-text-fill-color: currentColor !important;
  color: #e9f3ff;
}

/* 小屏：两行各自紧凑，避免把首屏撑太高 */
@media (max-width: 560px) {
  .ap-title--flip { font-size: clamp(32px, 9.4vw, 44px); }
}

.fb-board {
  display: flex;
  flex-direction: column;
  gap: 0.08em;
  align-items: center;      /* 与 .ap-title 的居中保持一致 */
  /* 不再加重底衬：之前那块深色圆角板浮在渐变上很突兀 */
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}

.fb-line {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.06em;
  /* 给翻动一点透视；不要用 preserve-3d + backface-visibility:hidden，
     那组合在 iOS Safari / 微信 WebView 上会让文字整块消失 */
  perspective: 700px;
}

.fb-tile {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0.9em;
  padding: 0.045em 0.055em 0.06em;
  border-radius: 0.08em;
  /* 半透明瓦片：让首屏的渐变光透上来，不再像一排实心按钮 */
  background: linear-gradient(180deg,
      rgba(20, 30, 47, .62) 0%,
      rgba(11, 18, 29, .70) 48%,
      rgba(8, 13, 22, .74) 52%,
      rgba(16, 25, 39, .64) 100%);
  border: 1px solid rgba(150, 200, 255, .10);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .07) inset,
    0 -1px 0 rgba(0, 0, 0, .34) inset,
    0 10px 26px -20px rgba(0, 0, 0, .85);
  color: #e9f3ff;
  font-variant-numeric: tabular-nums;
  transform-origin: 50% 50%;
  /* 见 .fb-line 注释：iOS/微信里 backface-visibility:hidden 会吞字，这里不用 */
  transform-style: flat;
  backface-visibility: visible;
  transition: transform .085s cubic-bezier(.4, 0, .6, 1),
              background-color .18s ease,
              border-color .18s ease;
  text-shadow: 0 0 22px rgba(120, 200, 255, .18);
}

/* 中间那道折缝 */
.fb-tile::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(0, 0, 0, .34);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04);
  pointer-events: none;
}

/* 上下两半的明暗，模拟翻片 */
.fb-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg,
      rgba(255, 255, 255, .05) 0%,
      rgba(255, 255, 255, 0) 44%,
      rgba(0, 0, 0, .16) 56%,
      rgba(0, 0, 0, .02) 100%);
  pointer-events: none;
}

.fb-tile .fb-ch {
  position: relative;
  z-index: 1;
  display: block;
  transform: translateZ(0);
  /* 再兜一层：防止父级渐变文字把字填成透明 */
  color: #eaf3ff;
  -webkit-text-fill-color: #eaf3ff;
  background: none;
}

/* 空格：只占位，不画框 */
.fb-tile.fb-space {
  background: none;
  border-color: transparent;
  box-shadow: none;
}
.fb-tile.fb-space::before,
.fb-tile.fb-space::after { display: none; }

/* 翻动瞬间：压暗 + 折起 */
.fb-tile.is-flip {
  transform: rotateX(-72deg) scaleY(.98);
  background-color: rgba(26, 38, 58, .85);
  border-color: rgba(140, 200, 255, .18);
}

/* 落定后的高亮（一次性） */
.fb-tile.is-done {
  border-color: rgba(120, 200, 255, .20);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .09) inset,
    0 -1px 0 rgba(0, 0, 0, .34) inset,
    0 0 18px -8px rgba(56, 189, 248, .38);
}

/* 关闭动画（无障碍） */
@media (prefers-reduced-motion: reduce) {
  .fb-tile,
  .fb-tile.is-flip { transition: none; transform: none; }
}

/* 小屏：字距与内边距收紧，避免换行 */
@media (max-width: 720px) {
  .fb-line { gap: 0.04em; }
  .fb-tile { padding: 0.05em 0.08em 0.07em; border-radius: 0.1em; }
}
