/* ============================================
   服务导航 - 复古手账风格
   ============================================ */

/* ---------- CSS 变量 ---------- */
:root {
  --bg-primary: #1a1612;
  --bg-secondary: #2a2420;
  --bg-card: rgba(255, 248, 235, 0.06);
  --bg-card-hover: rgba(255, 248, 235, 0.1);
  --bg-glass: rgba(255, 248, 235, 0.05);
  --text-primary: #f0e6d6;
  --text-secondary: #c4b8a4;
  --text-muted: #8a7e6c;
  --border-color: rgba(255, 248, 235, 0.1);
  --accent: #d4845a;
  --accent-glow: rgba(212, 132, 90, 0.25);
  --search-bg: rgba(255, 248, 235, 0.06);
  --search-border: rgba(255, 248, 235, 0.1);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
  --tooltip-bg: #3a3028;
  --paper-bg: #fff8eb;
  --paper-line: rgba(180, 160, 130, 0.2);
  --tape-color: rgba(200, 180, 100, 0.35);
  --pin-color: #c0392b;
  --icon-size: 80px;
}

[data-theme="light"] {
  --bg-primary: #f5efe6;
  --bg-secondary: #fff8eb;
  --bg-card: rgba(0, 0, 0, 0.03);
  --bg-card-hover: rgba(0, 0, 0, 0.06);
  --bg-glass: rgba(0, 0, 0, 0.04);
  --text-primary: #3d3428;
  --text-secondary: #6b5d4e;
  --text-muted: #a09080;
  --border-color: rgba(0, 0, 0, 0.1);
  --accent: #b85c38;
  --accent-glow: rgba(184, 92, 56, 0.2);
  --search-bg: rgba(0, 0, 0, 0.04);
  --search-border: rgba(0, 0, 0, 0.12);
  --shadow-card: 0 1px 4px rgba(0, 0, 0, 0.08);
  --shadow-card-hover: 0 3px 12px rgba(0, 0, 0, 0.12);
  --tooltip-bg: #eef8d5;
  --paper-bg: #fff8eb;
  --paper-line: rgba(180, 160, 130, 0.3);
  --tape-color: rgba(200, 180, 100, 0.4);
  --pin-color: #c0392b;
}

/* ---------- 重置 ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Georgia', 'Noto Serif SC', 'Source Han Serif SC', 'SimSun', serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  /* 纸张纹理 */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 28px,
      var(--paper-line) 28px,
      var(--paper-line) 29px
    );
  background-size: 100% 29px;
}

a {
  text-decoration: none;
  color: inherit;
}

/* ---------- 背景 ---------- */
.bg-gradient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 30% 20%, rgba(212, 132, 90, 0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(180, 140, 80, 0.06) 0%, transparent 60%);
}

[data-theme="light"] .bg-gradient {
  background: radial-gradient(ellipse at 30% 20%, rgba(184, 92, 56, 0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 80%, rgba(180, 140, 80, 0.05) 0%, transparent 60%);
}

/* ---------- 主容器 ---------- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 32px 60px;
}

/* ---------- 顶部栏：标题 + 搜索 + 主题切换 ---------- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 7px 80px;
}

.top-bar .search-wrapper {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.top-bar .theme-toggle {
  flex-shrink: 0;
}

/* 搜索框上方小字提示 */
.service-total-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

/* ---------- 主题切换按钮 ---------- */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 1px 1px 0 rgba(0,0,0,0.1);
}

.theme-toggle:hover {
  transform: rotate(20deg) scale(1.1);
  border-color: var(--accent);
}

/* ---------- 搜索框 ---------- */
.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 12px 44px 12px 40px;
  background: var(--bg-secondary);
  border: 2px dashed var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.search-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.search-input:focus {
  border-color: var(--accent);
  border-style: solid;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-clear {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: none;
  background: var(--accent);
  color: #fff8eb;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.search-clear:hover {
  transform: translateY(-50%) scale(1.1);
}

.search-count {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: italic;
  pointer-events: none;
}

/* ---------- 分类导航 ---------- */
.category-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

.category-btn {
  padding: 8px 18px;
  background: var(--bg-secondary);
  border: 1.5px solid var(--border-color);
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
}

.category-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.category-btn.active {
  background: var(--accent);
  color: #fff8eb;
  border-color: var(--accent);
  box-shadow: 2px 2px 0 rgba(0,0,0,0.15);
  transform: rotate(-0.5deg);
}

.category-btn .count {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  background: rgba(0,0,0,0.08);
  border-radius: 3px;
  font-size: 0.7rem;
}

.category-btn.active .count {
  background: rgba(255,255,255,0.2);
}

/* ---------- 子分类标签 ---------- */
.subcategory-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 28px;
}

.subcategory-tab {
  padding: 5px 12px;
  background: transparent;
  border: 1px dashed var(--border-color);
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.subcategory-tab:hover {
  color: var(--text-secondary);
  border-color: var(--accent);
}

.subcategory-tab.active {
  color: var(--accent);
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-glow);
}

/* ---------- 分组区域 ---------- */
.group-section {
  margin-bottom: 40px;
  animation: fadeInUp 0.4s ease both;
}

.group-section:nth-child(2) { animation-delay: 0.05s; }
.group-section:nth-child(3) { animation-delay: 0.1s; }
.group-section:nth-child(4) { animation-delay: 0.15s; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border-color);
  position: relative;
}


.group-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  font-style: italic;
}

.group-count {
  padding: 2px 10px;
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
}

.group-divider {
  flex: 1;
  height: 0;
}

/* ---------- 卡片网格 ---------- */
.dock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 18px 12px;
  justify-items: center;
}

/* ---------- Dock 卡片 ---------- */
.dock-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 10px;
  /* background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px; */
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  width: 100%;
  max-width: 110px;
  position: relative;
}

.dock-card:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--accent);
}

.dock-card:active {
  transform: translateY(0) rotate(0deg);
}

/* 图标容器 */
.dock-icon {
  width: var(--icon-size);
  height: var(--icon-size);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 1px solid var(--border-color);
}

.dock-card:hover .dock-icon {
  border-color: var(--accent);
}

/* 图标颜色主题 */
.dock-icon.color-0,
.dock-icon.color-1,
.dock-icon.color-2,
.dock-icon.color-3,
.dock-icon.color-4,
.dock-icon.color-5 {
  border-left: none;
}

/* 图标文字（emoji） */
.dock-icon .icon-text {
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: inherit;
}

/* 图标 favicon 图片 */
.dock-icon .icon-img {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: contain;
}

/* ---------- 骨架屏加载动画 ---------- */
.icon-skeleton {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(110deg, rgba(160,140,110,0.2) 30%, rgba(160,140,110,0.05) 50%, rgba(160,140,110,0.2) 70%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.dock-icon.is-loading .icon-img {
  opacity: 0;
}

/* 服务名称 */
.dock-name {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.dock-card:hover .dock-name {
  color: var(--accent);
}

/* ---------- Tooltip ---------- */
.dock-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  padding: 8px 14px;
  background: var(--tooltip-bg);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.78rem;
  color: var(--text-primary);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: all 0.2s ease;
  z-index: 100;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  font-style: italic;
}

.dock-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--tooltip-bg);
}

.dock-card:hover .dock-tooltip {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-state .empty-text {
  font-size: 1rem;
  margin-bottom: 4px;
  font-style: italic;
}

.empty-state .empty-hint {
  font-size: 0.8rem;
}

/* ---------- 回到顶部按钮 ---------- */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-secondary);
  color: #fff8eb;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  transition: all 0.2s ease;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  z-index: 50;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  transform: translateY(-2px) rotate(-5deg);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.25);
}

/* ---------- 移动端菜单按钮 ---------- */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  width: 42px;
  height: 42px;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 200;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.15);
}

/* ---------- 移动端侧边分类抽屉 ---------- */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mobile-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100%;
  background: var(--bg-secondary);
  border-right: 2px solid var(--border-color);
  z-index: 160;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  padding: 24px 16px;
}

.mobile-drawer.show {
  transform: translateX(0);
}

.mobile-drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
  margin-left:75px;
  padding-left: 4px;
  font-style: italic;
  border-bottom: 2px dashed var(--border-color);
  padding-bottom: 10px;
}

.mobile-category-item {
  padding: 10px 14px;
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 3px;
}

.mobile-category-item:hover,
.mobile-category-item.active {
  background: var(--accent-glow);
  color: var(--text-primary);
}

.mobile-category-item.active {
  background: var(--accent);
  color: #fff8eb;
  font-weight: 600;
}

.mobile-subcategory-item {
  padding: 8px 14px 8px 28px;
  border-radius: 3px;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

.mobile-subcategory-item:hover,
.mobile-subcategory-item.active {
  background: var(--bg-glass);
  color: var(--text-secondary);
}

.mobile-subcategory-item.active {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- 页面过渡 ---------- */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.fade-enter-from {
  opacity: 0;
  transform: translateY(12px);
}

.fade-leave-to {
  opacity: 0;
  transform: translateY(-12px);
}

/* ---------- 减弱动画 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- focus-visible ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1200px) {
  .dock-grid {
    grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 20px 16px 40px;
  }

  .header h1 {
    font-size: 1.6rem;
  }

  .category-nav {
    display: none;
  }

  .mobile-menu-btn {
    display: flex;
  }

  .mobile-overlay,
  .mobile-drawer {
    display: block;
  }

  .dock-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 6px 4px;
  }

  .dock-icon {
    width: 58px;
    height: 58px;
    font-size: 1.5rem;
  }

  .dock-icon .icon-img {
    width: 40px;
    height: 40px;
  }

  .dock-name {
    font-size: 0.64rem;
  }

  .dock-card {
    padding: 4px 2px;
    max-width: none;
    gap: 4px;
  }

  /* 移动端隐藏 tooltip，避免遮挡点击 */
  .dock-tooltip {
    display: none;
  }

  .top-bar {
    margin: 7px 12px 7px 58px;
    justify-content: flex-end;
    gap: 8px;
  }

  .top-bar .search-wrapper {
    flex: 1;
  }

  .top-bar .theme-toggle {
    flex-shrink: 0;
  }

  .service-total-hint {
    font-size: 0.72rem;
  }

  .group-section {
    margin-bottom: 24px;
  }

  .group-header {
    margin-bottom: 10px;
  }

  .back-to-top {
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
  }
}

@media (max-width: 480px) {
  .dock-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px 2px;
  }

  .dock-icon {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
  }

  .dock-icon .icon-img {
    width: 36px;
    height: 36px;
  }

  .subcategory-tabs {
    gap: 4px;
  }

  .subcategory-tab {
    padding: 4px 8px;
    font-size: 0.72rem;
  }
}

/* ---------- safe-area ---------- */
@supports (padding: env(safe-area-inset-bottom)) {
  .app-container {
    padding-bottom: calc(60px + env(safe-area-inset-bottom));
  }
}
