/* ============================================================
   Karly Ma · 个人网站样式
   设计基调：极简排版 + 深色默认主题，可切换明亮主题
   ============================================================ */

:root {
  /* 英文与数字用衬线体 Georgia（中文自动回落到无衬线）；终端窗口另用等宽体 --font-term */
  --font-sans: Georgia, "Times New Roman", "Segoe UI", -apple-system, "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-mono: Georgia, "Times New Roman", "PingFang SC", "Microsoft YaHei", serif;
  --font-term: "Cascadia Code", Consolas, "JetBrains Mono", "SF Mono", monospace;

  --max-width: 1080px;
  --nav-height: 64px;
}

/* ---------- 主题变量 ---------- */
html[data-theme="dark"] {
  --bg: #0d0d0f;
  --bg-soft: #131316;
  --bg-card: #17171b;
  --text: #e8e8e6;
  --text-dim: #9b9ba3;
  --line: #26262c;
  --accent: #5eead4;
  --accent-dim: rgba(94, 234, 212, 0.12);
  --grad: linear-gradient(100deg, #5eead4 0%, #818cf8 55%, #e879f9 100%);
  --glow: radial-gradient(ellipse 60% 45% at 50% 0%, rgba(94, 234, 212, 0.07), transparent);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #fafafa;
  --bg-soft: #f2f2f0;
  --bg-card: #ffffff;
  --text: #17171a;
  --text-dim: #6b6b72;
  --line: #e4e4e0;
  --accent: #0d9488;
  --accent-dim: rgba(13, 148, 136, 0.08);
  --grad: linear-gradient(100deg, #0d9488 0%, #4f46e5 55%, #c026d3 100%);
  --glow: radial-gradient(ellipse 60% 45% at 50% 0%, rgba(13, 148, 136, 0.05), transparent);
  color-scheme: light;
}

/* ---------- 语言切换：只显示当前语言 ---------- */
html[data-lang="zh"] [lang="en"] { display: none; }
html[data-lang="en"] [lang="zh"] { display: none; }

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background 0.35s ease, color 0.35s ease;
}

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

a { color: inherit; text-decoration: none; }

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

/* ---------- 导航 ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 32px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  z-index: 100;
}

.nav-brand {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

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

.nav-actions { display: flex; gap: 10px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--text-dim); }

/* 语言分段开关（中 | EN），当前语言高亮，让"可切换"一目了然 */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 30px;
  padding: 3px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-mono);
}
.lang-switch:hover { border-color: var(--text-dim); }
.lang-opt {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 9px;
  font-size: 12px;
  line-height: 1;
  color: var(--text-dim);
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}
.lang-opt.active {
  background: var(--accent);
  color: var(--bg);
  font-weight: 700;
}

/* 主题按钮：暗色下显示太阳，亮色下显示月亮 */
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="light"] .icon-sun { display: none; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--nav-height) 32px 0;
  background-image:
    var(--glow),
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: auto, 56px 56px, 56px 56px;
}
/* 网格淡出遮罩 */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bg) 30%, transparent) 0%,
    color-mix(in srgb, var(--bg) 65%, transparent) 55%,
    var(--bg) 100%);
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  width: 100%;
}

.kicker {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 20px;
}

.hero h1 {
  font-size: clamp(40px, 7vw, 76px);
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.15;
}

.hero-statement {
  font-size: clamp(20px, 3vw, 30px);
  margin-top: 18px;
  font-weight: 500;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  width: fit-content;
}

.hero-sub {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 26px;
  letter-spacing: 0.5px;
  min-height: 1.6em; /* 打字机效果占位，防止布局跳动 */
}

.type-cursor {
  color: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}

.hero-cta { display: flex; gap: 14px; margin-top: 42px; }

.hero-scroll {
  position: absolute;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  color: var(--text-dim);
  font-size: 18px;
  animation: bob 2.2s ease-in-out infinite;
  z-index: 1;
}
@keyframes bob {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.5; }
  50%      { transform: translate(-50%, 8px); opacity: 1; }
}

/* ---------- 极光背景（Hero） ---------- */
.aurora {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.aurora i {
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(95px);
  opacity: 0.3;
}
html[data-theme="light"] .aurora i { opacity: 0.18; }
.aurora i:first-child {
  background: #14b8a6;
  top: -140px; left: 8%;
  animation: drift1 16s ease-in-out infinite alternate;
}
.aurora i:last-child {
  background: #6366f1;
  top: 8%; right: 4%;
  animation: drift2 21s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(130px, 90px) scale(1.15); } }
@keyframes drift2 { to { transform: translate(-150px, 70px) scale(0.88); } }

/* ---------- 技能跑马灯 ---------- */
.marquee {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  overflow: hidden;
  padding: 13px 0;
}
.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee-scroll 38s linear infinite;
}
.marquee-track span {
  position: relative;
  padding: 0 22px;
  font-size: 12.5px;
  letter-spacing: 1px;
  color: var(--text-dim);
  white-space: nowrap;
}
.marquee-track span::after {
  content: "✦";
  position: absolute;
  right: -6px;
  color: var(--accent);
  opacity: 0.55;
  font-size: 10px;
}
@keyframes marquee-scroll { to { transform: translateX(-50%); } }

/* ---------- 数据统计条 ---------- */
.stats {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 60px 32px 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.stat {
  text-align: center;
  padding: 28px 12px 24px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.stat-num {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 700;
  line-height: 1.2;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.stat-label {
  display: block;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 8px;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 11px 26px;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  transition: transform 0.15s, background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover { transform: translateY(-2px); }

.btn-primary {
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
}
.btn-primary:hover { background: var(--grad); color: #fff; }

.btn-ghost {
  border-color: var(--line);
  color: var(--text-dim);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text); }

/* ---------- 通用区块 ---------- */
.section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 110px 32px 10px;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 44px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.section-num {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent);
}

.section-head h2 {
  font-size: clamp(24px, 3.4vw, 34px);
  font-weight: 700;
  letter-spacing: -0.5px;
}

.section-lead {
  margin: -26px 0 36px;
  font-size: 14.5px;
  color: var(--text-dim);
  max-width: 70ch;
}

/* ---------- 关于我 ---------- */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 56px;
  align-items: start;
}

.about-text p { margin-bottom: 18px; max-width: 62ch; }
.about-text p:last-child { color: var(--text-dim); }

.avatar-placeholder {
  width: 200px;
  height: 200px;
  border-radius: 16px;
  border: 1px dashed var(--line);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--accent);
}

.aside-note {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 10px;
}

/* ---------- 侧栏信息卡 ---------- */
.facts {
  list-style: none;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-dim);
}
.facts li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}
.facts li:last-child { border-bottom: none; }

/* ---------- 经历时间线 ---------- */
.timeline {
  position: relative;
  padding-left: 28px;
  border-left: 1px solid var(--line);
}

.timeline-item {
  position: relative;
  padding-bottom: 40px;
}
.timeline-item:last-child { padding-bottom: 8px; }

/* 时间线节点圆点 */
.timeline-item::before {
  content: "";
  position: absolute;
  left: -33px;
  top: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
}

.timeline-item .time {
  font-size: 12.5px;
  color: var(--accent);
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.timeline-item h3 {
  font-size: 17px;
  font-weight: 650;
  margin-bottom: 8px;
}

.timeline-desc {
  font-size: 14px;
  color: var(--text-dim);
  max-width: 72ch;
}

/* ---------- 项目卡片 ---------- */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 20px;
}

.card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 26px 24px;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 12px 32px -14px rgba(0, 0, 0, 0.4);
}

/* 卡片跟随鼠标的聚光效果（--mx/--my 由脚本更新） */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%),
              var(--accent-dim), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.card:hover::after { opacity: 1; }

.card-index {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 1px;
  margin-bottom: 14px;
}

.card h3 {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.4;
  margin-bottom: 12px;
}

.card p {
  font-size: 14px;
  color: var(--text-dim);
  flex: 1;
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}
.tags li {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
}

/* 开源卡片高亮 + 查看源码链接 */
.card-featured {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.card-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s, gap 0.2s;
  width: fit-content;
}
.card-link:hover { border-color: var(--accent); gap: 8px; }

/* ---------- 协作方式 ---------- */
.workflow-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 48px;
  align-items: center;
}

.workflow-steps { list-style: none; counter-reset: step; }
.workflow-steps li {
  counter-increment: step;
  position: relative;
  padding: 0 0 26px 52px;
}
.workflow-steps li::before {
  content: "0" counter(step);
  position: absolute;
  left: 0; top: 2px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
}
.workflow-steps h4 { font-size: 16px; margin-bottom: 4px; }
.workflow-steps p { font-size: 14px; color: var(--text-dim); }

/* 终端窗口 */
.terminal {
  background: #0b0d10;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.55);
}
html[data-theme="light"] .terminal { border-color: #d8d8d4; }

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 11px 14px;
  background: #14171b;
  border-bottom: 1px solid #22262b;
}
.terminal-bar .dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #3a3f45;
}
.terminal-bar .dot:first-child { background: #f87171; }
.terminal-bar .dot:nth-child(2) { background: #fbbf24; }
.terminal-bar .dot:nth-child(3) { background: #34d399; }

.terminal-title {
  margin-left: 8px;
  font-size: 11.5px;
  color: #6b7280;
  font-family: var(--font-term);
}

.terminal-body {
  padding: 18px 18px 22px;
  font-size: 12.8px;
  line-height: 2;
  color: #c9d1d9;
  font-family: var(--font-term);
}
.terminal-body p { transition: opacity 0.35s ease; }
.terminal-body .prompt { color: #5eead4; }
.terminal-body .str { color: #a5b4fc; }
.terminal-body .dim { color: #8b949e; }
.terminal-body .ok { color: #4ade80; }
.terminal-body .cursor { animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- 技能 ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 20px;
}

.skill-group {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px 22px;
}
.skill-group h4 {
  font-size: 14px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.skill-group ul { list-style: none; }
.skill-group li {
  font-size: 13.5px;
  color: var(--text-dim);
  padding: 4px 0 4px 18px;
  position: relative;
}
.skill-group li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 11px;
}

/* ---------- 联系 ---------- */
.section-contact { text-align: center; padding-bottom: 40px; }
.section-contact .section-head { justify-content: center; }

.contact-lead {
  color: var(--text-dim);
  margin-bottom: 26px;
}

.contact-email {
  display: inline-block;
  font-size: clamp(20px, 3.6vw, 34px);
  font-weight: 600;
  letter-spacing: -0.5px;
  border-bottom: 2px solid var(--line);
  padding-bottom: 6px;
  transition: color 0.2s, border-color 0.2s;
}
.contact-email:hover { color: var(--accent); border-color: var(--accent); }

.contact-links {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-top: 36px;
}

.contact-location {
  margin-top: 28px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- 页脚 ---------- */
.footer {
  text-align: center;
  padding: 60px 32px 36px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- 滚动渐显 ----------
   仅在 html.js（脚本已就绪）时才隐藏元素，
   无 JS 环境下内容始终可见（渐进增强） */
html.js .reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
html.js .reveal.visible {
  opacity: 1;
  transform: none;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* 用户偏好减少动效时全部禁用 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .hero-scroll, .cursor, .type-cursor, .aurora i, .marquee-track { animation: none; }
}

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .nav { padding: 0 20px; }
  .nav-links { display: none; }

  .section { padding: 80px 20px 10px; }
  .hero { padding: var(--nav-height) 20px 0; }

  .stats { grid-template-columns: repeat(2, 1fr); padding: 44px 20px 0; }

  .about-grid { grid-template-columns: 1fr; gap: 32px; }
  .about-aside { display: flex; align-items: center; gap: 16px; }
  .avatar-placeholder { width: 120px; height: 120px; font-size: 26px; }

  .workflow-grid { grid-template-columns: 1fr; gap: 36px; }
}
