/* ==========================================================================
   主题变量：白天（原画直出 + 文字微光增强） / 黑夜（静谧暮雪）
   ========================================================================== */
:root,
body[data-theme="day"] {
  --text-primary: #121922;
  --text-secondary: #222c38;
  --text-muted: #384554;
  --link-underline: rgba(18, 25, 34, 0.36);
  --link-underline-hover: rgba(18, 25, 34, 0.92);

  --nav-bg: rgba(252, 252, 250, 0.58);
  --nav-border: rgba(255, 255, 255, 0.74);
  --nav-pill: rgba(255, 255, 255, 0.9);
  --nav-divider: rgba(26, 34, 44, 0.12);
  --nav-text: #434f5e;
  --nav-text-active: #141b24;

  --card-bg: rgba(253, 252, 249, 0.94);
  --card-border: rgba(255, 255, 255, 0.86);
  --card-shadow: 0 18px 40px rgba(20, 28, 40, 0.14), 0 2px 8px rgba(20, 28, 40, 0.06);

  /* 白天原画直出：贴着字迹边缘的一层克制微光，既清晰又不抢油画质感 */
  --text-halo:
    0 0 6px rgba(255, 255, 255, 0.88),
    0 1px 14px rgba(255, 255, 255, 0.72),
    0 0 24px rgba(255, 255, 255, 0.48);
  --cursor-color: #121922;
}

/* 黑夜：静谧暮雪 */
body[data-theme="night"] {
  --text-primary: #f5f3ee;
  --text-secondary: rgba(245, 243, 238, 0.86);
  --text-muted: rgba(245, 243, 238, 0.64);
  --link-underline: rgba(245, 243, 238, 0.42);
  --link-underline-hover: rgba(245, 243, 238, 0.96);

  --nav-bg: rgba(20, 26, 36, 0.48);
  --nav-border: rgba(255, 255, 255, 0.16);
  --nav-pill: rgba(255, 255, 255, 0.16);
  --nav-divider: rgba(255, 255, 255, 0.16);
  --nav-text: rgba(245, 243, 238, 0.72);
  --nav-text-active: #ffffff;

  --card-bg: rgba(24, 30, 40, 0.88);
  --card-border: rgba(255, 255, 255, 0.16);
  --card-shadow: 0 20px 44px rgba(0, 0, 0, 0.38);

  --text-halo: 0 2px 16px rgba(10, 14, 22, 0.5);
  --cursor-color: #f5f3ee;
}

/* ==========================================================================
   全局重置与基础排版
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   背景层：莫奈《喜鹊》固定不变
   ========================================================================== */
.bg-artwork {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #d6dad9;
  background-image: url("./assets/the-magpie.jpg");
  background-size: cover;
  /* 保证左侧篱笆上的喜鹊在不同屏幕比例下都优雅露面 */
  background-position: 32% 46%;
  background-repeat: no-repeat;
  transform: scale(1.01);
}

.bg-atmosphere {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background:
    radial-gradient(
      ellipse 60% 54% at 20% 78%,
      rgba(15, 21, 31, 0.62) 0%,
      rgba(15, 21, 31, 0.36) 58%,
      rgba(15, 21, 31, 0.24) 100%
    ),
    rgba(16, 22, 32, 0.3);
  transition: opacity 0.45s ease;
}

/* 白天原画直出：零遮罩；黑夜静谧暮雪：平滑浮现夜幕滤镜 */
body[data-theme="night"] .bg-atmosphere {
  opacity: 1;
}

/* ==========================================================================
   顶部标签栏 + 最右侧白天/黑夜切换按钮
   ========================================================================== */
.site-header {
  position: fixed;
  top: 28px;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.top-nav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: var(--nav-bg);
  border: 1px solid var(--nav-border);
  backdrop-filter: blur(14px) saturate(135%);
  -webkit-backdrop-filter: blur(14px) saturate(135%);
  box-shadow: 0 6px 24px rgba(24, 32, 44, 0.07);
  pointer-events: auto;
  transition: background 0.4s ease, border-color 0.4s ease;
}

.nav-tabs {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nav-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 72px;
  border-radius: 999px;
  background: var(--nav-pill);
  box-shadow: 0 2px 8px rgba(20, 28, 38, 0.08);
  transition:
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.4s ease;
  z-index: 0;
}

.nav-tab {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  background: transparent;
  padding: 7px 18px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--nav-text);
  cursor: pointer;
  transition: color 0.25s ease;
}

.nav-tab:hover,
.nav-tab.is-active {
  color: var(--nav-text-active);
}

.nav-tab:focus-visible,
.theme-switch:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 2px;
}

.nav-divider {
  width: 1px;
  height: 16px;
  background: var(--nav-divider);
  transition: background 0.4s ease;
}

/* 最右侧白天/黑夜切换按钮 */
.theme-switch {
  position: relative;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--nav-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.25s ease, background 0.25s ease;
}

.theme-switch:hover {
  color: var(--nav-text-active);
  background: var(--nav-pill);
}

.theme-icon {
  position: absolute;
  width: 16px;
  height: 16px;
  transition:
    opacity 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 白天显示太阳，黑夜切换为月亮 */
body[data-theme="day"] .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

body[data-theme="day"] .icon-moon {
  opacity: 0;
  transform: rotate(-45deg) scale(0.65);
}

body[data-theme="night"] .icon-sun {
  opacity: 0;
  transform: rotate(45deg) scale(0.65);
}

body[data-theme="night"] .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ==========================================================================
   主体内容区布局
   ========================================================================== */
.site-main {
  position: fixed;
  inset: 0;
  z-index: 8;
  pointer-events: none;
}

.tab-panel {
  pointer-events: auto;
  animation: panelFadeIn 0.36s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.tab-panel[hidden] {
  display: none;
}

/* 首页位置：中间靠左下角 */
.panel-home {
  position: fixed;
  left: clamp(28px, 8.5vw, 136px);
  bottom: clamp(56px, 14vh, 148px);
  max-width: min(520px, calc(100vw - 56px));
}

/* Project / Blog 位置：调高到喜鹊上方的开阔天空区域 */
.panel-tbc {
  position: fixed;
  left: clamp(28px, 16vw, 260px);
  top: clamp(148px, 27vh, 270px);
  max-width: calc(100vw - 56px);
}

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

/* 首页排版 */
.hero-title {
  font-family: "Newsreader", "Georgia", "Times New Roman", serif;
  font-size: clamp(2.1rem, 3.6vw, 2.85rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text-primary);
  text-shadow: var(--text-halo);
  margin-bottom: 14px;
  transition: color 0.4s ease, text-shadow 0.4s ease;
}

.hero-bio {
  font-size: clamp(0.98rem, 1.15vw, 1.06rem);
  line-height: 1.65;
  color: var(--text-secondary);
  text-shadow: var(--text-halo);
  margin-bottom: 18px;
  transition: color 0.4s ease, text-shadow 0.4s ease;
}

/* 底部链接 github / email */
.hero-links {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 0.92rem;
  color: var(--text-secondary);
  text-shadow: var(--text-halo);
  transition: color 0.4s ease, text-shadow 0.4s ease;
}

.hero-links a,
.inline-link {
  color: var(--text-primary);
  text-shadow: var(--text-halo);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  transition: color 0.2s ease, text-decoration-color 0.2s ease, text-shadow 0.4s ease;
}

.hero-links a:hover,
.inline-link:hover {
  text-decoration-color: var(--link-underline-hover);
}

.link-divider {
  color: var(--text-muted);
  opacity: 0.75;
  user-select: none;
}

/* ==========================================================================
   Somewhere 悬浮详情卡片 (Hover Card)
   ========================================================================== */
.hover-card-wrapper {
  position: relative;
  display: inline-block;
}

.hover-card {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translateX(-50%) translateY(6px) scale(0.97);
  width: 256px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--card-shadow);
  text-shadow: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.22s;
  z-index: 30;
}

/* 透明桥接区，防止鼠标移向卡片时意外断开悬停 */
.hover-card::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 14px;
}

.hover-card-wrapper:hover .hover-card,
.hover-card-wrapper:focus-within .hover-card {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}

.hover-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.hover-card-title {
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.hover-card-arrow {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hover-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(128, 138, 150, 0.18);
}

.hover-card-desc {
  display: block;
  font-size: 0.83rem;
  line-height: 1.48;
  color: var(--text-secondary);
}

/* ==========================================================================
   Project / Blog 页面：to be continued... + 闪烁光标
   ========================================================================== */
.tbc-text {
  font-family: "Newsreader", "Georgia", "Times New Roman", serif;
  font-size: clamp(1.65rem, 2.7vw, 2.2rem);
  font-weight: 400;
  line-height: 1.3;
  color: var(--text-primary);
  text-shadow: var(--text-halo);
  display: inline-flex;
  align-items: center;
  transition: color 0.4s ease, text-shadow 0.4s ease;
}

.blinking-cursor {
  display: inline-block;
  width: 2px;
  height: 1.08em;
  margin-left: 5px;
  background-color: var(--cursor-color);
  vertical-align: middle;
  animation: cursorBlink 1.05s steps(2, start) infinite;
  transition: background-color 0.4s ease;
}

@keyframes cursorBlink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

/* ==========================================================================
   右下角画作署名
   ========================================================================== */
.art-caption {
  position: fixed;
  right: clamp(20px, 3vw, 36px);
  bottom: clamp(16px, 2.6vh, 28px);
  z-index: 9;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-shadow: var(--text-halo);
  opacity: 0.78;
  user-select: none;
  transition: opacity 0.25s ease, color 0.4s ease, text-shadow 0.4s ease;
}

.art-caption:hover {
  opacity: 1;
}

/* ==========================================================================
   移动端自适应微调
   ========================================================================== */
@media (max-width: 640px) {
  .bg-artwork {
    background-position: 24% 44%;
  }

  .site-header {
    top: 20px;
  }

  .panel-home {
    left: 24px;
    right: 24px;
    bottom: 68px;
  }

  .panel-tbc {
    left: 28px;
    right: 28px;
    top: 24vh;
  }

  .hero-bio {
    position: relative;
  }

  .hover-card-wrapper {
    position: static;
  }

  .hover-card {
    left: 0;
    width: min(260px, 100%);
    transform: translateX(0) translateY(6px) scale(0.97);
  }

  .hover-card-wrapper:hover .hover-card,
  .hover-card-wrapper:focus-within .hover-card {
    transform: translateX(0) translateY(0) scale(1);
  }

  .art-caption {
    left: 24px;
    right: auto;
    bottom: 20px;
  }
}
