/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --bg: #08090c;
  --bg-soft: #0d0f14;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e8eaf0;
  --muted: #8b90a0;
  --accent-a: #4f8cff;
  --accent-b: #7c5cff;
  --accent-c: #22d3ee;
  --radius: 16px;
  --radius-sm: 10px;
  --maxw: 1040px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

/* ============================================================
   Base
   ============================================================ */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

::selection { background: rgba(124, 92, 255, 0.35); color: #fff; }

:focus-visible {
  outline: 2px solid var(--accent-c);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 16px; }

/* ============================================================
   Background layers
   ============================================================ */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.bg-grid {
  position: absolute;
  inset: -40% -10% 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 75%);
}

.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
}
.bg-glow-a {
  width: 46vw;
  height: 46vw;
  min-width: 320px;
  min-height: 320px;
  top: -14vw;
  left: -8vw;
  background: radial-gradient(circle, rgba(79, 140, 255, 0.55), transparent 70%);
  animation: drift-a 22s var(--ease) infinite alternate;
}
.bg-glow-b {
  width: 38vw;
  height: 38vw;
  min-width: 280px;
  min-height: 280px;
  top: 6vw;
  right: -10vw;
  background: radial-gradient(circle, rgba(124, 92, 255, 0.45), transparent 70%);
  animation: drift-b 26s var(--ease) infinite alternate;
}

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(6vw, 4vw, 0) scale(1.12); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.08); }
  to   { transform: translate3d(-5vw, 6vw, 0) scale(1); }
}

/* ============================================================
   Nav
   ============================================================ */
.nav-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 14px 24px 0;
}
.nav {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 12, 17, 0.62);
  backdrop-filter: blur(14px) saturate(150%);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.16em;
}
.brand-mark {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b) 55%, var(--accent-c));
  box-shadow: 0 0 14px rgba(124, 92, 255, 0.7);
}
.nav-links { display: flex; gap: 4px; }
.nav-links a {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
}
.nav-links a:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.nav-links a[aria-current="true"] { color: var(--text); background: rgba(255, 255, 255, 0.08); }

/* ============================================================
   Layout
   ============================================================ */
.hero,
.section,
.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.hero { padding-top: clamp(72px, 14vh, 150px); padding-bottom: clamp(48px, 8vh, 90px); }

.section { padding-top: clamp(48px, 7vh, 80px); padding-bottom: clamp(48px, 7vh, 80px); }

/* ============================================================
   Hero
   ============================================================ */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 22px;
  padding: 5px 12px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #35d399;
  box-shadow: 0 0 0 3px rgba(53, 211, 153, 0.16);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(53, 211, 153, 0.16); }
  50%      { box-shadow: 0 0 0 6px rgba(53, 211, 153, 0.05); }
}

.hero-title {
  margin: 0 0 20px;
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 650;
}
.grad-text {
  background: linear-gradient(100deg, var(--accent-a), var(--accent-b) 45%, var(--accent-c));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  max-width: 54ch;
  margin: 0 0 34px;
  font-size: clamp(1rem, 1.6vw, 1.12rem);
  color: var(--muted);
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 56px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 550;
  transition: transform 0.18s var(--ease), box-shadow 0.25s var(--ease),
    background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  box-shadow: 0 8px 26px -10px rgba(94, 110, 255, 0.85);
}
.btn-primary:hover { box-shadow: 0 14px 34px -12px rgba(94, 110, 255, 1); }
.btn-ghost {
  color: var(--text);
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.07); }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 560px;
  margin: 0;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.hero-stats dt {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.hero-stats dd { margin: 0; font-size: 15px; font-weight: 550; }

/* ============================================================
   Section head
   ============================================================ */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 34px;
}
.section-index {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent-c);
  letter-spacing: 0.08em;
}
.section-head h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
  font-weight: 600;
}

/* ============================================================
   About
   ============================================================ */
.about-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 40px;
  align-items: start;
}
.prose p { margin: 0 0 16px; color: #c2c7d4; }
.prose p:last-child { margin-bottom: 0; }

.skill-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.skill-list li {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--mono);
  font-size: 12.5px;
  color: #c2c7d4;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.skill-list li:hover { border-color: rgba(124, 92, 255, 0.5); color: #fff; }

/* ============================================================
   Project cards
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(268px, 1fr));
  gap: 16px;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015));
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease),
    box-shadow 0.3s var(--ease);
  overflow: hidden;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%),
    rgba(124, 92, 255, 0.16), transparent 62%);
  opacity: 0;
  transition: opacity 0.32s var(--ease);
  pointer-events: none;
}
.card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: 0 24px 48px -30px rgba(0, 0, 0, 0.9); }
.card:hover::after { opacity: 1; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-c);
}
.card-link {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  color: var(--muted);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.card-link:hover { color: #fff; border-color: var(--line-strong); transform: rotate(45deg); }

.card h3 { margin: 0 0 8px; font-size: 1.06rem; font-weight: 600; letter-spacing: -0.01em; }
.card p { margin: 0 0 18px; font-size: 14.5px; color: var(--muted); }

.tag-row {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: auto 0 0;
  padding: 0;
}
.tag-row li {
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--mono);
  font-size: 11.5px;
  color: #a9afbe;
}

/* ============================================================
   Contact
   ============================================================ */
.contact-card {
  padding: clamp(28px, 5vw, 48px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(600px circle at 15% 0%, rgba(79, 140, 255, 0.14), transparent 60%),
    radial-gradient(600px circle at 90% 100%, rgba(124, 92, 255, 0.14), transparent 60%),
    rgba(255, 255, 255, 0.02);
  text-align: center;
}
.contact-lead {
  margin: 0 auto 26px;
  max-width: 46ch;
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  color: #d6dae4;
}
.social-row {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 28px 0 0;
  padding: 0;
}
.social-row a {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13.5px;
  color: var(--muted);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.social-row a:hover { color: #fff; border-color: var(--line-strong); background: rgba(255, 255, 255, 0.06); }

/* ============================================================
   Footer
   ============================================================ */
.footer {
  padding-top: 28px;
  padding-bottom: 44px;
  border-top: 1px solid var(--line);
  margin-top: 40px;
}
.footer p {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: #6f7484;
}

/* ============================================================
   Reveal on scroll
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
  .about-grid { grid-template-columns: 1fr; gap: 26px; }
  .hero-stats { grid-template-columns: 1fr 1fr; }
  .nav-wrap { padding: 10px 14px 0; }
  .hero, .section, .footer { padding-left: 18px; padding-right: 18px; }
  .nav-links a { padding: 6px 9px; font-size: 13px; }
}

@media (max-width: 420px) {
  .hero-stats { grid-template-columns: 1fr; }
  .brand-text { display: none; }
}

/* ============================================================
   Motion / contrast preferences
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

@media print {
  .bg, .nav-wrap { display: none; }
  body { background: #fff; color: #000; }
}
