/* ============================================================
   设计令牌
   ============================================================ */
:root {
  --bg: #101016;
  --bg-elev: #17171f;
  --bg-card: #1b1b25;
  --text: #e8e6e1;
  --text-dim: #9a98a3;
  --accent: #ffd479;          /* 暖黄 —— 呼应灯光主题 */
  --accent-soft: rgba(255, 212, 121, 0.14);
  --border: #2b2b38;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --sans: "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --radius: 12px;
  --nav-h: 64px;

  /* 灯光系统变量（JS 驱动） */
  --mx: 50vw;   /* 手电筒光斑中心 X（视口坐标） */
  --my: 50vh;   /* 手电筒光斑中心 Y */
  --lx: 50vw;   /* 吊灯主光源落点 X */
  --ly: 140px;  /* 吊灯主光源落点 Y */
}

/* 可动画的光斑半径（Chromium 支持；不支持时直接呈现，优雅降级） */
@property --lr {
  syntax: "<length>";
  initial-value: 320px;
  inherits: true;
}
@property --mr {
  syntax: "<length>";
  initial-value: 240px;
  inherits: true;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.75;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.mono { font-family: var(--mono); color: var(--accent); }

/* ============================================================
   吊灯（装饰层，位于遮罩之上）
   ============================================================ */
.lamp {
  position: fixed;
  top: 0;
  left: 50%;
  translate: -50% 0;
  z-index: 60;
  pointer-events: none;
  transform-origin: top center;
  animation: lamp-sway 7s ease-in-out infinite;
  filter: drop-shadow(0 18px 28px rgba(255, 212, 121, 0.25));
}

@keyframes lamp-sway {
  0%, 100% { rotate: -2.4deg; }
  50%      { rotate: 2.4deg; }
}

.lamp-bulb { animation: bulb-glow 3.2s ease-in-out infinite; }

@keyframes bulb-glow {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.72; }
}

/* 灯罩下投射的圆锥微光 */
.lamp-cone {
  position: absolute;
  top: 128px;
  left: 50%;
  translate: -50% 0;
  width: 340px;
  height: 420px;
  background: linear-gradient(rgba(255, 212, 121, 0.10), transparent 82%);
  clip-path: polygon(38% 0, 62% 0, 100% 100%, 0 100%);
}

/* Three.js 吊灯画布：3D 就绪后接管，隐藏 SVG 回退吊灯 */
#lampCanvas {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;   /* 拖拽事件挂在 window 上，画布不拦截页面交互 */
}
body.lamp3d-active .lamp { display: none; }

/* 首屏终端彩蛋 */
.hero-egg {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 20px;
  opacity: 0.85;
}
.egg-caret { animation: caret-blink 0.9s steps(1) infinite; color: var(--accent); }

/* ============================================================
   导航
   ============================================================ */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 70;               /* 高于遮罩，保证可点击 */
  height: var(--nav-h);
  transition: background 0.3s, box-shadow 0.3s;
}

.nav.scrolled {
  background: rgba(16, 16, 22, 0.86);
  backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 var(--border);
}

.nav-inner {
  max-width: 1080px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-logo { font-family: var(--mono); font-weight: 700; color: var(--text); }
.nav-logo:hover { color: var(--accent); text-decoration: none; }

.nav-links {
  display: flex;
  gap: 22px;
  list-style: none;
  margin-left: auto;
}

.nav-links a {
  color: var(--text-dim);
  font-size: 14px;
  transition: color 0.2s;
}

.nav-links a:hover { color: var(--text); text-decoration: none; }
.nav-links a.active { color: var(--accent); }

.light-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.light-toggle:hover { border-color: var(--accent); }

.scroll-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #ff9d5c);
}

/* ============================================================
   布局
   ============================================================ */
main { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

.section { padding: 96px 0 24px; }

.section-title {
  font-size: clamp(24px, 3vw, 32px);
  margin-bottom: 32px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
  margin-left: 12px;
  align-self: center;
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}

.hero-eyebrow { font-family: var(--mono); color: var(--accent); margin-bottom: 12px; }

.hero-name {
  font-size: clamp(44px, 7vw, 76px);
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.hero-typed {
  font-family: var(--mono);
  font-size: clamp(18px, 2.4vw, 26px);
  color: var(--text-dim);
  margin-top: 14px;
  min-height: 1.6em;
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent);
  vertical-align: -0.15em;
  margin-left: 2px;
  animation: caret-blink 0.9s steps(1) infinite;
}

@keyframes caret-blink { 50% { opacity: 0; } }

.hero-desc { max-width: 560px; color: var(--text-dim); margin-top: 22px; }

.hero-cta { display: flex; gap: 16px; margin-top: 36px; }

.hero-hint {
  margin-top: 64px;
  font-size: 13px;
  color: var(--text-dim);
  opacity: 0.7;
}

/* ============================================================
   按钮 / 标签 / 卡片
   ============================================================ */
.btn {
  display: inline-block;
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 15px;
  cursor: pointer;
  transition: translate 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn:hover { text-decoration: none; translate: 0 -2px; }

.btn-primary {
  background: var(--accent);
  color: #101016;
  font-weight: 600;
  border: none;
}
.btn-primary:hover { box-shadow: 0 8px 24px rgba(255, 212, 121, 0.3); }

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text);
  background: transparent;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }

.tags li {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 4px 14px;
  transition: border-color 0.2s, translate 0.2s;
}
.tags li:hover { border-color: var(--accent); translate: 0 -2px; }

/* ============================================================
   关于我 / 技能
   ============================================================ */
.about-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 40px;
  align-items: start;
}

.about-cards { list-style: none; display: grid; gap: 12px; }

.about-cards li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
}

.card-key { color: var(--text-dim); font-size: 14px; }
.card-val { font-weight: 600; text-align: right; }

/* 实习经历横幅 */
.exp-banner {
  margin-top: 32px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px 24px;
}

.exp-badge {
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 4px 14px;
}

.exp-banner strong { font-size: 17px; }
.exp-date { color: var(--text-dim); font-family: var(--mono); font-size: 13px; margin-left: 12px; }
.exp-banner p { color: var(--text-dim); margin-top: 8px; font-size: 15px; }

/* 荣誉与证书 */
.honors-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

.honor-list {
  list-style: none;
  display: grid;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.honor-list li { font-size: 15px; }

.skills-groups { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }

.skill-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: translate 0.25s, border-color 0.25s;
}
.skill-group:hover { translate: 0 -4px; border-color: var(--accent); }
.skill-group h3 { font-size: 16px; margin-bottom: 14px; }

/* ============================================================
   项目
   ============================================================ */
.project-list { display: grid; gap: 24px; }

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: translate 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.project-card:hover {
  translate: 0 -4px;
  border-color: var(--accent);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.project-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.project-head h3 { font-size: 20px; }
.project-tag {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 10px;
  margin-left: 10px;
  vertical-align: 3px;
}
.project-link { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.project-desc { color: var(--text-dim); margin: 12px 0 16px; }
.project-result {
  color: var(--text);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 15px;
}
.project-result strong { color: var(--accent); }

/* ============================================================
   AI 分身 · 聊天
   ============================================================ */
.agent-intro { color: var(--text-dim); margin-bottom: 20px; }
.agent-intro strong { color: var(--accent); }

.chat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.chat-messages {
  height: 320px;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 78%;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 15px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-bot {
  align-self: flex-start;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  box-shadow: 0 0 18px rgba(255, 212, 121, 0.06);
}

.msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #101016;
}

.msg-error { border-left-color: #ff7a7a; color: #ffb3b3; }

.chat-form {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 10px 18px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.chat-form input:focus { border-color: var(--accent); }
.chat-form input:disabled { opacity: 0.5; }

.chat-form .btn { padding: 10px 22px; }
.chat-form .btn:disabled { opacity: 0.5; cursor: not-allowed; translate: none; box-shadow: none; }

/* ============================================================
   Built with AI / 联系方式 / 页脚
   ============================================================ */
.ai-report {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.ai-report ol { margin: 14px 0 0 20px; display: grid; gap: 10px; color: var(--text-dim); }
.ai-report strong { color: var(--text); }

.contact-lead { color: var(--text-dim); margin-bottom: 16px; }
.contact-list { list-style: none; display: grid; gap: 12px; font-size: 17px; }

.footer {
  margin-top: 96px;
  padding: 32px 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* ============================================================
   滚动入场动画
   ============================================================ */
.reveal { opacity: 0; translate: 0 24px; transition: opacity 0.6s ease, translate 0.6s ease; }
.reveal.visible { opacity: 1; translate: 0 0; }

/* ============================================================
   黑暗遮罩 —— 核心灯光效果（双光源）
   两层 mask 各自挖洞：吊灯主光源 + 鼠标手电筒，
   intersect（source-in）合成后两个光洞同时生效
   ============================================================ */
.darkness {
  position: fixed;
  inset: 0;
  z-index: 50;                 /* 低于导航(70)与吊灯(60)，高于内容 */
  pointer-events: none;        /* 不拦截任何点击 */
  background: #050508;
  --lr: 0px;                   /* 吊灯主光源半径，开场动画点亮 */
  --mr: 0px;                   /* 手电筒半径 */
  transition: --lr 1.4s ease, --mr 1.1s ease;
  mask-image:
    radial-gradient(circle var(--lr) at var(--lx) var(--ly), transparent 0%, transparent 42%, black 82%),
    radial-gradient(circle var(--mr) at var(--mx) var(--my), transparent 0%, transparent 42%, black 82%);
  mask-composite: intersect;
  -webkit-mask-image:
    radial-gradient(circle var(--lr) at var(--lx) var(--ly), transparent 0%, transparent 42%, black 82%),
    radial-gradient(circle var(--mr) at var(--mx) var(--my), transparent 0%, transparent 42%, black 82%);
  -webkit-mask-composite: source-in;
}

body.lit .darkness { --lr: 320px; --mr: 240px; }

/* 全亮模式 / 减少动效 / 触摸设备：直接隐藏遮罩 */
body.lights-on .darkness { display: none; }
body.lights-on .hero-hint { display: none; }

/* ============================================================
   开场引导弹窗
   ============================================================ */
.intro-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 8, 0.55);
  backdrop-filter: blur(3px);
  transition: opacity 0.5s ease, visibility 0.5s;
}

.intro-modal.hidden { opacity: 0; visibility: hidden; }

.intro-card {
  max-width: 460px;
  margin: 0 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 212, 121, 0.08);
}

.intro-emoji { font-size: 40px; margin-bottom: 12px; }
.intro-card h2 { font-size: 22px; margin-bottom: 14px; }
.intro-card p { color: var(--text-dim); font-size: 15px; margin-bottom: 12px; }

.intro-tips {
  font-size: 13px !important;
  color: var(--accent) !important;
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 22px !important;
}

@media (hover: none), (prefers-reduced-motion: reduce) {
  .darkness { display: none; }
  .hero-hint { display: none; }
  .lamp { animation: none; }
  .reveal { opacity: 1; translate: none; transition: none; }
}

/* ============================================================
   桌面端窄屏微调（作业只要求电脑端，做基本兼容）
   ============================================================ */
@media (max-width: 860px) {
  .about-grid, .skills-groups, .honors-grid { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}
