/* ============ Tokens ============ */
:root {
  --c1: #22d3ee;   /* cyan */
  --c2: #8b5cf6;   /* violet */
  --c3: #3b82f6;   /* blue */
  --radius: 16px;
  --max: 1160px;
  --sans: "Inter", "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, "Microsoft YaHei", monospace;
}
[data-theme="dark"] {
  --bg: #05060a;
  --surface: rgba(255, 255, 255, .035);
  --surface-2: rgba(255, 255, 255, .06);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #e8eaf0;
  --muted: #8b93a7;
  --grid: rgba(255, 255, 255, .045);
  --glow: .55;
}
[data-theme="light"] {
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, .7);
  --surface-2: rgba(255, 255, 255, .9);
  --border: rgba(15, 23, 42, .08);
  --border-strong: rgba(15, 23, 42, .18);
  --text: #0b1020;
  --muted: #566079;
  --grid: rgba(15, 23, 42, .05);
  --glow: .3;
}

/* ============ Base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; background: var(--bg); color: var(--text); }
body {
  background: var(--bg); color: var(--text); font-family: var(--sans); line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
/* film grain */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100; opacity: .05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
::selection { background: color-mix(in srgb, var(--c1) 35%, transparent); }
a { color: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--c1); outline-offset: 3px; border-radius: 8px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--c1); color: #000; padding: 8px 12px; border-radius: 8px; z-index: 200; }
.skip:focus { left: 8px; }

/* ============ Ambient background ============ */
.bg-layer { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; background: var(--bg); }
.grid-lines {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 85%);
}
.aurora { position: absolute; border-radius: 50%; filter: blur(90px); opacity: var(--glow); will-change: transform; }
.a1 { width: 46vw; height: 46vw; left: -10vw; top: -14vw; background: radial-gradient(circle, var(--c2), transparent 65%); animation: drift1 22s ease-in-out infinite; }
.a2 { width: 40vw; height: 40vw; right: -12vw; top: 8vh; background: radial-gradient(circle, var(--c1), transparent 65%); animation: drift2 26s ease-in-out infinite; opacity: calc(var(--glow) * .7); }
.a3 { width: 36vw; height: 36vw; left: 30vw; bottom: -18vw; background: radial-gradient(circle, var(--c3), transparent 65%); animation: drift1 30s ease-in-out infinite reverse; opacity: calc(var(--glow) * .5); }
@keyframes drift1 { 50% { transform: translate(8vw, 6vh) scale(1.1); } }
@keyframes drift2 { 50% { transform: translate(-6vw, 10vh) scale(.9); } }

.scroll-progress {
  position: fixed; top: 0; left: 0; height: 2px; width: 100%; z-index: 60; transform-origin: 0 50%; transform: scaleX(0);
  background: linear-gradient(90deg, var(--c2), var(--c1)); box-shadow: 0 0 12px var(--c1);
}

/* ============ Nav ============ */
.nav {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  padding: 14px max(20px, calc((100% - var(--max)) / 2));
  background: color-mix(in srgb, var(--bg) 65%, transparent); backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.logo-mark {
  font-family: var(--mono); font-size: .8rem; padding: 4px 7px; border-radius: 8px; color: var(--c1);
  border: 1px solid color-mix(in srgb, var(--c1) 40%, transparent); background: color-mix(in srgb, var(--c1) 10%, transparent);
}
.nav ul { display: flex; gap: 6px; list-style: none; }
.nav ul a {
  display: flex; align-items: baseline; gap: 6px; text-decoration: none; color: var(--muted); font-size: .92rem;
  padding: 6px 12px; border-radius: 999px; transition: color .2s, background .2s;
}
.nav ul a i { font-style: normal; font-family: var(--mono); font-size: .7rem; color: var(--c1); opacity: .7; }
.nav ul a:hover { color: var(--text); background: var(--surface-2); }
.nav ul a.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.nav-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text); width: 38px; height: 38px;
  border-radius: 10px; cursor: pointer; font-size: 1rem; transition: border-color .2s;
}
.icon-btn:hover { border-color: var(--border-strong); }
.menu-btn { display: none; }

/* ============ Layout ============ */
main { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.section { padding: 110px 0 20px; }
.label { color: var(--c1); font-size: .8rem; letter-spacing: .14em; margin-bottom: 10px; }
h2 { font-size: clamp(1.8rem, 3.6vw, 2.6rem); line-height: 1.2; letter-spacing: -.01em; margin-bottom: 36px; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; }

/* glass surface used by cards */
.glass, .skill-card, .card, .stat, .edu-card, .contact-card, .timeline > li {
  position: relative; background: linear-gradient(180deg, var(--surface-2), var(--surface)); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 20px 50px -30px rgba(0, 0, 0, .6);
}
/* cursor spotlight + gradient border on hover */
.spot::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), color-mix(in srgb, var(--c1) 12%, transparent), transparent 45%);
}
.spot::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity .3s;
  padding: 1px; background: radial-gradient(300px circle at var(--mx, 50%) var(--my, 50%), var(--c1), var(--c2) 40%, transparent 70%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}
.spot:hover::before, .spot:hover::after { opacity: 1; }

/* ============ Hero ============ */
.hero {
  position: relative; min-height: calc(100vh - 67px); display: grid; grid-template-columns: 1.15fr .85fr;
  align-items: center; gap: 48px; padding: 40px 0 80px;
}
#particles { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none;
  mask-image: radial-gradient(ellipse at 60% 45%, #000 40%, transparent 80%); -webkit-mask-image: radial-gradient(ellipse at 60% 45%, #000 40%, transparent 80%); }
.hero-text { display: flex; flex-direction: column; gap: 22px; }
.status-pill {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px 6px 10px; border-radius: 999px;
  font-size: .85rem; color: var(--muted); background: var(--surface); border: 1px solid var(--border);
}
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 0 rgba(34, 197, 94, .6); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.hero-id { display: flex; align-items: center; gap: 22px; }
.avatar-ring {
  position: relative; flex-shrink: 0; width: 104px; height: 104px; border-radius: 50%; padding: 3px;
  background: conic-gradient(from var(--ang, 0deg), var(--c1), var(--c2), var(--c3), var(--c1)); animation: spin 6s linear infinite;
  box-shadow: 0 0 40px -6px color-mix(in srgb, var(--c1) 70%, transparent);
}
@property --ang { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
@keyframes spin { to { --ang: 360deg; } }
.avatar {
  width: 100%; height: 100%; border-radius: 50%; border: 3px solid var(--bg); display: grid; place-items: center;
  font-size: 2rem; font-weight: 800; background: var(--surface-2) center / cover;
}
.hello { color: var(--muted); font-size: .9rem; margin-bottom: 2px; }
h1 { font-size: clamp(2.8rem, 7vw, 5rem); line-height: 1.05; letter-spacing: .02em; font-weight: 900; }
.grad {
  background: linear-gradient(100deg, var(--text) 0%, var(--text) 30%, var(--c1) 50%, var(--c2) 65%, var(--text) 85%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
}
.shimmer { animation: shimmer 6s ease-in-out infinite; }
@keyframes shimmer { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }
.typed { font-size: clamp(1.05rem, 2.2vw, 1.35rem); color: var(--text); min-height: 1.7em; }
.prompt { color: var(--c1); }
.cursor { color: var(--c1); margin-left: 2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 580px; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 24px; border-radius: 12px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; color: var(--text); overflow: hidden;
  border: 1px solid var(--border-strong); background: var(--surface); transition: transform .2s, box-shadow .3s, border-color .2s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--c1); }
.btn.primary {
  border: 0; color: #fff; background: linear-gradient(120deg, var(--c2), var(--c3) 50%, var(--c1));
  background-size: 200% 100%; box-shadow: 0 10px 30px -10px color-mix(in srgb, var(--c2) 80%, transparent), inset 0 1px 0 rgba(255,255,255,.25);
  transition: background-position .5s, transform .2s, box-shadow .3s;
}
.btn.primary:hover { background-position: 100% 0; box-shadow: 0 14px 40px -10px color-mix(in srgb, var(--c1) 80%, transparent); }

/* code window */
.code-window { overflow: hidden; transform: perspective(1200px) rotateY(-8deg) rotateX(4deg); transition: transform .6s; }
.code-window:hover { transform: none; }
.code-window::before {
  content: ""; position: absolute; inset: -40%; z-index: -1;
  background: conic-gradient(from 180deg, transparent, color-mix(in srgb, var(--c1) 25%, transparent), transparent 30%);
  animation: spin2 8s linear infinite; opacity: .6;
}
@keyframes spin2 { to { transform: rotate(360deg); } }
.win-bar { display: flex; align-items: center; gap: 7px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot.r { background: #ff5f57; } .dot.y { background: #febc2e; } .dot.g { background: #28c840; }
.win-title { margin-left: 10px; font-size: .78rem; color: var(--muted); }
#code { padding: 20px 22px 24px; font-size: .86rem; line-height: 1.9; white-space: pre-wrap; word-break: break-word; min-height: 300px; color: var(--text); }
#code .ln { display: inline-block; width: 1.6em; color: var(--muted); opacity: .45; user-select: none; }
#code .k { color: #c084fc; } #code .p { color: #7dd3fc; } #code .s { color: #86efac; } #code .n { color: #fbbf24; } #code .c { color: var(--muted); font-style: italic; }
[data-theme="light"] #code .k { color: #7c3aed; } [data-theme="light"] #code .p { color: #0369a1; } [data-theme="light"] #code .s { color: #15803d; } [data-theme="light"] #code .n { color: #b45309; }

.scroll-hint {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: .7rem; letter-spacing: .3em; color: var(--muted); text-decoration: none; text-transform: uppercase;
}
.scroll-hint span { width: 1px; height: 40px; background: linear-gradient(var(--c1), transparent); animation: drop 2s ease-in-out infinite; transform-origin: top; }
@keyframes drop { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1); opacity: 0; } }

/* ============ About ============ */
.about-wrap { display: grid; grid-template-columns: 1.5fr 1fr; gap: 40px; align-items: start; }
#about-text p { margin-bottom: 16px; color: var(--muted); font-size: 1.04rem; }
#about-text p:first-child { color: var(--text); font-size: 1.12rem; }
.stats { display: grid; gap: 14px; }
.stat { padding: 20px 24px; display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 6px; overflow: hidden; }
.stat::after { content: ""; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c1) 25%, transparent), transparent 70%); }
.stat-num, .stat-unit { font-family: var(--mono); font-size: 2.4rem; font-weight: 700; line-height: 1.1;
  background: linear-gradient(90deg, var(--c1), var(--c2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-unit { font-size: 1.6rem; }
.stat p { grid-column: 1 / -1; color: var(--muted); font-size: .88rem; }

/* ============ Skills ============ */
.skill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.skill-card { padding: 26px; transition: transform .3s; }
.skill-card:hover { transform: translateY(-4px); }
.skill-card h3 { margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.skill-icon {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; font-size: 1.25rem; flex-shrink: 0; margin-bottom: 16px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c2) 22%, transparent), color-mix(in srgb, var(--c1) 18%, transparent));
  border: 1px solid var(--border);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }
.chips li, .tag {
  font-family: var(--mono); font-size: .78rem; padding: 4px 10px; border-radius: 8px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); transition: border-color .2s, color .2s;
}
.chips li:hover { border-color: color-mix(in srgb, var(--c1) 60%, transparent); color: var(--c1); }

/* ============ Projects ============ */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.filters button {
  font-family: var(--mono); padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; font-size: .8rem; transition: all .2s;
}
.filters button:hover { color: var(--text); border-color: var(--border-strong); }
.filters button[aria-pressed="true"] { color: var(--bg); background: var(--c1); border-color: var(--c1); box-shadow: 0 0 20px -4px var(--c1); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.card { padding: 26px; display: flex; flex-direction: column; gap: 12px; text-decoration: none; transition: transform .3s; counter-increment: proj; }
.grid { counter-reset: proj; }
.card:hover { transform: translateY(-4px); }
.card h3 { display: flex; justify-content: space-between; gap: 10px; font-size: 1.1rem; }
.card h3::before { content: counter(proj, decimal-leading-zero); font-family: var(--mono); font-size: .75rem; color: var(--c1); order: 2; opacity: .8; }
.card p { color: var(--muted); flex: 1; font-size: .95rem; }
.card .tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============ Timeline ============ */
.timeline { list-style: none; position: relative; padding-left: 34px; display: grid; gap: 22px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px;
  background: linear-gradient(var(--c1), var(--c2), transparent); }
.timeline > li { padding: 26px 28px; }
.timeline > li > .node {
  position: absolute; left: -32px; top: 30px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--c1); box-shadow: 0 0 0 4px color-mix(in srgb, var(--c1) 15%, transparent), 0 0 16px var(--c1);
}
.timeline .when { font-family: var(--mono); font-size: .8rem; color: var(--c1); letter-spacing: .04em; }
.timeline h3 { margin: 6px 0 2px; font-size: 1.15rem; }
.timeline .org { display: block; color: var(--muted); margin-bottom: 14px; font-size: .95rem; }
.points { list-style: none; display: grid; gap: 8px; color: var(--muted); font-size: .95rem; }
.points li { position: relative; padding-left: 20px; }
.points li::before { content: "▹"; position: absolute; left: 0; color: var(--c1); }

/* ============ Education ============ */
.edu-card { display: flex; gap: 20px; align-items: flex-start; padding: 26px 28px; max-width: 760px; }
.edu-card .skill-icon { margin: 0; }
.edu-card h3 { font-size: 1.15rem; }
.edu-card .org { color: var(--muted); }
.edu-card .when { display: block; font-family: var(--mono); font-size: .8rem; color: var(--c1); margin: 4px 0 14px; }

/* ============ Contact ============ */
.contact-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin: 26px 0 22px; }
.contact-card { display: flex; align-items: center; gap: 14px; padding: 18px 20px; text-decoration: none; transition: transform .3s; }
a.contact-card:hover { transform: translateY(-3px); }
.contact-card .skill-icon { margin: 0; }
.c-label { display: block; font-size: .78rem; color: var(--muted); }
.c-value { display: block; font-family: var(--mono); font-weight: 600; font-size: .95rem; overflow-wrap: anywhere; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 28px; }
.form .full { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 8px; font-size: .85rem; color: var(--muted); font-weight: 500; }
.form input, .form textarea {
  font: inherit; font-size: .98rem; padding: 12px 14px; border-radius: 10px; color: var(--text); resize: vertical;
  background: color-mix(in srgb, var(--bg) 60%, transparent); border: 1px solid var(--border); transition: border-color .2s, box-shadow .2s;
}
.form input::placeholder, .form textarea::placeholder { color: var(--muted); opacity: .6; }
.form input:focus, .form textarea:focus { outline: none; border-color: var(--c1); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c1) 20%, transparent); }
.form [aria-invalid="true"] { border-color: #f43f5e; }
.form-status { min-height: 1.4em; font-size: .9rem; }
.form-status.err { color: #f43f5e; }
.form-status.ok { color: #22c55e; }
.socials { display: flex; gap: 18px; list-style: none; margin-top: 24px; flex-wrap: wrap; }
.socials a { color: var(--muted); text-decoration: none; }
.socials a:hover { color: var(--c1); }

.footer { text-align: center; color: var(--muted); padding: 80px 20px 40px; font-size: .8rem; letter-spacing: .04em; }
.footer p::before { content: "</> "; color: var(--c1); }

/* ============ Reveal ============ */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s ease, transform .7s cubic-bezier(.2,.7,.2,1); }
.reveal.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
  .code-window { transform: none; }
}

/* ============ Responsive ============ */
@media (max-width: 960px) {
  .hero { grid-template-columns: 1fr; gap: 36px; padding-top: 48px; }
  .code-window { transform: none; }
  .scroll-hint { display: none; }
  .about-wrap { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
  .menu-btn { display: block; }
  .nav ul {
    display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; gap: 2px; padding: 10px 12px;
    background: var(--bg); border-bottom: 1px solid var(--border-strong);
    box-shadow: 0 24px 48px rgba(0, 0, 0, .65);
  }
  .nav ul.open { display: flex; }
  .nav ul a { padding: 12px 16px; border-radius: 10px; }
}
@media (max-width: 600px) {
  .section { padding-top: 80px; }
  .hero-id { gap: 16px; }
  .avatar-ring { width: 80px; height: 80px; }
  .stats { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-num { font-size: 1.7rem; } .stat-unit { font-size: 1.2rem; }
  .grid { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; padding: 20px; }
  .timeline { padding-left: 26px; }
  .timeline > li { padding: 20px; }
  .timeline > li > .node { left: -24px; }
  .timeline::before { left: 4px; }
  #code { font-size: .78rem; min-height: 0; }
}
