/* ============================================================
   亮品牌 · 组件层（components.css）
   全站唯一的组件实现：按钮 / 图标按钮 / 卡片 / 标签 / 表单 / 表格 /
   提示条 / 弹窗 / 媒体网格。
   前台、编辑器、后台一律引用本文件，禁止各端再写一份。
   依赖：tokens.css（令牌）→ base.css（基线）→ 本文件
   命名：无前缀语义名；修饰符用 .xxx；状态用 .is-xxx；编辑器浮层专用 ed-
   ============================================================ */

/* ---------------- 按钮 ---------------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  gap: 10px; min-height: 44px;                 /* HIG §4.4 触控目标 */
  padding: 14px 28px; font: inherit; font-size: 0.875rem; font-weight: 500; letter-spacing: .02em;
  border: 1px solid var(--ink); border-radius: var(--radius-pill);
  background: var(--ink); color: var(--on-dark); cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; }

.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--depth-base); border-color: var(--ink); }
.btn.danger { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.block { width: 100%; }
/* 按钮内箭头（前台内容区使用）*/
.btn .arr { transition: transform .35s var(--ease); }
.btn:hover .arr { transform: translateX(4px); }
/* 深色底上的按钮（前台 CTA 区块）*/
.btn.on-dark { border-color: var(--on-dark); color: var(--on-dark); }
.btn.on-dark:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary { background: var(--ink); color: var(--on-dark); border-color: var(--ink); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.sm { min-height: 34px; padding: 0 14px; font-size: 0.8125rem; }
.btn.sm.ghost { min-height: 34px; }

/* ---------------- 图标按钮 ---------------- */
.icon-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;                    /* HIG §4.4 */
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--depth-elevated); color: var(--ink-2);
  font-size: 14px; line-height: 1; cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { border-color: var(--ink); color: var(--ink); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon-btn.danger:hover { border-color: var(--accent); color: var(--accent); }

/* ---------------- 卡片（elevated 层） ---------------- */
.card {
  background: var(--depth-elevated);
  border: 1px solid var(--line); border-radius: var(--radius-card);
  padding: clamp(20px, 2.6vw, 30px); margin-bottom: 18px;
}
.card > h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 6px; }
.card > h2:only-child { margin-bottom: 0; }
.hint { font-size: 0.8125rem; line-height: 1.65; color: var(--ink-3); margin: 8px 0 18px; }
.hint:last-child { margin-bottom: 0; }

/* ---------------- 标签 ---------------- */
.tag {
  display: inline-block; font-size: 0.6875rem; letter-spacing: .1em; line-height: 1.6;
  padding: 2px 8px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--ink-2);
}
.tag.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field > label, .field-label {
  display: block; font-size: 0.75rem; letter-spacing: .06em; color: var(--ink-2); margin-bottom: 7px;
}
.input, input.input, textarea.input, select.input {
  width: 100%; min-height: 44px; padding: 10px 13px;
  font: inherit; font-size: 0.875rem; color: var(--ink);
  background: var(--depth-elevated);
  border: 1px solid var(--line-strong); border-radius: 10px;
  transition: border-color var(--dur-fast) var(--ease);
}
textarea.input { min-height: 92px; resize: vertical; line-height: 1.6; }
.input:focus, .input:focus-visible { outline: none; border-color: var(--ink); }
.input::placeholder { color: var(--ink-3); }
.field.has-error .input { border-color: var(--accent); }
/* HIG §2.2：错误不能只靠颜色 → 带符号的第二指示 */
.field-error { display: block; margin-top: 6px; font-size: 0.75rem; color: var(--accent); }
.field-error::before { content: '⚠ '; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > * { flex: 1 1 160px; min-width: 0; }
.row2, .row3 { display: flex; gap: 14px; flex-wrap: wrap; }
.row2 > * { flex: 1 1 200px; min-width: 0; }
.row3 > * { flex: 1 1 140px; min-width: 0; }
.withbtn { display: flex; gap: 8px; align-items: center; }
.withbtn > .input { flex: 1 1 auto; }

/* ---------------- 表格 ---------------- */
.table {
  width: 100%; border-collapse: collapse;
  background: var(--depth-elevated);
  border: 1px solid var(--line); border-radius: var(--radius-card); overflow: hidden;
  font-size: 0.8125rem;
}
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: 0.6875rem; letter-spacing: .1em; color: var(--ink-3); font-weight: 500; background: var(--depth-base); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--depth-base); }
.table .row-actions { white-space: nowrap; text-align: right; }
.table .row-actions .icon-btn { width: 34px; height: 34px; }

/* ---------------- 提示条（HIG §2.2：状态带图形符号） ---------------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 200;
  transform: translateX(-50%) translateY(14px);
  max-width: min(560px, calc(100vw - 40px));
  padding: 12px 22px; font-size: 0.8125rem; line-height: 1.5;
  color: var(--on-dark); border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--dark) 92%, transparent);
  backdrop-filter: blur(12px) saturate(1.1); -webkit-backdrop-filter: blur(12px) saturate(1.1);
  box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast::before { font-weight: 700; }
.toast.ok::before { content: '✓  '; }
.toast.err::before { content: '✗  '; }

/* ---------------- 弹窗（elevated 层 + 遮罩） ---------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 190;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(10, 10, 10, .5);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  opacity: 0; transition: opacity var(--dur) var(--ease);
}
.modal-mask.show { opacity: 1; }
.modal {
  width: min(760px, 96vw); max-height: 88vh;
  display: flex; flex-direction: column;
  background: var(--depth-elevated);
  border: 1px solid var(--line-strong); border-radius: var(--radius-card);
  box-shadow: var(--shadow-lg); overflow: hidden;
  transform: translateY(10px) scale(.99);
  transition: transform var(--dur) var(--ease);
}
.modal-mask.show .modal { transform: none; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-head .icon-btn { width: 36px; height: 36px; border: 0; background: none; font-size: 15px; }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--line);
}

/* ---------------- 媒体网格（选图器） ---------------- */
.media-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px;
}
.media-item, .media-up {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 118px; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; background: var(--depth-base);
  cursor: pointer; transition: border-color var(--dur-fast) var(--ease);
}
.media-item:hover, .media-up:hover { border-color: var(--ink); }
.media-item img, .media-item video { width: 100%; height: 100px; object-fit: cover; display: block; }
.media-name {
  font-size: 0.6875rem; color: var(--ink-3); padding: 4px 6px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-up { border-style: dashed; color: var(--ink-3); font-size: 0.75rem; }
.media-up b { font-size: 1.375rem; font-weight: 300; }

/* ---------------- 无障碍工具类 ---------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
