:root {
  --bg: #0b1220;
  --bg2: #111b2a;
  --card: #162233;
  --line: #2b3a4e;
  --text: #f0f5fa;
  --muted: #b0bdcc;
  --accent: #45dfa0;
  --accent2: #59c7ff;
  --radius: 16px;
  --maxw: 1080px;
}

:root[data-theme="light"] {
  --bg: #f6f8fc;
  --bg2: #edf2f8;
  --card: #ffffff;
  --line: #d3deea;
  --text: #172334;
  --muted: #435366;
  --accent: #087a51;
  --accent2: #086caa;
}

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

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

body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.75 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

a:focus-visible,
button:focus-visible {
  outline: 3px solid var(--accent2);
  outline-offset: 4px;
}

::selection {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
}

h1,
h2,
h3 {
  font-family: "Space Grotesk", Inter, sans-serif;
  line-height: 1.15;
}

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

section {
  padding: 92px 0;
}

.eyebrow {
  margin-bottom: 12px;
  color: var(--accent);
  font: 500 13px "JetBrains Mono", monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  margin-bottom: 36px;
  font-size: clamp(29px, 4vw, 42px);
  letter-spacing: -0.025em;
}

/* Navigation */
nav {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(12px);
}

nav .wrap {
  display: flex;
  height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font: 700 19px "Space Grotesk", sans-serif;
}

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

.links {
  display: flex;
  gap: 24px;
  color: var(--muted);
  font-size: 14px;
}

.links a,
.btn-s,
.btn,
.proj {
  transition:
    color 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

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

.tools {
  display: flex;
  gap: 8px;
}

.btn-s {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  padding: 7px 13px;
  font: 500 13px "JetBrains Mono", monospace;
  cursor: pointer;
}

.btn-s:hover {
  border-color: var(--accent);
  background: var(--bg2);
}

@media (max-width: 760px) {
  .links {
    display: none;
  }
}

/* Hero */
.hero {
  padding: 104px 0 82px;
  background:
    radial-gradient(
      900px 400px at 85% -10%,
      color-mix(in srgb, var(--accent2) 18%, transparent),
      transparent
    ),
    radial-gradient(
      700px 360px at 0% 0%,
      color-mix(in srgb, var(--accent) 14%, transparent),
      transparent
    );
}

.hero h1 {
  margin: 8px 0 16px;
  font-size: clamp(39px, 7vw, 70px);
  letter-spacing: -0.035em;
}

.hero h1 em {
  color: var(--accent);
  font-style: normal;
}

.role {
  max-width: 680px;
  color: var(--muted);
  font-size: clamp(18px, 2.4vw, 23px);
}

.tag {
  margin-top: 18px;
  color: var(--accent2);
  font: 400 15px "JetBrains Mono", monospace;
}

.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.btn {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 20px;
  font-weight: 600;
}

.btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--card);
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #04130c;
}

.btn.primary:hover {
  background: color-mix(in srgb, var(--accent) 86%, white);
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  padding: 7px 13px;
  font-size: 14px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}

/* About */
.about {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 40px;
}

@media (max-width: 820px) {
  .about {
    grid-template-columns: 1fr;
  }
}

.about p {
  max-width: 68ch;
  margin-bottom: 16px;
  color: var(--muted);
}

.facts {
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 24px;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 12px;
  font-size: 15px;
}

.facts div:last-child {
  border: 0;
  padding: 0;
}

.facts b {
  color: var(--muted);
  font-weight: 500;
}

/* Experience and education */
.tl {
  display: grid;
  gap: 18px;
}

.item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 26px;
}

.item header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 12px;
}

.item h3 {
  font-size: 21px;
}

.item .org {
  color: var(--accent2);
  font-weight: 600;
}

.item .when {
  color: var(--muted);
  font: 400 13px "JetBrains Mono", monospace;
}

.item ul {
  margin-left: 20px;
  color: var(--muted);
}

.item li {
  margin: 6px 0;
  padding-left: 2px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg2);
  color: var(--text);
  padding: 5px 11px;
  font: 400 12px "JetBrains Mono", monospace;
}

/* Score legend */
.score {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.score span {
  border-radius: 8px;
  padding: 6px 10px;
  font: 500 12px "JetBrains Mono", monospace;
}

.s-g {
  border: 1px solid #3ddc9755;
  background: #1f9d6a22;
  color: #3ddc97;
}

.s-o {
  border: 1px solid #f0a50055;
  background: #f0a50022;
  color: #f0a500;
}

.s-r {
  border: 1px solid #e5484d55;
  background: #e5484d22;
  color: #ff6b70;
}

:root[data-theme="light"] .s-g {
  color: #0a7a4d;
}

:root[data-theme="light"] .s-o {
  color: #9a6500;
}

:root[data-theme="light"] .s-r {
  color: #b3262b;
}

/* Projects */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr));
  gap: 20px;
}

.proj {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 26px;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease;
}

.proj:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 14px 32px color-mix(in srgb, var(--bg) 45%, transparent);
}

.proj .kicker {
  margin-bottom: 9px;
  color: var(--accent);
  font: 500 12px "JetBrains Mono", monospace;
}

.proj h3 {
  margin-bottom: 10px;
  font-size: 22px;
}

.proj p,
.proj ul {
  color: var(--muted);
  font-size: 16px;
}

.proj p {
  margin-bottom: 8px;
}

.proj ul {
  margin: 6px 0 0 20px;
}

.proj li {
  margin: 5px 0;
}

.proj .chips {
  margin-top: auto;
  padding-top: 18px;
}

.wip {
  color: #f0a500;
}

/* Skills */
.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 18px;
}

.sk {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 22px;
}

.sk h3 {
  margin-bottom: 13px;
  color: var(--accent);
  font: 500 15px "JetBrains Mono", monospace;
}

.sk .chips {
  margin: 0;
}

/* Education */
.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 760px) {
  .two {
    grid-template-columns: 1fr;
  }
}

/* Contact */
.contact {
  border-top: 1px solid var(--line);
  background: var(--bg2);
  text-align: center;
}

.contact p {
  max-width: 540px;
  margin: 0 auto 28px;
  color: var(--muted);
}

.contact .cta {
  justify-content: center;
}

footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: 600ms ease;
}

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

@media (max-width: 600px) {
  .wrap {
    padding: 0 18px;
  }

  section {
    padding: 68px 0;
  }

  .hero {
    padding: 76px 0 62px;
  }

  .item,
  .proj {
    padding: 21px;
  }

  .facts {
    padding: 20px;
  }

  .facts div {
    flex-wrap: wrap;
  }

  .cta .btn {
    flex: 1 1 180px;
  }
}

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

  html {
    scroll-behavior: auto;
  }
}

/* =====================================================================
   Enhancements
   ===================================================================== */

/* Accessibility helpers */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 60;
  border-radius: 10px;
  background: var(--accent);
  color: #04130c;
  padding: 10px 16px;
  font-weight: 600;
}

.skip:focus {
  top: 12px;
}

/* Lazy rendering: off-screen sections are skipped until needed */
main > section {
  content-visibility: auto;
  contain-intrinsic-size: auto 720px;
}

.alt {
  background: var(--bg2);
}

/* Scroll progress bar */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 50;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transform: scaleX(0);
  transform-origin: 0 50%;
}

nav.scrolled {
  box-shadow: 0 8px 24px color-mix(in srgb, var(--bg) 60%, transparent);
}

.links a.active {
  color: var(--text);
  box-shadow: 0 2px 0 var(--accent);
}

.menu-btn {
  display: none;
}

@media (max-width: 760px) {
  .menu-btn {
    display: inline-block;
  }

  .links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    padding: 12px 18px 18px;
  }

  .links.open {
    display: flex;
  }

  .links a {
    padding: 10px 4px;
    font-size: 16px;
  }
}

/* Hero */
.hero {
  position: relative;
  overflow: hidden;
}

.hero .wrap {
  position: relative;
  z-index: 1;
}

.blob {
  position: absolute;
  z-index: 0;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.35;
  animation: float 14s ease-in-out infinite alternate;
}

.b1 {
  top: -140px;
  right: -80px;
  background: var(--accent2);
}

.b2 {
  bottom: -200px;
  left: -120px;
  background: var(--accent);
  animation-delay: -6s;
}

@keyframes float {
  to {
    transform: translate3d(-40px, 30px, 0) scale(1.12);
  }
}

.role {
  min-height: 1.5em;
}

#typed {
  color: var(--text);
}

.caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -0.12em;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 640px;
  margin-top: 44px;
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--card) 80%, transparent);
  backdrop-filter: blur(6px);
  padding: 14px 16px;
}

.stats dt {
  color: var(--muted);
  font-size: 13px;
}

.stats dd {
  color: var(--accent);
  font: 700 30px "Space Grotesk", sans-serif;
  line-height: 1.2;
}

@media (max-width: 600px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Staggered reveal */
.reveal {
  transition-delay: var(--d, 0ms);
}

/* Project cards: cover image, spotlight, tilt */
.proj {
  --pad: 26px;
  --rx: 0deg;
  --ry: 0deg;
  position: relative;
  overflow: hidden;
  padding: 0;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry));
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 120ms ease-out,
    opacity 600ms ease;
}

.proj.reveal:not(.in) {
  transform: translateY(14px);
}

.proj:hover {
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(-3px);
}

.proj::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    420px circle at var(--mx, 50%) var(--my, 50%),
    color-mix(in srgb, var(--accent2) 16%, transparent),
    transparent 60%
  );
  transition: opacity 200ms ease;
}

.proj:hover::after {
  opacity: 1;
}

.proj .body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: var(--pad);
}

@media (max-width: 600px) {
  .proj {
    --pad: 21px;
  }
}

.media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(
    100deg,
    var(--bg2) 30%,
    color-mix(in srgb, var(--line) 70%, var(--bg2)) 50%,
    var(--bg2) 70%
  );
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

.media.loaded {
  animation: none;
}

.media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition:
    opacity 600ms ease,
    transform 900ms ease;
}

.media.loaded img {
  opacity: 1;
  transform: none;
}

.proj:hover .media.loaded img {
  transform: scale(1.04);
}

.media.failed img {
  display: none;
}

@keyframes shimmer {
  to {
    background-position: -220% 0;
  }
}

.proj .foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 18px;
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}

.proj .link {
  color: var(--accent);
  font-weight: 600;
}

.proj .link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.meta {
  color: var(--muted);
  font: 400 12px "JetBrains Mono", monospace;
  opacity: 0;
  transition: opacity 400ms ease;
}

.meta.show {
  opacity: 1;
}

/* Back to top + toast */
.totop {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 200ms ease,
    transform 200ms ease,
    border-color 200ms ease;
}

.totop.show {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

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

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 40;
  max-width: calc(100% - 32px);
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--card);
  padding: 12px 18px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition:
    opacity 200ms ease,
    transform 200ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

button.btn {
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .blob,
  .caret,
  .media {
    animation: none;
  }

  .proj,
  .proj:hover,
  .proj.reveal:not(.in) {
    transform: none;
  }

  .media img {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

@media print {
  nav,
  .progress,
  .totop,
  .toast,
  .blob,
  .cta {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

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