/*
 * 圈圈发布页 · 动态大标题
 * 所有选择器都以 .kt 开头，可以直接并入发布页样式而不影响其他部分。
 * 构图：横屏按 1600×900（16:9）设计，竖屏按 9:14 设计，都会缩放到当前窗口内。
 * 动效只动 transform 和 opacity；循环周期 4 秒；尊重“减少动态效果”设置。
 */

.kt {
  /* 品牌色 */
  --kt-ink: #1B1B1F;
  --kt-paper: #F4F1EA;
  --kt-accent: #FF5A36;
  /* 循环周期：胶片环转一圈 = 标题波动一次 */
  --kt-loop: 4s;
  --kt-font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, sans-serif;

  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--kt-ink);
  color: var(--kt-paper);
  font-family: var(--kt-font);
  -webkit-font-smoothing: antialiased;
}

.kt *,
.kt *::before,
.kt *::after {
  box-sizing: border-box;
}

/* 舞台：保持构图比例，宽高都不超过当前窗口 */
.kt-stage {
  position: relative;
  width: min(100%, 100vh * 16 / 9);
  width: min(100%, 100svh * 16 / 9);
  aspect-ratio: 16 / 9;
  container-type: inline-size;
}

/* 4% 安全边距：1600×900 下左右 64px、上下 36px */
.kt-frame {
  position: absolute;
  inset: 0;
  padding: 2.25cqw 4cqw;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.kt-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 56cqw;
}

.kt-eyebrow {
  margin: 0 0 2.4cqw;
  font-size: max(12px, 1.5cqw);
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.06em;
  color: rgb(244 241 234 / 0.72);
  animation: kt-fade 0.7s cubic-bezier(0.2, 0.9, 0.2, 1) backwards;
}

.kt-title {
  margin: 0;
  font-size: 11cqw;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

/* 遮罩行：字从行底升起。上下留白，给循环波动留出空间，避免被裁切 */
.kt-line {
  display: flex;
  overflow: hidden;
  padding: 0.12em 0.06em 0.08em 0;
  margin: -0.12em -0.06em -0.08em 0;
}

.kt-char {
  display: inline-block;
  animation: kt-rise 0.8s cubic-bezier(0.2, 0.9, 0.2, 1) backwards;
  animation-delay: calc(0.15s + var(--i) * 0.07s);
}

.kt-char > span {
  display: inline-block;
  animation: kt-wave var(--kt-loop) ease-in-out infinite;
  animation-delay: calc(1.6s + var(--i) * 0.08s);
}

.kt-sub {
  margin: 0;
  font-size: max(16px, 3cqw);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  animation: kt-fade 0.7s cubic-bezier(0.2, 0.9, 0.2, 1) backwards;
  animation-delay: calc(0.75s + var(--i) * 0.15s);
}

.kt-title + .kt-sub {
  margin-top: 2.2cqw;
}

/* 辅助图形：胶片环 */
.kt-ring {
  position: absolute;
  right: 5.5cqw;
  top: calc(50% - 16cqw);
  width: 32cqw;
  aspect-ratio: 1;
  animation: kt-ring-in 1.1s cubic-bezier(0.2, 0.9, 0.2, 1) 0.1s backwards;
}

.kt-ring svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.kt-film {
  fill: none;
  stroke: var(--kt-accent);
}

.kt-cut {
  fill: none;
  stroke: var(--kt-ink);
}

.kt-playhead {
  fill: var(--kt-paper);
}

.kt-reel {
  transform-box: view-box;
  transform-origin: 50% 50%;
  animation: kt-spin var(--kt-loop) linear infinite;
  will-change: transform;
}

/* 暂停 / 播放按钮 */
.kt-toggle {
  position: absolute;
  z-index: 2;
  right: 4cqw;
  bottom: 2.25cqw;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  min-width: 44px;
  min-height: 44px;
  padding: 0 1.1em 0 0.95em;
  border: 1.5px solid rgb(244 241 234 / 0.5);
  border-radius: 999px;
  background: var(--kt-ink);
  color: var(--kt-paper);
  font: 600 clamp(14px, 1cqw, 18px) / 1 var(--kt-font);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.kt-toggle:hover {
  border-color: var(--kt-paper);
}

.kt-toggle:focus-visible {
  outline: 3px solid var(--kt-accent);
  outline-offset: 3px;
}

.kt-icon {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.kt-toggle[data-icon="pause"] .kt-icon-play,
.kt-toggle[data-icon="play"] .kt-icon-pause {
  display: none;
}

/* 只给读屏软件的整句标题 */
.kt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 竖屏（手机）：9:14 构图，环在上，三行字在下，按钮在右下 */
@media (max-aspect-ratio: 1/1) {
  .kt-stage {
    width: min(100%, 100vh * 9 / 14);
    width: min(100%, 100svh * 9 / 14);
    aspect-ratio: 9 / 14;
  }

  .kt-frame {
    padding: 6cqw 5.5cqw calc(10cqw + 44px);
  }

  .kt-copy {
    flex: 1;
    justify-content: flex-end;
    max-width: none;
  }

  .kt-eyebrow {
    margin-bottom: auto;
    font-size: max(12px, 3.6cqw);
  }

  .kt-title {
    font-size: 17.5cqw;
  }

  .kt-sub {
    font-size: max(16px, 5.6cqw);
  }

  .kt-title + .kt-sub {
    margin-top: 3.5cqw;
  }

  .kt-ring {
    top: 18cqw;
    right: 5.5cqw;
    width: 72cqw;
  }

  .kt-toggle {
    right: 5.5cqw;
    bottom: 5cqw;
  }
}

@keyframes kt-fade {
  from {
    opacity: 0;
    transform: translateY(0.5em);
  }
}

@keyframes kt-rise {
  from {
    transform: translateY(115%);
  }
}

@keyframes kt-wave {
  0%,
  22%,
  100% {
    transform: translateY(0);
  }
  8% {
    transform: translateY(-0.08em);
  }
  15% {
    transform: translateY(0.015em);
  }
}

@keyframes kt-ring-in {
  from {
    opacity: 0;
    transform: scale(0.72) rotate(-60deg);
  }
}

@keyframes kt-spin {
  to {
    transform: rotate(360deg);
  }
}

/* 播放状态由 hero.js 写在 data-state 上 */
.kt[data-state="paused"] * {
  animation-play-state: paused !important;
}

.kt[data-state="static"] * {
  animation: none !important;
}

/* 系统开了“减少动态效果”：默认显示静止的最终画面；用户点“播放动画”后才动 */
@media (prefers-reduced-motion: reduce) {
  .kt:not([data-state="playing"]):not([data-state="paused"]) * {
    animation: none !important;
  }
}
