/* =====================================================================
   05 · 留言内嵌样式
   ---------------------------------------------------------------------
   独立文件。配色走 05 的 flexoki 变量，正文栏宽度由 .ac-read__inner 控制。
   这一份只覆盖配色与内嵌节奏，结构类名与 04 完全一致。
   ===================================================================== */

/* 面板的左边距 / 内边距 / 宽度共用一个来源：
   --cm-pad 既是内边距也是左边空隙，--cm-w 是面板宽度。
   按钮要正好落在面板的中线上，所以两个值都得能在面板外读到。 */
:root {
  --cm-pad: clamp(20px, 4vw, 44px);
  --cm-w: calc(50vw - var(--cm-pad));
  /* 正文那一栏的左边界，按钮的最左端要跟它对齐（跟 .ac-read 的左内边距同一套值） */
  --cm-text-x: calc(clamp(24px, 5vw, 72px) + 140px);
}

/* 留言这套组件挂在 body 上，不在 [data-page-module] 作用域里，
   拿不到那边的 border-box，得自己声明一遍——不然 width+padding 会撑出面板。 */
.cm-trigger,
.cm-overlay,
.cm-panel,
.cm-panel *,
.cm-trigger * {
  box-sizing: border-box;
}

/* ---------- 触发按钮（05 用内嵌，这个用不到，留着备抽屉版） ---------- */
.cm-trigger {
  position: fixed;
  /* 最左端和正文左边界对齐（--cm-text-x 由上面的 :root 给出） */
  left: var(--cm-text-x);
  bottom: 26px;
  z-index: 9000;
  padding: 11px 20px;
  border: 1px solid var(--line, #e6e4d9);
  border-radius: 999px;
  background: var(--paper, #fff);
  color: var(--ink, #100f0f);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.07);
  transition: border-color 0.2s, transform 0.2s, opacity 0.2s;
}

.cm-trigger:hover {
  border-color: var(--ink, #100f0f);
  transform: translateY(-1px);
}

.cm-trigger.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* ---------- 遮罩与抽屉（同上，备用） ---------- */
.cm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9001;
  background: rgba(16, 15, 15, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

.cm-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* 从底部升起的抽屉：高度封顶，内部滚动，不再占正文的位置 */
.cm-panel {
  position: fixed;
  right: auto;
  bottom: 0;
  /* 只在左半边弹。左边空隙 = 内边距，这样「文字到面板边」和
     「面板到屏幕边」一样宽，两条留白看起来是一条 */
  left: var(--cm-pad);
  width: var(--cm-w);
  z-index: 9002;
  display: flex;
  flex-direction: column;
  max-height: min(78dvh, 640px);
  background: var(--paper, #fff);
  border-top: 1px solid var(--line, #e6e4d9);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -24px 60px rgba(16, 15, 15, 0.18);
  transform: translateY(100%);
  transition: transform 0.36s cubic-bezier(0.22, 0.68, 0.21, 1);
  will-change: transform;
}

.cm-panel.is-open {
  transform: translateY(0);
}

/* 抽屉顶上的小横条 */
.cm-panel::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  width: 38px;
  height: 3px;
  margin-left: -19px;
  border-radius: 2px;
  background: var(--line, #e6e4d9);
  pointer-events: none;
}

/* 抽屉里只这一层滚动，滚到头也不会把整页带着走 */
.cm-panel .cm-inside {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 26px var(--cm-pad) 34px;
  gap: 1.2em;
  /* 宽屏上别让留言横跨 1440，收到 680 居中 */
  width: min(100%, 680px);
  margin-inline: auto;
}

/* 抽屉开着时锁住整页滚动 */
body.cm-locked {
  overflow: hidden;
}

.cm-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  z-index: 3;
  border-radius: 50%;
  background: var(--paper, #fff);
  color: var(--faint, #b7b5ac);
  font-family: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

/* ---------- 内嵌容器（05 的实际形态） ---------- */
.cm-inline {
  margin-top: 3.2em;
  padding-top: 2em;
  border-top: 1px solid var(--line, #e6e4d9);
}

.cm-inside {
  display: flex;
  flex-direction: column;
  gap: 1.5em;
}

.cm-title {
  margin: 0;
  font-size: 1.05em;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink, #100f0f);
}

.cm-count {
  margin-left: 0.5em;
  font-size: 0.78em;
  font-weight: 400;
  color: var(--faint, #b7b5ac);
}

/* ---------- 列表 ---------- */
.cm-list {
  display: flex;
  flex-direction: column;
  gap: 1.25em;
}

.cm-empty {
  margin: 0;
  font-size: 0.85em;
  color: var(--faint, #b7b5ac);
}

.cm-item {
  padding-bottom: 1.25em;
  border-bottom: 1px solid var(--line, #e6e4d9);
}

.cm-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.cm-item__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.7em;
  margin-bottom: 0.5em;
}

.cm-item__name {
  font-size: 0.85em;
  font-weight: 500;
  color: var(--ink, #100f0f);
}

.cm-item__time {
  font-size: 0.75em;
  font-variant-numeric: tabular-nums;
  color: var(--faint, #b7b5ac);
}

.cm-item__tag {
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 0.7em;
  letter-spacing: 0.03em;
}

.cm-item__tag--approved {
  background: #eef2ec;
  color: #4a6b4e;
}

.cm-item__tag--pending {
  background: #f7f2e8;
  color: #8a6d38;
}

.cm-item__tag--rejected {
  background: #f5eeee;
  color: #94484a;
}

.cm-item__text {
  margin: 0;
  font-size: 0.88em;
  line-height: 1.72;
  color: var(--ink, #100f0f);
  white-space: pre-wrap;
  word-break: break-word;
}

.cm-item__acts {
  display: flex;
  gap: 0.5em;
  margin-top: 0.7em;
}

/* ---------- 表单 ---------- */
.cm-form {
  display: flex;
  flex-direction: column;
  gap: 0.6em;
}

.cm-input,
.cm-textarea {
  width: 100%;
  padding: 0.55em 0.7em;
  border: 1px solid var(--line, #e6e4d9);
  border-radius: 3px;
  background: var(--wash, #f2f0e5);
  color: var(--ink, #100f0f);
  font-family: inherit;
  font-size: 0.85em;
  line-height: 1.6;
  transition: border-color 0.2s, background 0.2s;
}

.cm-textarea {
  resize: vertical;
  min-height: 5em;
}

.cm-input:focus,
.cm-textarea:focus {
  outline: none;
  border-color: var(--ink, #100f0f);
  background: #fff;
}

.cm-input::placeholder,
.cm-textarea::placeholder {
  color: var(--faint, #b7b5ac);
}

.cm-submit {
  align-self: flex-start;
  margin-top: 0.3em;
  padding: 0.5em 1.3em;
  border: 0;
  border-radius: 3px;
  background: var(--ink, #100f0f);
  color: #fff;
  font-family: inherit;
  font-size: 0.82em;
  cursor: pointer;
  transition: opacity 0.2s;
}

.cm-submit:hover:not(:disabled) {
  opacity: 0.82;
}

.cm-submit:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.cm-hint {
  margin: 0;
  font-size: 0.75em;
  line-height: 1.6;
  color: var(--faint, #b7b5ac);
}

.cm-hint--done {
  color: #4a6b4e;
}

.cm-btn {
  padding: 0.3em 0.9em;
  border: 1px solid var(--line, #e6e4d9);
  border-radius: 2px;
  background: #fff;
  font-family: inherit;
  font-size: 0.75em;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.cm-btn--ok:hover {
  border-color: #4a6b4e;
  color: #4a6b4e;
}

.cm-btn--no:hover {
  border-color: #94484a;
  color: #94484a;
}

.cm-foot {
  margin: 0;
  font-size: 0.75em;
  line-height: 1.6;
  color: var(--faint, #b7b5ac);
}

/* 窄屏是单栏布局，抽屉恢复全宽 */
@media (max-width: 1099px) {
  /* 单栏时抽屉占满剩余宽度，左边照样留出那一格空隙 */
  :root {
    --cm-w: calc(100vw - var(--cm-pad));
    --cm-text-x: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cm-panel,
  .cm-overlay,
  .cm-trigger {
    transition: none;
  }
}

/* ---------- 深色模式（2026-10-28） ----------
   这份文件里几处写死了浅色值，深色下会白得刺眼，单独覆盖一遍。
   其余颜色都走 var(--paper/--ink/--line/--faint/--wash)，跟着 05 的深色变量自动走。 */
[data-theme="dark"] .cm-item__tag--approved { background: #1e2a20; color: #8fbb97; }
[data-theme="dark"] .cm-item__tag--pending  { background: #2a2419; color: #d3a668; }
[data-theme="dark"] .cm-item__tag--rejected { background: #2b1e1e; color: #cf8b8b; }

[data-theme="dark"] .cm-input:focus,
[data-theme="dark"] .cm-textarea:focus { background: #0d0b09; }

/* 提交钮底色是 var(--ink)（深色下变浅），字得跟着反过来 */
[data-theme="dark"] .cm-submit { color: var(--paper, #16140f); }

[data-theme="dark"] .cm-hint--done { color: #8fbb97; }

[data-theme="dark"] .cm-btn { background: #100e0b; color: var(--ink, #f2f0e8); }
[data-theme="dark"] .cm-btn--ok:hover { border-color: #8fbb97; color: #8fbb97; }
[data-theme="dark"] .cm-btn--no:hover { border-color: #cf8b8b; color: #cf8b8b; }
