:root {
  --bg: #0a0e14;
  --bg-soft: #0f1521;
  --panel: #121a26;
  --panel-2: #18222f;
  --line: #1f2c3d;
  --text: #e6edf3;
  --muted: #8b9bb1;
  --accent: #00e5a0;
  --accent-2: #2ea0ff;
  --accent-glow: rgba(0, 229, 160, 0.35);
  --danger: #ff5c7c;
  --radius: 16px;
  --maxw: 1080px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sans: "Sora", system-ui, -apple-system, sans-serif;
}

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

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#matrix-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
}

main, .nav, .footer { position: relative; z-index: 1; }

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

.grad {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  background: rgba(10, 14, 20, 0.6);
  border-bottom: 1px solid transparent;
  transition: border-color .3s, background .3s;
}
.nav.scrolled {
  border-bottom-color: var(--line);
  background: rgba(10, 14, 20, 0.85);
}
.nav__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav__brand { display: flex; align-items: center; gap: 12px; font-weight: 700; }
.nav__brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121a;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 0 20px var(--accent-glow);
}
.nav__brand-name { font-size: 15px; letter-spacing: .3px; }
.nav__links { display: flex; align-items: center; gap: 28px; }
.nav__links a {
  font-size: 14px;
  color: var(--muted);
  transition: color .2s;
  position: relative;
}
.nav__links a:hover { color: var(--text); }
.nav__cta {
  padding: 8px 18px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent) !important;
}
.nav__cta:hover { background: var(--accent); color: #04121a !important; }
.nav__toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none; border: none; cursor: pointer;
}
.nav__toggle span {
  width: 26px; height: 2px; background: var(--text);
  transition: transform .3s, opacity .3s;
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 120px 24px 80px;
}
.hero__inner {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  align-items: center;
  gap: 50px;
}
.hero__portrait { display: flex; justify-content: center; transform: translateY(-40px); }
.portrait {
  position: relative;
  width: min(340px, 80vw);
  aspect-ratio: 1;
}
.portrait img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 30px 70px rgba(0,0,0,.5);
}
.portrait__fallback {
  display: none;
  position: absolute;
  inset: 0;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--panel), var(--panel-2));
  font-family: var(--mono);
  font-size: 84px;
  font-weight: 700;
  color: var(--accent);
  place-items: center;
}
.portrait--empty .portrait__fallback { display: grid; }
.portrait__ring {
  position: absolute;
  inset: -14px;
  border-radius: 36px;
  border: 1.5px solid transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)) border-box;
  -webkit-mask: linear-gradient(#000 0 0) padding-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: .85;
  animation: ringpulse 3.5s ease-in-out infinite;
}
@keyframes ringpulse {
  0%, 100% { opacity: .45; filter: drop-shadow(0 0 6px var(--accent-glow)); }
  50% { opacity: .95; filter: drop-shadow(0 0 18px var(--accent-glow)); }
}
.portrait__badge {
  position: absolute;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: rgba(10,14,20,.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
}
.hero__eyebrow {
  font-family: var(--mono);
  color: var(--accent);
  letter-spacing: 2px;
  text-transform: uppercase;
  font-size: 14px;
  margin-bottom: 18px;
}
.hero__title {
  font-size: clamp(48px, 9vw, 104px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
}
.hero__typed {
  font-family: var(--mono);
  font-size: clamp(16px, 3vw, 24px);
  color: var(--accent-2);
  margin: 22px 0 8px;
  min-height: 1.5em;
}
.cursor { animation: blink 1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }
.hero__lead {
  max-width: 620px;
  color: var(--muted);
  font-size: 17px;
  margin-top: 18px;
}
.hero__actions { display: flex; gap: 16px; margin-top: 34px; flex-wrap: wrap; }
.btn {
  padding: 14px 28px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  transition: transform .2s, box-shadow .2s, background .2s;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #04121a;
  box-shadow: 0 8px 30px var(--accent-glow);
}
.btn--primary:hover { transform: translateY(-3px); box-shadow: 0 12px 40px var(--accent-glow); }
.btn--ghost { border-color: var(--line); color: var(--text); }
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-3px); }
.btn__icon { font-size: 14px; margin-right: 2px; }

.hero__stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-top: 60px;
  max-width: 720px;
}
.stat { display: flex; flex-direction: column; }
.stat__num {
  font-family: var(--mono);
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  color: var(--text);
  display: inline;
}
.stat__plus { color: var(--accent); font-family: var(--mono); font-size: 24px; }
.stat__label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.hero__scroll {
  position: absolute;
  bottom: 30px; left: 50%;
  transform: translateX(-50%);
  font-size: 22px;
  color: var(--muted);
  animation: bob 2s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translate(-50%,0);} 50% { transform: translate(-50%,10px);} }

/* ---------- Sections ---------- */
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 90px 24px;
}
.section__head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 44px; }
.section__index {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 16px;
}
.section__title {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 700;
  letter-spacing: -1px;
}
.section__title::after {
  content: "";
  display: inline-block;
  width: 90px; height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
  margin-left: 18px; vertical-align: middle;
}

/* ---------- About ---------- */
.about { display: grid; grid-template-columns: 1.6fr 1fr; gap: 40px; }
.about__text p { color: var(--muted); margin-bottom: 18px; font-size: 16px; }
.about__text p:first-child { color: var(--text); }
.about__card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  height: fit-content;
}
.about__card h3 { font-family: var(--mono); font-size: 14px; color: var(--accent); margin-bottom: 18px; text-transform: uppercase; letter-spacing: 1px; }
.about__card ul { list-style: none; }
.about__card li {
  display: flex; justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.about__card li:last-child { border-bottom: none; }
.about__card li span { color: var(--muted); }

/* ---------- Skills ---------- */
.skills { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.skill-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  transition: transform .25s, border-color .25s;
}
.skill-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.skill-card--wide { grid-column: 1 / -1; }
.skill-card h3 { font-size: 18px; margin-bottom: 18px; }
.tags { display: flex; flex-wrap: wrap; gap: 9px; }
.tags span {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 6px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  transition: color .2s, border-color .2s, background .2s;
}
.tags span:hover { color: var(--accent); border-color: var(--accent); background: rgba(0,229,160,.07); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 30px; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px;
  width: 2px; background: linear-gradient(var(--accent), var(--accent-2), transparent);
}
.tl-item { position: relative; padding-bottom: 40px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item__dot {
  position: absolute; left: -30px; top: 6px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
  box-shadow: 0 0 14px var(--accent-glow);
}
.tl-item__body {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 26px;
  transition: border-color .25s;
}
.tl-item__body:hover { border-color: var(--accent-2); }
.tl-item__head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.tl-item__head h3 { font-size: 20px; }
.tl-item__date { font-family: var(--mono); font-size: 13px; color: var(--accent); }
.tl-item__org { color: var(--accent-2); font-size: 14px; margin: 4px 0 16px; font-weight: 500; }
.tl-item ul { list-style: none; }
.tl-item li {
  color: var(--muted);
  font-size: 15px;
  padding: 5px 0 5px 22px;
  position: relative;
}
.tl-item li::before { content: "▹"; position: absolute; left: 0; color: var(--accent); }

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.proj {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  position: relative;
  overflow: hidden;
  transition: transform .25s, border-color .25s;
}
.proj:last-child { grid-column: 1 / -1; }
.proj:hover { transform: translateY(-4px); border-color: var(--accent); }
.proj__num {
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 700;
  color: var(--panel-2);
  position: absolute;
  top: 14px; right: 22px;
  -webkit-text-stroke: 1px var(--line);
}
.proj h3 { font-size: 19px; margin-bottom: 12px; max-width: 80%; }
.proj p { color: var(--muted); font-size: 15px; margin-bottom: 18px; }
.proj__tags { display: flex; flex-wrap: wrap; gap: 8px; }
.proj__tags span {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* ---------- Credentials ---------- */
.creds { display: grid; grid-template-columns: 1fr 1.2fr; gap: 40px; }
.creds__col h3 { font-family: var(--mono); color: var(--accent); font-size: 14px; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 20px; }
.creds__list { list-style: none; display: flex; flex-direction: column; gap: 16px; }
.creds__list li {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 16px 20px;
}
.creds__list strong { display: block; font-size: 16px; }
.creds__list em { color: var(--accent); font-style: normal; font-size: 13px; }
.creds__list span { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- Contact ---------- */
.section--contact { padding-bottom: 60px; }
.contact__lead { max-width: 560px; color: var(--muted); font-size: 18px; margin-bottom: 36px; }
.contact__links { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.contact__link {
  display: flex; align-items: center; gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  transition: transform .2s, border-color .2s;
}
.contact__link:hover { transform: translateY(-3px); border-color: var(--accent); }
.contact__icon {
  display: grid; place-items: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--accent);
  font-size: 20px;
  flex-shrink: 0;
}
.contact__link span:last-child { display: flex; flex-direction: column; font-weight: 600; font-size: 15px; word-break: break-all; }
.contact__link small { color: var(--muted); font-weight: 400; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--line);
  text-align: center;
  padding: 36px 24px;
  color: var(--muted);
  font-size: 14px;
}
.footer__note { font-family: var(--mono); font-size: 12px; margin-top: 6px; color: var(--line); }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity .7s ease, transform .7s ease; }
.reveal.visible { opacity: 1; transform: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--accent);
  color: #04121a;
  padding: 12px 24px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .hero__inner { grid-template-columns: 1fr; gap: 40px; }
  .hero__portrait { order: -1; transform: none; }
  .about, .skills, .projects, .creds { grid-template-columns: 1fr; }
  .skill-card--wide, .proj:last-child { grid-column: auto; }
  .hero__stats { grid-template-columns: repeat(2, 1fr); gap: 24px; }
  .nav__links {
    position: fixed;
    top: 71px; right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
    background: var(--bg-soft);
    border-left: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 26px 32px;
    width: 240px;
    transform: translateX(100%);
    transition: transform .3s;
    height: auto;
  }
  .nav__links.open { transform: translateX(0); }
  .nav__toggle { display: flex; }
  .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); }
}
@media (max-width: 460px) {
  .hero__stats { grid-template-columns: 1fr 1fr; }
  .nav__brand-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; }
}
