/**
 * ═════════════════════════════════════════════════════
 *  许跳跳 XuTiaotiao · Personal Page — Stylesheet
 *  Version: 1.0.0 | Last Updated: 2026-07-29
 *  Author: 许跳跳 (XuTiaotiao)
 * ═════════════════════════════════════════════════════
 *
 *  Table of Contents:
 *  ────────────────
 *  1. Theme Tokens (Light / Dark)
 *  2. Reset & Base
 *  3. Layout Primitives
 *  4. Typography
 *  5. Background Atmosphere
 *  6. Theme Toggle Button
 *  7. Hero Section (Avatar, Name)
 *  8. Contact Buttons (IconPark Icons)
 *  9. WeChat Hover QR Popup
 * 10. Hitokoto Quote Section
 * 11. Footer & Links
 * 12. Animations
 * 13. Responsive Breakpoints
 * 14. Scrollbar & Selection
 * ═════════════════════════════════════════════════════
 */

/* ─── 1. Theme Tokens ──────────────────────────────── */
:root {
  /* Light theme */
  --bg: #f5f5f4;
  --bg-secondary: #ebebea;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --fg: #1a1a1a;
  --fg-secondary: #333333;
  --muted: #737373;
  --border: #e0e0de;
  --border-light: #ececea;
  --accent: #00a080;
  --accent-hover: #008866;
  --accent-glow: rgba(0, 160, 128, 0.08);
  --accent-soft: rgba(0, 160, 128, 0.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);

  /* Type — Inter for Latin, MiSans for CJK */
  --font-display: 'Inter Variable', 'Inter', 'MiSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-body: 'Inter Variable', 'Inter', 'MiSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Scale */
  --fs-h1: clamp(40px, 7vw, 68px);
  --fs-h2: clamp(26px, 3.5vw, 36px);
  --fs-h3: 20px;
  --fs-body: 16px;
  --fs-meta: 13px;
  --fs-quote: clamp(17px, 2.2vw, 22px);
  --fs-en: clamp(15px, 2vw, 19px);

  /* Spacing */
  --gap-xs: 6px;
  --gap-sm: 10px;
  --gap-md: 12px;
  --gap-lg: 18px;
  --gap-xl: 28px;
  --gutter: clamp(16px, 3vw, 32px);

  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
}

/* Dark theme override */
[data-theme="dark"] {
  --bg: #0c0c0d;
  --bg-secondary: #131315;
  --surface: #161618;
  --surface-2: #1c1c1f;
  --fg: #ededed;
  --fg-secondary: #d4d4d4;
  --muted: #8b8b8d;
  --border: #28282b;
  --border-light: #222225;
  --accent: #00d4aa;
  --accent-hover: #00eebb;
  --accent-glow: rgba(0, 212, 170, 0.12);
  --accent-soft: rgba(0, 212, 170, 0.07);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

/* ─── 2. Reset & Base ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

img { display: block; max-width: 100%; }
svg { display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }
p { text-wrap: pretty; }
h1, h2, h3 { text-wrap: balance; }

/* ─── 3. Layout Primitives ──────────────────────────── */
.container {
  width: 100%;
  max-width: 680px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.section {
  padding-block: clamp(50px, 9vh, 90px);
}
.stack { display: flex; flex-direction: column; }
.stack > * + * { margin-top: var(--gap-md); }
.row { display: flex; align-items: center; gap: var(--gap-md); flex-wrap: wrap; }
.center { display: flex; flex-direction: column; align-items: center; text-align: center; }

/* ─── 4. Typography ─────────────────────────────────── */
.h1, h1 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 800;
}
.h2, h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  line-height: 1.18;
  letter-spacing: -0.015em;
  font-weight: 600;
}
.h3, h3 {
  font-size: var(--fs-h3);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.lead {
  font-size: 17px;
  line-height: 1.6;
  color: var(--muted);
  max-width: 52ch;
}
.meta {
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  color: var(--muted);
  letter-spacing: 0.02em;
}
.name-en {
  font-family: 'Inter Variable', 'Inter', var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.06em;
}

/* ─── 5. Background Atmosphere ──────────────────────── */
.bg-pattern {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 1px 1px, var(--border-light) 1px, transparent 0);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}
[data-theme="dark"] .bg-pattern {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255,255,255,0.03) 1px, transparent 0);
  background-size: 32px 32px;
  opacity: 1;
}

/* ─── 6. Theme Toggle Button ────────────────────────── */
.theme-toggle {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 100;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 0.25s ease;
  color: var(--fg);
}
.theme-toggle:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}
.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}
.theme-toggle:hover svg {
  transform: rotate(15deg);
}
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
:not([data-theme="dark"]) .icon-sun { display: none; }
:not([data-theme="dark"]) .icon-moon { display: block; }

/* ─── Dark Mode Icon Color Fix ───────────────────────
   <img> 加载的外部 SVG 中 currentColor 不继承父元素 color
   用 filter 让图标在深色模式下自动适配 */
[data-theme="dark"] .contact-btn img {
  /* 联系按钮图标：黑色 → 白色（反色+提亮） */
  filter: invert(1) brightness(1.15);
}
[data-theme="dark"] .role-tag img {
  /* 学位帽：黑色 → 青绿强调色 #00d4aa */
  filter: invert(77%) sepia(94%) saturate(600%) hue-rotate(115deg) brightness(0.92);
}
[data-theme="dark"] .refresh-btn img {
  /* 刷新按钮：黑色 → 青绿强调色 #00d4aa */
  filter: invert(77%) sepia(94%) saturate(600%) hue-rotate(115deg) brightness(0.92);
}

/* ─── 7. Hero Section ───────────────────────────────── */
.hero {
  min-height: 100vh;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--gap-lg);
  position: relative;
  z-index: 1;
}

/* Avatar */
.avatar-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
}
.avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--accent);
  box-shadow: 0 0 30px var(--accent-glow), var(--shadow-lg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.avatar:hover {
  transform: scale(1.05);
  box-shadow: 0 0 44px var(--accent-glow), 0 8px 32px rgba(0,0,0,0.15);
}
.status-dot {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 50%;
  border: 3px solid var(--bg);
}

/* Name & Title */
.name-block { margin-top: var(--gap-md); }
.name-cn {
  font-family: 'MiSans', var(--font-display);
  font-size: clamp(32px, 5.5vw, 48px);
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--fg);
}
.name-en {
  font-size: var(--fs-en);
  color: var(--accent);
  text-transform: uppercase;
  margin-top: 4px;
}
.role-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: var(--gap-sm);
  padding: 5px 14px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  border-radius: var(--radius-full);
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
}
.role-tag svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ─── 8. Contact Buttons (IconPark Icons) ────────────── */
.contact-section {
  margin-top: var(--gap-md);
  width: 100%;
}
.contact-buttons {
  display: flex;
  justify-content: center;
  gap: var(--gap-md);
  flex-wrap: wrap;
}

.contact-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  position: relative;
}
.contact-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-3px) scale(1.06);
  box-shadow: var(--shadow-md), 0 0 16px var(--accent-glow);
}
.contact-btn svg {
  width: 24px;
  height: 24px;
}

/* ─── 9. WeChat Hover QR Popup ──────────────────────── */
.wechat-wrapper { position: relative; }
.wechat-qr-popup {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) scale(0.92);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--gap-md);
  opacity: 0;
  visibility: hidden;
  transition: all 0.25s ease;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  min-width: 170px;
}
.wechat-qr-popup::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 7px solid transparent;
  border-top-color: var(--border);
}
.wechat-wrapper:hover .wechat-qr-popup,
.wechat-wrapper:focus-within .wechat-qr-popup {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
  pointer-events: auto;
}
.qr-title {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-bottom: var(--gap-sm);
}
.qr-image {
  width: 140px;
  height: 140px;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  display: block;
  margin: 0 auto;
}
.qr-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  text-align: center;
  margin-top: var(--gap-sm);
}

/* ─── 10. Hitokoto Quote Section ────────────────────── */
.hitokoto-section {
  width: 100%;
  max-width: 600px;
  margin-top: var(--gap-md);
}
.quote-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--gap-md);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}
.quote-card:hover {
  box-shadow: var(--shadow-md);
}
.quote-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.quote-mark {
  font-size: 28px;
  color: var(--accent);
  opacity: 0.35;
  line-height: 1;
  font-family: Georgia, serif;
  flex-shrink: 0;
  margin-top: 2px;
}
.quote-text {
  font-size: var(--fs-quote);
  line-height: 1.6;
  color: var(--fg-secondary);
  font-style: italic;
  min-height: 48px;
  transition: opacity 0.4s ease;
}
.quote-text.loading {
  opacity: 0.4;
}
.quote-source {
  margin-top: var(--gap-sm);
  padding-top: var(--gap-sm);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.quote-source .from {
  font-family: var(--font-mono);
  font-size: 11px;
}
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
}
.refresh-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.refresh-btn svg {
  width: 13px;
  height: 13px;
  transition: transform 0.3s ease;
}
.refresh-btn:hover svg {
  transform: rotate(180deg);
}

/* ─── 11. Footer & Links ────────────────────────────── */
footer {
  padding: var(--gap-md) var(--gutter);
  text-align: center;
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin-inline: auto;
}
footer .meta {
  opacity: 0.5;
}
footer img {
  display: inline-block;
  vertical-align: middle;
  margin-right: 3px;
}
.icp-link {
  margin-top: 6px;
  font-size: 12px;
  transition: color 0.2s ease;
}
.icp-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.hitokoto-link {
  color: var(--accent);
  transition: color 0.2s ease;
}
.hitokoto-link:hover {
  text-decoration: underline;
}

/* ─── 12. Animations ────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fadeInUp 0.55s ease forwards;
}
.delay-1 { animation-delay: 0.08s; opacity: 0; }
.delay-2 { animation-delay: 0.16s; opacity: 0; }
.delay-3 { animation-delay: 0.28s; opacity: 0; }
.delay-4 { animation-delay: 0.40s; opacity: 0; }
.delay-5 { animation-delay: 0.52s; opacity: 0; }

/* ─── 13. Responsive Breakpoints ─────────────────────── */
@media (max-width: 480px) {
  :root {
    --gutter: 16px;
    --gap-lg: 20px;
    --gap-xl: 36px;
  }
  .avatar-wrapper {
    width: 100px;
    height: 100px;
  }
  .avatar {
    width: 100px;
    height: 100px;
  }
  .contact-btn {
    width: 42px;
    height: 42px;
  }
  .contact-btn svg {
    width: 20px;
    height: 20px;
  }
  .quote-card {
    padding: var(--gap-md);
  }
  .wechat-qr-popup {
    min-width: 155px;
  }
  .qr-image {
    width: 120px;
    height: 120px;
  }
  .theme-toggle {
    bottom: 16px;
    left: 16px;
    width: 38px;
    height: 38px;
  }
}

/* ─── 14. Scrollbar & Selection ─────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

::selection {
  background: var(--accent);
  color: var(--bg);
}