/**
 * 对联门框预览 — 样式
 * ---------------------------------------------------------------------------
 * 用于：对联书站文章页（每副「门框预览」）、对联工具页（选中即预览）
 *
 * 设计原则（全站视觉规范）：不画门框线条、不描边，用「门洞背景色 + 红纸色块」
 * 表达横批在上、上联在右、下联在左的空间关系 —— 即「抽象门框」。
 * 竖排用 flex column 逐字堆叠，禁用 writing-mode（历史上两处踩坑）。
 */

/* 三档字体：均为自托管子集（3500/6500 常用字），font-display:swap 懒加载。
   font-weight 必须写 400 700，否则浏览器合成粗体（faux bold）会把笔画糊掉。 */
@font-face {
  font-family: "Ma Shan Zheng";
  src: url("/static/fonts/ma-shan-zheng/v1.0/mashanzheng-3500.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Zhi Mang Xing";
  src: url("/static/fonts/zhi-mang-xing/v1.0/zhimangxing-3500.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}

/* ===== 文章页：每副对联的「门框预览」小按钮 ===== */
.dl-couplet { position: relative; }
.dlf-trigger {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  border: none;
  border-radius: 50px;
  background: var(--bg-tertiary, #2b261f);
  color: var(--text-secondary, #c6c1b5);
  font-size: .72rem;
  line-height: 1.6;
  cursor: pointer;
  opacity: .55;
  transition: opacity .15s, background .15s, color .15s;
}
.dl-couplet:hover .dlf-trigger,
.dlf-trigger:focus-visible { opacity: 1; }
.dlf-trigger:hover { background: var(--accent-bg, rgba(61,165,94,.14)); color: var(--accent, #3da55e); }
/* 手机上卡片是两行字 + 一个按钮：按钮垂直居中，别钉在右上角留出右下空洞 */
@media (max-width: 640px) {
  .dlf-trigger {
    top: 50%;
    transform: translateY(-50%);
    right: 10px;
    padding: 7px 12px;
    font-size: .78rem;
  }
}

/* ===== 遮罩 ===== */
.dlf-mask {
  position: fixed;
  inset: 0;
  z-index: 100002;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, .68);
  animation: dlfFadeIn .16s ease;
}
.dlf-mask.dlf-leave { animation: dlfFadeOut .14s ease forwards; }

/* ===== 面板 ===== */
.dlf-panel {
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: calc(100vh - 24px);
  background: var(--bg-card, #252018);
  color: var(--text-primary, #e8e4dc);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, .5);
  overflow: hidden;
  animation: dlfScaleIn .18s ease;
}

/* 头部 */
.dlf-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 18px;
  flex: 0 0 auto;
  background: var(--bg-surface, #1c1814);
}
.dlf-head-title { flex: 1; min-width: 0; font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dlf-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-muted, #928c7e);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
.dlf-close:hover { background: var(--bg-tertiary, #2b261f); color: var(--text-primary, #e8e4dc); }

/* 顺次浏览：文章页一页几百副，关掉再找按钮太累 */
.dlf-nav {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: var(--bg-tertiary, #2b261f);
  color: var(--text-secondary, #c6c1b5);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.dlf-nav:disabled { opacity: .32; cursor: default; }
.dlf-nav:not(:disabled):hover { color: var(--text-primary, #e8e4dc); }

/* ===== 舞台：门洞 + 红纸 ===== */
.dlf-stage {
  flex: 1 1 auto;
  min-height: 0;
  padding: 26px 16px 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  overflow: auto;
  /* 门洞：比面板更深的底色，红纸浮在其上 */
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, .05), transparent 62%),
    var(--bg-primary, #171410);
}

/* 横批（门楣） */
.dlf-hp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .12em;
  padding: .22em .3em;
  border-radius: 4px;
  background: linear-gradient(172deg, #cf3236 0%, #b32227 58%, #9c1b20 100%);
  color: #ffe6b8;
  font-size: var(--dlf-hp-fs, 30px);
  line-height: 1.15;
  letter-spacing: .02em;
  text-shadow: 0 1px 2px rgba(80, 0, 0, .45);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
}
.dlf-hp span { display: block; }
.dlf-hp[hidden] { display: none; }

/* 两列（上联右、下联左 —— DOM 顺序即左右顺序） */
.dlf-pair {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(20px, 9vw, 56px);
}
.dlf-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .04em;
  padding: .4em .26em;
  border-radius: 4px;
  background: linear-gradient(174deg, #cf3236 0%, #b32227 60%, #9c1b20 100%);
  color: #ffe6b8;
  font-size: var(--dlf-fs, 30px);
  line-height: 1.22;
  text-shadow: 0 1px 2px rgba(80, 0, 0, .45);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .35);
}
.dlf-col span { display: block; }

/* 字体档位 */
.dlf-stage { font-family: "Ma Shan Zheng", "STKaiti", "KaiTi", serif; }
.dlf-stage[data-font="kai"] { font-family: "LXGW WenKai GB", "STKaiti", "KaiTi", serif; }
.dlf-stage[data-font="xing"] { font-family: "Zhi Mang Xing", "STKaiti", "KaiTi", serif; }

/* 舞台底部提示（字数信息） */
.dlf-meta {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: .74rem;
  color: var(--text-muted, #928c7e);
  letter-spacing: .02em;
}

/* ===== 工具栏 ===== */
.dlf-bar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bg-surface, #1c1814);
}
.dlf-group { display: flex; gap: 4px; padding: 3px; border-radius: 50px; background: var(--bg-tertiary, #2b261f); }
.dlf-pill {
  padding: 5px 13px;
  border: none;
  border-radius: 50px;
  background: none;
  color: var(--text-secondary, #c6c1b5);
  font-size: .78rem;
  line-height: 1.7;
  cursor: pointer;
  white-space: nowrap;
}
.dlf-pill.on { background: var(--bg-card, #252018); color: var(--accent, #3da55e); font-weight: 600; }
.dlf-pill:not(.on):hover { color: var(--text-primary, #e8e4dc); }

/* 横批下拉 */
.dlf-hp-select {
  flex: 1 1 150px;
  min-width: 0;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: var(--bg-tertiary, #2b261f);
  color: var(--text-secondary, #c6c1b5);
  font-size: .78rem;
  line-height: 1.6;
  cursor: pointer;
}

/* 主/次按钮 */
.dlf-actions { display: flex; gap: 6px; margin-left: auto; }
.dlf-btn {
  padding: 6px 15px;
  border: none;
  border-radius: 50px;
  font-size: .78rem;
  font-weight: 500;
  line-height: 1.7;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}
.dlf-btn:hover { opacity: .86; }
.dlf-btn-ghost { background: var(--bg-tertiary, #2b261f); color: var(--text-secondary, #c6c1b5); }
.dlf-btn-primary { background: var(--accent, #3da55e); color: #fff; }

/* 文章页专用：去工具页挑更多（2026-11-27 场景互补出口；工具页自身不传 toolLink） */
.dlf-tool-hint {
  flex: 0 0 auto;
  padding: 0 16px 14px;
  text-align: center;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: .8rem;
  line-height: 1.6;
}
.dlf-tool-hint a {
  color: var(--text-muted, #928c7e);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.dlf-tool-hint a:hover { color: var(--accent, #3da55e); }

/* 手机端保存：摊开图片长按存相册（iOS/微信内 download 无任何反馈） */
.dlf-save {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
  overflow: auto;
  background: var(--bg-card, #252018);
}
.dlf-save-tip { font-size: .88rem; color: var(--text-secondary, #c6c1b5); text-align: center; }
.dlf-save-img { max-width: 100%; max-height: 66vh; border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.45); }
.dlf-save-done { min-width: 150px; }

/* ===== 手机端：底部上滑面板（拇指自然区），控件放大到能点 ===== */
@media (max-width: 640px) {
  .dlf-mask { align-items: flex-end; padding: 0; }
  .dlf-panel {
    width: 100%;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .dlf-head { padding: 12px 10px 12px 16px; }
  .dlf-head-title { font-size: .92rem; }
  .dlf-close { width: 40px; height: 40px; font-size: 1.2rem; }
  .dlf-nav { width: 40px; height: 40px; }
  .dlf-stage { padding: 18px 12px 20px; gap: 14px; }
  /* 第一行：字体胶囊 + 横批下拉并排；第二行：两个按钮各占一半 */
  .dlf-bar { padding: 10px 12px 12px; gap: 8px; }
  .dlf-pill { padding: 9px 11px; font-size: .82rem; line-height: 1.5; }
  .dlf-hp-select { flex: 1 1 0; min-width: 0; height: 38px; font-size: .82rem; }
  .dlf-actions { margin-left: 0; width: 100%; gap: 8px; }
  .dlf-btn { flex: 1; padding: 10px 12px; font-size: .86rem; line-height: 1.5; }
  .dlf-tool-hint { padding: 0 12px 12px; font-size: .78rem; }
}

/* ===== 入场动画 ===== */
@keyframes dlfFadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes dlfFadeOut { from { opacity: 1 } to { opacity: 0 } }
@keyframes dlfScaleIn { from { opacity: 0; transform: scale(.94) } to { opacity: 1; transform: scale(1) } }

/* ===== 文章页「分批显示」：超过首批的条目先隐藏（SEO 全量保留在 HTML） ===== */
.dl-couplet[hidden] { display: none; }
.dlf-more-wrap { display: flex; justify-content: center; margin: 4px 0 18px; }
.dlf-more {
  padding: 9px 30px;
  border: none;
  border-radius: 50px;
  background: var(--bg-surface, #1c1c1c);
  color: var(--text-secondary, #c6c1b5);
  font-size: .84rem;
  cursor: pointer;
}
.dlf-more:hover { background: var(--accent-bg, rgba(61,165,94,.14)); color: var(--accent, #3da55e); }
