:root {
  color-scheme: dark;
  --bg: #0d0f12;
  --bg-2: #15181d;
  --panel: rgba(255, 255, 255, 0.055);
  --text: #f5f2ec;
  --muted: #a9aaa7;
  --line: rgba(245, 242, 236, 0.13);
  --primary: #e6b45c;
  --secondary: #61c7c2;
  --accent: #9cc66d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
  --radius: 8px;
  --paper: rgba(245, 242, 236, 0.035);
}

:root.light {
  color-scheme: light;
  --bg: #f5f0e8;
  --bg-2: #ece4d8;
  --panel: rgba(255, 252, 246, 0.76);
  --text: #25231f;
  --muted: #67635b;
  --line: rgba(37, 35, 31, 0.14);
  --shadow: 0 20px 70px rgba(15, 23, 42, 0.12);
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(245, 242, 236, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245, 242, 236, 0.018) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px, 34px 34px, auto;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

body.modal-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

/* Scroll Progress */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
  z-index: 1001;
  will-change: width;
}

/* Space Canvas */
#space-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Floating Orbs - Simplified */
.floating-orbs { position: fixed; inset: 0; pointer-events: none; z-index: 1; overflow: hidden; }

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.15;
  will-change: transform;
}

.orb-1 { width: 300px; height: 300px; background: var(--secondary); top: -150px; right: -150px; animation: float1 25s ease-in-out infinite; }
.orb-2 { width: 250px; height: 250px; background: var(--accent); bottom: -150px; left: -150px; animation: float2 20s ease-in-out infinite; }

@keyframes float1 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-20px, 20px); }
}

@keyframes float2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, -20px); }
}

/* Section Band */
.section-band {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 60px 0 18px;
}

/* Hero */
.hero {
  display: grid;
  min-height: calc(100vh);
  grid-template-columns: minmax(0, 0.98fr) minmax(360px, 0.9fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 4.5rem);
  padding-top: 40px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--primary);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1, h2, h3 { margin: 0; font-family: "Space Grotesk", sans-serif; letter-spacing: 0; }

h1 {
  max-width: 760px;
  font-size: clamp(3rem, 6.2vw, 6.2rem);
  line-height: 0.92;
}

h2 {
  max-width: 780px;
  font-size: clamp(1.85rem, 3.45vw, 3.2rem);
  line-height: 1.06;
}

h3 { font-size: 1.12rem; }

.typing-line {
  min-height: 2rem;
  margin: 22px 0 0;
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
}

#typing-role::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 1.1em;
  margin-left: 5px;
  vertical-align: -0.18em;
  background: var(--accent);
  animation: blink 0.8s steps(2) infinite;
}

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

.hero-text {
  max-width: 650px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.14rem);
  line-height: 1.78;
}

.hero-proof {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.hero-proof span {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--muted);
  padding: 8px 10px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.hero-proof span:hover {
  border-color: var(--secondary);
  transform: translateY(-2px);
}

.hero-actions, .social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

/* Buttons */
.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  font-weight: 750;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  will-change: transform;
}

.button:hover, .filter-button:hover, .project-card:hover, .repo-card:hover {
  transform: translateY(-3px);
}

.button.primary, .filter-button.active {
  border-color: transparent;
  background: var(--text);
  color: var(--bg);
}

.button.primary:hover { box-shadow: 0 8px 25px rgba(245, 242, 236, 0.25); }

.button.secondary {
  background: rgba(156, 198, 109, 0.1);
  border-color: rgba(156, 198, 109, 0.42);
}

.button.secondary:hover { background: rgba(156, 198, 109, 0.2); }

.button.ghost, .filter-button { background: var(--panel); }

.filter-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-button:hover { border-color: var(--secondary); }

/* Ripple */
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0);
  animation: ripple 0.5s linear;
  pointer-events: none;
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

/* Hero Stage */
.hero-stage { perspective: 1000px; }

.webgl-card {
  position: relative;
  min-height: 500px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(230, 180, 92, 0.08), rgba(97, 199, 194, 0.06)), var(--panel);
  box-shadow: var(--shadow);
  animation: cardFloat 8s ease-in-out infinite;
  will-change: transform;
}

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

.webgl-card::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--secondary), var(--accent));
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.webgl-card:hover::before { opacity: 0.5; }

#hero-3d { display: block; width: 100%; height: 500px; }

.scene-label {
  position: absolute;
  right: 18px; bottom: 18px;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(13, 15, 18, 0.7);
  backdrop-filter: blur(14px);
  transition: transform 0.3s ease;
}

.webgl-card:hover .scene-label { transform: translateY(-5px); }

.desk-note {
  position: absolute;
  left: 18px; top: 18px;
  display: grid;
  gap: 6px;
  width: min(230px, calc(100% - 36px));
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(13, 15, 18, 0.72);
  padding: 12px 13px;
  color: var(--muted);
  backdrop-filter: blur(12px);
  transition: transform 0.3s ease;
}

.webgl-card:hover .desk-note { transform: translateY(-5px); }

.desk-note code { color: var(--accent); font-family: "JetBrains Mono", monospace; font-size: 0.78rem; }
.scene-label span { color: var(--muted); font-size: 0.8rem; }

/* About Grid */
.about-grid, .contact-grid {
  display: grid;
  grid-template-columns: 0.86fr 1.14fr;
  gap: 22px;
  align-items: start;
}

.glass-panel, .timeline-mini, .contact-form {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.glass-panel { padding: clamp(22px, 3.2vw, 34px); }
.glass-panel p { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.85; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 26px;
}

.stats-row span {
  display: grid;
  gap: 4px;
  min-height: 82px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  color: var(--muted);
  transition: all 0.2s ease;
}

.stats-row span:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
}

.stats-row strong {
  color: var(--text);
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.8rem;
}

.timeline-mini {
  grid-column: 2;
  display: grid;
  gap: 15px;
  padding: 22px;
}

.timeline-mini div {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  align-items: start;
  transition: transform 0.2s ease;
}

.timeline-mini div:hover { transform: translateX(8px); }

.timeline-mini span, .timeline-dot {
  width: 14px;
  height: 14px;
  margin-top: 5px;
  border-radius: 999px;
  background: radial-gradient(circle, var(--text) 0 16%, var(--accent) 18% 48%, transparent 50%);
  box-shadow: 0 0 18px rgba(156, 198, 109, 0.25);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 18px rgba(156, 198, 109, 0.25); }
  50% { box-shadow: 0 0 25px rgba(156, 198, 109, 0.45); }
}

.timeline-mini p, .timeline p, .repo-card p, .project-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

/* Stack */
.orbit-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 10px;
}

.stack-chip {
  display: flex;
  min-height: 74px;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  transition: all 0.25s ease;
  cursor: pointer;
}

.stack-chip:hover {
  border-color: rgba(230, 180, 92, 0.45);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  transform: translateY(-3px);
}

.stack-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 7px;
  background: rgba(230, 180, 92, 0.09);
  color: var(--primary);
  font-family: "JetBrains Mono", monospace;
  font-weight: 800;
  transition: transform 0.3s ease;
}

.stack-chip:hover .stack-icon { transform: rotateY(180deg); }

/* Filter Bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 18px; }

/* Project Grid */
.project-grid, .repo-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
}

.project-card, .repo-card {
  display: flex;
  min-height: 262px;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(245, 242, 236, 0.055), transparent 72%), var(--panel);
  transition: all 0.25s ease;
  will-change: transform;
  position: relative;
  overflow: hidden;
}

.project-card::before, .repo-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}

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

.project-card { grid-column: span 4; padding: 20px; }
.project-card:nth-child(1), .project-card:nth-child(5) { grid-column: span 5; }
.project-card:nth-child(2), .project-card:nth-child(6) { grid-column: span 3; }

.project-card:hover, .repo-card:hover {
  border-color: rgba(230, 180, 92, 0.45);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.project-card header, .repo-card header { display: grid; gap: 10px; }

.project-card .category, .repo-card .language {
  width: fit-content;
  padding: 6px 9px;
  border: 1px solid rgba(156, 198, 109, 0.35);
  border-radius: 7px;
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.project-card:hover .category { background: rgba(156, 198, 109, 0.15); }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }

.tag-list span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.tag-list span:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }

.project-focus {
  border-left: 2px solid var(--primary);
  padding-left: 10px;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.project-card:hover .project-focus { border-left-color: var(--secondary); padding-left: 14px; }

.card-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* Repo Tools */
.repo-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
  margin: 24px 0 18px;
}

.repo-tools label, .contact-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  outline: none;
  padding: 13px 14px;
  transition: all 0.2s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(97, 199, 194, 0.12);
}

.repo-state { min-height: 24px; margin-bottom: 16px; color: var(--muted); }

.repo-card { grid-column: span 4; min-height: 230px; padding: 18px; }

.repo-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: 0.86rem; }

/* Experience */
.experience { position: relative; }

.timeline {
  position: relative;
  display: grid;
  gap: 18px;
  max-width: 850px;
  margin-top: 28px;
  padding-left: 24px;
}

.timeline::before {
  position: absolute;
  top: 9px; bottom: 9px; left: 6px;
  width: 2px;
  content: "";
  background: linear-gradient(var(--secondary), var(--primary), var(--accent));
}

.timeline article {
  position: relative;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(12px);
  transition: all 0.25s ease;
}

.timeline article:hover {
  transform: translateX(8px);
  border-color: rgba(97, 199, 194, 0.3);
}

.timeline .timeline-dot {
  position: absolute;
  left: -25px; top: 20px;
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.contact-grid { padding-bottom: 80px; }

.social-links a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--panel);
  transition: all 0.2s ease;
}

.social-links a:hover {
  color: var(--secondary);
  border-color: var(--secondary);
  transform: translateY(-3px);
}

.contact-form { padding: 24px; }
.contact-form .button { width: fit-content; }
.form-note { min-height: 22px; margin: 0; color: var(--accent); font-weight: 700; }

/* Footer */
.site-footer {
  display: flex;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 28px;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
  color: var(--muted);
}

.site-footer a:hover { color: var(--primary); transform: translateY(-2px); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 20px;
}

.modal.is-open { display: grid; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.2s ease;
}

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

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 38px);
  animation: modalIn 0.3s ease both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-panel p { color: var(--muted); line-height: 1.7; }

.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--primary);
  color: var(--bg);
  transform: rotate(90deg);
}

/* Reveal Animations */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  transition-delay: var(--delay, 0ms);
}

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

/* Stagger */
.stagger-children > * {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.stagger-children.is-visible > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.is-visible > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.is-visible > *:nth-child(3) { transition-delay: 0.3s; }

.stagger-children.is-visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* Custom Cursor */
.custom-cursor {
  position: fixed;
  width: 20px;
  height: 20px;
  border: 2px solid var(--secondary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
  mix-blend-mode: difference;
  will-change: left, top;
  transition: width 0.2s ease, height 0.2s ease, border-color 0.2s ease;
}

.custom-cursor.hovering {
  width: 40px;
  height: 40px;
  border-color: var(--primary);
}

.custom-cursor-dot {
  position: fixed;
  width: 6px;
  height: 6px;
  background: var(--secondary);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10001;
  transform: translate(-50%, -50%);
}

/* Section Heading */
.section-heading::after {
  content: '';
  display: block;
  margin-top: 10px;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.section-heading:hover::after { width: 100px; }

/* Responsive */
@media (max-width: 900px) {
  .hero, .about-grid, .contact-grid, .repo-tools { grid-template-columns: 1fr; }
  .hero { min-height: auto; padding-top: 40px; }
  .webgl-card, #hero-3d { min-height: 360px; height: 360px; }
  .timeline-mini { grid-column: auto; }
  .project-grid, .repo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-card, .project-card:nth-child(1), .project-card:nth-child(2), .project-card:nth-child(5), .project-card:nth-child(6), .repo-card { grid-column: auto; }
  .custom-cursor, .custom-cursor-dot { display: none; }
}

@media (max-width: 620px) {
  .section-band { width: min(100% - 24px, 1180px); padding-top: 40px; }
  .hero-actions, .card-actions, .social-links { align-items: stretch; flex-direction: column; }
  .button, .social-links a { width: 100%; }
  .stats-row, .project-grid, .repo-grid, .orbit-stack { grid-template-columns: 1fr; }
  .project-card, .repo-card { min-height: auto; }
  .site-footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
