/* =========================================
   CSS Custom Properties
   ========================================= */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  --bg-page: #fafbfc;
  --bg-card: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #5a6275;
  --text-muted: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --accent-soft-hover: #dbeafe;
  --border: #e5e7eb;
  --border-light: #f1f5f9;
  --tag-bg: #f1f5f9;
  --tag-text: #334155;
  --tag-proficient-bg: #2563eb;
  --tag-proficient-text: #ffffff;
  --tag-skilled-border: #2563eb;
  --tag-skilled-text: #2563eb;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-full: 9999px;
  --transition: 200ms ease;
  --transition-slow: 350ms ease;
  --max-width: 800px;
}

[data-theme="dark"] {
  --bg-page: #0f172a;
  --bg-card: #1e293b;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #60a5fa;
  --accent-hover: #93bbfd;
  --accent-soft: #1e3a5f;
  --accent-soft-hover: #1e4a7a;
  --border: #334155;
  --border-light: #1e293b;
  --tag-bg: #334155;
  --tag-text: #cbd5e1;
  --tag-skilled-border: #60a5fa;
  --tag-skilled-text: #60a5fa;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition-slow), color var(--transition-slow);
}

/* =========================================
   Typography
   ========================================= */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

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

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

strong {
  font-weight: 600;
}

ul {
  list-style: none;
}

/* =========================================
   Layout
   ========================================= */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

.section {
  padding: 72px 0;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 32px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.section-subtitle {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* =========================================
   Skip Link
   ========================================= */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  z-index: 1000;
  font-size: 0.875rem;
}

.skip-link:focus {
  top: 16px;
}

/* =========================================
   Header / Navigation
   ========================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-page);
  border-bottom: 1px solid transparent;
  transition: background var(--transition-slow), border-color var(--transition), box-shadow var(--transition);
}

.site-header.scrolled {
  border-bottom-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-brand {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.03em;
}

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

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

.nav-link {
  display: block;
  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,
.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.nav-toggle-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

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

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

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

/* =========================================
   Hero Section
   ========================================= */
.hero {
  padding: 80px 0 56px;
  text-align: center;
}

.hero-name {
  font-size: 3rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  margin-bottom: 8px;
}

.hero-title {
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 20px;
  font-family: var(--font-mono);
  font-size: 0.95rem;
}

.hero-contact {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.contact-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.hero-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* =========================================
   Bio Section
   ========================================= */
.bio-text {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

/* =========================================
   Timeline (Work Experience)
   ========================================= */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 40px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -37px;
  top: 10px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg-page);
  box-shadow: 0 0 0 2px var(--accent);
}

.timeline-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.timeline-content:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

.timeline-header {
  margin-bottom: 12px;
}

.timeline-date {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 8px;
}

.timeline-company {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.timeline-eng {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.timeline-role {
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 500;
  margin-top: 2px;
}

.timeline-details {
  list-style: disc;
  padding-left: 20px;
}

.timeline-details li {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  line-height: 1.6;
}

.timeline-details li:last-child {
  margin-bottom: 0;
}

/* =========================================
   Project Cards
   ========================================= */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}

.project-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.project-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.project-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 2px;
}

.project-detail {
  margin-bottom: 16px;
}

.project-detail dt {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 10px;
  margin-bottom: 2px;
}

.project-detail dt:first-child {
  margin-top: 0;
}

.project-detail dd {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-left: 0;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

/* =========================================
   Tags
   ========================================= */
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--tag-bg);
  color: var(--tag-text);
  transition: background var(--transition), color var(--transition);
}

.tag-proficient {
  background: var(--tag-proficient-bg);
  color: var(--tag-proficient-text);
}

.tag-skilled {
  background: transparent;
  color: var(--tag-skilled-text);
  border: 1.5px solid var(--tag-skilled-border);
}

/* =========================================
   Skills Grid
   ========================================= */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.skill-category {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.skill-cat-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* =========================================
   Evaluation / Education
   ========================================= */
.eval-text {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.education {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* =========================================
   Footer
   ========================================= */
.site-footer {
  padding: 32px 0;
  text-align: center;
  border-top: 1px solid var(--border);
}

.site-footer p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* =========================================
   Scroll Reveal Animation
   ========================================= */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================
   Print Styles
   ========================================= */
@media print {
  .site-header,
  .nav-toggle,
  .theme-toggle,
  .skip-link,
  .site-footer {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 13px;
    line-height: 1.5;
  }

  .section {
    padding: 24px 0;
    break-inside: avoid;
  }

  .section-title {
    font-size: 1.2rem;
    border-bottom-color: #000;
  }

  .hero {
    padding: 0 0 24px;
  }

  .hero-name {
    font-size: 2rem;
  }

  .contact-link {
    border: none;
    background: none;
    padding: 2px 8px;
    color: #000;
  }

  .timeline-content,
  .project-card,
  .skill-category {
    box-shadow: none;
    border: 1px solid #ddd;
    break-inside: avoid;
  }

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

  .tag-proficient {
    background: #000;
    color: #fff;
  }

  a {
    color: #000;
  }
}

/* =========================================
   Responsive: Tablet (640px - 1023px)
   ========================================= */
@media (max-width: 1023px) {
  .project-grid,
  .skills-grid {
    grid-template-columns: 1fr;
  }

  .hero-name {
    font-size: 2.5rem;
  }
}

/* =========================================
   Responsive: Mobile (< 640px)
   ========================================= */
@media (max-width: 639px) {
  .container {
    padding: 0 20px;
  }

  .section {
    padding: 48px 0;
  }

  .section-title {
    font-size: 1.25rem;
  }

  .hero {
    padding: 48px 0 32px;
  }

  .hero-name {
    font-size: 2rem;
  }

  .hero-contact {
    flex-direction: column;
    gap: 6px;
  }

  .contact-link {
    width: 100%;
    justify-content: center;
  }

  /* Mobile navigation */
  .nav-toggle {
    display: flex;
    z-index: 101;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px 20px;
    box-shadow: var(--shadow-md);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-link {
    width: 100%;
    padding: 10px 14px;
    font-size: 1rem;
  }

  .timeline {
    padding-left: 24px;
  }

  .timeline-marker {
    left: -29px;
  }

  .timeline-content {
    padding: 16px;
  }

  .bio-text,
  .eval-text {
    font-size: 0.95rem;
  }

  .skills-grid {
    gap: 16px;
  }
}

/* =========================================
   Accessibility
   ========================================= */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }
}

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