/* ===== CSS Variables ===== */
:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.6);
  --border: rgba(56, 189, 248, 0.15);
  --border-hover: rgba(56, 189, 248, 0.4);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.3);
  --accent-secondary: #818cf8;
  --gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #c084fc 100%);
  --font-sans: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --header-h: 72px;
}

/* ===== Reset ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

ul { list-style: none; }

img { max-width: 100%; display: block; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 100px 0;
  position: relative;
}

/* ===== Background Effects ===== */
#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 70%);
}

main, .header, .footer {
  position: relative;
  z-index: 1;
}

/* ===== Glass Effect ===== */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.glass:hover {
  border-color: var(--border-hover);
  box-shadow: 0 0 30px var(--accent-glow);
}

/* ===== Header ===== */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: var(--header-h);
  transition: background var(--transition), box-shadow var(--transition);
}

.header.scrolled {
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.25rem;
}

.logo-img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 16px var(--accent-glow);
  transition: box-shadow var(--transition), transform var(--transition);
}

.logo:hover .logo-img {
  box-shadow: 0 0 24px var(--accent-glow);
  transform: scale(1.05);
}

.footer .logo-img {
  width: 32px;
  height: 32px;
}

.logo-text .accent {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-link {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-primary);
  transition: var(--transition);
  border-radius: 2px;
}

.nav-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.btn-primary {
  background: var(--gradient);
  color: #0a0e17;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56, 189, 248, 0.05);
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ===== Section Header ===== */
.section-header {
  text-align: center;
  margin-bottom: 64px;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.section-title {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  margin: 12px 0;
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-desc {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 500px;
  margin: 0 auto;
}

/* ===== Hero ===== */
.hero {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 48px;
  padding-top: var(--header-h);
}

.hero-content {
  padding: 60px 24px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-radius: 100px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 24px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); }
  50% { opacity: 0.8; box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
}

.hero-title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
}

.greeting {
  display: block;
  font-size: 0.45em;
  font-weight: 400;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.name {
  background: var(--gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-family: var(--font-mono);
  font-size: clamp(1.1rem, 2.5vw, 1.4rem);
  color: var(--accent);
  margin-bottom: 20px;
  min-height: 1.6em;
}

.cursor-blink {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.hero-desc {
  color: var(--text-secondary);
  font-size: 1.05rem;
  max-width: 520px;
  margin-bottom: 36px;
}

.hero-actions {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 48px;
}

.hero-stats {
  display: flex;
  gap: 40px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 2.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1;
}

.stat-suffix {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  display: inline;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Code Window */
.hero-visual {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 24px;
}

.code-window {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow), 0 0 60px var(--accent-glow);
  animation: float 6s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.code-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid var(--border);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot.red { background: #ef4444; }
.dot.yellow { background: #eab308; }
.dot.green { background: #22c55e; }

.code-title {
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.code-body {
  padding: 24px;
  background: rgba(0, 0, 0, 0.3);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.8;
  overflow-x: auto;
}

.code-body .kw { color: #c084fc; }
.code-body .type { color: #38bdf8; }
.code-body .prop { color: #94a3b8; }
.code-body .str { color: #86efac; }
.code-body .num { color: #fbbf24; }
.code-body .var { color: #f472b6; }
.code-body .fn { color: #38bdf8; }

/* ===== About ===== */
.about-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 48px;
  align-items: start;
}

.about-card {
  padding: 40px 32px;
  text-align: center;
  position: sticky;
  top: calc(var(--header-h) + 24px);
}

.about-avatar {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--gradient) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin 8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.avatar-img {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 1;
  box-shadow: 0 0 24px var(--accent-glow);
}

.about-card h3 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.about-role {
  color: var(--accent);
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.about-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.about-tags span {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.8rem;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding-left: 24px;
  border-left: 2px solid var(--border);
}

.timeline-item {
  position: relative;
  padding-left: 24px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -31px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.timeline-year {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
}

.timeline-item h4 {
  font-size: 1.15rem;
  margin: 4px 0 8px;
}

.timeline-item p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.about-note {
  margin-top: 32px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: rgba(56, 189, 248, 0.05);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ===== Skills ===== */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.skill-category {
  padding: 32px 28px;
}

.skill-category:hover {
  transform: translateY(-4px);
}

.skill-icon {
  font-size: 2rem;
  margin-bottom: 16px;
}

.skill-category h3 {
  font-size: 1.15rem;
  margin-bottom: 16px;
}

.skill-category ul {
  margin-bottom: 20px;
}

.skill-category li {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.skill-category li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.75rem;
}

.skill-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.skill-fill {
  height: 100%;
  width: 0;
  background: var(--gradient);
  border-radius: 4px;
  transition: width 1.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.skill-fill.animated {
  width: var(--w);
}

/* ===== Projects ===== */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 28px;
}

.project-card {
  overflow: hidden;
}

.project-card:hover {
  transform: translateY(-6px);
}

.project-img {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    hsla(var(--hue, 200), 70%, 50%, 0.15),
    hsla(var(--hue, 200), 70%, 30%, 0.05)
  );
  border-bottom: 1px solid var(--border);
}

.project-icon {
  font-size: 3.5rem;
  filter: drop-shadow(0 0 20px hsla(var(--hue, 200), 70%, 50%, 0.4));
}

.project-body {
  padding: 24px 28px 28px;
}

.project-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.project-tags span {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 100px;
  background: rgba(56, 189, 248, 0.1);
  color: var(--accent);
  font-family: var(--font-mono);
}

.project-body h3 {
  font-size: 1.15rem;
  margin-bottom: 10px;
}

.project-body p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.project-link {
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  transition: gap var(--transition);
}

.project-link:hover {
  text-decoration: underline;
}

/* ===== Blog ===== */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 24px;
}

.blog-card {
  padding: 28px 32px;
}

.blog-card:hover {
  transform: translateY(-4px);
}

.blog-card time {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.blog-card h3 {
  font-size: 1.1rem;
  margin: 12px 0;
  line-height: 1.5;
}

.blog-card h3 a {
  transition: color var(--transition);
}

.blog-card h3 a:hover {
  color: var(--accent);
}

.blog-card > p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.blog-meta {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.blog-meta span:first-child {
  color: var(--accent);
  font-family: var(--font-mono);
}

/* ===== Contact ===== */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

.contact-info {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
}

.contact-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.contact-item h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.contact-item p {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.contact-form {
  padding: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: border-color var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

/* ===== Footer ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 48px 0 32px;
  margin-top: 40px;
}

.footer-content {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 32px;
  align-items: start;
}

.footer-brand p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-legal {
  text-align: right;
}

.footer-legal p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.icp a {
  color: var(--text-secondary);
  transition: color var(--transition);
}

.icp a:hover {
  color: var(--accent);
}

.site-purpose {
  font-size: 0.8rem !important;
  color: var(--text-muted) !important;
}

/* ===== Back to Top ===== */
.back-to-top {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all var(--transition);
  z-index: 999;
  backdrop-filter: blur(12px);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* ===== Scroll Animations ===== */
.fade-in {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 14px 28px;
  background: rgba(17, 24, 39, 0.95);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 0.9rem;
  z-index: 10000;
  backdrop-filter: blur(16px);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    min-height: auto;
    padding-bottom: 60px;
  }

  .hero-desc {
    margin-left: auto;
    margin-right: auto;
  }

  .hero-actions {
    justify-content: center;
  }

  .hero-stats {
    justify-content: center;
  }

  .hero-visual {
    order: -1;
    padding-top: 100px;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .about-card {
    position: static;
  }

  .contact-grid {
    grid-template-columns: 1fr;
  }

  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }

  .footer-legal {
    text-align: center;
  }
}

@media (max-width: 768px) {
  .nav-links {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: rgba(10, 14, 23, 0.95);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: 24px;
    gap: 4px;
    transform: translateY(-120%);
    opacity: 0;
    transition: transform var(--transition), opacity var(--transition);
    border-bottom: 1px solid var(--border);
  }

  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
  }

  .nav-link {
    padding: 12px 16px;
    font-size: 1rem;
  }

  .nav-toggle {
    display: flex;
  }

  .section {
    padding: 72px 0;
  }

  .projects-grid,
  .blog-grid {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    gap: 24px;
  }

  .stat-num {
    font-size: 2rem;
  }
}
