/* ============================================================
   BanShit · base.css
   设计令牌（明暗双主题）+ 重置 + 排版 + 跨页面共享组件
   杂志 / 编辑风：衬线标题、细线分栏、锐角、纸墨配色
   ============================================================ */

/* ---------- 设计令牌：亮色（纸面）为默认 ---------- */
:root {
  --bg: #f5f1e6;
  --panel: #fcfaf2;
  --text: #23201a;
  --muted: #6f6a59;
  --line: #d9d2bc;
  --accent: #b23a1f;
  --accent-hover: #c74b28;
  --on-accent: #fff7ea;
  --field: #fdfbf3;
  --photo: #e8e2d0;
  --danger: #a3341c;
  --danger-bg: #f6e3da;
  --serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", Georgia, serif;
  --sans: Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  color-scheme: light;
}

/* ---------- 暗色（墨色）：跟随系统 ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191712;
    --panel: #221f18;
    --text: #ece7d6;
    --muted: #a29b86;
    --line: #3e3a2d;
    --accent: #e2603c;
    --accent-hover: #ec7452;
    --on-accent: #26130a;
    --field: #14120e;
    --photo: #121109;
    --danger: #ff9d88;
    --danger-bg: #352119;
    color-scheme: dark;
  }
}

/* ---------- 手动切换覆盖系统偏好（见 theme.js） ---------- */
:root[data-theme="light"] {
  --bg: #f5f1e6;
  --panel: #fcfaf2;
  --text: #23201a;
  --muted: #6f6a59;
  --line: #d9d2bc;
  --accent: #b23a1f;
  --accent-hover: #c74b28;
  --on-accent: #fff7ea;
  --field: #fdfbf3;
  --photo: #e8e2d0;
  --danger: #a3341c;
  --danger-bg: #f6e3da;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #191712;
  --panel: #221f18;
  --text: #ece7d6;
  --muted: #a29b86;
  --line: #3e3a2d;
  --accent: #e2603c;
  --accent-hover: #ec7452;
  --on-accent: #26130a;
  --field: #14120e;
  --photo: #121109;
  --danger: #ff9d88;
  --danger-bg: #352119;
  color-scheme: dark;
}

/* ---------- 重置 ---------- */
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  transition: background 0.2s, color 0.2s;
}
a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  color: var(--accent);
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
::selection {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---------- 布局容器 ---------- */
.wrap {
  width: min(1240px, calc(100% - 80px));
  margin: auto;
}

/* ---------- 报头（masthead） ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 92px;
  border-bottom: 3px double var(--text);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand .brand-mark {
  width: 36px;
  height: 36px;
  align-self: center;
  border-radius: 8px;
  flex: none;
}
.brand-mark .mark-bg {
  fill: var(--accent);
}
.brand-mark .mark-body {
  fill: var(--on-accent);
}
.brand-mark .mark-face {
  fill: var(--accent);
  stroke: var(--accent);
}
.brand small {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--muted);
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 13px;
}
.header-nav a {
  color: var(--muted);
}
.header-nav a:hover {
  color: var(--accent);
}

/* ---------- 按钮 ---------- */
button {
  padding: 11px 20px;
  background: var(--accent);
  color: var(--on-accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  transition: background 0.15s var(--ease), border-color 0.15s, color 0.15s,
    transform 0.15s var(--ease), box-shadow 0.15s var(--ease), opacity 0.15s;
}
button:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 26%, transparent);
}
button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: none;
}
button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
button.secondary:hover:not(:disabled) {
  background: var(--panel);
  border-color: var(--text);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--text) 8%, transparent);
}
button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  padding: 8px 10px;
  font-weight: 400;
}
button.ghost:hover:not(:disabled) {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  box-shadow: none;
}

/* ---------- 表单 ---------- */
label {
  display: block;
  margin: 22px 0 9px;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--muted);
}
input,
textarea,
select {
  width: 100%;
  min-width: 0;
  padding: 12px;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  outline: none;
  transition: border-color 0.15s;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}
textarea {
  resize: vertical;
  line-height: 1.7;
}

/* ---------- 面板与提示 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 30px;
}
.muted,
.hint {
  color: var(--muted);
}
.hint {
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.7;
}
.notice {
  padding: 13px 18px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 3px;
  background: var(--panel);
  overflow-wrap: anywhere;
}
.notice.error {
  border-left-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}
.pill {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
  white-space: nowrap;
}
.empty {
  padding: 65px 20px;
  border: 1px dashed var(--line);
  border-radius: 3px;
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}
/* 空状态的便便剪影（颜色跟随主题） */
.empty::before {
  content: "";
  display: block;
  width: 58px;
  height: 58px;
  margin: 0 auto 16px;
  background: var(--muted);
  opacity: 0.5;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cg%3E%3Cellipse cx='32' cy='44' rx='20' ry='9'/%3E%3Cellipse cx='32' cy='33' rx='15' ry='8'/%3E%3Cellipse cx='32' cy='24' rx='10.5' ry='6.5'/%3E%3Cellipse cx='32' cy='17' rx='6' ry='4.5'/%3E%3Ccircle cx='38.5' cy='13' r='3'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cg%3E%3Cellipse cx='32' cy='44' rx='20' ry='9'/%3E%3Cellipse cx='32' cy='33' rx='15' ry='8'/%3E%3Cellipse cx='32' cy='24' rx='10.5' ry='6.5'/%3E%3Cellipse cx='32' cy='17' rx='6' ry='4.5'/%3E%3Ccircle cx='38.5' cy='13' r='3'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

/* ---------- 章节标题（报纸栏题） ---------- */
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 12px 0;
  border-top: 2px solid var(--text);
  border-bottom: 1px solid var(--line);
}
.section-heading h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
}
.section-heading h2 small {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-left: 8px;
}
.sec-no {
  color: var(--accent);
  font-style: italic;
  margin-right: 10px;
  font-size: 15px;
}

/* ---------- 页脚（版权栏） ---------- */
footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 60px;
  padding: 26px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 1px;
}

/* ---------- 全局通知 ---------- */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 13px 22px;
  background: var(--text);
  color: var(--bg);
  border-radius: 3px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
  font-size: 14px;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
#toast:not([hidden]) {
  animation: toast-in 0.25s var(--ease);
}

/* ---------- 通用动作行 ---------- */
.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 减少动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 窄屏共享适配 ---------- */
@media (max-width: 600px) {
  .wrap {
    width: calc(100% - 32px);
  }
  .header-row {
    height: auto;
    min-height: 64px;
    flex-wrap: wrap;
    padding: 10px 0;
    row-gap: 4px;
  }
  .brand {
    font-size: 21px;
  }
  .brand small {
    display: none;
  }
  .header-nav {
    gap: 10px;
    font-size: 12px;
    margin-left: auto;
  }
  .header-nav a,
  .header-nav button {
    white-space: nowrap;
  }
  .header-nav button.ghost {
    padding: 6px;
  }
  .header-nav button.secondary {
    padding: 7px 12px;
  }
  button {
    padding: 10px 14px;
  }
  footer {
    flex-direction: column;
    gap: 6px;
    margin-top: 36px;
  }
}
