/* ============================================================
   Design Tokens
   ============================================================ */
:root {
  --bg: #05080f;
  --bg-alt: #070b16;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.07);
  --border-accent: rgba(0, 212, 255, 0.28);
  --border-gold: rgba(245, 158, 11, 0.35);
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.1);
  --accent-mid: rgba(0, 212, 255, 0.22);
  --purple: #8b5cf6;
  --purple-dim: rgba(139, 92, 246, 0.1);
  --gold: #f59e0b;
  --gold-dim: rgba(245, 158, 11, 0.1);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #475569;
  --radius: 14px;
  --tr-fast: 160ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr: 280ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr-slow: 520ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   Animated Border Property
   ============================================================ */
@property --border-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

/* Hide system cursor on precise pointer devices */
@media (pointer: fine) {
  * { cursor: none !important; }
}

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

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.032) 1px, transparent 1px);
  background-size: 28px 28px;
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Ambient glow layers */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 55% 50% at 12% 38%, rgba(0, 212, 255, 0.022) 0%, transparent 65%),
    radial-gradient(ellipse 45% 55% at 88% 72%, rgba(139, 92, 246, 0.028) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* Film grain overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  opacity: 0.032;
  pointer-events: none;
  z-index: 9998;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.78' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 160px 160px;
}

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

h1, h2, h3, p { overflow-wrap: anywhere; margin: 0; }

/* ============================================================
   Custom Cursor
   ============================================================ */
.cursor,
.cursor-trail {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  will-change: left, top;
}

.cursor {
  width: 8px;
  height: 8px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.95), 0 0 22px rgba(0, 212, 255, 0.45);
  transition: width var(--tr-fast), height var(--tr-fast), box-shadow var(--tr-fast);
}

.cursor.is-hovering {
  width: 14px;
  height: 14px;
  box-shadow: 0 0 16px rgba(0, 212, 255, 1), 0 0 40px rgba(0, 212, 255, 0.55);
}

.cursor-trail {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(0, 212, 255, 0.4);
  background: transparent;
  transition: width var(--tr-fast), height var(--tr-fast), border-color var(--tr-fast);
}

.cursor-trail.is-hovering {
  width: 52px;
  height: 52px;
  border-color: rgba(0, 212, 255, 0.65);
}

@media (pointer: coarse) {
  .cursor, .cursor-trail { display: none; }
}

/* ============================================================
   Scroll Progress Bar
   ============================================================ */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  z-index: 200;
  transition: width 50ms linear;
  box-shadow: 0 0 14px rgba(0, 212, 255, 0.7);
}

/* ============================================================
   Header
   ============================================================ */
.site-header {
  position: fixed;
  z-index: 100;
  top: 0;
  inset-inline: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(20px, 4vw, 56px);
  background: rgba(5, 8, 15, 0.65);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  transition: border-color var(--tr), box-shadow var(--tr);
}

.site-header[data-elevated="true"] {
  border-color: var(--border);
  box-shadow: 0 1px 40px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.94rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #05080f;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: 'Space Mono', monospace;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.brand-text {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: clamp(14px, 2.5vw, 30px);
  font-size: 0.88rem;
  font-weight: 500;
}

.nav a {
  color: var(--text-muted);
  position: relative;
  padding-bottom: 2px;
  transition: color var(--tr-fast);
}

.nav a::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--purple));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--tr-fast);
}

.nav a:hover,
.nav a.active { color: var(--accent); }

.nav a:hover::after,
.nav a.active::after { transform: scaleX(1); }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(110px, 14vh, 170px) clamp(20px, 5vw, 72px) clamp(70px, 12vh, 110px);
  overflow: hidden;
}

#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-content {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr minmax(300px, 400px);
  gap: clamp(40px, 6vw, 80px);
  align-items: center;
  max-width: 1440px;
}

/* Hero eyebrow */
.hero .eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  color: var(--accent);
  font-family: 'Space Mono', monospace;
  font-size: 0.73rem;
  font-weight: 400;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  opacity: 0;
  animation: fadeInUp 0.8s 0.15s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hero .eyebrow::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--accent);
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-size: clamp(3.4rem, 8.5vw, 8.5rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.03em;
  opacity: 0;
  animation: fadeInUp 1s 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

h1 .line1 {
  display: block;
  background: linear-gradient(135deg, #fff 40%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h1 .line2 {
  display: block;
  background: linear-gradient(135deg, var(--text) 20%, var(--purple) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-copy {
  max-width: 580px;
  margin-top: 28px;
  color: var(--text-muted);
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
  line-height: 1.7;
  opacity: 0;
  animation: fadeInUp 1s 0.48s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 36px;
  opacity: 0;
  animation: fadeInUp 1s 0.64s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ============================================================
   Buttons
   ============================================================ */
.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 26px;
  border-radius: var(--radius);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.91rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform var(--tr-fast), box-shadow var(--tr-fast), background var(--tr-fast);
  position: relative;
  overflow: hidden;
  border: none;
}

.button::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.14), transparent 60%);
  opacity: 0;
  transition: opacity var(--tr-fast);
}

.button:hover { transform: translateY(-3px); }
.button:hover::after { opacity: 1; }

.button.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #0098cc 100%);
  color: #04060c;
  font-weight: 700;
  box-shadow: 0 4px 24px rgba(0, 212, 255, 0.28);
}

.button.primary:hover {
  box-shadow: 0 8px 36px rgba(0, 212, 255, 0.48);
}

.button.secondary {
  border: 1px solid var(--border-accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.button.secondary:hover {
  background: var(--accent-mid);
  box-shadow: 0 4px 24px rgba(0, 212, 255, 0.14);
}

/* ============================================================
   Hero Panel — Spinning Gradient Border
   ============================================================ */
.hero-panel-glow {
  border-radius: 19px;
  padding: 1px;
  background: conic-gradient(
    from var(--border-angle),
    var(--accent) 0%,
    var(--purple) 35%,
    rgba(139, 92, 246, 0.1) 50%,
    rgba(0, 212, 255, 0.1) 72%,
    var(--accent) 100%
  );
  animation: spinBorder 6s linear infinite;
  filter: drop-shadow(0 0 18px rgba(0, 212, 255, 0.1));
  opacity: 0;
  animation: fadeInRight 1s 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards, spinBorder 6s 1.5s linear infinite;
}

@keyframes spinBorder {
  to { --border-angle: 360deg; }
}

.hero-panel {
  padding: 28px 30px;
  border-radius: 18px;
  border: none;
  background: rgba(5, 8, 15, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  position: relative;
  overflow: hidden;
}

.hero-panel::after {
  content: '';
  position: absolute;
  bottom: -60px;
  right: -60px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero-panel dl,
.hero-panel dd { margin: 0; }

.hero-panel div + div {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.hero-panel dt {
  color: var(--accent);
  font-family: 'Space Mono', monospace;
  font-size: 0.66rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.hero-panel dd {
  color: var(--text);
  font-weight: 500;
  font-size: 0.93rem;
  line-height: 1.55;
}

/* ============================================================
   Scroll Hint
   ============================================================ */
.hero-scroll-hint {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.67rem;
  font-family: 'Space Mono', monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  z-index: 2;
  opacity: 0;
  animation: fadeIn 1s 1.3s forwards;
}

.scroll-line {
  display: block;
  width: 1px;
  height: 38px;
  background: linear-gradient(to bottom, var(--accent), transparent);
  animation: scrollPulse 2.2s ease-in-out infinite;
}

@keyframes scrollPulse {
  0%, 100% { opacity: 0.9; transform: scaleY(1); }
  50%       { opacity: 0.3; transform: scaleY(0.55); }
}

/* ============================================================
   Reveal Keyframes
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes fadeInRight {
  from { opacity: 0; transform: translateX(28px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   Scroll-triggered Reveal
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity var(--tr-slow), transform var(--tr-slow);
}

[data-reveal][data-delay="1"] { transition-delay: 110ms; }
[data-reveal][data-delay="2"] { transition-delay: 220ms; }
[data-reveal][data-delay="3"] { transition-delay: 330ms; }
[data-reveal][data-delay="4"] { transition-delay: 440ms; }

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

/* ============================================================
   Shared Section Layout
   ============================================================ */
section {
  position: relative;
  z-index: 1;
  padding: clamp(72px, 10vw, 130px) clamp(20px, 5vw, 72px);
}

.section-heading {
  margin-bottom: clamp(36px, 5.5vw, 64px);
}

/* Eyebrow — non-hero */
.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-family: 'Space Mono', monospace;
  font-size: 0.73rem;
  font-weight: 400;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.75rem, 3.8vw, 3.6rem);
  font-weight: 700;
  line-height: 1.06;
  letter-spacing: -0.025em;
  color: var(--text);
  max-width: 820px;
}

h3 {
  font-size: clamp(1rem, 1.7vw, 1.25rem);
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

/* ============================================================
   Card Base
   ============================================================ */
.metric-grid article,
.project-card,
.recognition-item,
.split-grid article,
.publication-list article {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(20px, 3vw, 30px);
  transition:
    border-color var(--tr),
    box-shadow var(--tr),
    transform var(--tr),
    background var(--tr);
  overflow: hidden;
}

/* Shimmer line at top of each card */
.metric-grid article::before,
.project-card::before,
.recognition-item::before,
.split-grid article::before,
.publication-list article::before {
  content: '';
  position: absolute;
  top: 0;
  left: 15%;
  right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}

/* Default hover */
.metric-grid article:hover,
.project-card:hover,
.split-grid article:hover,
.publication-list article:hover {
  border-color: var(--border-accent);
  background: var(--surface-hover);
  box-shadow: 0 0 36px rgba(0, 212, 255, 0.06), 0 20px 44px rgba(0,0,0,0.35);
  transform: translateY(-4px);
}

/* ============================================================
   Metrics — Diagonal Band
   ============================================================ */
.metrics {
  background: transparent;
  z-index: 2;
}

.metrics::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-alt);
  clip-path: polygon(0 3.5%, 100% 0, 100% 96.5%, 0 100%);
  z-index: 0;
}

.metrics > * {
  position: relative;
  z-index: 1;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-grid article {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-grid strong {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: clamp(2rem, 4.2vw, 3.8rem);
  font-weight: 700;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.metric-grid span {
  display: block;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

/* ============================================================
   Work / Timeline
   ============================================================ */
.timeline {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.project-meta {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 0.69rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 14px;
}

.project-card h3 { margin-bottom: 12px; }

.project-card p {
  color: var(--text-muted);
  font-size: 0.91rem;
  line-height: 1.67;
  margin-top: 8px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.tag-list li {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0, 212, 255, 0.2);
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.77rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: border-color var(--tr-fast), background var(--tr-fast);
}

.project-card:hover .tag-list li {
  border-color: rgba(0, 212, 255, 0.35);
  background: rgba(0, 212, 255, 0.14);
}

/* ============================================================
   Contributions — Diagonal Band
   ============================================================ */
.contributions {
  background: transparent;
  z-index: 2;
}

.contributions::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-alt);
  clip-path: polygon(0 3.5%, 100% 0, 100% 96.5%, 0 100%);
  z-index: 0;
}

.contributions > * {
  position: relative;
  z-index: 1;
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.split-grid h3 { margin-bottom: 10px; }

.split-grid p {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.62;
  margin-top: 8px;
}

/* ============================================================
   Recognition
   ============================================================ */
.recognition-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.recognition-item {
  transition:
    border-color var(--tr),
    box-shadow var(--tr),
    transform var(--tr),
    background var(--tr);
}

.recognition-item:hover {
  border-color: var(--border-gold);
  background: var(--gold-dim);
  box-shadow: 0 0 36px rgba(245, 158, 11, 0.08), 0 20px 44px rgba(0,0,0,0.35);
  transform: translateY(-4px);
}

.label {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 0.67rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}

.recognition-item h3 { margin-bottom: 8px; }

.recognition-item p {
  color: var(--text-muted);
  font-size: 0.87rem;
  margin-top: 6px;
  line-height: 1.55;
}

/* ============================================================
   Writing / Publications
   ============================================================ */
.publication-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.publication-list article {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.publication-list h3 {
  font-size: clamp(1rem, 1.6vw, 1.15rem);
}

.publication-list p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

/* ============================================================
   Contact
   ============================================================ */
.contact {
  text-align: center;
  position: relative;
}

.contact::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 50%, rgba(0, 212, 255, 0.035) 0%, transparent 65%);
  pointer-events: none;
}

.contact-inner {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}

.contact .eyebrow {
  display: block;
  margin-bottom: 16px;
}

.contact h2 {
  margin: 0 auto 38px;
  max-width: 640px;
}

.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  position: relative;
  z-index: 1;
  padding: 22px clamp(20px, 5vw, 72px) 38px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-family: 'Space Mono', monospace;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  .metric-grid,
  .recognition-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .hero-content {
    grid-template-columns: 1fr;
  }
  .hero-panel-glow {
    max-width: 520px;
  }
  .hero-scroll-hint { display: none; }
  /* Reduce diagonal on smaller screens */
  .metrics::before,
  .contributions::before {
    clip-path: polygon(0 2%, 100% 0, 100% 98%, 0 100%);
  }
}

@media (max-width: 720px) {
  .site-header {
    position: sticky;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px clamp(16px, 4vw, 32px);
  }
  .nav {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 0.83rem;
  }
  h1 { font-size: clamp(2.2rem, 9vw, 3.4rem); }
  .metric-grid,
  .timeline,
  .recognition-grid,
  .split-grid,
  .publication-list {
    grid-template-columns: 1fr;
  }
  .metrics::before,
  .contributions::before {
    clip-path: none;
    background: var(--bg-alt);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  [data-reveal] {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .hero .eyebrow,
  h1,
  .hero-copy,
  .hero-actions,
  .hero-panel-glow,
  .hero-scroll-hint {
    opacity: 1;
    animation: none;
  }
}
