/* ============================================================
   个人导航页 · 苹果布局 × 液态玻璃（Liquid Glass）
   Apple-layout × Liquid Glass, Light / Dark dual themes
   ------------------------------------------------------------
   主题机制：
   - <html data-theme="light|dark">  由内联脚本/主题管理器切换
   - 所有颜色均通过 CSS 变量定义，浅/深两套变量组
   - 切换时关键属性带 transition，实现平滑过渡
   ============================================================ */

/* ---------- 浅色主题变量（默认） ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  --bg-base: #eef1f7;             /* 冷调浅灰白，Apple 风 */
  --bg-tint: radial-gradient(ellipse at 50% -10%, rgba(255,255,255,0.9), transparent 60%);

  --text-primary: #1d1d1f;
  --text-secondary: #58585e;
  --text-muted: #9a9aa0;

  --accent: #0071e3;              /* Apple 系统蓝 */
  --accent-soft: rgba(0, 113, 227, 0.12);

  /* 液态玻璃材质（浅色：白瓷半透明 + 高折射模糊） */
  --glass-bg: rgba(255, 255, 255, 0.52);
  --glass-bg-hover: rgba(255, 255, 255, 0.68);
  --glass-border: rgba(255, 255, 255, 0.85);
  --glass-blur: 22px;
  --glass-saturate: 180%;
  --glass-inner-light: rgba(255, 255, 255, 0.9);   /* 顶部内高光 */
  --glass-inner-shadow: rgba(120, 130, 160, 0.10);

  --icon-bg: rgba(255, 255, 255, 0.6);

  --shadow-card: 0 2px 6px rgba(80, 90, 130, 0.08), 0 12px 32px rgba(80, 90, 130, 0.12);
  --shadow-card-hover: 0 4px 10px rgba(80, 90, 130, 0.10), 0 18px 44px rgba(80, 90, 130, 0.18);

  --separator: rgba(0, 0, 0, 0.10);
  --badge-bg: rgba(0, 0, 0, 0.055);

  /* 背景光斑：浅色模式用低饱和粉彩 */
  --blob-1: #8ea7ff;
  --blob-2: #7dd3fc;
  --blob-3: #c4b5fd;
  --blob-4: #fda4af;
  --blob-opacity: 0.35;

  --scrollbar-thumb: rgba(0, 0, 0, 0.18);
}

/* ---------- 深色主题变量 ---------- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg-base: #0b0f1e;
  --bg-tint: radial-gradient(ellipse at 50% -10%, rgba(30, 40, 80, 0.5), transparent 60%);

  --text-primary: rgba(255, 255, 255, 0.94);
  --text-secondary: rgba(255, 255, 255, 0.64);
  --text-muted: rgba(255, 255, 255, 0.42);

  --accent: #6ea8ff;
  --accent-soft: rgba(110, 168, 255, 0.16);

  /* 液态玻璃材质（深色：深色半透明 + 边缘微光） */
  --glass-bg: rgba(255, 255, 255, 0.07);
  --glass-bg-hover: rgba(255, 255, 255, 0.12);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-blur: 22px;
  --glass-saturate: 160%;
  --glass-inner-light: rgba(255, 255, 255, 0.35);
  --glass-inner-shadow: rgba(0, 0, 0, 0.25);

  --icon-bg: rgba(255, 255, 255, 0.08);

  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.35);
  --shadow-card-hover: 0 16px 44px rgba(0, 0, 0, 0.5);

  --separator: rgba(255, 255, 255, 0.14);
  --badge-bg: rgba(255, 255, 255, 0.09);

  /* 背景光斑：深色模式高饱和霓虹 */
  --blob-1: #4f46e5;
  --blob-2: #0ea5e9;
  --blob-3: #9333ea;
  --blob-4: #f43f5e;
  --blob-opacity: 0.45;

  --scrollbar-thumb: rgba(255, 255, 255, 0.18);
}

/* ---------- 基础 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  /* 主题切换平滑过渡 */
  transition: background-color 0.45s ease, color 0.45s ease;
}

::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; }

/* ---------- 背景光斑（液态玻璃的氛围光源） ---------- */
.background {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg-tint);
  transition: background 0.45s ease;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  background: var(--blob-c, var(--blob-1));
  opacity: var(--blob-opacity);
  transition: background 0.6s ease, opacity 0.6s ease;
  will-change: transform;
}

.blob-1 { width: 45vw; height: 45vw; top: -12%; left: -10%;
  --blob-c: var(--blob-1); animation: drift-1 26s ease-in-out infinite alternate; }
.blob-2 { width: 38vw; height: 38vw; top: 18%; right: -12%;
  --blob-c: var(--blob-2); animation: drift-2 32s ease-in-out infinite alternate; }
.blob-3 { width: 34vw; height: 34vw; bottom: -14%; left: 22%;
  --blob-c: var(--blob-3); animation: drift-3 28s ease-in-out infinite alternate; }
.blob-4 { width: 26vw; height: 26vw; bottom: 6%; right: 14%;
  --blob-c: var(--blob-4); opacity: calc(var(--blob-opacity) * 0.65);
  animation: drift-4 22s ease-in-out infinite alternate; }

@keyframes drift-1 { to { transform: translate(8vw, 10vh) scale(1.15); } }
@keyframes drift-2 { to { transform: translate(-7vw, 12vh) scale(0.9); } }
@keyframes drift-3 { to { transform: translate(10vw, -8vh) scale(1.1); } }
@keyframes drift-4 { to { transform: translate(-9vw, -10vh) scale(1.2); } }

/* ---------- 页面容器 ---------- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 72px 24px 40px;
}

/* ---------- 主题切换器（右上角玻璃胶囊） ---------- */
.theme-switch {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 10;
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--shadow-card),
    inset 0 1px 0 var(--glass-inner-light);
  transition: background 0.45s ease, border-color 0.45s ease;
}

.theme-switch button {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
}

.theme-switch button:hover { background: var(--glass-bg-hover); transform: scale(1.06); }

.theme-switch button[aria-pressed="true"] {
  background: var(--accent);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* ---------- 头部：时钟区（Apple 式排版） ---------- */
.header {
  text-align: center;
  margin-bottom: 48px;
}

.clock {
  font-size: clamp(3rem, 8vw, 4.4rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  transition: color 0.45s ease;
}

.clock-seconds {
  font-size: 0.38em;
  font-weight: 500;
  color: var(--text-secondary);
  margin-left: 0.35em;
}

.date {
  margin-top: 8px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.greeting {
  margin-top: 10px;
  font-size: 1.05rem;
  color: var(--text-secondary);
}

.greeting-sub { margin-left: 0.5em; color: var(--text-muted); }

/* ---------- 搜索框（液态玻璃胶囊） ---------- */
.search-box {
  position: relative;
  max-width: 540px;
  margin: 32px auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--shadow-card),
    inset 0 1px 0 var(--glass-inner-light);
  transition: background 0.45s ease, border-color 0.45s ease,
    box-shadow 0.25s ease, background-color 0.25s ease;
}

.search-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  box-shadow: var(--shadow-card-hover),
    0 0 0 4px var(--accent-soft);
}

.search-icon {
  width: 18px; height: 18px;
  flex: none;
  color: var(--text-muted);
}

#search {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
}

#search::placeholder { color: var(--text-muted); }

.search-clear {
  flex: none;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  border: none; border-radius: 50%;
  background: var(--badge-bg);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.search-clear:hover { background: color-mix(in srgb, var(--text-muted) 30%, transparent); }

.search-kbd {
  flex: none;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--separator);
  background: var(--glass-bg);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-family: inherit;
}

/* ---------- 站点分组 ---------- */
.groups {
  display: flex;
  flex-direction: column;
  gap: 44px;
}

.group { animation: fadeUp 0.5s ease both; }

.group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-left: 4px;
}

.group-icon { font-size: 1.25rem; line-height: 1; }

.group-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.group-count {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--badge-bg);
  border: 1px solid var(--separator);
  font-variant-numeric: tabular-nums;
}

.group-header::after {
  content: "";
  flex: 1;
  height: 1px;
  margin-left: 12px;
  background: linear-gradient(90deg, var(--separator), transparent);
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

/* ---------- 站点卡片（液态玻璃核心） ---------- */
.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  /* 内高光 + 内暗影 + 外投影：模拟玻璃折射厚度 */
  box-shadow: var(--shadow-card),
    inset 0 1px 0 var(--glass-inner-light),
    inset 0 -1px 0 var(--glass-inner-shadow);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform 0.25s ease, background 0.45s ease, background-color 0.25s ease,
    border-color 0.25s ease, box-shadow 0.3s ease;
  animation: fadeUp 0.4s ease both;
  animation-delay: calc(var(--i, 0) * 40ms);
}

/* 顶部 specular 高光线：玻璃边缘反光 */
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 8%; right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--glass-inner-light), transparent);
  opacity: 0.8;
  transition: opacity 0.45s ease;
}

/* 悬停液态流光：一道柔和高光扫过卡片（液态玻璃灵魂） */
.card::after {
  content: "";
  position: absolute;
  top: -40%; left: -30%;
  width: 60%; height: 180%;
  background: radial-gradient(ellipse at center,
    color-mix(in srgb, var(--accent) 14%, transparent), transparent 65%);
  opacity: 0;
  transform: rotate(18deg) translateX(-30%);
  transition: opacity 0.4s ease, transform 0.55s ease;
  pointer-events: none;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  background-color: var(--glass-bg-hover);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--glass-border));
  box-shadow: var(--shadow-card-hover),
    inset 0 1px 0 var(--glass-inner-light),
    inset 0 -1px 0 var(--glass-inner-shadow),
    0 0 24px color-mix(in srgb, var(--accent) 16%, transparent);
  outline: none;
}

.card:hover::after,
.card:focus-visible::after {
  opacity: 1;
  transform: rotate(18deg) translateX(60%);
}

.card-icon {
  flex: none;
  width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  border-radius: 12px;
  background: var(--icon-bg);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 var(--glass-inner-light);
  transition: background 0.45s ease, border-color 0.45s ease;
}

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

.card-name {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc {
  margin-top: 3px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-arrow {
  flex: none;
  color: var(--text-muted);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.25s ease, transform 0.25s ease, color 0.25s ease;
}

.card:hover .card-arrow,
.card:focus-visible .card-arrow {
  opacity: 1;
  transform: translateX(0);
  color: var(--accent);
}

/* ---------- 空状态 / 页脚 ---------- */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  border-radius: 18px;
  background: var(--glass-bg);
  border: 1px dashed var(--glass-border);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-card);
  transition: background 0.45s ease, border-color 0.45s ease;
}

.empty-icon { font-size: 2.2rem; }

.empty-title { margin-top: 12px; font-size: 1.1rem; font-weight: 600; }

.empty-desc { margin-top: 6px; font-size: 0.85rem; color: var(--text-secondary); }

.footer {
  margin-top: 56px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.theme-status {
  margin-bottom: 6px;
  padding: 3px 12px;
  display: inline-block;
  border-radius: 999px;
  background: var(--badge-bg);
  border: 1px solid var(--separator);
  transition: background 0.45s ease, border-color 0.45s ease;
}

/* ---------- 通用动画 ---------- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .container { padding: 84px 16px 24px; }

  .search-kbd { display: none; }

  .theme-switch { top: 12px; right: 12px; padding: 4px; }
  .theme-switch button { width: 32px; height: 32px; font-size: 0.9rem; }

  .group-grid { grid-template-columns: 1fr; gap: 12px; }
  .groups { gap: 32px; }
}

/* ---------- 减弱动态效果（无障碍） ---------- */
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  .card, .group { animation: none; }
  .card { transition: none; }
  .card::after { display: none; }
  html { scroll-behavior: auto; }
}
