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

:root {
  --bg: #0b0b0c;
  --bg-2: #232327;
  --surface: #131314;
  --border: #232325;
  --text: #e8e8e8;
  --text-dim: #9a9a9d;
  --text-faint: #656567;
  --accent: #5b8cff;
  --accent-2: #86868b;
  --grad-start: #ffffff;
  --grad-end: #7a7a7f;
  --radius: 8px;
  --max-width: 800px;
  font-size: 16px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fbfbfa;
  --bg-2: #dedcd8;
  --surface: #f2f2f1;
  --border: #e3e3e1;
  --text: #17171a;
  --text-dim: #55555a;
  --text-faint: #8a8a8d;
  --accent: #3b63e0;
  --accent-2: #86868b;
  --grad-start: #101012;
  --grad-end: #8a8a8f;
  color-scheme: light;
}

html {
  scroll-behavior: smooth;
}

body {
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="light"] body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}

/* ---------- Theme switch fade ---------- */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.5s;
  animation-timing-function: ease;
}

h1, h2, h3 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: inherit;
  text-decoration: none;
}

img { max-width: 100%; display: block; }

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.nav.scrolled {
  border-bottom-color: var(--border);
}

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

.logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 1.05rem;
}

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

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

.nav-link {
  position: relative;
  font-size: 0.9rem;
  color: var(--text-dim);
  transition: color 0.2s ease;
}

.nav-link::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -6px;
  width: 100%;
  height: 1px;
  background: var(--text);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

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

.nav-link:hover::after {
  transform: scaleX(1);
}

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

.nav-link.active::after {
  background: var(--accent);
  transform: scaleX(1);
}

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

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: color 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
}

.lang-switch {
  position: relative;
}

.lang-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 9px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.lang-toggle:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.lang-switch.open .lang-toggle {
  color: var(--accent);
  border-color: var(--accent);
}

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 140px;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 50;
}

.lang-switch.open .lang-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.lang-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 5px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.lang-option:hover {
  background: var(--surface);
  color: var(--text);
}

.lang-option.active {
  color: var(--accent);
  font-weight: 500;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

.theme-toggle .icon-moon { display: none; }

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

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
}

.hamburger span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text);
  margin: 0 auto;
  transition: all 0.2s ease;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 22px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
}

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

.btn-primary:hover {
  opacity: 0.88;
}

.btn-ghost {
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Hero ---------- */
.hero {
  padding-top: 100px;
  padding-bottom: 80px;
}

.hero-inner {
  padding-top: 20px;
}

.hero-inner > .reveal:nth-child(1) { transition-delay: 0s; }
.hero-inner > .reveal:nth-child(2) { transition-delay: 0.06s; }
.hero-inner > .reveal:nth-child(3) { transition-delay: 0.12s; }
.hero-inner > .reveal:nth-child(4) { transition-delay: 0.18s; }
.hero-inner > .reveal:nth-child(5) { transition-delay: 0.24s; }
.hero-inner > .reveal:nth-child(6) { transition-delay: 0.3s; }

.eyebrow {
  color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.hero-title {
  font-size: clamp(2.2rem, 6vw, 3rem);
  line-height: 1.1;
  margin-bottom: 8px;
  background: linear-gradient(160deg, var(--grad-start) 15%, var(--grad-end) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--accent);
  font-weight: 500;
  margin-bottom: 22px;
}

.hero-text {
  max-width: 600px;
  color: var(--text-dim);
  font-size: 1rem;
  margin-bottom: 30px;
}

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

.hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

/* GitHub card */
.github-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 620px;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.github-card:hover {
  border-color: var(--text-dim);
  transform: translateY(-3px);
}

.github-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.gh-stat-inline {
  margin-left: auto;
  color: var(--text-faint);
}

.gh-graph {
  --crop-ratio: 0.47;
  --crop-width-ratio: 0.53;
  overflow: hidden;
  border-radius: 6px;
  aspect-ratio: calc(663 * var(--crop-width-ratio)) / 104;
}

.gh-graph img {
  width: calc(100% / var(--crop-width-ratio));
  max-width: none;
  transform: translateX(calc(-1 * var(--crop-ratio) * 100%));
  filter: invert(0.92) hue-rotate(180deg) brightness(0.95) contrast(0.9);
}

:root[data-theme="light"] .gh-graph img {
  filter: none;
}

.scroll-cue {
  display: none;
}

/* ---------- Sections ---------- */
.section {
  padding: 80px 0;
  border-top: 1px solid var(--border);
}

.section-tag {
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.section-title {
  font-size: clamp(1.5rem, 3.5vw, 1.9rem);
  margin-bottom: 44px;
}

/* ---------- Timeline (Education) ---------- */
.timeline {
  position: relative;
  padding-left: 28px;
  border-left: 1px solid var(--border);
}

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

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

.timeline-dot {
  position: absolute;
  left: -33px;
  top: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--accent);
}

.timeline-dot.dot-accent-2 {
  border-color: var(--accent-2);
}

.timeline-date {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-faint);
  margin-bottom: 8px;
}

.timeline-content h3 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.timeline-role {
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 10px;
  font-size: 0.92rem;
}

.timeline-content p:not(.timeline-role) {
  color: var(--text-dim);
  max-width: 600px;
  font-size: 0.95rem;
}

/* ---------- Project card ---------- */
.project-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.project-card:hover {
  border-color: var(--text-dim);
  transform: translateY(-3px);
}

.project-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.project-title {
  font-size: 1.2rem;
}

.project-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 2px;
}

.project-link {
  margin-left: auto;
  color: var(--text-dim);
  transition: color 0.15s ease;
}

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

.project-desc {
  color: var(--text-dim);
  margin-bottom: 14px;
  font-size: 0.95rem;
}

.project-desc strong {
  color: var(--text);
  font-weight: 600;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 22px;
}

.tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.tag.tag-accent {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent);
}

.tag.tag-accent-2 {
  border-color: color-mix(in srgb, var(--accent-2) 45%, var(--border));
  color: var(--accent-2);
}

.tag {
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.tag:hover {
  border-color: var(--text-dim);
  transform: translateY(-2px);
}

.project-footer {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-faint);
  font-size: 0.85rem;
}

.stat svg { color: var(--accent-2); }

.more-projects {
  margin-top: 20px;
  color: var(--text-faint);
  font-size: 0.9rem;
}

.more-projects a {
  color: var(--accent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ---------- Certifications ---------- */
.cert-card {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  align-items: start;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.cert-card:hover {
  border-color: var(--text-dim);
  transform: translateY(-3px);
}

.cert-preview img {
  transition: transform 0.4s ease;
}

.cert-card:hover .cert-preview img {
  transform: scale(1.04);
}

.cert-preview {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1.4 / 1;
  background: var(--surface);
}

.cert-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cert-preview-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.15s ease;
  font-size: 0.85rem;
  font-weight: 500;
}

.cert-preview:hover .cert-preview-overlay { opacity: 1; }

.cert-info h3 {
  font-size: 1.15rem;
  margin-bottom: 4px;
}

.cert-meta {
  color: var(--accent-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  margin-bottom: 14px;
}

.cert-info p:not(.cert-meta) {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.cert-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Contact ---------- */
.contact-text {
  color: var(--text-dim);
  max-width: 480px;
  margin-bottom: 32px;
}

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

.contact-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 0.92rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.contact-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-3px);
}

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px 0;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-faint);
  font-size: 0.82rem;
}

.back-to-top {
  color: var(--text-dim);
  transition: color 0.15s ease;
}

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

/* ---------- Scroll reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .nav-links {
    position: fixed;
    top: 65px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg);
    padding: 20px 24px;
    gap: 18px;
    border-bottom: 1px solid var(--border);
    transform: translateY(-120%);
    opacity: 0;
    transition: all 0.2s ease;
    pointer-events: none;
  }

  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .hamburger { display: flex; }

  .hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
  .hamburger.open span:nth-child(2) { opacity: 0; }
  .hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

  .cert-card {
    grid-template-columns: 1fr;
  }

  .cert-preview {
    aspect-ratio: 16 / 9;
  }

  .gh-stat-inline {
    margin-left: 0;
  }

  .section { padding: 60px 0; }
  .hero { padding-top: 80px; padding-bottom: 50px; }
}

@media (max-width: 480px) {
  .icon-btn { display: none; }
}
