/* ========================================
   张鸿儒 — 个人主页 · 全新设计
   玻璃拟态 · Bento Grid · 粒子动画
   ======================================== */

/* --- CSS 变量 --- */
:root {
  --bg: #f0f4f8;
  --bg-glass: rgba(255,255,255,0.75);
  --text: #1a1a2e;
  --text-secondary: #4a5568;
  --text-muted: #8892b0;
  --border-glass: rgba(255,255,255,0.6);
  --primary: #5b6af0;
  --primary-light: #eef0ff;
  --accent: #8b5cf6;
  --shadow-glass: 0 8px 32px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-hover: 0 16px 48px rgba(91,106,240,0.15);
  --radius: 20px;
  --radius-sm: 12px;
  --transition: 0.3s cubic-bezier(0.4,0,0.2,1);
  --max-width: 1000px;
}

[data-theme="dark"] {
  --bg: #0a0a1a;
  --bg-glass: rgba(20,20,50,0.7);
  --text: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #64748b;
  --border-glass: rgba(255,255,255,0.08);
  --shadow-glass: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-hover: 0 16px 48px rgba(91,106,240,0.2);
  --primary-light: rgba(91,106,240,0.12);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background 0.5s, color 0.5s;
  overflow-x: hidden;
}

a { color: var(--primary); text-decoration: none; }

/* ========================================
   玻璃拟态组件
   ======================================== */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  box-shadow: var(--shadow-glass);
}

/* ========================================
   粒子背景
   ======================================== */
.particles {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  animation: floatUp linear infinite;
  opacity: 0;
}

@keyframes floatUp {
  0%   { transform: translateY(100vh) scale(0); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ========================================
   导航栏 — 毛玻璃
   ======================================== */
.navbar {
  position: sticky;
  top: 12px;
  z-index: 100;
  margin: 12px auto 0;
  max-width: var(--max-width);
  width: calc(100% - 24px);
}

.navbar.glass {
  border-radius: 50px;
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
}

.nav-logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-dot {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
}

.nav-links a {
  padding: 6px 14px;
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-links a:hover, .nav-links a.active {
  color: var(--primary);
  background: var(--primary-light);
}

.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  padding: 4px 6px;
  border-radius: 50%;
  transition: all var(--transition);
}

.theme-toggle:hover { transform: scale(1.15); }

/* ========================================
   Hero
   ======================================== */
.hero {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 80px 24px 50px;
  max-width: 600px;
  margin: 0 auto;
}

.hero-avatar {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5b6af0, #8b5cf6, #ec4899);
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  box-shadow: 0 12px 40px rgba(91,106,240,0.35);
  animation: avatarPulse 4s ease-in-out infinite;
}

@keyframes avatarPulse {
  0%, 100% { box-shadow: 0 12px 40px rgba(91,106,240,0.35); }
  50% { box-shadow: 0 16px 56px rgba(139,92,246,0.5); }
}

.hero-name {
  font-size: 2.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

/* 打字机效果 */
.typewriter-wrapper {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  min-height: 28px;
}

.typewriter {
  color: var(--primary);
  font-weight: 600;
  border-right: 2px solid var(--primary);
  animation: blink 0.8s infinite;
}

@keyframes blink {
  0%, 100% { border-color: var(--primary); }
  50% { border-color: transparent; }
}

.hero-bio {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.7;
  margin-bottom: 20px;
}

/* 时钟 */
.hero-clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 22px;
}

.clock-time {
  font-size: 2rem;
  font-weight: 300;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  letter-spacing: 0.06em;
  color: var(--text);
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 6px 24px;
  border-radius: 30px;
  border: 1px solid var(--border-glass);
}

.clock-date {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* 社交链接 */
.hero-social {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.social-link {
  font-size: 1.4rem;
  transition: all var(--transition);
  opacity: 0.7;
}

.social-link:hover {
  opacity: 1;
  transform: translateY(-3px) scale(1.1);
}

/* ========================================
   Bento Grid 布局
   ======================================== */
.bento-container {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto 60px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 20px;
}

.bento-card {
  padding: 28px 24px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.bento-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0;
  transition: opacity var(--transition);
}

.bento-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.bento-card:hover::before {
  opacity: 1;
}

.card-icon {
  font-size: 1.8rem;
  margin-bottom: 14px;
}

.bento-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text);
}

.bento-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* 关于卡片 — 跨2列 */
.about-card { grid-column: span 2; }

/* 技能卡片 — 跨2列 */
.skills-card { grid-column: span 2; grid-row: span 1; }

/* 座右铭卡片 */
.quote-card {
  grid-row: span 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.quote-icon { font-size: 2rem; margin-bottom: 8px; }

.quote-text {
  font-size: 1.05rem;
  font-style: italic;
  color: var(--text);
  font-weight: 500;
  line-height: 1.6;
}

.quote-author {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* 技能标签 */
.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.skill-tags .tag,
.tag {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary);
  transition: all var(--transition);
  border: 1px solid transparent;
}

.skill-tags .tag:hover {
  transform: scale(1.06);
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 项目卡片 */
.project-card .card-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
}

/* ========================================
   留言板
   ======================================== */
.section {
  position: relative;
  z-index: 1;
  padding: 40px 24px 60px;
}

.section-inner {
  max-width: 720px;
  margin: 0 auto;
}

.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

.guestbook-form {
  padding: 28px;
  margin-bottom: 28px;
}

.form-row {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
}

.form-row input,
.guestbook-form textarea {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.93rem;
  background: rgba(255,255,255,0.6);
  color: var(--text);
  outline: none;
  transition: all var(--transition);
  font-family: inherit;
}

[data-theme="dark"] .form-row input,
[data-theme="dark"] .guestbook-form textarea {
  background: rgba(0,0,0,0.3);
}

.form-row input:focus,
.guestbook-form textarea:focus {
  border-color: var(--primary);
  background: rgba(255,255,255,0.9);
  box-shadow: 0 0 0 4px rgba(91,106,240,0.08);
}

[data-theme="dark"] .form-row input:focus,
[data-theme="dark"] .guestbook-form textarea:focus {
  background: rgba(0,0,0,0.5);
}

.guestbook-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 90px;
}

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  gap: 12px;
}

.form-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn-submit {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  border: none;
  border-radius: 25px;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(91,106,240,0.35);
}

.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* 留言列表 */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message-card {
  padding: 18px 22px;
  border-radius: var(--radius-sm);
  animation: msgSlide 0.4s ease backwards;
}

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

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.message-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
}

.message-time {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.message-body {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.92rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.message-email {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.no-messages {
  text-align: center;
  color: var(--text-muted);
  padding: 36px;
}

/* 加载更多 */
.load-more { text-align: center; margin-top: 20px; }

.btn-load {
  padding: 10px 28px;
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  border-radius: 25px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-load:hover {
  background: var(--primary);
  color: #fff;
}

/* 管理员 */
.admin-entry {
  text-align: center;
  margin-top: 28px;
  opacity: 0.25;
  transition: opacity var(--transition);
}
.admin-entry:hover { opacity: 0.7; }
.admin-entry a { font-size: 1.15rem; }

.admin-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.admin-modal-content {
  padding: 32px;
  width: 90%;
  max-width: 400px;
}

.admin-modal-content h3 {
  text-align: center;
  margin-bottom: 14px;
}

.admin-modal-content input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: rgba(255,255,255,0.6);
  color: var(--text);
  outline: none;
  font-family: inherit;
}

[data-theme="dark"] .admin-modal-content input {
  background: rgba(0,0,0,0.3);
}

.admin-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.btn-cancel {
  flex: 1;
  padding: 10px;
  background: rgba(0,0,0,0.05);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  color: var(--text-secondary);
}

.admin-messages {
  margin-top: 16px;
  max-height: 55vh;
  overflow-y: auto;
}

/* 状态提示 */
.form-status {
  text-align: center;
  padding: 8px;
  border-radius: 10px;
  font-size: 0.88rem;
  margin-bottom: 10px;
  display: none;
}
.form-status.success { display: block; background: #dcfce7; color: #16a34a; }
.form-status.error { display: block; background: #fef2f2; color: #dc2626; }
[data-theme="dark"] .form-status.success { background: #052e16; color: #4ade80; }
[data-theme="dark"] .form-status.error { background: #450a0a; color: #fca5a5; }

/* ========================================
   页脚
   ======================================== */
.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 30px 24px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ========================================
   滚动渐显
   ======================================== */
.fade-in {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================
   响应式
   ======================================== */
@media (max-width: 768px) {
  .bento-container {
    grid-template-columns: 1fr;
  }

  .about-card, .skills-card {
    grid-column: span 1;
  }

  .hero-name { font-size: 2rem; }
  .clock-time { font-size: 1.5rem; }
  .nav-links a { padding: 4px 10px; font-size: 0.8rem; }
  .form-row { flex-direction: column; }
  .form-footer { flex-direction: column; align-items: stretch; }
  .btn-submit { justify-content: center; }
  .navbar.glass { border-radius: 28px; }
}

@media (max-width: 480px) {
  .hero-name { font-size: 1.7rem; }
  .typewriter-wrapper { font-size: 1rem; }
  .bento-card { padding: 20px 16px; }
}
