/* ============================================
   迹遇 - 设计系统 Design System
   城市信息精准分发 + 线下打卡社交平台
   ============================================ */

:root {
  /* ── 主色调：地图探索感 ── */
  --primary: #1A73E8;
  --primary-light: #4A9AF5;
  --primary-dark: #1557B0;
  --primary-bg: #E8F0FE;

  /* ── 功能色 ── */
  --success: #34A853;
  --warning: #FBBC04;
  --danger: #EA4335;
  --info: #4285F4;

  /* ── 分类色彩 ── */
  --cat-checkin: #FF6B6B;    /* 打卡类 - 活力红 */
  --cat-help: #FFA726;       /* 求助类 - 警示橙 */
  --cat-share: #66BB6A;      /* 分享类 - 自然绿 */
  --cat-social: #AB47BC;     /* 社交类 - 社交紫 */
  --cat-utility: #42A5F5;    /* 实用类 - 实用蓝 */

  /* ── 中性色 ── */
  --gray-50: #FAFBFC;
  --gray-100: #F5F6F8;
  --gray-200: #EBEDF0;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* ── 背景与边框 ── */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F5F6F8;
  --bg-tertiary: #EBEDF0;
  --border-color: #E5E7EB;
  --border-light: #F0F1F3;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  /* ── 间距系统（8px网格） ── */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ── 字体 ── */
  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-xs: 11px;
  --font-sm: 13px;
  --font-base: 15px;
  --font-md: 17px;
  --font-lg: 20px;
  --font-xl: 24px;
  --font-2xl: 28px;
  --font-3xl: 34px;

  /* ── 圆角 ── */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* ── 布局常量 ── */
  --header-height: 52px;
  --tabbar-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --content-max: 750px;
}

/* ── 全局重置 ── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--gray-800);
  background: var(--bg-secondary);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
input, textarea, button { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

/* ── 页面容器 ── */
.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

.page-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 8px);
}

.page-content.no-tabbar {
  padding-bottom: var(--safe-bottom);
}

/* ── 头部导航 ── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-light);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-transparent {
  background: transparent;
  border-bottom: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

.header-title {
  flex: 1;
  text-align: center;
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--gray-800);
}

.header-back {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: rgba(0,0,0,0.05);
  cursor: pointer;
}

.header-back svg {
  width: 20px;
  height: 20px;
  color: var(--gray-700);
}

.header-action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-600);
}

.header-btn svg { width: 22px; height: 22px; }

/* ── 底部Tab栏 ── */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  height: calc(var(--tabbar-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex;
  align-items: stretch;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-light);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}

.tabbar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--gray-400);
  transition: color 0.2s;
  text-decoration: none;
  position: relative;
}

.tabbar-item.active { color: var(--primary); }

.tabbar-item.publish-btn {
  color: var(--bg-primary);
}

.tabbar-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tabbar-icon svg { width: 24px; height: 24px; }

.tabbar-label {
  font-size: var(--font-xs);
  line-height: 1;
}

.tabbar-item.publish-btn .tabbar-icon {
  width: 44px;
  height: 44px;
  background: var(--primary);
  border-radius: var(--radius-full);
  color: white;
  margin-top: -18px;
  box-shadow: 0 4px 12px rgba(26,115,232,0.35);
}

.tabbar-item.publish-btn .tabbar-icon svg {
  width: 26px;
  height: 26px;
}

/* ── 未读角标 ── */
.badge {
  position: absolute;
  top: 2px;
  right: 50%;
  margin-right: -18px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: white;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.badge-dot {
  min-width: 8px;
  height: 8px;
  padding: 0;
  top: 4px;
  margin-right: -14px;
}

/* ── 搜索框 ── */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-primary);
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
}

.search-input-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--gray-400);
  flex-shrink: 0;
}

.search-input-wrap input {
  flex: 1;
  border: none;
  background: none;
  outline: none;
  color: var(--gray-800);
  font-size: var(--font-sm);
}

.search-input-wrap input::placeholder {
  color: var(--gray-400);
}

/* ── 卡片组件 ── */
.card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-hover {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card-hover:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-sm);
}

/* ── 信息卡片 ── */
.info-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s;
}

.info-card:active { transform: scale(0.98); }

.info-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.info-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

.info-card-user {
  flex: 1;
  min-width: 0;
}

.info-card-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.info-card-time {
  font-size: var(--font-xs);
  color: var(--gray-400);
}

.info-card-body {
  margin-bottom: var(--space-3);
}

.info-card-text {
  font-size: var(--font-base);
  color: var(--gray-700);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.info-card-images {
  display: grid;
  gap: 4px;
  margin-top: var(--space-2);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.info-card-images.count-1 { grid-template-columns: 1fr; max-height: 240px; }
.info-card-images.count-2 { grid-template-columns: 1fr 1fr; }
.info-card-images.count-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.info-card-images.count-4 { grid-template-columns: 1fr 1fr; }
.info-card-images.count-n { grid-template-columns: repeat(3, 1fr); }

.info-card-images img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 1;
}

.info-card-images.count-1 img { aspect-ratio: 4/3; max-height: 240px; }
.info-card-images.count-3 img:first-child { grid-row: 1/3; }

.info-card-footer {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-light);
}

.info-card-action {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-sm);
  color: var(--gray-400);
  cursor: pointer;
  transition: color 0.2s;
  background: none;
  border: none;
  padding: var(--space-1);
}

.info-card-action:hover, .info-card-action.active {
  color: var(--primary);
}

.info-card-action svg {
  width: 18px;
  height: 18px;
}

.info-card-action.liked { color: var(--danger); }

/* ── 标签 ── */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  line-height: 1.4;
  white-space: nowrap;
}

.tag-primary { background: var(--primary-bg); color: var(--primary); }
.tag-checkin { background: rgba(255,107,107,0.12); color: var(--cat-checkin); }
.tag-help { background: rgba(255,167,38,0.12); color: var(--cat-help); }
.tag-share { background: rgba(102,187,106,0.12); color: var(--cat-share); }
.tag-social { background: rgba(171,71,188,0.12); color: var(--cat-social); }
.tag-utility { background: rgba(66,165,245,0.12); color: var(--cat-utility); }
.tag-urgent { background: rgba(234,67,53,0.12); color: var(--danger); animation: pulse-urgent 1.5s infinite; }

/* ── 分类图标 ── */
.category-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.category-icon.small {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 18px;
}

.cat-checkin { background: rgba(255,107,107,0.12); }
.cat-help { background: rgba(255,167,38,0.12); }
.cat-share { background: rgba(102,187,106,0.12); }
.cat-social { background: rgba(171,71,188,0.12); }
.cat-utility { background: rgba(66,165,245,0.12); }

/* ── 按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(26,115,232,0.3);
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(26,115,232,0.2);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-ghost {
  background: rgba(26,115,232,0.08);
  color: var(--primary);
}

.btn-sm {
  padding: var(--space-1) var(--space-4);
  font-size: var(--font-sm);
}

.btn-lg {
  padding: var(--space-4) var(--space-8);
  font-size: var(--font-md);
}

.btn-block {
  width: 100%;
}

/* ── 输入框 ── */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--gray-800);
  font-size: var(--font-base);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* ── 筛选栏 ── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--bg-primary);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s;
  border: 1.5px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--gray-600);
}

.filter-chip.active {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}

.filter-chip svg {
  width: 14px;
  height: 14px;
}

/* ── 空状态 ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-8);
  text-align: center;
}

.empty-state-icon {
  width: 120px;
  height: 120px;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--font-md);
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: var(--space-2);
}

.empty-state-desc {
  font-size: var(--font-sm);
  color: var(--gray-400);
  max-width: 240px;
}

/* ── 分割线 ── */
.divider {
  height: 1px;
  background: var(--border-light);
  margin: 0;
}

.section-divider {
  height: var(--space-3);
  background: var(--bg-secondary);
}

/* ── 加载更多 ── */
.load-more {
  text-align: center;
  padding: var(--space-4);
  color: var(--gray-400);
  font-size: var(--font-sm);
}

.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ── 模态框/弹窗 ── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 100%;
  max-width: var(--content-max);
  background: var(--bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-6);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 80vh;
  overflow-y: auto;
}

.modal-overlay.show .modal-content {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-300);
  border-radius: var(--radius-full);
  margin: 0 auto var(--space-4);
}

.modal-title {
  font-size: var(--font-md);
  font-weight: 700;
  text-align: center;
  margin-bottom: var(--space-4);
}

/* ── 吐司提示 ── */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  padding: var(--space-3) var(--space-6);
  background: rgba(0,0,0,0.75);
  color: white;
  border-radius: var(--radius-md);
  font-size: var(--font-sm);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.toast.show { opacity: 1; }

/* ── 动画关键帧 ── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-urgent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes slideInUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.animate-fadeInUp { animation: fadeInUp 0.4s ease-out; }
.animate-fadeIn { animation: fadeIn 0.3s ease-out; }
.animate-slideInRight { animation: slideInRight 0.3s ease-out; }
.animate-slideInUp { animation: slideInUp 0.3s ease-out; }
.animate-scaleIn { animation: scaleIn 0.25s ease-out; }

/* ── 工具类 ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.text-center { text-align: center; }
.text-sm { font-size: var(--font-sm); }
.text-xs { font-size: var(--font-xs); }
.text-gray { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.p-4 { padding: var(--space-4); }
.rounded-full { border-radius: var(--radius-full); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── 安全区域适配 ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .tabbar { padding-bottom: env(safe-area-inset-bottom); }
}
