/* ============================================
   James Kuang — Personal Website
   Modern CSS with custom properties & themes
   ============================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 720px;
  --nav-height: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

/* --- Dark Theme (default) --- */
[data-theme="dark"] {
  --bg: #0a0a0b;
  --bg-secondary: #141416;
  --bg-card: #1a1a1f;
  --bg-card-hover: #222228;
  --border: #2a2a30;
  --text-primary: #f0f0f2;
  --text-secondary: #9a9aa8;
  --text-tertiary: #6a6a78;
  --accent: #6c9cff;
  --accent-hover: #8bb4ff;
  --accent-subtle: rgba(108, 156, 255, 0.1);
  --nav-bg: rgba(10, 10, 11, 0.85);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.4);
}

/* --- Light Theme --- */
[data-theme="light"] {
  --bg: #fafafa;
  --bg-secondary: #f0f0f2;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f5f7;
  --border: #e2e2e8;
  --text-primary: #111113;
  --text-secondary: #5a5a68;
  --text-tertiary: #8a8a98;
  --accent: #3b6fd4;
  --accent-hover: #2d5ab8;
  --accent-subtle: rgba(59, 111, 212, 0.08);
  --nav-bg: rgba(250, 250, 250, 0.85);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition), color var(--transition);
}

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

a:hover {
  color: var(--accent-hover);
}

/* --- Navigation --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  transition: background var(--transition), border-color var(--transition);
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  transition: color var(--transition);
}

.nav-logo:hover {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--accent-subtle);
}

.nav-link.active {
  color: var(--text-primary);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  margin-left: 4px;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.theme-toggle:hover {
  color: var(--text-primary);
  background: var(--accent-subtle);
  border-color: var(--accent);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* --- Main Content --- */
main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  padding-top: var(--nav-height);
}

/* --- Hero Section --- */
.hero {
  padding: 80px 0 60px;
}

.hero-greeting {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.hero-name {
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.hero-tagline {
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 480px;
  margin-bottom: 32px;
}

.hero-tagline strong {
  color: var(--text-primary);
  font-weight: 600;
}

.hero-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: var(--font-sans);
  transition: all var(--transition);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Section Titles --- */
.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.section-subtitle {
  font-size: 0.95rem;
  color: var(--text-tertiary);
  margin-bottom: 32px;
}

/* --- Projects --- */
.projects {
  padding: 40px 0 80px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.project-card {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all var(--transition);
  color: var(--text-primary);
}

.project-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  color: var(--text-primary);
}

.project-icon {
  font-size: 1.6rem;
  margin-bottom: 12px;
  line-height: 1;
}

.project-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.project-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
  margin-bottom: 16px;
}

.project-link {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  transition: color var(--transition);
}

.project-card:hover .project-link {
  color: var(--accent-hover);
}

/* --- Blog --- */
.blog-section {
  padding: 80px 0;
}

.blog-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.blog-post-preview {
  padding: 24px 0;
  border-bottom: 1px solid var(--border);
}

.blog-post-preview:first-child {
  border-top: 1px solid var(--border);
}

.blog-date {
  font-size: 0.82rem;
  color: var(--text-tertiary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.blog-post-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 6px 0 8px;
  letter-spacing: -0.01em;
}

.blog-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* --- Footer --- */
.footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  transition: border-color var(--transition);
}

.footer p {
  font-size: 0.82rem;
  color: var(--text-tertiary);
}

/* --- Animations --- */
@media (prefers-reduced-motion: no-preference) {
  .hero-greeting,
  .hero-name,
  .hero-tagline,
  .hero-links {
    animation: fadeUp 0.5s ease both;
  }

  .hero-greeting { animation-delay: 0s; }
  .hero-name { animation-delay: 0.08s; }
  .hero-tagline { animation-delay: 0.16s; }
  .hero-links { animation-delay: 0.24s; }

  .project-card {
    animation: fadeUp 0.4s ease both;
  }

  .project-card:nth-child(1) { animation-delay: 0.1s; }
  .project-card:nth-child(2) { animation-delay: 0.18s; }
  .project-card:nth-child(3) { animation-delay: 0.26s; }
  .project-card:nth-child(4) { animation-delay: 0.34s; }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .hero {
    padding: 60px 0 40px;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .hero-links {
    flex-direction: column;
  }

  .btn {
    justify-content: center;
  }
}

/* --- Selection --- */
::selection {
  background: var(--accent);
  color: #fff;
}

/* --- Focus Visible --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- Scrollbar (Webkit) --- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}
