:root {
  --bg: #05060f;
  --bg-alt: #0a0c17;
  --panel: #171a24;
  --line: #3f4959;
  --text: #d1e4fa;
  --text-dim: #9da7ba;
  --accent: #663af3;
  --accent-soft: rgba(102, 58, 243, 0.14);
  --accent-rgb: 102, 58, 243;
  --carrier: #e46d4c;
  --carrier-rgb: 228, 109, 76;
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Public Sans", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --max: 1200px;
  --section-gap: 120px;
  --card-padding: 24px;
  --mx: 50%;
  --my: 50%;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Tech background */
.bg-fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.bg-grid {
  position: absolute;
  inset: -1px;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 85%);
}
.bg-glow {
  position: absolute;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.16;
}
.bg-glow-a {
  background: var(--accent);
  top: -220px;
  left: -140px;
  animation: drift-a 26s ease-in-out infinite;
}
.bg-glow-b {
  background: var(--carrier);
  bottom: -260px;
  right: -160px;
  opacity: 0.09;
  animation: drift-b 32s ease-in-out infinite;
}
@keyframes drift-a {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(60px, 40px); }
}
@keyframes drift-b {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-50px, -30px); }
}
.bg-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.03) 50%, transparent);
  background-size: 100% 6px;
  mix-blend-mode: overlay;
  animation: scan-move 9s linear infinite;
  opacity: 0.5;
}
@keyframes scan-move {
  0% { background-position: 0 0; }
  100% { background-position: 0 240px; }
}

@media (prefers-reduced-motion: reduce) {
  .bg-glow, .bg-scan { animation: none; }
}

/* Scroll progress */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  z-index: 200;
  background: linear-gradient(90deg, var(--accent), var(--carrier));
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.6);
  transition: width 0.08s linear;
}

/* Cursor glow */
.cursor-glow {
  position: fixed;
  top: 0;
  left: 0;
  width: 460px;
  height: 460px;
  margin-left: -230px;
  margin-top: -230px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.10) 0%, rgba(var(--accent-rgb), 0.04) 35%, transparent 70%);
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.4s ease;
  will-change: transform;
}
.cursor-glow.is-active { opacity: 1; }
@media (prefers-reduced-motion: reduce), (pointer: coarse) {
  .cursor-glow { display: none; }
}

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

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

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.4em;
  letter-spacing: -0.01em;
}

p { margin: 0 0 1em; max-width: 62ch; }

a { color: inherit; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  z-index: 100;
  font-weight: 600;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
}

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

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(5, 6, 15, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  transition: background 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease;
}
.site-header.is-scrolled {
  background: rgba(3, 4, 10, 0.92);
  box-shadow: 0 8px 30px -12px rgba(0,0,0,0.5);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  transition: height 0.3s ease;
}
.site-header.is-scrolled .header-inner { height: 58px; }

.mark {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  text-decoration: none;
  letter-spacing: 0.02em;
}
.mark-dot {
  color: var(--accent);
  animation: dot-blink 2.4s ease-in-out infinite;
}
@keyframes dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.main-nav {
  display: flex;
  gap: 28px;
  position: relative;
}
.main-nav a {
  text-decoration: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  position: relative;
  padding: 4px 0;
  transition: color 0.25s ease;
}
.main-nav a:hover { color: var(--text); }
.main-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.main-nav a:hover::after { transform: scaleX(1); }
.main-nav a.is-active { color: var(--accent); }

.nav-indicator {
  position: absolute;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--carrier));
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.7);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), width 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  width: 0;
  opacity: 0;
  pointer-events: none;
}
.nav-indicator.is-visible { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .mark-dot { animation: none; }
}

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
}

/* Hero */
.hero {
  padding: 96px 0 72px;
  border-bottom: 1px solid var(--line);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
}
.eyebrow {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.85rem;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.6);
  animation: eyebrow-ping 2.2s ease-out infinite;
}
@keyframes eyebrow-ping {
  0% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}
.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.4rem);
  margin-bottom: 18px;
}
.hero-name {
  background: linear-gradient(100deg, var(--text) 30%, var(--accent) 60%, var(--carrier) 90%);
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: name-shine 7s ease-in-out infinite;
}
@keyframes name-shine {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.hero-role {
  font-size: 1.25rem;
  color: var(--text);
  max-width: 46ch;
}
.hero-caret {
  color: var(--accent);
  font-family: var(--font-mono);
  animation: caret-blink 1.1s step-end infinite;
}
@keyframes caret-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .eyebrow-dot, .hero-name, .hero-caret { animation: none; }
}
.hero-sub {
  color: var(--text-dim);
  max-width: 52ch;
}
.hero-actions {
  display: flex;
  gap: 16px;
  margin-top: 28px;
  flex-wrap: wrap;
}

/* Hero entrance */
@keyframes fade-up-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}
.hero-copy > * {
  opacity: 0;
  animation: fade-up-in 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.hero-copy > *:nth-child(1) { animation-delay: 0.05s; }
.hero-copy > *:nth-child(2) { animation-delay: 0.15s; }
.hero-copy > *:nth-child(3) { animation-delay: 0.25s; }
.hero-copy > *:nth-child(4) { animation-delay: 0.35s; }
.hero-copy > *:nth-child(5) { animation-delay: 0.45s; }
.hero-diagram {
  opacity: 0;
  animation: fade-up-in 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: 0.3s;
}
@media (prefers-reduced-motion: reduce) {
  .hero-copy > *, .hero-diagram { opacity: 1; animation: none; }
}

.btn {
  position: relative;
  display: inline-block;
  padding: 12px 22px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid transparent;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}
.btn span { position: relative; z-index: 1; }
.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,0.35) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 0.6s ease;
}
.btn:hover::before { transform: translateX(120%); }
.btn:hover { transform: translateY(-2px); }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: #7c52f5;
  box-shadow: 0 10px 30px -10px rgba(var(--accent-rgb), 0.6);
}
.btn-ghost {
  border-color: var(--line);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 10px 30px -14px rgba(var(--accent-rgb), 0.5);
}
@media (prefers-reduced-motion: reduce) {
  .btn:hover { transform: none; }
  .btn::before { display: none; }
}

/* Hero diagram */
.hero-diagram svg { width: 100%; height: auto; }
.diagram-lines line {
  stroke: var(--line);
  stroke-width: 1.5;
}
.diagram-nodes circle {
  fill: var(--panel);
  stroke: var(--line);
  stroke-width: 1.5;
}
.node-hub circle {
  fill: var(--accent-soft);
  stroke: var(--accent);
  stroke-width: 2;
  animation: hub-pulse 3s ease-in-out infinite;
  transform-origin: 210px 190px;
}
@keyframes hub-pulse {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(var(--accent-rgb),0)); }
  50% { filter: drop-shadow(0 0 10px rgba(var(--accent-rgb),0.55)); }
}
.node-carrier circle {
  stroke: var(--carrier);
}
.diagram-nodes text {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--text-dim);
  text-anchor: middle;
}
.node-hub text { fill: var(--text); font-size: 11px; }

.flow-dot {
  fill: var(--accent);
  filter: drop-shadow(0 0 4px rgba(var(--accent-rgb),0.8));
}
.flow-dot-carrier {
  fill: var(--carrier);
  filter: drop-shadow(0 0 4px rgba(var(--carrier-rgb),0.8));
}
@media (prefers-reduced-motion: reduce) {
  .node-hub circle { animation: none; }
  .diagram-flow { display: none; }
}

/* Sections */
.section {
  padding: var(--section-gap) 0;
  border-bottom: 1px solid var(--line);
}
.section-alt { background: var(--bg-alt); }

.section-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.6fr;
  gap: 48px;
}
.section-head h2 { font-size: 1.7rem; }
.section-intro { color: var(--text-dim); }
.lede { font-size: 1.1rem; max-width: 60ch; }

.section-index {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  opacity: 0.85;
}
.section-contact .section-index { margin-top: 0; }

/* Marquee */
.marquee {
  position: relative;
  z-index: 1;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--bg-alt);
  padding: 18px 0;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee-track {
  display: flex;
  width: max-content;
  gap: 48px;
  animation: marquee-scroll 26s linear infinite;
}
.marquee-track span {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
}

/* Stats */
.stats-bar {
  position: relative;
  z-index: 1;
  padding: 56px 0;
  border-bottom: 1px solid var(--line);
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.stat-value {
  display: flex;
  align-items: baseline;
  gap: 2px;
}
.stat-num {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 2.6rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-suffix {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}
.stat-label {
  color: var(--text-dim);
  font-size: 0.88rem;
  max-width: 20ch;
}

.fact-list {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}
.fact-list div { display: flex; gap: 12px; }
.fact-list dt {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 0.85rem;
  width: 110px;
  flex: none;
}
.fact-list dd { margin: 0; }

/* Timeline */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}
.timeline-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 24px;
  padding: 0 0 40px 24px;
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.timeline-content h3 { margin-bottom: 4px; font-size: 1.15rem; }
.timeline-org {
  color: var(--accent);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

/* Case studies */
.case-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 24px;
}
.case {
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: var(--card-padding);
  overflow: hidden;
}
.case-num {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  opacity: 0.6;
  margin-bottom: 10px;
}
.case h3 { font-size: 1.1rem; }
.case p { color: var(--text-dim); margin-bottom: 0; }

/* Tilt / spotlight cards */
.tilt {
  position: relative;
  overflow: hidden;
  --mx: 50%;
  --my: 50%;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.35s ease, box-shadow 0.35s ease;
  transform: perspective(800px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0);
  will-change: transform;
}
.tilt::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: radial-gradient(280px circle at var(--mx) var(--my), rgba(var(--accent-rgb), 0.14), transparent 65%);
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.tilt:hover::before,
.tilt.is-hovering::before { opacity: 1; }
.tilt:hover, .tilt.is-hovering {
  border-color: rgba(var(--accent-rgb), 0.45);
  box-shadow: 0 18px 40px -22px rgba(0,0,0,0.55);
}
.tilt > * { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) {
  .tilt { transform: none !important; transition: border-color 0.35s ease, box-shadow 0.35s ease; }
}

/* Skills */
.skill-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px 24px;
}
.skill-group {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: var(--card-padding);
}
.skill-group h3 {
  font-size: 0.95rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 8px;
}
.skill-group p { margin: 0; }

/* Education */
.fact-block {
  margin-bottom: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: var(--card-padding);
}
.fact-block h3 { font-size: 1.15rem; margin-bottom: 4px; }
.cert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.cert-list li {
  padding-left: 18px;
  position: relative;
  color: var(--text-dim);
}
.cert-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 6px;
  height: 6px;
  background: var(--accent);
}

/* Contact */
.section-contact { padding: var(--section-gap) 0 calc(var(--section-gap) + 12px); border-bottom: none; }
.section-contact h2 { font-size: 1.7rem; }
.contact-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 24px;
}
.contact-item {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  text-decoration: none;
  border: 1px solid var(--line);
  padding: 12px 18px;
  border-radius: 6px;
}
a.contact-item:hover { border-color: var(--accent); color: var(--accent); }
.contact-static { color: var(--text-dim); }

/* Footer */
.site-footer {
  padding: 28px 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.site-footer p { margin: 0; }

/* Scroll reveal */
.reveal {
  opacity: 0;
  transform: translateX(-14px);
  border-left: 1px solid transparent;
  padding-left: 0;
  transition: opacity 0.7s ease, transform 0.7s ease, border-color 0.7s ease, padding-left 0.7s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: translateX(0);
}
.section-head.reveal.is-visible {
  border-left-color: var(--accent);
  padding-left: 18px;
}
.reveal-item {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  transition-delay: var(--reveal-delay, 0s);
}
.reveal-item.is-visible { opacity: 1; transform: translateY(0); }

.case-list .reveal-item:nth-child(1) { --reveal-delay: 0s; }
.case-list .reveal-item:nth-child(2) { --reveal-delay: 0.08s; }
.case-list .reveal-item:nth-child(3) { --reveal-delay: 0.16s; }
.case-list .reveal-item:nth-child(4) { --reveal-delay: 0.24s; }
.skill-groups .reveal-item:nth-child(1) { --reveal-delay: 0s; }
.skill-groups .reveal-item:nth-child(2) { --reveal-delay: 0.08s; }
.skill-groups .reveal-item:nth-child(3) { --reveal-delay: 0.16s; }
.skill-groups .reveal-item:nth-child(4) { --reveal-delay: 0.24s; }
.stats-grid .reveal-item:nth-child(1) { --reveal-delay: 0s; }
.stats-grid .reveal-item:nth-child(2) { --reveal-delay: 0.1s; }
.stats-grid .reveal-item:nth-child(3) { --reveal-delay: 0.2s; }
.stats-grid .reveal-item:nth-child(4) { --reveal-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
  .reveal, .reveal-item {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .section-head.reveal.is-visible { padding-left: 0; border-color: transparent; }
}

/* Responsive */
@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-diagram { order: -1; max-width: 320px; margin: 0 auto; }
  .section-grid { grid-template-columns: 1fr; }
  .case-list { grid-template-columns: 1fr; }
  .skill-groups { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 32px 24px; }
}

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

@media (max-width: 680px) {
  .main-nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    padding: 12px 24px 20px;
    gap: 16px;
    display: none;
  }
  .main-nav.open { display: flex; }
  .nav-toggle { display: flex; }
  .nav-indicator { display: none; }
  .main-nav a::after { display: none; }
}
.mark-logo { height: 32px; width: auto; display: block; }
