/* =========================================================================
   Paris Travel Archive · base.css
   全站三色 design tokens（设计书 §4.3）：
   🐰 rabbit 粉紫 = person_a 的内容   🐶 dog 粉蓝 = person_b 的内容
   🧀 cheese 芝士黄 = 公共信息与操作   中性色 = 未知归属 / 照片底
   ========================================================================= */

:root {
  --bg-page: #FFFDF8;
  --bg-card: #FFFFFF;
  --text-main: #3F3A35;
  --text-sub: #6B6258;
  --border-soft: #EAE3D8;

  --rabbit-bg: #F6E7FA;
  --rabbit-main: #D79AE8;
  --rabbit-border: #C982DC;
  --rabbit-text: #6B4B76;

  --dog-bg: #E7F4FC;
  --dog-main: #9ED4F2;
  --dog-border: #7CC2E8;
  --dog-text: #48697A;

  --cheese-bg: #FFF7D6;
  --cheese-main: #F7D96B;
  --cheese-border: #E7C95C;
  --cheese-text: #6B501B;

  --unknown-bg: #F2F0EB;
  --unknown-border: #CFC6B8;

  /* 两人共同：粉紫 → 粉蓝渐变（中间色用于标签小尖角等无法渐变的部分） */
  --shared-bg: linear-gradient(90deg, var(--rabbit-bg), var(--dog-bg));
  --shared-border: linear-gradient(90deg, var(--rabbit-border), var(--dog-border));
  --shared-main: linear-gradient(90deg, var(--rabbit-main), var(--dog-main));
  --shared-bg-mid: #EEEDFB;
  --shared-border-mid: #A2A2E2;
  --shared-main-mid: #BAB7ED;
  --shared-text: #595A78;

  /* 角色主题变量：默认中性，由 [data-theme] 覆盖（见下方唯一映射） */
  --role-bg: var(--unknown-bg);
  --role-main: var(--border-soft);
  --role-border: var(--unknown-border);
  --role-text: var(--text-sub);

  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Noto Sans CJK SC", "Apple SD Gothic Neo", "Noto Sans KR", "Microsoft YaHei", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
    Georgia, "Songti SC", "Noto Serif CJK SC", serif;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(63, 58, 53, .05), 0 2px 8px rgba(63, 58, 53, .06);
  --shadow-2: 0 2px 6px rgba(63, 58, 53, .08), 0 14px 36px rgba(63, 58, 53, .12);
  --ease: cubic-bezier(.2, .8, .2, 1);

  --tap: 44px;
  --gutter: 16px;
  --header-h: 52px;
  --datebar-h: 60px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  color-scheme: light;
}

/* ---- 角色主题唯一映射：data-theme 由 participants.js 从 config.participants 写入 ---- */
[data-theme="rabbit"] {
  --role-bg: var(--rabbit-bg);
  --role-main: var(--rabbit-main);
  --role-border: var(--rabbit-border);
  --role-text: var(--rabbit-text);
}
[data-theme="dog"] {
  --role-bg: var(--dog-bg);
  --role-main: var(--dog-main);
  --role-border: var(--dog-border);
  --role-text: var(--dog-text);
}
[data-theme="cheese"] {
  --role-bg: var(--cheese-bg);
  --role-main: var(--cheese-main);
  --role-border: var(--cheese-border);
  --role-text: var(--cheese-text);
}
[data-theme="unknown"] {
  --role-bg: var(--unknown-bg);
  --role-main: var(--border-soft);
  --role-border: var(--unknown-border);
  --role-text: var(--text-sub);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}
h1, h2, h3, h4, p, figure, dl, dd { margin: 0; }
ol, ul { margin: 0; padding: 0; list-style: none; }
img, video, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
code { font-size: .9em; }
[hidden] { display: none !important; }

:where(button, a, select, input, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--cheese-text);
  outline-offset: 3px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; z-index: 2000; left: 12px; top: -60px;
  padding: 10px 16px; border-radius: var(--radius-pill);
  background: var(--cheese-main); color: var(--cheese-text);
  font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 15px; font-weight: 600; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .15s;
}
.btn:hover { background: var(--cheese-bg); border-color: var(--cheese-border); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--cheese-main); border-color: var(--cheese-border); color: var(--cheese-text); }
.btn--primary:hover { background: var(--cheese-main); border-color: var(--cheese-text); }
.btn--soft { background: var(--cheese-bg); border-color: var(--cheese-border); color: var(--cheese-text); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--cheese-text); padding: 0 10px; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn--lg { min-height: 52px; padding: 0 28px; font-size: 17px; }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: var(--tap); height: var(--tap);
  padding: 0;
  border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: var(--cheese-text);
  font-size: 18px; line-height: 1;
  transition: background-color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--cheese-bg); border-color: var(--cheese-border); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; border-color: transparent; }

/* ---- 公共筛选 chip（芝士黄；选中态除颜色外还有深色描边） ---- */
.chip-row {
  display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: none;
  padding: 3px; margin: -3px;
  -webkit-overflow-scrolling: touch;
}
.chip-row::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: none; position: relative;
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--cheese-border); border-radius: var(--radius-pill);
  background: var(--cheese-bg); color: var(--cheese-text);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.filter-chip::after { content: ""; position: absolute; inset: -3px 0; }
.filter-chip:hover { border-color: var(--cheese-text); }
.filter-chip[aria-pressed="true"] {
  background: var(--cheese-main);
  border-color: var(--cheese-text);
  box-shadow: inset 0 0 0 1px var(--cheese-text);
}

/* ---- 来源徽章（人物色；只描述内容归属） ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 10px 1px 6px;
  border: 1px solid var(--role-border); border-radius: var(--radius-pill);
  background: var(--role-bg); color: var(--role-text);
  font-size: 13px; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.badge__emoji { font-size: 15px; line-height: 1; }
.badge--emoji { padding: 1px 8px; }
.badge--unknown { border-style: dashed; padding: 1px 10px; }
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---- 地点 chip（公共芝士黄，与人物无关） ---- */
.place-chip {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 100%; min-height: 32px;
  padding: 3px 12px;
  border: 1px solid var(--cheese-border); border-radius: var(--radius-pill);
  background: var(--cheese-bg); color: var(--cheese-text);
  font-size: 13px; font-weight: 700; line-height: 1.4;
  text-decoration: none; overflow-wrap: anywhere;
}
button.place-chip:hover { background: var(--cheese-main); }
.place-chip[data-theme="rabbit"],
.place-chip[data-theme="dog"] { background: var(--role-bg); border-color: var(--role-border); color: var(--role-text); }
.place-chip[data-theme="shared"] {
  border-color: transparent;
  background: var(--shared-bg) padding-box, var(--shared-border) border-box;
  color: var(--shared-text);
}

.tag-unknown {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 0 8px;
  border: 1px dashed var(--unknown-border); border-radius: var(--radius-pill);
  background: var(--unknown-bg); color: var(--text-sub);
  font-size: 12px; font-weight: 600; line-height: 1.7; white-space: nowrap;
}

.public-note {
  background: var(--cheese-bg);
  border: 1px solid var(--cheese-border);
  border-radius: var(--radius);
  color: var(--cheese-text);
  padding: 10px 14px;
  font-size: 14px;
}

/* ---- 统一状态组件：加载 / 空 / 错误 ---- */
.state {
  display: grid; justify-items: center; gap: 8px;
  padding: 48px 24px;
  text-align: center; color: var(--text-sub);
}
.state__icon { font-size: 36px; line-height: 1; }
.state__title { color: var(--text-main); font-size: 17px; font-weight: 700; }
.state__desc { font-size: 14px; max-width: 32em; }
.state .btn { margin-top: 8px; }
.state--error .state__title::before { content: "⚠️ "; }

.skeleton { display: grid; gap: 10px; width: min(100%, 420px); margin-bottom: 8px; }
.skeleton span {
  display: block; height: 44px; border-radius: 16px;
  background: linear-gradient(90deg, var(--unknown-bg) 0%, #F8F6F1 50%, var(--unknown-bg) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton span:nth-child(2) { width: 70%; justify-self: end; }
.skeleton span:nth-child(3) { width: 85%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---- Toast（公共提示） ---- */
.toast {
  position: fixed; z-index: 1500; left: 50%;
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px);
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border: 1px solid var(--cheese-border); border-radius: var(--radius-pill);
  background: var(--cheese-bg); color: var(--cheese-text);
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-2);
  opacity: 0; pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .2s, transform .2s var(--ease);
}
.toast:empty { display: none; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---- 尊重减少动态效果偏好 ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
