/* ==========================================================================
   意见箱（mailbox.php，docs/backend/mailbox.md）— 横幅沿用 legal.css 的 legal- 样式，本页类名使用 mbx- 前缀
   ========================================================================== */

/* base.css 显现后的 clip-path 会裁掉卡片阴影，本页取消（与隐私政策页相同） */
.js .page-mailbox [data-reveal].is-revealed { clip-path: none; }
.page-mailbox #main { overflow-x: clip; }
.legal-hero--mailbox .legal-hero__glyph { color: rgba(232, 135, 159, 0.05); }

/* ---------- 布局：左边信纸，右边「写信之前」 ---------- */
.mbx-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: clamp(28px, 4vw, 56px); align-items: start; }
.mbx-main { grid-column: 1; grid-row: 1; min-width: 0; }
.mbx-tips { grid-column: 2; grid-row: 1; position: sticky; top: calc(var(--header-h) + 24px); }

.mbx-card {
  position: relative;
  padding: clamp(22px, 3.4vw, 40px);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(ellipse 70% 50% at 100% 0%, rgba(232, 135, 159, 0.07), transparent 70%),
    linear-gradient(180deg, rgba(35, 27, 28, 0.92), rgba(19, 15, 16, 0.94));
  box-shadow: var(--shadow-1);
}
.mbx-card::before {
  content: "";
  position: absolute; left: clamp(22px, 3.4vw, 40px); right: clamp(22px, 3.4vw, 40px); top: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--c-gold), transparent);
  opacity: 0.7;
}

/* ---------- 表单 ---------- */
.mbx-form__title { display: flex; align-items: center; gap: 10px; margin: 0 0 26px; font-family: var(--f-serif); font-size: clamp(1.2rem, 2vw, 1.4rem); font-weight: 700; color: var(--c-gold-2); }
.mbx-form__title .icon { width: 24px; height: 24px; color: var(--c-gold); }

.mbx-field { display: grid; gap: 8px; min-width: 0; margin: 0 0 22px; padding: 0; border: 0; }
.mbx-label { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 0; font-weight: 600; font-size: 0.98rem; color: var(--c-text); }
.mbx-req { color: var(--c-peach); }
.mbx-tag { padding: 1px 8px; border: 1px solid var(--c-line-strong); border-radius: 999px; font-size: 0.72rem; font-weight: 500; line-height: 1.6; color: var(--c-muted); }

.mbx-input {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius);
  background: rgba(13, 10, 11, 0.6);
  color: var(--c-text);
  font-size: 1rem;
  line-height: 1.6;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.mbx-input::placeholder { color: rgba(148, 134, 131, 0.8); }
.mbx-input:hover { border-color: rgba(240, 214, 220, 0.36); }
.mbx-input:focus { outline: none; border-color: var(--c-peach); background: rgba(13, 10, 11, 0.85); box-shadow: 0 0 0 3px rgba(232, 135, 159, 0.22); }
.mbx-input--area { min-height: 230px; resize: vertical; }
.has-error .mbx-input { border-color: #e0675d; }
.has-error .mbx-input:focus { box-shadow: 0 0 0 3px rgba(224, 103, 93, 0.25); }

.mbx-counter { justify-self: end; margin: -2px 0 0; font-size: 0.8rem; color: var(--c-muted); font-variant-numeric: tabular-nums; }
.mbx-counter.is-near { color: var(--c-gold); }
.mbx-hint { margin: 0; font-size: 0.85rem; line-height: 1.7; color: var(--c-muted); }
.mbx-error { display: flex; align-items: flex-start; gap: 6px; margin: 0; font-size: 0.88rem; line-height: 1.7; color: #ff9d94; }
.mbx-error .icon { flex: none; width: 1em; height: 1em; margin-top: 0.3em; }

/* 类型：药丸形单选 */
.mbx-cats { display: flex; flex-wrap: wrap; gap: 10px; }
.mbx-cat { position: relative; display: inline-flex; }
.mbx-cat__input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: var(--cur-pointer); }
.mbx-cat__face {
  display: inline-flex; align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--c-line-strong);
  border-radius: 999px;
  background: rgba(13, 10, 11, 0.5);
  color: var(--c-text-2);
  font-size: 0.95rem;
  transition: color 0.2s, background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.mbx-cat:hover .mbx-cat__face { color: var(--c-text); border-color: rgba(232, 135, 159, 0.55); }
.mbx-cat__input:checked + .mbx-cat__face { color: #fff; border-color: var(--c-peach); background: rgba(232, 135, 159, 0.2); box-shadow: inset 0 0 0 1px rgba(232, 135, 159, 0.45); }
.mbx-cat__input:focus-visible + .mbx-cat__face { outline: 2px solid var(--c-peach-2); outline-offset: 2px; }
.has-error .mbx-cat__face { border-color: rgba(224, 103, 93, 0.6); }

.mbx-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }

/* 验证码：图片 + 换一张 + 输入框 */
.mbx-captcha { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; }
.mbx-captcha__pic { display: inline-block; flex: none; width: 150px; height: 50px; overflow: hidden; border-radius: var(--radius); background: #f6eee4; box-shadow: 0 0 0 1px var(--c-line-strong); }
.mbx-captcha__pic img { display: block; width: 150px; height: 50px; }
.mbx-captcha__refresh {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--c-text-2);
  font-size: 0.92rem;
  transition: color 0.2s, border-color 0.2s;
}
.mbx-captcha__refresh:hover { color: var(--c-text); border-color: rgba(232, 135, 159, 0.55); }
.mbx-captcha__refresh:focus-visible { outline: 2px solid var(--c-peach-2); outline-offset: 2px; }
.mbx-captcha__refresh .icon { width: 18px; height: 18px; }
.mbx-captcha__refresh.is-busy .icon { animation: tl-spin 0.9s linear infinite; }
.mbx-captcha__input { flex: none; width: 140px; font-family: var(--f-num); font-size: 1.25rem; letter-spacing: 0.3em; text-align: center; }

/* 机器人陷阱：看不见，也不能用 Tab 进入 */
.mbx-hp { position: absolute !important; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

.mbx-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; margin-top: 6px; padding-top: 22px; border-top: 1px solid var(--c-line); }
.mbx-consent { max-width: 460px; margin: 0; font-size: 0.85rem; line-height: 1.7; color: var(--c-muted); }
.mbx-consent a, .mbx-tips a { color: var(--c-peach-2); text-decoration: underline; text-underline-offset: 3px; }
.mbx-submit[disabled] { opacity: 0.7; pointer-events: none; }

/* 错误汇总 */
.mbx-summary { margin: 0 0 24px; padding: 14px 18px; border: 1px solid rgba(224, 103, 93, 0.5); border-radius: var(--radius); background: rgba(194, 59, 50, 0.1); }
.mbx-summary:focus { outline: none; box-shadow: 0 0 0 3px rgba(224, 103, 93, 0.3); }
.mbx-summary__title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-weight: 600; color: #ffb3ab; }
.mbx-summary__title .icon { width: 18px; height: 18px; }
.mbx-summary ul { margin: 0; padding-left: 1.6em; color: #ffd0cb; font-size: 0.92rem; line-height: 1.8; }
.mbx-summary a { color: #ffd0cb; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- 写信之前 ---------- */
.mbx-tips { padding: 22px 22px 18px; border: 1px solid var(--c-line); border-radius: var(--radius-lg); background: rgba(255, 255, 255, 0.015); }
.mbx-tips__title { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; font-family: var(--f-serif); font-size: 1.1rem; font-weight: 700; color: var(--c-gold-2); }
.mbx-tips__title .icon { width: 22px; height: 22px; color: var(--c-gold); }
.mbx-tips__list { display: grid; gap: 14px; margin: 0 0 14px; padding: 0; list-style: none; }
.mbx-tips__list li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; font-size: 0.92rem; line-height: 1.75; color: var(--c-text-2); }
.mbx-tips__list .icon { width: 20px; height: 20px; margin-top: 0.25em; color: var(--c-peach-2); }
.mbx-tips__list strong { color: var(--c-text); }
.mbx-tips__foot { margin: 0; padding-top: 12px; border-top: 1px dashed var(--c-line); font-size: 0.85rem; line-height: 1.7; color: var(--c-muted); }
.mbx-tips__foot + .mbx-tips__foot { padding-top: 6px; border-top: 0; }

/* ---------- 寄出成功 / 不能寄信 ---------- */
.mbx-done, .mbx-state { display: grid; justify-items: center; gap: 12px; padding-block: clamp(40px, 6vw, 68px); text-align: center; }
.mbx-done__seal {
  display: grid; place-items: center;
  width: 76px; height: 76px;
  border-radius: 50%;
  color: #fff;
  background: radial-gradient(circle at 32% 30%, #dd5d52, var(--c-cinnabar) 70%);
  box-shadow: 0 12px 34px rgba(194, 59, 50, 0.38), inset 0 0 0 3px rgba(255, 255, 255, 0.12);
  transform: rotate(-6deg);
}
.mbx-done__seal .icon { width: 36px; height: 36px; }
.mbx-done__title { margin: 8px 0 0; font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.2; }
.mbx-done__number { margin: 0; color: var(--c-text-2); }
.mbx-done__number b { font-family: var(--f-num); font-size: 1.2em; color: var(--c-gold-2); }
.mbx-done__text, .mbx-state__text { max-width: 520px; margin: 0; line-height: 1.8; color: var(--c-text-2); }
.mbx-done__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 12px; }
.mbx-state__icon { display: grid; place-items: center; width: 64px; height: 64px; border: 1px solid var(--c-line-strong); border-radius: 50%; color: var(--c-gold); background: rgba(217, 191, 134, 0.06); }
.mbx-state__icon .icon { width: 28px; height: 28px; }
.mbx-state__title { margin: 4px 0 0; font-family: var(--f-serif); font-size: 1.4rem; font-weight: 700; color: var(--c-text); }
.mbx-state .btn { margin-top: 10px; }

@media (max-width: 1024px) {
  .mbx-layout { grid-template-columns: minmax(0, 1fr); }
  .mbx-tips { position: static; grid-column: 1; grid-row: 1; }
  .mbx-main { grid-row: 2; }
}

@media (max-width: 640px) {
  .mbx-row { grid-template-columns: minmax(0, 1fr); }
  .mbx-cats { gap: 8px; }
  .mbx-cat__face { padding: 0 14px; }
  .mbx-actions { flex-direction: column; align-items: stretch; }
  .mbx-submit { justify-content: center; width: 100%; }
  .mbx-tips { padding: 18px 16px 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .mbx-captcha__refresh.is-busy .icon { animation: none; }
}
