/* overlay.css — 自定义诗句 + 分享 UI 覆盖层样式（v1.9）
   设计令牌与 params.js PARAMS.ui / PARAMS.share z-index 保持同源（params.js 为唯一真源）。 */

:root {
  --af-paper: #efe4cd;
  --af-ink: #3a2c21;
  --af-white: #fcfcfd;
  --af-amber: #ffb250;
  --af-font: 'Songti SC', 'STSong', 'SimSun', serif;
  --af-ending-z: 1500;
  --af-panel-z: 2000;
  --af-preview-z: 2500;
  --af-toast-z: 3000;
}

/* ============ 结尾 DOM 按钮组（z 1500，锚定在画布「再想你一次」下方 12px） ============ */
#af-ending-row {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--af-ending-z);
  display: none;
  flex-direction: column; /* 纵向排列：primary 组（写下我的诗句…）在上，share 组（保存/发布/截屏分享）在下 */
  align-items: center;    /* 子组水平居中 → 「写下我的诗句」几何中心落在画布中轴 */
  gap: var(--af-ending-group-gap, 12px);
  max-width: min(640px, calc(100vw - 24px));
  padding: 0 8px; /* 仅水平留白；列向布局下无底部内容，避免容器底边探出视口 */
  padding-bottom: max(0px, env(safe-area-inset-bottom)); /* iOS 安全区：真机 env()>0 时避让 home indicator；PC/无安全区设备归零，行盒不探出视口 */
  box-sizing: border-box;
  pointer-events: none; /* 容器不拦截空白，按钮自身可点，不挡画布返回按钮 */
}
#af-ending-row > * { pointer-events: auto; }

.af-ending-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--af-ending-inner-gap, 10px);
}

/* 结尾按钮 = 画布「再想你一次」胶囊同族（drawReturnCue 转译）：
   高度/字号/内边距/各透明度由 share.js 从 PARAMS.story / PARAMS.ui.endingBtn 写入 CSS 变量，
   不在 CSS 里硬编码魔法数字（PARAMS 集中原则）。DOM 按钮无 ↺ 图标 → 文字居中（与画布左对齐不同，合理）。 */
.af-ending-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--af-ending-h, 46px);                /* = story.returnBtnHeight，≥44 iOS HIG */
  padding: 0 var(--af-ending-pad, 22px);           /* = story.returnBtnPadding */
  border-radius: calc(var(--af-ending-h, 46px) / 2); /* 全胶囊 = 高/2，与画布一致 */
  border: var(--af-ending-border-width, 1px) solid rgba(255, 255, 255, var(--af-ending-border-alpha, 0.4)); /* 宽度/alpha 由 share.js 从 PARAMS.ui.endingBtn 写入 CSS 变量；1px 单物理像素渲染稳定、两个相邻按钮线条等感（0.5px 抗锯齿发虚会显成"线条不统一"假象） */
  background: rgba(12, 12, 14, var(--af-ending-bg-alpha, 0.5));
  color: rgba(252, 252, 253, var(--af-ending-text-alpha, 0.78));
  font-family: var(--af-font);
  font-size: var(--af-ending-fs, 24.6px);          /* = verseSize × returnBtnFontScale */
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  user-select: none;
  transition: transform 0.12s ease-out, border-color 0.16s ease-out, box-shadow 0.16s ease-out;
}
/* 悬停：白边 0.72 + 白色叠层 0.10（与画布 hovering 态一致） */
.af-ending-btn:hover {
  border-color: rgba(255, 255, 255, var(--af-ending-border-hover-alpha, 0.72));
  color: rgba(252, 252, 253, var(--af-ending-text-hover-alpha, 0.92));
  box-shadow: inset 0 0 0 999px rgba(255, 255, 255, var(--af-ending-hover-overlay-alpha, 0.10));
}
/* 按下：scale 0.97 + 白边 0.56（与画布 active 态一致） */
.af-ending-btn:active {
  transform: scale(0.97);
  border-color: rgba(255, 255, 255, var(--af-ending-border-active-alpha, 0.56));
  box-shadow: none;
}

.af-publish-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: var(--af-ending-hint-gap, 6px);
}
.af-ending-hint {
  font-family: var(--af-font);
  font-size: 12px;
  color: rgba(252, 252, 253, 0.78);
  letter-spacing: 0.5px;
  line-height: 1.4;
  text-align: center;
  padding: 0 8px;
}
/* 直接挂在组内的提示文案（截屏分享/长按提示）独占一行、居中于其上方按钮下方；
   publish-wrap 内的「编辑后发布」不受此规则影响（避免列向容器里 100% 高度） */
.af-ending-group > .af-ending-hint {
  flex: 0 0 100%;
}

/* 呼吸引导：首次结尾「写下我的诗句」约 3.2s 强调（localStorage['airfill.guideSeen'] 标记后不再重复） */
@keyframes af-breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 178, 80, 0); }
  50% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(255, 178, 80, 0.30); }
}
.af-breathe {
  animation: af-breathe 3.2s ease-in-out 1;
}

/* ============ 填词面板覆盖层（z 2000，米色纸面卡片） ============ */
.af-panel {
  position: fixed;
  inset: 0;
  z-index: var(--af-panel-z);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--af-font);
}
.af-panel-scrim {
  position: absolute;
  inset: 0;
  background: rgba(18, 12, 8, 0.45);
}
.af-panel-card {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--af-paper);
  color: var(--af-ink);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(20, 12, 6, 0.45);
  padding: 14px 20px 22px;
  box-sizing: border-box;
}
.af-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.af-panel-title {
  font-size: 17px;
  font-weight: bold;
  letter-spacing: 2px;
}
.af-icon-btn {
  width: 44px; /* ≥44px 最小点击目标 */
  height: 44px;
  border: none;
  background: transparent;
  color: var(--af-ink);
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
  border-radius: 10px;
  flex: 0 0 auto;
}
.af-icon-btn:active { background: rgba(58, 44, 33, 0.10); }

.af-step-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 10px;
}
.af-input {
  width: 100%;
  height: 48px; /* ≥44px 最小点击目标 */
  padding: 0 14px;
  box-sizing: border-box;
  border: 1px solid rgba(58, 44, 33, 0.35);
  border-radius: 8px;
  background: var(--af-white);
  color: var(--af-ink);
  font-family: var(--af-font);
  font-size: 17px;
  outline: none;
  touch-action: manipulation;
}
.af-input:focus { border-color: var(--af-amber); }
.af-hint {
  font-size: 13px;
  color: rgba(58, 44, 33, 0.72);
  margin-top: 8px;
  line-height: 1.5;
}
.af-warn {
  font-size: 13px;
  color: #b0562c;
  margin-top: 8px;
  line-height: 1.5;
  min-height: 0;
}

.af-btn-primary {
  width: 100%;
  height: 48px; /* ≥44px 最小点击目标 */
  margin-top: 14px;
  border: none;
  border-radius: 24px;
  background: var(--af-ink);
  color: var(--af-white);
  font-family: var(--af-font);
  font-size: 16px;
  letter-spacing: 2px;
  cursor: pointer;
  touch-action: manipulation;
}
.af-btn-primary:disabled {
  opacity: 0.4;
  cursor: default;
}
.af-btn-restore {
  display: block;
  width: 100%;
  height: 44px; /* ≥44px 最小点击目标 */
  margin-top: 6px;
  border: none;
  background: transparent;
  color: rgba(58, 44, 33, 0.80);
  font-family: var(--af-font);
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
  touch-action: manipulation;
}

/* 动作词胶囊（5 选 1 + 自定义） */
.af-pills { margin-top: 12px; }
.af-action-custom { margin-top: 10px; }  /* 自定义动作词输入框：与胶囊行拉开间距 */
.af-pills-label {
  font-size: 13px;
  color: rgba(58, 44, 33, 0.72);
  margin-bottom: 6px;
}
.af-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.af-pill {
  height: 44px; /* ≥44px 最小点击目标 */
  padding: 0 18px;
  border-radius: 22px;
  border: 1px solid rgba(58, 44, 33, 0.40);
  background: transparent;
  color: var(--af-ink);
  font-family: var(--af-font);
  font-size: 15px;
  cursor: pointer;
  touch-action: manipulation;
}
.af-pill.active {
  background: var(--af-ink);
  color: var(--af-white);
  border-color: var(--af-ink);
}

/* 示例词库 */
.af-example { margin-top: 12px; }
.af-example-label {
  font-size: 13px;
  color: rgba(58, 44, 33, 0.72);
  margin-bottom: 6px;
}
.af-example-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.af-example-chip {
  height: 44px; /* ≥44px 最小点击目标 */
  padding: 0 16px;
  border-radius: 22px;
  border: 1px dashed rgba(58, 44, 33, 0.45);
  background: transparent;
  color: var(--af-ink);
  font-family: var(--af-font);
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
}

/* 预览区 */
.af-preview {
  margin-top: 14px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
}
.af-preview-label {
  font-size: 13px;
  color: rgba(58, 44, 33, 0.72);
  margin-bottom: 6px;
}
.af-preview-verse {
  font-size: 18px;
  font-weight: bold;
  line-height: 1.6;
  letter-spacing: 2px;
  word-break: break-all;
}
.af-preview-line {
  font-size: 16px;
  line-height: 1.6;
  margin-top: 4px;
  letter-spacing: 1px;
  word-break: break-all;
}
.af-preview-note {
  font-size: 12px;
  color: rgba(58, 44, 33, 0.60);
  margin-top: 6px;
}

/* ============ 分享预览覆盖层（z 2500，长按图片另存降级用） ============ */
.af-preview-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--af-preview-z);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(10, 8, 6, 0.86);
}
.af-preview-img {
  max-width: min(86vw, 480px);
  max-height: 68vh;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  user-select: none;
  -webkit-user-select: none;
  /* 不设 -webkit-touch-callout: none —— 保留长按「存储图像」系统菜单 */
}
.af-preview-hint {
  font-family: var(--af-font);
  font-size: 14px;
  color: var(--af-white);
  letter-spacing: 1px;
}
.af-preview-close {
  width: 44px; /* ≥44px 最小点击目标 */
  height: 44px;
  border: 1px solid rgba(252, 252, 253, 0.4);
  border-radius: 50%;
  background: rgba(58, 44, 33, 0.6);
  color: var(--af-white);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
}

/* ============ Toast 轻提示（z 3000） ============ */
.af-toast {
  position: fixed;
  left: 50%;
  bottom: 120px;
  transform: translateX(-50%) translateY(10px);
  z-index: var(--af-toast-z);
  max-width: calc(100vw - 48px);
  padding: 12px 22px;
  border-radius: 999px;
  background: rgba(58, 44, 33, 0.94);
  color: var(--af-white);
  font-family: var(--af-font);
  font-size: 14px;
  letter-spacing: 1px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.af-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
