/* FoldText 折叠动效 · React Bits 原生移植（WAAPI 替代 gsap，零依赖 / file:// 直开）
   仅作用于带 data-foldtext 标记的元素内部；不依赖任何 CDN 或构建步骤。 */

.fold-text {
  /* 组件默认是 inline-block（适合单行标题），这里改为 inline 以允许中文多行换行 */
  display: inline;
  color: var(--fold-text-color, currentColor);
  font-size: var(--fold-text-font-size, inherit);
  font-weight: var(--fold-text-font-weight, inherit);
  line-height: inherit;
  letter-spacing: inherit;
  white-space: pre-wrap;
  user-select: text;
}

.fold-text-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fold-text-visual { display: inline; }
.fold-text-line { display: block; }
.fold-text-whitespace { display: inline; }

.fold-text-segment {
  display: inline-block;
  line-height: inherit;
  perspective: var(--fold-perspective, 700px);
  transform-style: preserve-3d;
  vertical-align: baseline;
}

.fold-text-piece {
  position: relative;
  display: inline-block;
  color: inherit;
  line-height: inherit;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

/* 折叠阴影层：用真实子元素 + opacity 动画（WAAPI 可动画），
   替代原组件依赖 gsap 的 --fold-crease 自定义属性。 */
.fold-text__crease {
  position: absolute;
  inset: -0.08em -0.02em;
  pointer-events: none;
  mix-blend-mode: multiply;
  border-radius: 0.08em;
  opacity: 0;
}

.fold-text-piece[data-fold-hinge='top'] .fold-text__crease {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.22) 42%, rgba(255, 255, 255, 0.26) 100%);
}
.fold-text-piece[data-fold-hinge='bottom'] .fold-text__crease {
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.22) 42%, rgba(255, 255, 255, 0.26) 100%);
}
.fold-text-piece[data-fold-hinge='left'] .fold-text__crease {
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.22) 42%, rgba(255, 255, 255, 0.26) 100%);
}
.fold-text-piece[data-fold-hinge='right'] .fold-text__crease {
  background: linear-gradient(270deg, rgba(0, 0, 0, 0.58) 0%, rgba(0, 0, 0, 0.22) 42%, rgba(255, 255, 255, 0.26) 100%);
}

@media (prefers-reduced-motion: reduce) {
  .fold-text-piece { transform: none !important; }
  .fold-text__crease { opacity: 0 !important; }
}
