/* ============================================================
   Andrei-Emil Muntean — Portfolio
   Dark · data-driven · WebGL
   ============================================================ */

:root {
  --bg: #05070d;
  --bg-2: #0a0e1a;
  --surface: #0d1220;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e9edf5;
  --muted: #9aa3b8;
  --dim: #67718a;
  --cyan: #22d3ee;
  --violet: #8b5cf6;
  --pink: #e879f9;
  --grad: linear-gradient(90deg, var(--cyan), var(--violet) 55%, var(--pink));
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --nav-h: 72px;
}

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

/* NOTE: no `scroll-behavior: smooth` here — it fights Lenis (double smoothing) */

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(139, 92, 246, 0.45); color: #fff; }

.mono { font-family: var(--font-mono); }
.dim { color: var(--dim); }

.grad-text {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; }

/* ============ Preloader ============ */
#preloader {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.9s var(--ease), visibility 0s 0.9s;
}
body.loaded #preloader { transform: translateY(-100%); visibility: hidden; }
.pre-inner { display: flex; flex-direction: column; gap: 14px; width: min(420px, 80vw); }
.pre-label { font-size: 12px; color: var(--dim); letter-spacing: 0.08em; }
.pre-count { font-size: 64px; font-weight: 500; line-height: 1;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.pre-count::after { content: '%'; font-size: 0.4em; margin-left: 4px; }
.pre-bar { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.pre-bar i { display: block; height: 100%; width: 0%; background: var(--grad); transition: width 0.15s linear; }

/* ============ Cursor ============ */
.cursor-ring, .cursor-dot { display: none; }
@media (pointer: fine) {
  .cursor-ring {
    display: block; position: fixed; z-index: 999; pointer-events: none;
    width: 36px; height: 36px; border: 1.5px solid rgba(139, 92, 246, 0.6);
    border-radius: 50%; top: 0; left: 0;
    transform: translate(-50%, -50%);
    transition: width 0.25s, height 0.25s, border-color 0.25s, opacity 0.25s;
  }
  .cursor-dot {
    display: block; position: fixed; z-index: 999; pointer-events: none;
    width: 5px; height: 5px; background: var(--cyan); border-radius: 50%;
    top: 0; left: 0; transform: translate(-50%, -50%);
  }
  .cursor-ring.is-hover { width: 64px; height: 64px; border-color: var(--cyan); }
  body.cursor-hidden .cursor-ring, body.cursor-hidden .cursor-dot { opacity: 0; }
}

/* ============ WebGL canvas ============ */
#bg-canvas {
  position: fixed; inset: 0; z-index: 0;
  width: 100%; height: 100vh;
  pointer-events: none;
}
main { position: relative; z-index: 1; }
.nav, .mobile-menu { z-index: 10; }

/* ============ Navigation ============ */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--nav-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 56px);
  transition: transform 0.45s var(--ease), background 0.3s, border-color 0.3s;
  border-bottom: 1px solid transparent;
}
.nav.scrolled {
  background: rgba(5, 7, 13, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}
.nav.hidden { transform: translateY(-100%); }
.nav-logo { font-size: 20px; font-weight: 500; letter-spacing: 0.02em; }
.nav-links { display: flex; gap: clamp(18px, 2.5vw, 36px); }
.nav-links a {
  font-size: 14px; color: var(--muted); position: relative;
  transition: color 0.25s;
}
.nav-links a::after {
  content: ''; position: absolute; left: 0; bottom: -5px;
  width: 100%; height: 1.5px; background: var(--grad);
  transform: scaleX(0); transform-origin: right;
  transition: transform 0.35s var(--ease);
}
.nav-links a:hover { color: var(--text); }
.nav-links a:hover::after { transform: scaleX(1); transform-origin: left; }
.nav-cta {
  font-size: 14px; font-weight: 500;
  padding: 10px 22px; border-radius: 100px;
  border: 1px solid var(--line);
  transition: border-color 0.3s, background 0.3s;
}
.nav-cta:hover { border-color: var(--violet); background: rgba(139, 92, 246, 0.12); }

/* Burger */
.burger {
  display: none; background: none; border: 0; cursor: pointer;
  width: 40px; height: 40px; position: relative; z-index: 30;
}
.burger span {
  display: block; width: 24px; height: 2px; background: var(--text);
  margin: 5px auto; transition: transform 0.35s var(--ease), opacity 0.3s;
}
body.menu-open .burger span:nth-child(1) { transform: translateY(3.5px) rotate(45deg); }
body.menu-open .burger span:nth-child(2) { transform: translateY(-3.5px) rotate(-45deg); }

/* Mobile menu */
.mobile-menu {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(5, 7, 13, 0.96);
  backdrop-filter: blur(20px);
  display: flex; flex-direction: column; justify-content: center; gap: 8vh;
  padding: 0 clamp(24px, 8vw, 64px);
  opacity: 0; visibility: hidden;
  transition: opacity 0.4s var(--ease), visibility 0s 0.4s;
}
body.menu-open .mobile-menu { opacity: 1; visibility: visible; transition-delay: 0s; }
.mobile-links { display: flex; flex-direction: column; gap: 6px; }
.mobile-links a {
  font-family: var(--font-display);
  font-size: clamp(34px, 9vw, 56px); font-weight: 600;
  display: flex; align-items: baseline; gap: 18px;
  color: var(--muted); transition: color 0.25s;
}
.mobile-links a:hover { color: var(--text); }
.mm-idx { font-size: 13px; color: var(--violet); }
.mobile-menu-foot { display: flex; gap: 28px; font-size: 13px; color: var(--dim); }
.mobile-menu-foot a:hover { color: var(--cyan); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-body); font-size: 15px; font-weight: 500;
  padding: 15px 34px; border-radius: 100px;
  transition: transform 0.3s var(--ease), box-shadow 0.3s, background 0.3s, border-color 0.3s;
  will-change: transform;
}
.btn-primary {
  background: var(--grad); color: #06070c;
  box-shadow: 0 0 0 rgba(139, 92, 246, 0);
}
.btn-primary:hover { box-shadow: 0 8px 40px rgba(139, 92, 246, 0.45); }
.btn-ghost { border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--cyan); background: rgba(34, 211, 238, 0.08); }

/* ============ Hero ============ */
.hero {
  min-height: 100svh;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--nav-h) + 4vh) clamp(20px, 6vw, 96px) 12vh;
  position: relative;
}
.hero-eyebrow {
  font-size: clamp(12px, 1.4vw, 15px); color: var(--cyan);
  letter-spacing: 0.12em; margin-bottom: 22px;
  opacity: 0; animation: fadeUp 0.8s var(--ease) 0.15s forwards;
}
body:not(.loaded) .hero-eyebrow { animation-play-state: paused; }
.hero-title {
  font-family: var(--font-display);
  font-size: clamp(52px, 11.5vw, 152px);
  font-weight: 700; line-height: 0.98; letter-spacing: -0.03em;
  text-transform: uppercase;
}
.hero-title .line { display: block; overflow: hidden; padding-bottom: 0.06em; }
.hero-title .line span {
  display: block; transform: translateY(115%);
}
body.loaded .hero-title .line span { animation: riseUp 1s var(--ease) forwards; }
body.loaded .hero-title .line:nth-child(2) span { animation-delay: 0.12s; }
.hero-title .outline span {
  color: transparent;
  -webkit-text-stroke: 1.5px rgba(233, 237, 245, 0.85);
}
.hero-sub {
  margin-top: 34px; max-width: 560px;
  font-size: clamp(16px, 2vw, 19px); color: var(--muted);
  opacity: 0;
}
body.loaded .hero-sub { animation: fadeUp 0.9s var(--ease) 0.5s forwards; }
.hero-cta { display: flex; gap: 16px; margin-top: 42px; flex-wrap: wrap; opacity: 0; }
body.loaded .hero-cta { animation: fadeUp 0.9s var(--ease) 0.65s forwards; }
.hero-hud {
  position: absolute; left: clamp(20px, 6vw, 96px); right: clamp(20px, 6vw, 96px); bottom: 30px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; letter-spacing: 0.1em; color: var(--dim);
  opacity: 0;
}
body.loaded .hero-hud { animation: fadeUp 1s var(--ease) 0.9s forwards; }
.hud-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: #34d399; display: inline-block;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.6);
  animation: pulse 2.2s infinite;
}
.hud-scroll { animation: bob 2.4s ease-in-out infinite; }

@keyframes riseUp { to { transform: translateY(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }

/* ============ Marquee ============ */
.marquee {
  overflow: hidden;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 18px 0;
  background: rgba(10, 14, 26, 0.5);
}
.marquee-track {
  display: flex; align-items: center; gap: 44px;
  width: max-content;
  animation: marquee 32s linear infinite;
  font-size: 13px; letter-spacing: 0.22em; color: var(--muted);
}
.marquee-track span { white-space: nowrap; }
.marquee-track i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--grad); flex-shrink: 0;
}
@keyframes marquee { to { transform: translateX(-50%); } }

/* ============ Sections ============ */
.section { padding: clamp(90px, 14vh, 160px) clamp(20px, 6vw, 96px); max-width: 1380px; margin: 0 auto; }
.section-head { margin-bottom: clamp(48px, 7vh, 80px); }
.sec-index {
  display: block; font-size: 12.5px; letter-spacing: 0.22em;
  color: var(--cyan); margin-bottom: 18px;
}
.sec-title {
  font-family: var(--font-display);
  font-size: clamp(38px, 6.5vw, 76px);
  font-weight: 700; line-height: 1.04; letter-spacing: -0.02em;
}
.sec-title em { font-style: normal; }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(44px); transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); }
.reveal.in { opacity: 1; transform: translateY(0); }

/* ============ About ============ */
.about-grid {
  display: grid; grid-template-columns: minmax(300px, 440px) 1fr;
  gap: clamp(40px, 6vw, 90px); align-items: start;
}
.about-media { position: relative; }
.portrait-wrap {
  position: relative; border-radius: 22px; overflow: hidden;
  border: 1px solid var(--line);
}
.portrait-wrap img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  filter: grayscale(35%) contrast(1.05);
  transition: filter 0.6s, transform 0.8s var(--ease);
}
.portrait-wrap:hover img { filter: grayscale(0%); transform: scale(1.03); }
.portrait-wrap::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(200deg, rgba(34, 211, 238, 0.16), transparent 45%, rgba(139, 92, 246, 0.2));
  pointer-events: none;
}
.portrait-ring {
  position: absolute; inset: 0; border-radius: 22px;
  border: 1px solid transparent;
  background: var(--grad) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0.55; pointer-events: none;
}

.about-copy p { color: var(--muted); font-size: clamp(16px, 1.6vw, 18px); margin-bottom: 22px; max-width: 620px; }
.about-copy strong { color: var(--text); font-weight: 600; }
.stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 18px; margin-top: 44px;
  border-top: 1px solid var(--line); padding-top: 34px;
}
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-num {
  font-family: var(--font-display); font-size: clamp(30px, 3.6vw, 46px); font-weight: 700;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stat-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }

/* ============ Experience ============ */
.timeline { display: flex; flex-direction: column; }
.tl-item {
  display: grid; grid-template-columns: 210px 1fr;
  gap: clamp(20px, 4vw, 60px);
  padding: 40px 0;
  border-top: 1px solid var(--line);
  position: relative;
}
.tl-item:last-of-type { border-bottom: 1px solid var(--line); }
.tl-item::before {
  content: ''; position: absolute; left: -18px; top: 49px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--grad);
  box-shadow: 0 0 14px rgba(139, 92, 246, 0.8);
}
.tl-period { font-size: 12.5px; letter-spacing: 0.1em; color: var(--dim); padding-top: 6px; }
.tl-role { font-family: var(--font-display); font-size: clamp(21px, 2.6vw, 28px); font-weight: 600; letter-spacing: -0.01em; }
.tl-company { font-size: 12.5px; color: var(--cyan); margin: 6px 0 16px; letter-spacing: 0.06em; }
.tl-points li {
  color: var(--muted); font-size: 15.5px;
  padding-left: 22px; position: relative; margin-bottom: 9px;
}
.tl-points li::before {
  content: '›'; position: absolute; left: 4px; color: var(--violet); font-weight: 600;
}
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.tags span {
  font-size: 11px; letter-spacing: 0.06em; color: var(--muted);
  border: 1px solid var(--line); padding: 4px 12px; border-radius: 100px;
  transition: border-color 0.25s, color 0.25s;
}
.tags span:hover { border-color: var(--cyan); color: var(--cyan); }

.edu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 56px; }
.edu-card {
  border: 1px solid var(--line); border-radius: 18px;
  padding: 28px 30px; background: rgba(13, 18, 32, 0.55);
  transition: border-color 0.3s, transform 0.4s var(--ease);
}
.edu-card:hover { border-color: rgba(139, 92, 246, 0.5); transform: translateY(-4px); }
.edu-tag { display: block; font-size: 11px; color: var(--cyan); letter-spacing: 0.16em; margin-bottom: 12px; }
.edu-card h3 { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin-bottom: 8px; }
.edu-card p { color: var(--muted); font-size: 14.5px; }

/* ============ Projects ============ */
.projects-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.project-card {
  position: relative; display: block;
  border: 1px solid var(--line); border-radius: 20px;
  padding: 34px 32px 30px;
  background: rgba(13, 18, 32, 0.55);
  overflow: hidden;
  transition: border-color 0.35s, transform 0.5s var(--ease);
  will-change: transform;
}
.project-card::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(520px circle at var(--mx, 50%) var(--my, 50%),
    rgba(139, 92, 246, 0.14), rgba(34, 211, 238, 0.06) 40%, transparent 65%);
  opacity: 0; transition: opacity 0.4s; pointer-events: none;
}
.project-card:hover::before { opacity: 1; }
.project-card:hover { border-color: rgba(139, 92, 246, 0.55); }
.pc-index {
  display: block; font-size: 12px; letter-spacing: 0.2em; color: var(--dim); margin-bottom: 22px;
}
.pc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 12px; }
.project-card h3 {
  font-family: var(--font-display); font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 600; line-height: 1.25; letter-spacing: -0.01em;
}
.pc-arrow {
  font-size: 22px; color: var(--dim);
  transition: transform 0.35s var(--ease), color 0.3s;
  flex-shrink: 0;
}
.project-card:hover .pc-arrow, .contact-email:hover .pc-arrow { color: var(--cyan); transform: translate(4px, -4px); }
.project-card p { color: var(--muted); font-size: 14.5px; margin-bottom: 20px; }
.projects-more { margin-top: 40px; display: flex; justify-content: center; }

/* ============ Skills ============ */
.skills-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.skill-group {
  border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 26px 24px; background: rgba(13, 18, 32, 0.55);
  transition: border-color 0.3s;
}
.skill-group:hover { border-color: rgba(34, 211, 238, 0.45); }
.skill-group h3 { font-size: 12px; font-weight: 500; letter-spacing: 0.16em; color: var(--cyan); margin-bottom: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chips span {
  font-size: 13px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 100px;
  padding: 7px 15px;
  transition: color 0.25s, border-color 0.25s, transform 0.25s;
}
.chips span:hover { color: var(--text); border-color: var(--violet); transform: translateY(-2px); }
.certs { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 40px; }
.cert {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 12.5px; letter-spacing: 0.06em; color: var(--muted);
  border: 1px solid var(--line); border-radius: 100px; padding: 10px 20px;
}

/* ============ Contact ============ */
.contact { text-align: left; }
.contact-lede { color: var(--muted); font-size: clamp(16px, 1.8vw, 19px); max-width: 520px; margin-bottom: 40px; }
.contact-email {
  display: inline-flex; align-items: baseline; gap: 16px;
  font-family: var(--font-display);
  font-size: clamp(20px, 3.6vw, 44px); font-weight: 600; letter-spacing: -0.01em;
  border-bottom: 2px solid var(--line);
  padding-bottom: 10px; margin-bottom: 48px;
  transition: border-color 0.35s;
  word-break: break-all;
}
.contact-email:hover { border-color: var(--violet); }
.contact-actions { display: flex; gap: 16px; flex-wrap: wrap; }

/* ============ Footer ============ */
.footer {
  display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 30px clamp(20px, 6vw, 96px) 36px;
  border-top: 1px solid var(--line);
  font-size: 12px; letter-spacing: 0.08em; color: var(--muted);
  max-width: 1380px; margin: 0 auto;
}

/* ============ Responsive ============ */
@media (max-width: 1024px) {
  .skills-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .nav-links, .nav-cta { display: none; }
  .burger { display: block; }
  .about-grid { grid-template-columns: 1fr; }
  .about-media { max-width: 440px; }
  .projects-grid { grid-template-columns: 1fr; }
  .tl-item { grid-template-columns: 1fr; gap: 8px; padding: 32px 0; }
  .tl-item::before { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .edu-grid { grid-template-columns: 1fr; }
  .hero-hud .hud-status { display: none; }
}
@media (max-width: 560px) {
  .skills-grid { grid-template-columns: 1fr; }
  .hero { padding-bottom: 16vh; }
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .reveal { opacity: 1; transform: none; }
  .hero-title .line span { transform: none; }
  .hero-eyebrow, .hero-sub, .hero-cta, .hero-hud { opacity: 1; }
  #bg-canvas { display: none; }
}
