/*
 * p-aigc.css — /aigc/ AI 创作演示（2026-10-18）。首屏小字、页尾一行沿用 p-layers.css。
 * 四个演示窗口 .gen（fyro.css 的 .window）：左边输入（选项、提示词、生成按钮），右边输出（思考框、结果、状态行）。
 * 动效只在点了生成之后：思考框里的小字符格和逐行思路、细进度条；海报由大像素块逐级细化成图，其余由模糊到清晰；不做滚动入场。
 * 每件结果左上角一枚「AI 生成」（显式标识）。没有脚本时：结果照常显示，音频、视频用浏览器自带的控件。
 */

/* 末节「来源」只有标题区，不留下方的间距 */
#source .sec-head { margin-bottom: 0; }

/* ---------- 窗口：左输入、右输出 ---------- */
.gen-body { display: grid; grid-template-columns: minmax(250px, 0.78fr) minmax(0, 2.22fr); }
.gen-input { display: flex; flex-direction: column; gap: 10px; padding: 26px 24px; border-right: 1px solid var(--edge-soft); background: var(--surface-well); }
.gen-output { display: grid; align-content: start; gap: 18px; min-width: 0; padding: 26px; }
.gen-label { margin-top: 10px; font-size: 12px; letter-spacing: 0.08em; color: var(--muted); }
.gen-label:first-child { margin-top: 0; }
.gen-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gen-chips.is-col { grid-template-columns: minmax(0, 1fr); }
/* 选项：10-26 质感版，同 sim.css 的 .sim-opt（照样稿收银台的付款方式）：浮起的小卡片，选中的外面一圈墨色细线、影深一档 */
.gen-chip {
  padding: 9px 12px;
  border: 1px solid var(--edge);
  border-radius: var(--r-md);
  background: var(--sheet);
  background-image: var(--surface-card);
  box-shadow: var(--shadow-card);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--ink-2);
  transition: border-color var(--t-base) ease-out, box-shadow var(--t-base) ease-out, color var(--t-base) ease-out, translate var(--t-press) var(--ease-key);
}
.gen-chip small { display: block; margin-top: 1px; font-size: 12px; font-weight: 400; color: var(--muted); }
.gen-chip[aria-pressed="true"] { border-color: var(--ink-soft); color: var(--ink); box-shadow: 0 0 0 1px var(--ink-soft), var(--shadow-card-hover); }
.gen-chip:not(:disabled):active { translate: 0 1px; }
.gen-chip:disabled { cursor: default; opacity: 0.55; }
@media (hover: hover) and (pointer: fine) { .gen-chip:not(:disabled):not([aria-pressed="true"]):hover { border-color: var(--line-3); } }
.gen-prompt { padding: 11px 14px; border: 1px solid var(--edge-soft); border-radius: var(--r-md); background: var(--surface-panel); font-size: 14px; line-height: 1.8; color: var(--ink-2); text-wrap: pretty; }
.gen-input > .gen-go { margin-top: 8px; }
.gen-go:disabled { cursor: progress; opacity: 0.62; }
.gen-status { min-height: 1.6em; font-size: 13px; letter-spacing: 0.02em; color: var(--muted); }
.gen[aria-busy="true"] .gen-status { color: var(--ink-2); }

/* ---------- 思考：小字符格 + 逐行思路；想完收成「思考了 n 秒」，思路留着、变淡；生成完字符格收成一个勾 ---------- */
.gen-think { padding: 12px 16px 14px; border: 1px solid var(--edge-soft); border-radius: var(--r-lg); background: var(--surface-panel); }
.think-head { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
/* 小字符格（10-20 起，原来是小 orb）：aigc.js 的 Orb 在这块 28px 画布里画 2×2 四个字符，颜色读这里的 color（字符集同首屏的字符粒子）；生成完收成一个同色的勾（10-20 第三次） */
.think-orb { width: 28px; height: 28px; margin: -2px 0; color: var(--cinnabar); }
.think-lines { display: grid; gap: 3px; margin-top: 8px; padding-left: 38px; }
.think-lines li { position: relative; min-height: 1.75em; font-size: 13.5px; line-height: 1.75; color: var(--ink-soft); text-wrap: pretty; }
.think-lines li::before { content: ""; position: absolute; left: -16px; top: 0.72em; width: 5px; height: 5px; border-radius: 50%; background: var(--line-2); }
.think-lines li.is-typing::after { content: ""; display: inline-block; width: 1.5px; height: 1em; margin-left: 2px; vertical-align: -0.12em; background: var(--ink-2); animation: think-caret 0.9s steps(1) infinite; }
.think-lines li.is-ok::before { background: var(--ink-2); }
.think-lines li:empty::before { background: rgb(var(--ink-rgb) / 0.1); }
.gen-think.is-thinking .think-title { color: var(--ink); }
.gen-think.is-done .think-lines li { color: var(--muted); }
@keyframes think-caret { 50% { opacity: 0; } }

/* 思考时，上一次的结果先变淡 */
.is-stale { opacity: 0.42; filter: saturate(0.4); transition: opacity 300ms ease, filter 300ms ease; }

/* 进度条：一条细朱线，只在加载时出现 */
.gen-bar { position: absolute; z-index: 3; left: 0; right: 0; bottom: 0; height: 3px; background: rgb(var(--ink-rgb) / 0.1); opacity: 0; transition: opacity 200ms ease; pointer-events: none; }
.gen-bar i { display: block; height: 100%; background: var(--cinnabar); transform: scaleX(0); transform-origin: left; }
.is-loading > .gen-bar, .is-loading .gen-bar.is-stage { opacity: 1; }

/* 「AI 生成」（.ai-tag 在 fyro.css）：等待和生成中先藏起来 */
.is-wait .ai-tag, .is-loading .ai-tag { opacity: 0; }

/* 等待和生成中的底：极淡的点阵（只在空位里，不铺页面） */
.poster-card, .video-frames li { background: var(--paper-tint) radial-gradient(circle, rgb(var(--ink-rgb) / 0.16) 1px, transparent 1.4px) center / 12px 12px; }

/* ---------- 海报 ---------- */
.poster-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.poster-card { position: relative; display: block; width: 100%; aspect-ratio: 3 / 4; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; transition: translate 200ms var(--ease), box-shadow 200ms ease-out; }
.poster-media { position: absolute; inset: 0; }
.poster-media img { width: 100%; height: 100%; object-fit: cover; }
.is-wait .poster-media img { opacity: 0; }
/* 生成中：像素块画在 canvas 上（aigc.js 的 pixelate），完成后换回原图 */
.poster-px { position: absolute; inset: 0; z-index: 1; display: none; width: 100%; height: 100%; image-rendering: pixelated; }
.poster-card.is-loading .poster-px { display: block; }
.poster-card.is-loading .poster-media img { opacity: 0; }
.gen-step { position: absolute; z-index: 3; right: 8px; bottom: 10px; font-size: 11px; line-height: 1; color: var(--ink-2); opacity: 0; transition: opacity 200ms ease; }
.is-loading .gen-step, .is-wait .gen-step { opacity: 1; }
.poster-card:not(.is-loading):not(.is-wait) { cursor: zoom-in; }
@media (hover: hover) and (pointer: fine) {
  .gen:not([aria-busy="true"]) .poster-card:hover { translate: 0 -2px; box-shadow: 0 18px 30px -20px rgb(var(--shadow-rgb) / 0.5); }
}

/* ---------- 短片 ---------- */
.gen-src { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: var(--sheet); }
.gen-src img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.gen-src figcaption { padding: 6px 10px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.video-stage { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 12px; background: var(--night); box-shadow: 0 24px 40px -30px rgb(31 33 32 / 0.8); }
.video-stage .gen-video, .video-stage .video-src { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
html.js .video-stage .gen-video { cursor: pointer; }
.video-stage .video-src { z-index: 1; opacity: 0.5; filter: saturate(0.5); }
.video-stage.is-loading .gen-video { opacity: 0; }
.video-scan { position: absolute; z-index: 2; top: 0; bottom: 0; left: 0; width: 2px; background: linear-gradient(180deg, transparent, rgb(255 255 255 / 0.95) 30%, rgb(255 255 255 / 0.95) 70%, transparent); box-shadow: 0 0 18px 4px rgb(255 255 255 / 0.35); opacity: 0; pointer-events: none; }
.video-stage.is-scan .video-scan { opacity: 1; }
.video-label { position: absolute; z-index: 3; left: 50%; top: 50%; translate: -50% -50%; padding: 6px 14px; border-radius: 999px; background: rgb(31 33 32 / 0.6); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); font-size: 13px; letter-spacing: 0.04em; color: #ffffff; white-space: nowrap; }
.video-sound { position: absolute; z-index: 3; right: 10px; bottom: 12px; padding: 3px 12px; border: 1px solid rgb(255 255 255 / 0.3); border-radius: 999px; background: rgb(31 33 32 / 0.55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); font-size: 12.5px; line-height: 1.6; color: #ffffff; }
.video-frames { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.video-frames li { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; }
.video-frames img { width: 100%; height: 100%; object-fit: cover; }
.video-frames li.is-wait img { opacity: 0; }

/* ---------- 配音：逐字跟随 ---------- */
.voice-text { font-size: clamp(16px, 1.5vw, 18px); line-height: 2; letter-spacing: 0.02em; color: var(--ink); text-wrap: pretty; }
.voice-text.is-karaoke span { color: var(--muted); transition: color 120ms linear; }
.voice-text.is-karaoke span.on { color: var(--ink); }
.voice-text.is-karaoke span.now { color: var(--accent-text-sm); }

/* ---------- 播放条（配音、歌曲共用） ---------- */
.player { position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px 16px 10px 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: rgb(255 255 255 / 0.6); }
.player-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: var(--paper); transition: background-color 160ms ease-out; }
.player-btn svg { width: 18px; height: 18px; fill: currentColor; }
.player-btn .ic-pause, .player.is-playing .player-btn .ic-play { display: none; }
.player.is-playing .player-btn .ic-pause { display: inline; }
.player-btn:disabled { opacity: 0.5; cursor: progress; }
.player-wave { width: 100%; height: 44px; }
.player-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
html.js .player audio { display: none; }
html:not(.js) .player { grid-template-columns: minmax(0, 1fr); }
html:not(.js) .player-btn, html:not(.js) .player-wave, html:not(.js) .player-time { display: none; }
html:not(.js) .player audio { width: 100%; }

/* ---------- 歌曲 ---------- */
.song-lyrics { display: grid; gap: 2px; padding: 11px 14px; border: 1px solid var(--edge-soft); border-radius: var(--r-md); background: var(--surface-panel); font-size: 14px; line-height: 1.85; color: var(--ink-2); }
.song-card { display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); align-items: center; gap: 24px; }
.song-cover { position: relative; display: block; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-tint); box-shadow: 0 18px 30px -22px rgb(var(--shadow-rgb) / 0.6); }
.song-cover img { width: 100%; height: 100%; object-fit: cover; }
.song-meta { display: grid; gap: 6px; min-width: 0; }
.song-name { font-family: var(--head); font-size: clamp(24px, 2.4vw, 30px); font-weight: var(--w-title); line-height: 1.3; letter-spacing: var(--track-title); }
.song-sub { font-size: 13px; color: var(--muted); }
.song-meta .player { margin-top: 10px; }

/* ---------- 海报大图 ---------- */
.gen-lightbox { max-width: min(92vw, 760px); max-height: 94vh; padding: 0; overflow: visible; border: 0; background: transparent; }
.gen-lightbox::backdrop { background: rgb(24 25 24 / 0.82); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.gen-lightbox figure { display: grid; justify-items: center; gap: 12px; }
.gen-lightbox img { width: auto; max-width: 100%; max-height: calc(94vh - 48px); border-radius: 12px; box-shadow: 0 30px 60px -30px rgb(0 0 0 / 0.8); }
.gen-lightbox figcaption { font-size: 13px; letter-spacing: 0.04em; color: #ece7dc; text-align: center; }
.gen-lightbox-close { position: absolute; top: -6px; right: -6px; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: rgb(255 255 255 / 0.92); color: var(--ink); translate: 40% -40%; }
.gen-lightbox-close .i { width: 18px; height: 18px; }

/* ---------- 窄屏 ---------- */
@media (max-width: 1023px) {
  .gen-body { grid-template-columns: minmax(0, 1fr); }
  .gen-input { border-right: 0; border-bottom: 1px solid var(--line); }
  .gen-input > .gen-go { align-self: flex-start; }
  .gen-chips { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .gen-chips.is-2, .gen-chips.is-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gen-chips.is-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gen-src { max-width: 360px; }
}
@media (max-width: 639px) {
  .gen-input, .gen-output { padding: 18px 16px; }
  .gen-chips, .gen-chips.is-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gen-input > .gen-go { align-self: stretch; }
  .poster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .video-frames { gap: 5px; }
  .song-card { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .song-cover { width: min(220px, 62vw); }
  .player { grid-template-columns: 40px minmax(0, 1fr); padding-right: 12px; }
  .player-btn { width: 40px; height: 40px; }
  .player-time { grid-column: 2; margin-top: -6px; }
  .gen-lightbox-close { translate: 0 -110%; right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .think-lines li.is-typing::after { animation: none; }
}
