:root {
  --bg: #0f1117;
  --bg-elevated: #171a23;
  --text: #e8e9ee;
  --text-muted: #9a9fae;
  --accent: #6c8cff;
  --accent-hover: #8aa4ff;
  --accent-2: #22d3c7;
  --border: #262a37;
  --radius: 10px;
  --max-width: 960px;
  --gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Type scale (1.25 ratio) */
  --fs-xs: 0.8rem;
  --fs-sm: 0.9rem;
  --fs-base: 1rem;
  --fs-md: 1.1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.6rem;
  --fs-2xl: 2rem;
  --fs-hero: clamp(2.2rem, 5vw, 3.2rem);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --bg-elevated: #f5f6f8;
    --text: #1a1d24;
    --text-muted: #5b6070;
    --accent: #3b5bdb;
    --accent-hover: #2f4bc7;
    --accent-2: #0d9488;
    --border: #e3e5eb;
  }
}

/* Manual theme override (takes precedence over system preference) */
html[data-theme="dark"] {
  --bg: #0f1117;
  --bg-elevated: #171a23;
  --text: #e8e9ee;
  --text-muted: #9a9fae;
  --accent: #6c8cff;
  --accent-hover: #8aa4ff;
  --accent-2: #22d3c7;
  --border: #262a37;
}

html[data-theme="light"] {
  --bg: #ffffff;
  --bg-elevated: #f5f6f8;
  --text: #1a1d24;
  --text-muted: #5b6070;
  --accent: #3b5bdb;
  --accent-hover: #2f4bc7;
  --accent-2: #0d9488;
  --border: #e3e5eb;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

main > section {
  scroll-margin-top: 100px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.6;
  background-color: var(--bg);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--gradient);
  z-index: 200;
  transition: width 0.1s linear;
}

/* Header / Nav */
.site-header {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--text);
  text-decoration: none;
}

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin: 0;
  padding: 0;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--fs-sm);
  transition: color 0.15s ease;
}

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

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

.nav-pill-group {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.15rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem;
}

.nav-pill-group a {
  position: relative;
  z-index: 2;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
}

.nav-pill-highlight {
  position: absolute;
  top: 0.3rem;
  bottom: 0.3rem;
  left: 0.3rem;
  width: 0;
  border-radius: 999px;
  background: var(--gradient);
  opacity: 0.16;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  transition: left 0.3s cubic-bezier(0.65, 0, 0.35, 1), width 0.3s cubic-bezier(0.65, 0, 0.35, 1);
  z-index: 1;
  pointer-events: none;
}

.btn-small {
  color: var(--bg) !important;
  background: var(--accent);
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
}

.btn-small:hover { background: var(--accent-hover); }

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

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

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

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

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

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

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

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

.nav-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text);
  display: block;
}

/* Hero */
.hero {
  padding: 6rem 1.5rem 4rem;
  text-align: center;
}

/* Humanoid robot illustration */
.hero-robot {
  display: flex;
  justify-content: center;
  margin: 0 auto 1rem;
  width: 140px;
  cursor: pointer;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--accent) 35%, transparent));
  opacity: 0;
  animation: robotPatrol 7s ease-in-out infinite, heroFadeIn 0.6s ease-out forwards;
}

.hero-robot svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.robot-limb,
.robot-torso,
.robot-undercarriage {
  fill: color-mix(in srgb, var(--text-muted) 35%, var(--bg-elevated));
  stroke: var(--accent);
  stroke-width: 1.5;
}

.robot-head-shape {
  fill: color-mix(in srgb, var(--text-muted) 20%, var(--bg-elevated));
  stroke: var(--accent);
  stroke-width: 1.5;
}

.robot-hand,
.robot-wheel {
  fill: color-mix(in srgb, var(--text-muted) 45%, var(--bg-elevated));
  stroke: var(--accent);
  stroke-width: 1.2;
}

.robot-wheel-spoke {
  stroke: var(--accent);
  stroke-width: 1.2;
  stroke-linecap: round;
}

.robot-shadow {
  fill: color-mix(in srgb, var(--text) 12%, transparent);
}

.robot-neck {
  fill: color-mix(in srgb, var(--text-muted) 45%, var(--bg-elevated));
}

.robot-visor {
  fill: color-mix(in srgb, var(--text) 75%, var(--bg));
  stroke: var(--accent);
  stroke-width: 1.5;
}

.robot-chest-light,
.robot-antenna-tip {
  fill: var(--accent);
  animation: robotPulse 2.4s ease-in-out infinite;
}

.robot-antenna {
  stroke: var(--accent);
  stroke-width: 2;
}

.robot-pupil {
  fill: var(--accent-hover);
}

.robot-body {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: robotBob 3s ease-in-out infinite;
}

.robot-arm-left {
  transform-box: fill-box;
  transform-origin: 50% 0%;
  animation: robotArmSwayL 4s ease-in-out infinite;
}

.robot-arm-right {
  transform-box: fill-box;
  transform-origin: 50% 0%;
  animation: robotArmSwayR 4.5s ease-in-out infinite;
}

.robot-eye-l,
.robot-eye-r {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: robotBlink 6s ease-in-out infinite;
}

.robot-wheel-l,
.robot-wheel-r {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: robotWheelSpin 1.4s linear infinite;
}

@keyframes robotPatrol {
  0%, 100% { transform: translateX(-56px); }
  50% { transform: translateX(56px); }
}

@keyframes robotBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes robotArmSwayL {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(4deg); }
}

@keyframes robotArmSwayR {
  0%, 100% { transform: rotate(4deg); }
  50% { transform: rotate(-4deg); }
}

@keyframes robotBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

@keyframes robotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes robotWheelSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hero-robot.is-waving .robot-arm-right {
  animation: robotWave 0.9s ease-in-out;
}

@keyframes robotWave {
  0% { transform: rotate(4deg); }
  20% { transform: rotate(-120deg); }
  35% { transform: rotate(-95deg); }
  50% { transform: rotate(-130deg); }
  65% { transform: rotate(-95deg); }
  80% { transform: rotate(-120deg); }
  100% { transform: rotate(4deg); }
}

@media (max-width: 480px) {
  .hero-robot {
    width: 100px;
    animation: robotPatrolSmall 7s ease-in-out infinite, heroFadeIn 0.6s ease-out forwards;
  }
}

@keyframes robotPatrolSmall {
  0%, 100% { transform: translateX(-28px); }
  50% { transform: translateX(28px); }
}

.eyebrow {
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--fs-xs);
  margin-bottom: 0.5rem;
  opacity: 0;
  animation: heroFadeUp 0.6s ease-out 0.1s forwards;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  margin: 0 0 1rem;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
  animation: heroFadeUp 0.6s ease-out 0.2s forwards;
}

.hero-tagline {
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 2rem;
  font-size: var(--fs-md);
  opacity: 0;
  animation: heroFadeUp 0.6s ease-out 0.3s forwards;
}

.accent-word {
  font-family: "Playfair Display", Georgia, "Times New Roman", serif;
  font-style: italic;
  color: var(--text);
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  opacity: 0;
  animation: heroFadeUp 0.6s ease-out 0.4s forwards;
}

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

@keyframes heroFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Intro / brand section */
.intro-section {
  padding: 3rem 1.5rem 5rem;
}

.intro-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
  margin-bottom: 2.5rem;
}

.intro-meta a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.intro-meta a:hover {
  text-decoration: underline;
}

.intro-wordmark-wrap {
  position: relative;
  display: inline-block;
  margin-bottom: 0;
}

.intro-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.2rem, 14vw, 9.5rem);
  line-height: 0.9;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: -0.01em;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  user-select: none;
}

.intro-badge {
  position: absolute;
  top: 50%;
  left: 93%;
  width: 150px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem 0.8rem;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  transform-origin: top center;
  transform: translate(0%, -15%) rotate(-4deg);
  animation: badgeSwing 4.5s ease-in-out infinite;
}

.intro-badge::before {
  content: "";
  position: absolute;
  top: -17px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 12px;
  border: 3px solid var(--text-muted);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: var(--bg-elevated);
}

.intro-badge::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(
    115deg,
    transparent 25%,
    color-mix(in srgb, white 22%, transparent) 42%,
    transparent 58%
  );
  pointer-events: none;
}

.intro-badge span {
  position: relative;
  z-index: 1;
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.3;
}

@keyframes badgeSwing {
  0%, 100% { transform: translate(0%, -15%) rotate(-4deg); }
  50% { transform: translate(0%, -15%) rotate(3deg); }
}

.intro-bio {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.25rem, 2.8vw, 1.9rem);
  line-height: 1.4;
  color: var(--text-muted);
  max-width: 900px;
  margin: 0;
}

.intro-bio .hl {
  color: transparent;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
}

.intro-bio strong {
  color: var(--text);
  font-weight: 700;
}

.intro-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

@media (max-width: 480px) {
  .intro-badge {
    width: 110px;
    padding: 0.85rem 0.6rem;
  }

  .intro-meta {
    flex-direction: column;
    align-items: flex-start;
  }
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary:hover { filter: brightness(1.08); }

.btn-outline {
  border: 1px solid var(--border);
  color: var(--text);
}

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

/* Sections */
.section {
  position: relative;
  padding: 3.5rem 1.5rem;
}

.section::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border) 20%, var(--border) 80%, transparent);
}

.section h2 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  margin-bottom: 1.25rem;
}

.section-note {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-top: -0.5rem;
  margin-bottom: 1.5rem;
}

/* Skills */
.skills-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0;
  margin: 0;
}

.skills-list li {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: var(--fs-sm);
}

/* Projects */
.projects-grid {
  display: block;
  position: relative;
}

.project-card {
  position: sticky;
  top: 96px;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.6);
  padding: 2.5rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.project-card:nth-child(1) { z-index: 1; }
.project-card:nth-child(2) { z-index: 2; }
.project-card:nth-child(3) { z-index: 3; }
.project-card:nth-child(4) { z-index: 4; }
.project-card:nth-child(5) { z-index: 5; }
.project-card:nth-child(6) { z-index: 6; }
.project-card:nth-child(7) { z-index: 7; }
.project-card:nth-child(8) { z-index: 8; }

.project-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.4);
}

.project-card:hover::before {
  transform: scaleX(1);
}

.project-card.has-link {
  cursor: pointer;
}

.project-card h3 {
  font-family: var(--font-display);
  margin: 0 0 0.5rem;
  font-size: var(--fs-2xl);
}

.project-card p {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin: 0 0 1rem;
}

.project-card--placeholder {
  opacity: 0.6;
  border-style: dashed;
}

.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.tag {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.project-links {
  display: flex;
  gap: 1rem;
}

.project-links a {
  color: var(--accent);
  text-decoration: none;
  font-size: var(--fs-sm);
}

.project-links a:hover {
  text-decoration: underline;
}

.project-links a:not(.card-stretched-link) {
  position: relative;
  z-index: 2;
}

.card-stretched-link::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.link-disabled {
  pointer-events: none;
  color: var(--text-muted) !important;
}

/* Experience & Education */
.experience-item {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
}

.experience-item:last-of-type {
  border-bottom: none;
}

.experience-item h3 {
  font-family: var(--font-display);
  margin: 0 0 0.25rem;
  font-size: var(--fs-md);
}

.experience-meta {
  color: var(--accent);
  font-size: var(--fs-xs);
  margin: 0 0 0.75rem;
}

.experience-item ul {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.experience-item ul li {
  margin-bottom: 0.35rem;
}

.experience-item p {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin: 0;
}

.education-heading {
  margin-top: 2.5rem;
}

/* Contact */
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.contact-list a {
  color: var(--accent);
  text-decoration: none;
}

.contact-list a:hover { text-decoration: underline; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  border-top: 1px solid var(--border);
}

/* Mobile nav */
@media (max-width: 700px) {
  .nav-toggle { display: flex; }

  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.5rem;
    gap: 1rem;
    display: none;
  }

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

  .nav-pill-group {
    flex-direction: column;
    align-items: flex-start;
    background: none;
    border: none;
    padding: 0;
    gap: 0.75rem;
    width: 100%;
  }

  .nav-pill-highlight {
    display: none;
  }
}

/* Small-screen tightening */
@media (max-width: 480px) {
  .hero {
    padding: 4rem 1.25rem 3rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .section {
    padding: 2.5rem 1.25rem;
  }

  .nav {
    padding: 0.85rem 1.25rem;
  }

  .project-card {
    top: 76px;
    padding: 1.5rem;
  }

  .project-card h3 {
    font-size: var(--fs-lg);
  }
}

/* Scroll-reveal animation */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

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

@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .project-card,
  .project-card::before,
  .btn,
  .nav-links a,
  .nav-links a::after,
  .nav-pill-highlight {
    transition: none;
  }

  .hero-robot,
  .robot-body,
  .robot-arm-left,
  .robot-arm-right,
  .robot-eye-l,
  .robot-eye-r,
  .robot-wheel-l,
  .robot-wheel-r,
  .robot-chest-light,
  .robot-antenna-tip {
    animation: none;
  }

  .hero-robot,
  .eyebrow,
  .hero h1,
  .hero-tagline,
  .hero-actions {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .intro-badge {
    animation: none;
  }
}
