/* ============================================================
   RESET & TOKENS
============================================================ */

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

/* ============================================================
   THEME TOKENS
============================================================ */

:root {
  --bg: #ffffff;
  --bg-alt: #f5f5f5;

  --text: #111111;
  --text-muted: #555555;

  --border: #e0e0e0;

  --accent: #111111;

  --radius: 8px;

  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  --max-w: 860px;

  color-scheme: light;
}

/* ============================================================
   SYSTEM DARK MODE
   Default behavior when user has not selected a theme
============================================================ */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111;
    --bg-alt: #1a1a1a;

    --text: #f5f5f5;
    --text-muted: #a0a0a0;

    --border: #2d2d2d;

    --accent: #f5f5f5;

    color-scheme: dark;
  }
}

/* ============================================================
   EXPLICIT LIGHT MODE
============================================================ */

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-alt: #f5f5f5;

  --text: #111111;
  --text-muted: #555555;

  --border: #e0e0e0;

  --accent: #111111;

  color-scheme: light;
}

/* ============================================================
   EXPLICIT DARK MODE
============================================================ */

html[data-theme="dark"] {
  --bg: #111111;
  --bg-alt: #1a1a1a;

  --text: #f5f5f5;
  --text-muted: #a0a0a0;

  --border: #2d2d2d;

  --accent: #f5f5f5;

  color-scheme: dark;
}

/* ============================================================
   HTML / BODY
============================================================ */

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);

  background: var(--bg);
  color: var(--text);

  line-height: 1.6;

  -webkit-font-smoothing: antialiased;

  transition:
    background-color 0.25s ease,
    color 0.25s ease;
}

::selection {
  background: var(--text);
  color: var(--bg);
}

/* ============================================================
   NAVIGATION
============================================================ */

.nav {
  position: fixed;

  top: 0;
  left: 0;
  right: 0;

  background: color-mix(in srgb, var(--bg) 85%, transparent);

  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  border-bottom: 1px solid var(--border);

  z-index: 100;

  transition:
    background-color 0.25s ease,
    border-color 0.25s ease;
}

.nav-inner {
  max-width: var(--max-w);

  margin: 0 auto;

  padding: 0 24px;

  height: 60px;

  display: flex;

  align-items: center;

  justify-content: space-between;

  position: relative;
}

/* Logo */

.nav-logo {
  font-family: var(--font-mono);

  font-weight: 700;

  font-size: 1.1rem;

  color: var(--text);

  text-decoration: none;

  letter-spacing: -0.5px;

  transition: color 0.2s ease;
}

.nav-logo .dot {
  color: var(--text-muted);
}

/* Navigation Links */

.nav-links {
  display: flex;

  gap: 8px;

  list-style: none;
}

.nav-link {
  font-size: 0.85rem;

  font-weight: 500;

  color: var(--text-muted);

  text-decoration: none;

  padding: 6px 14px;

  border-radius: 20px;

  transition:
    color 0.2s,
    background 0.2s;
}

.nav-link:hover {
  color: var(--text);

  background: var(--bg-alt);
}

.nav-link.active {
  color: var(--bg);

  background: var(--text);
}

/* ============================================================
   NAV ACTIONS
============================================================ */

.nav-actions {
  display: flex;

  align-items: center;

  gap: 8px;
}

/* ============================================================
   THEME TOGGLE
============================================================ */

.theme-toggle {
  width: 36px;
  height: 36px;

  display: inline-flex;

  align-items: center;
  justify-content: center;

  border: 1px solid var(--border);

  border-radius: 50%;

  background: var(--bg);

  color: var(--text);

  cursor: pointer;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.theme-toggle:hover {
  background: var(--bg-alt);

  border-color: var(--text);

  transform: rotate(8deg);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--text);

  outline-offset: 3px;
}

/* Theme icons */

.theme-icon {
  display: none;
}

/*
   Default/light:
   show moon because clicking it will switch to dark.
*/

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

/*
   Explicit dark:
   show sun because clicking it will switch to light.
*/

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

/*
   System theme.

   When there is no explicit data-theme,
   use the system preference.
*/

html:not([data-theme]) .theme-icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) .theme-icon-moon {
    display: none;
  }

  html:not([data-theme]) .theme-icon-sun {
    display: block;
  }
}

/* ============================================================
   MOBILE MENU TOGGLE
============================================================ */

.nav-toggle {
  display: none;

  flex-direction: column;

  gap: 5px;

  background: none;

  border: none;

  cursor: pointer;

  padding: 4px;
}

.nav-toggle span {
  display: block;

  width: 22px;

  height: 2px;

  background: var(--text);

  transition:
    transform 0.25s,
    opacity 0.25s,
    background-color 0.25s;
}

.nav-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ============================================================
   LAYOUT
============================================================ */

main {
  max-width: var(--max-w);

  margin: 0 auto;

  padding: 0 24px;
}

section {
  scroll-margin-top: 80px;
}

/* ============================================================
   HERO
============================================================ */

.hero {
  padding: 140px 0 80px;
}

.hero-label {
  font-family: var(--font-mono);

  font-size: 0.8rem;

  color: var(--text-muted);

  margin-bottom: 16px;
}

.hero-name {
  font-size: clamp(2.4rem, 6vw, 3.6rem);

  font-weight: 700;

  letter-spacing: -2px;

  line-height: 1.1;

  margin-bottom: 8px;
}

.hero-role {
  font-family: var(--font-mono);

  font-size: 1rem;

  color: var(--text-muted);

  margin-bottom: 24px;
}

.hero-desc {
  font-size: 1.05rem;

  color: var(--text-muted);

  max-width: 560px;

  margin-bottom: 36px;
}

/* ============================================================
   HERO CONTACT
============================================================ */

.hero-contact {
  margin-top: 8px;
}

.contact-list {
  list-style: none;

  display: flex;

  align-items: center;

  gap: 12px;
}

.contact-item {
  display: flex;

  align-items: center;
  justify-content: center;

  width: 42px;
  height: 42px;

  text-decoration: none;

  color: var(--text);

  transition:
    transform 0.2s ease,
    color 0.2s ease;
}

.contact-item:hover {
  transform: translateY(-2px);
}

.contact-icon {
  display: flex;

  align-items: center;
  justify-content: center;

  width: 36px;
  height: 36px;

  border: 1px solid var(--border);

  border-radius: 8px;

  color: var(--text);

  flex-shrink: 0;

  transition:
    background-color 0.2s ease,
    border-color 0.2s ease;
}

.contact-item:hover .contact-icon {
  background: var(--bg-alt);

  border-color: var(--text);
}

/* ============================================================
   BUTTONS
============================================================ */

.btn {
  display: inline-block;

  font-size: 0.9rem;

  font-weight: 500;

  padding: 11px 24px;

  border-radius: var(--radius);

  text-decoration: none;

  cursor: pointer;

  transition: all 0.2s;

  border: 1px solid var(--text);
}

.btn-primary {
  background: var(--text);

  color: var(--bg);
}

.btn-primary:hover {
  background: var(--text-muted);

  border-color: var(--text-muted);
}

.btn-outline {
  background: transparent;

  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-alt);
}

/* ============================================================
   SECTIONS
============================================================ */

.section {
  padding: 60px 0;
}

.section-title {
  font-size: 1.3rem;

  font-weight: 600;

  letter-spacing: -0.5px;

  margin-bottom: 32px;

  display: flex;

  align-items: center;

  gap: 12px;
}

.section-title .num {
  font-family: var(--font-mono);

  font-size: 0.85rem;

  color: var(--text-muted);

  font-weight: 400;
}

/* ============================================================
   TIMELINE
============================================================ */

.timeline {
  position: relative;

  padding-left: 28px;
}

.timeline::before {
  content: "";

  position: absolute;

  left: 5px;

  top: 6px;

  bottom: 6px;

  width: 1px;

  background: var(--border);
}

.timeline-item {
  position: relative;

  padding-bottom: 40px;
}

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

.timeline-item::before {
  content: "";

  position: absolute;

  left: -28px;

  top: 7px;

  width: 11px;

  height: 11px;

  border-radius: 50%;

  background: var(--bg);

  border: 2px solid var(--text);
}

.timeline-date {
  font-family: var(--font-mono);

  font-size: 0.78rem;

  color: var(--text-muted);

  margin-bottom: 4px;
}

.timeline-content h3 {
  font-size: 1.05rem;

  font-weight: 600;

  display: inline;
}

.timeline-org {
  font-size: 0.9rem;

  color: var(--text-muted);
}

.timeline-org::before {
  content: " · ";
}

.timeline-content p {
  font-size: 0.92rem;

  color: var(--text-muted);

  margin: 8px 0 12px;
}

/* ============================================================
   TAGS
============================================================ */

.tags {
  display: flex;

  flex-wrap: wrap;

  gap: 6px;
}

.tag {
  font-family: var(--font-mono);

  font-size: 0.72rem;

  padding: 3px 10px;

  border: 1px solid var(--border);

  border-radius: 20px;

  color: var(--text-muted);

  background: var(--bg-alt);

  transition:
    background-color 0.25s ease,
    border-color 0.25s ease,
    color 0.25s ease;
}

/* ============================================================
   PROJECTS
============================================================ */

.projects-grid {
  display: grid;

  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));

  gap: 20px;
}

.project-card {
  border: 1px solid var(--border);

  border-radius: var(--radius);

  padding: 28px;

  background: var(--bg);

  transition:
    border-color 0.2s,
    transform 0.2s,
    box-shadow 0.2s,
    background-color 0.25s ease;

  display: flex;

  flex-direction: column;
}

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

  transform: translateY(-3px);

  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  .project-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  }
}

.project-top {
  display: flex;

  justify-content: space-between;

  align-items: center;

  margin-bottom: 20px;
}

.project-num {
  font-family: var(--font-mono);

  font-size: 0.8rem;

  color: var(--text-muted);
}

.project-links {
  display: flex;

  gap: 12px;
}

.project-links a {
  color: var(--text-muted);

  transition:
    color 0.2s,
    transform 0.2s;
}

.project-links a:hover {
  color: var(--text);

  transform: translateY(-1px);
}

.project-name {
  font-size: 1.15rem;

  font-weight: 600;

  letter-spacing: -0.3px;

  margin-bottom: 10px;
}

.project-desc {
  font-size: 0.9rem;

  color: var(--text-muted);

  margin-bottom: 20px;

  flex: 1;
}

/* ============================================================
   TECH STACK
============================================================ */

.stack-group-title {
  font-family: var(--font-mono);

  font-size: 0.8rem;

  font-weight: 500;

  color: var(--text-muted);

  text-transform: uppercase;

  letter-spacing: 1px;

  margin: 32px 0 16px;
}

.stack-grid {
  display: grid;

  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));

  gap: 14px;
}

.stack-card {
  border: 1px solid var(--border);

  border-radius: var(--radius);

  padding: 22px 18px;

  text-align: center;

  background: var(--bg);

  transition:
    border-color 0.2s,
    transform 0.2s,
    background-color 0.25s ease;
}

.stack-card:hover {
  border-color: var(--text);

  transform: translateY(-3px);
}

.stack-icon {
  display: inline-flex;

  align-items: center;
  justify-content: center;

  width: 48px;

  height: 48px;

  margin-bottom: 12px;
}

.stack-icon img {
  width: 40px;

  height: 40px;

  object-fit: contain;
}

.stack-card h4 {
  font-size: 0.85rem;

  font-weight: 600;
}

/*
   SVG stack icons should automatically follow
   the current text color.
*/

.stack-icon svg {
  color: var(--text);
}

/* ============================================================
   FOOTER
============================================================ */

.footer {
  border-top: 1px solid var(--border);

  margin-top: 40px;

  transition: border-color 0.25s ease;
}

.footer-inner {
  max-width: var(--max-w);

  margin: 0 auto;

  padding: 24px;

  display: flex;

  justify-content: space-between;

  align-items: center;

  flex-wrap: wrap;

  gap: 12px;

  font-size: 0.82rem;

  color: var(--text-muted);
}

.footer-note {
  font-family: var(--font-mono);

  font-size: 0.75rem;
}

/* ============================================================
   RESPONSIVE
============================================================ */

@media (max-width: 640px) {
  /* Navigation */

  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;

    position: absolute;

    top: 60px;

    left: 0;

    right: 0;

    flex-direction: column;

    background: var(--bg);

    border-bottom: 1px solid var(--border);

    padding: 12px 24px 20px;

    gap: 4px;

    transition:
      background-color 0.25s ease,
      border-color 0.25s ease;
  }

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

  .nav-link {
    display: block;

    padding: 10px 14px;
  }

  /* Hero */

  .hero {
    padding: 120px 0 60px;
  }

  /* Contact */

  .contact-label {
    display: none;
  }

  /* Footer */

  .footer-inner {
    justify-content: center;

    text-align: center;
  }

  /* Projects */

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

  /* Stack */

  .stack-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ============================================================
   ACCESSIBILITY
============================================================ */

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

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
