/* ============================================
   PORTFOLIO - Design System & Styles
   Palette: Void Space (dark) + Cloud Canvas (light)
   ============================================ */

/* --- Dark theme tokens (default) --- */
:root,
[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-hover: #1c2129;
  --primary: #58a6ff;
  --secondary: #79c0ff;
  --accent: #f78166;
  --text: #c9d1d9;
  --text-bright: #e6edf3;
  --muted: #8b949e;
  --border: #30363d;
  --radius: 6px;
  --transition: 150ms ease;
  --max-width: 1000px;
  --nav-height: 48px;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* --- Light theme tokens --- */
[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --surface-hover: #eef1f5;
  --primary: #0969da;
  --secondary: #0550ae;
  --accent: #cf222e;
  --text: #1f2328;
  --text-bright: #1f2328;
  --muted: #656d76;
  --border: #d0d7de;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 24px);
}

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.3s ease, color 0.3s ease;
}

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

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

ul,
ol {
  list-style: none;
}

/* --- Nav --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  transition: background-color 0.3s ease;
}

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

.nav-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
  letter-spacing: -0.3px;
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-links a {
  font-size: 13px;
  color: var(--muted);
  transition: color var(--transition);
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}

.nav-links a:hover {
  color: var(--text-bright);
}

.nav-links a.active {
  color: var(--text-bright);
  border-bottom-color: var(--primary);
}

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

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
}

.nav-toggle svg {
  width: 20px;
  height: 20px;
}

/* --- Theme toggle --- */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), border-color var(--transition);
}

.theme-toggle:hover {
  color: var(--text-bright);
  border-color: var(--muted);
}

.theme-toggle svg {
  width: 16px;
  height: 16px;
}

/* Show sun in dark mode, moon in light mode */
[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;
}

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

/* --- Sections --- */
section {
  padding: 64px 0;
  border-bottom: 1px solid var(--border);
}

section:last-of-type {
  border-bottom: none;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 32px;
  letter-spacing: 0.5px;
}

/* --- Fade-in on scroll --- */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- About --- */
.about {
  padding-top: calc(var(--nav-height) + 64px);
}

.about-name {
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.about-title {
  font-size: 16px;
  color: var(--primary);
  margin-bottom: 6px;
}

.about-tagline {
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 16px;
}

.about-desc {
  max-width: 640px;
  color: var(--text);
  margin-bottom: 12px;
}

.about-learning {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}

.about-learning strong {
  color: var(--text);
  font-weight: 500;
}

.about-links {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.about-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  transition: color var(--transition);
}

.about-links a:hover {
  color: var(--text-bright);
}

.about-links svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Experience --- */
.exp-list {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.exp-item {
  position: relative;
  padding-left: 20px;
  border-left: 2px solid var(--border);
}

.exp-item::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
}

.exp-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.exp-role {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
}

.exp-date {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.exp-company {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
}

.exp-bullets {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.exp-bullets li {
  font-size: 14px;
  color: var(--text);
  padding-left: 14px;
  position: relative;
}

.exp-bullets li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--muted);
}

/* --- Skills --- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.skill-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color var(--transition), background-color 0.3s ease;
}

.skill-card:hover {
  border-color: var(--muted);
}

.skill-card-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 8px;
}

.skill-card-items {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* --- Projects --- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), background-color 0.3s ease;
}

.project-card:hover {
  border-color: var(--muted);
}

.project-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.project-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
}

.project-card-link {
  color: var(--muted);
  transition: color var(--transition);
  flex-shrink: 0;
}

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

.project-card-link svg {
  width: 16px;
  height: 16px;
}

.project-card-desc {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 16px;
  flex: 1;
}

.project-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  transition: background-color 0.3s ease;
}

/* --- Education --- */
.edu-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.edu-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}

.edu-degree {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-bright);
}

.edu-year {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

.edu-detail {
  width: 100%;
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* --- Footer / Contact --- */
.footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  transition: background-color 0.3s ease;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-links {
  display: flex;
  gap: 20px;
  align-items: center;
}

.footer-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  transition: color var(--transition);
}

.footer-links a:hover {
  color: var(--text-bright);
}

.footer-links svg {
  width: 16px;
  height: 16px;
}

.footer-copy {
  font-size: 12px;
  color: var(--muted);
}

/* --- Back to top --- */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 36px;
  height: 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition), color var(--transition), border-color var(--transition);
  z-index: 50;
}

.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.back-to-top:hover {
  color: var(--text-bright);
  border-color: var(--muted);
}

.back-to-top svg {
  width: 16px;
  height: 16px;
}

/* --- Resume Preview Modal --- */
.resume-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.resume-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.resume-modal-content {
  position: relative;
  width: 90%;
  max-width: 900px;
  height: 85vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

.resume-modal-content embed {
  width: 100%;
  height: 100%;
  border: none;
}

.resume-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 210;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: color var(--transition), border-color var(--transition);
}

.resume-modal-close:hover {
  color: var(--text-bright);
  border-color: var(--muted);
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 12px 24px;
    gap: 12px;
  }

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

  .nav-links a {
    border-bottom: none;
    padding-bottom: 0;
  }

  .nav-links a.active {
    border-bottom: none;
  }

  .nav-toggle {
    display: block;
  }

  section {
    padding: 40px 0;
  }

  .about {
    padding-top: calc(var(--nav-height) + 40px);
  }

  .about-name {
    font-size: 24px;
  }

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

  .exp-header {
    flex-direction: column;
    gap: 2px;
  }

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

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

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --- Resume Preview Button (matches about-links a) --- */
.resume-preview-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-family: inherit;
  color: var(--muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 12px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.resume-preview-btn:hover {
  color: var(--text-bright);
  border-color: var(--muted);
}

.resume-preview-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* --- Print stylesheet --- */
@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 12px;
    line-height: 1.4;
  }

  .nav,
  .back-to-top,
  .theme-toggle,
  .nav-toggle,
  .resume-modal,
  .resume-preview-btn {
    display: none !important;
  }

  .container {
    max-width: 100%;
    padding: 0;
  }

  .about {
    padding-top: 0;
  }

  section {
    padding: 16px 0;
    border-bottom: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .skill-card,
  .project-card {
    background: transparent;
    border: 1px solid #ccc;
  }

  .project-tag {
    background: transparent;
    border: 1px solid #ccc;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  .about-links a::after {
    content: " (" attr(href) ")";
    font-size: 10px;
    color: #666;
  }

  .footer {
    padding: 8px 0;
  }

  .fade-in {
    opacity: 1 !important;
    transform: none !important;
  }
}