/* ============================================================
   NavHub · 个人主页 v3
   双屏结构：首屏英雄区 + 第二屏门户卡片
   全局方格互动背景，无分割线、无切换遮罩
   ============================================================ */

:root {
  --bg: #0a0a0d;
  --ink: #ececef;
  --muted: #8f8f9c;
  --faint: #5c5c68;
  --accent: #c8f542;
  --glow: rgba(200, 245, 66, 0.22);
  --font-display: "Space Grotesk Variable", "Space Grotesk", "Noto Sans SC", system-ui, sans-serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
  --bg: #f3f3ef;
  --ink: #17171b;
  --muted: #6b6b76;
  --faint: #a2a2ac;
  --accent: #6f8f12;
  --glow: rgba(111, 143, 18, 0.2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background 0.5s ease, color 0.5s ease;
  -webkit-font-smoothing: antialiased;
  line-height: 1.7;
}

::selection {
  background: var(--accent);
  color: #0a0a0d;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ============ 全局方格互动背景 ============ */
#grid-canvas {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
}

/* 胶片颗粒 */
.grain {
  position: fixed;
  inset: -50%;
  z-index: 60;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 3%); }
  50% { transform: translate(3%, -2%); }
  75% { transform: translate(-3%, -3%); }
  100% { transform: translate(2%, 2%); }
}

/* ============ 光标 ============ */
#cursor-dot,
#cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  pointer-events: none;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

#cursor-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  box-shadow: 0 0 14px var(--glow);
}

#cursor-ring {
  width: 38px;
  height: 38px;
  border: 1px solid color-mix(in srgb, var(--ink) 30%, transparent);
  transition: width 0.25s var(--ease), height 0.25s var(--ease), border-color 0.25s ease, opacity 0.25s ease;
}

#cursor-ring.is-hover {
  width: 62px;
  height: 62px;
  border-color: var(--accent);
}

#cursor-ring.is-down {
  width: 26px;
  height: 26px;
}

@media (pointer: coarse) {
  #cursor-dot,
  #cursor-ring {
    display: none;
  }
}

/* ============ 顶部导航 ============ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(22px, 5vw, 56px);
  padding-top: calc(22px + env(safe-area-inset-top));
  transition: background 0.4s ease, padding 0.4s ease, backdrop-filter 0.4s ease;
}

.nav.scrolled {
  padding-top: 14px;
  padding-top: calc(14px + env(safe-area-inset-top));
  padding-bottom: 14px;
  background: color-mix(in srgb, var(--bg) 68%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-dot {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
}

#theme-btn {
  font-size: 20px;
  color: var(--muted);
  line-height: 1;
  transition: transform 0.5s var(--ease), color 0.25s ease;
}

#theme-btn:hover {
  color: var(--accent);
  transform: rotate(180deg);
}

/* ============ 首屏英雄区 ============ */
.hero {
  height: 100vh;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 22px 80px;
  position: relative;
  perspective: 900px;
}

.hero-eyebrow {
  font-family: var(--font-display);
  font-size: clamp(14px, 1.8vw, 17px);
  color: var(--muted);
  letter-spacing: 0.12em;
  margin-bottom: clamp(26px, 4.5vh, 44px);
  animation: rise 1s 0.15s var(--ease) both;
}

#hero-name {
  color: var(--accent);
  font-weight: 700;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(46px, 10vw, 128px);
  font-weight: 800;
  line-height: 1.04;
  letter-spacing: -0.03em;
  transition: transform 0.35s var(--ease);
  will-change: transform;
}

.hero-title .line {
  display: block;
  overflow: hidden;
}

.hero-title .word {
  display: inline-block;
  transform: translateY(115%);
  animation: word-up 1.1s var(--ease) forwards;
}

.hero-title .line:nth-child(1) .word:nth-child(1) { animation-delay: 0.32s; }
.hero-title .line:nth-child(1) .word:nth-child(2) { animation-delay: 0.44s; }
.hero-title .line:nth-child(2) .word:nth-child(1) { animation-delay: 0.56s; }
.hero-title .line:nth-child(2) .word:nth-child(2) { animation-delay: 0.68s; }

@keyframes word-up {
  to { transform: translateY(0); }
}

.accent-word {
  background-image:
    linear-gradient(110deg, transparent 40%, rgba(255, 255, 255, 0.92) 50%, transparent 60%),
    linear-gradient(120deg, var(--accent) 10%, #7c5cff 90%);
  background-size: 300% 100%, 100% 100%;
  background-position: 0 0, 0 0;
  background-repeat: repeat-x, no-repeat;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* 「探索」：渐变底 + 周期性光泽扫过 */
.hero-title .accent-word {
  animation: word-up 1.1s var(--ease) forwards, shine-sweep 3.2s linear infinite;
}

@keyframes shine-sweep {
  to { background-position: 300% 0, 0 0; }
}

/* 「好奇」：呼吸光晕（仅深色主题下显示，浅色主题保持干净） */
[data-theme="dark"] .hero-title .glow-word {
  animation: word-up 1.1s var(--ease) forwards, word-glow 2.8s ease-in-out infinite;
}

@keyframes word-glow {
  0%, 100% {
    text-shadow: 0 0 14px rgba(200, 245, 66, 0.35);
    text-shadow: 0 0 14px color-mix(in srgb, var(--accent) 35%, transparent);
  }
  50% {
    text-shadow: 0 0 26px rgba(200, 245, 66, 0.8);
    text-shadow: 0 0 26px color-mix(in srgb, var(--accent) 80%, transparent);
  }
}

.hero-status {
  margin-top: clamp(24px, 4vh, 38px);
  font-size: clamp(15px, 2vw, 19px);
  color: var(--muted);
  min-height: 1.7em;
  animation: rise 1s 0.85s var(--ease) both;
}

#hitokoto {
  display: inline-block;
  cursor: pointer;
  max-width: min(720px, 88vw);
  transition: color 0.3s ease, opacity 0.4s ease, transform 0.3s var(--ease);
  will-change: transform;
}

#hitokoto:hover {
  color: var(--accent);
}

#hitokoto.fading {
  opacity: 0.18;
}

.hero-scroll {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  width: 26px;
  height: 44px;
  display: grid;
  place-items: start center;
  animation: rise 1s 1.2s var(--ease) both;
}

.scroll-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: scroll-hint 1.8s ease-in-out infinite;
}

@keyframes scroll-hint {
  0%   { transform: translateY(0); opacity: 0; }
  30%  { opacity: 1; }
  100% { transform: translateY(28px); opacity: 0; }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

/* ============ 第二屏：门户卡片 ============ */
.second {
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  padding: 40px 22px;
  overflow-y: auto;
}

.second-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}

.second-card.in {
  opacity: 1;
  transform: none;
}

.avatar {
  width: 92px;
  height: 92px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 800;
  color: #0a0a0d;
  background: linear-gradient(135deg, var(--accent), #7c5cff);
  box-shadow: 0 0 46px var(--glow);
}

.second-name {
  font-family: var(--font-display);
  font-size: clamp(28px, 4.5vw, 38px);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.second-sign {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.04em;
}

.second-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 30px;
  width: min(520px, 84vw);
}

.second-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 14px 10px 12px;
  border-radius: 16px;
  color: var(--muted);
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.55s var(--ease), transform 0.55s var(--ease),
    color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.second-link.shown {
  opacity: 1;
  transform: none;
}

.second-link:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: 0 10px 30px var(--glow);
  transform: translateY(-4px);
}

.sl-icon {
  width: 24px;
  height: 24px;
}

.sl-icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sl-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ============ 页脚（固定底栏，滑到底部时浮现） ============ */
.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 11px 16px 13px;
  padding-bottom: calc(13px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.45s var(--ease), transform 0.45s var(--ease);
  pointer-events: none;
}

.footer.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.footer-line {
  max-width: 92vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer a {
  color: var(--faint);
  transition: color 0.25s ease;
}

.footer a:hover {
  color: var(--accent);
}

.footer .uptime {
  color: var(--faint);
}

/* ============ 响应式 ============ */
@media (max-width: 760px) {
  .second-links {
    grid-template-columns: repeat(2, 1fr);
    width: min(440px, 88vw);
  }

  .nav {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .footer {
    font-size: 11px;
    padding: 9px 12px 11px;
  }

  .footer-line {
    white-space: normal;
  }
}

/* 矮屏 / 手机横屏：压缩留白与卡片尺寸，保证两屏内容完整可见 */
@media (max-height: 620px) {
  .hero {
    padding-top: 64px;
    padding-bottom: 48px;
  }

  .hero-title {
    font-size: clamp(32px, 8vh, 64px);
  }

  .hero-eyebrow {
    margin-bottom: 16px;
  }

  .hero-status {
    margin-top: 14px;
    font-size: 14px;
  }

  .hero-scroll {
    bottom: 14px;
  }

  .avatar {
    width: 62px;
    height: 62px;
    font-size: 28px;
    margin-bottom: 14px;
  }

  .second-name {
    font-size: 26px;
  }

  .second-sign {
    margin-top: 4px;
    font-size: 12.5px;
  }

  .second-links {
    margin-top: 18px;
    gap: 8px;
  }

  .second-link {
    padding: 10px 8px 9px;
    gap: 6px;
  }

  .sl-icon {
    width: 20px;
    height: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .hero-title .word {
    transform: none;
    animation: none;
  }

  .hero-title {
    animation: none;
  }

  #grid-canvas {
    display: none;
  }
}
