/* ==========================================================================
   Balaji M - Portfolio
   Structure: 1 Tokens · 2 Base · 3 Layout · 4 Components · 5 Sections
              6 Motion helpers · 7 Responsive · 8 Reduced motion · 9 Print
   Naming: BEM-like (block__element--modifier)
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
@property --angle { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

:root {
  /* Fonts */
  --font-head: 'Sora', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-body: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

  /* Fluid type scale */
  --fs-xs: 0.8125rem;
  --fs-sm: 0.9375rem;
  --fs-base: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);
  --fs-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.375rem);
  --fs-xl: clamp(1.5rem, 1.2rem + 1.4vw, 2.25rem);
  --fs-2xl: clamp(1.9rem, 1.3rem + 3vw, 3.5rem);
  --fs-hero: clamp(3rem, 0.5rem + 17vw, 6.25rem);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 5rem;
  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2rem);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  /* Layout */
  --container: 1180px;
  --nav-h: 68px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Accent colours that never change (glows, shapes, borders) */
  --cyan-raw: #22d3ee;
  --violet-raw: #a78bfa;
  --pink-raw: #f472b6;
  --lime-raw: #a3e635;
  --ok-raw: #22c55e;
}

/* Dark theme (default) */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #000000;
  --bg-elev: #0b0b0e;
  --bg-card: #0e0e12;
  --text: #f5f5f5;
  --text-muted: #a1a1aa;
  --border: #26262c;
  --nav-bg: rgba(0, 0, 0, 0.6);
  --nav-bg-solid: rgba(0, 0, 0, 0.96);
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  --glow-alpha: 0.28;
  /* Text-safe accents (AA on the background) */
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --pink: #f472b6;
  --lime: #a3e635;
}

/* Light theme */
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-elev: #f6f6f7;
  --bg-card: #ffffff;
  --text: #0a0a0a;
  --text-muted: #52525b;
  --border: #e0e0e5;
  --nav-bg: rgba(255, 255, 255, 0.7);
  --nav-bg-solid: rgba(255, 255, 255, 0.97);
  --shadow: 0 20px 50px rgba(10, 10, 20, 0.12);
  --glow-alpha: 0.2;
  --cyan: #0e7490;
  --violet: #6d28d9;
  --pink: #be185d;
  --lime: #4d7c0f;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 8px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4 { margin: 0; font-family: var(--font-head); line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0 0 var(--space-4); }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }

::selection { background: var(--cyan-raw); color: #000; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 8px; left: 8px; z-index: 10000;
  padding: 0.7rem 1.1rem; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); font-weight: 700;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

.icon {
  width: 1.25em; height: 1.25em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- 3. Layout ---------- */
.container { width: min(calc(100% - 2 * var(--gutter)), var(--container)); margin-inline: auto; }

.section {
  position: relative;
  padding-block: clamp(4.5rem, 3rem + 7vw, 8.5rem);
  overflow: hidden; /* fallback */
  overflow: clip;
}

.section__head { margin-bottom: var(--space-7); max-width: 46rem; }
.section__title { font-size: var(--fs-2xl); font-weight: 800; }
.section__lead { margin-top: var(--space-4); color: var(--text-muted); }

/* ---------- 404 page ---------- */
.not-found { min-height: 100svh; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding-block: var(--space-7); }
.not-found__actions { width: 100%; display: flex; justify-content: flex-end; margin-bottom: var(--space-7); }
.not-found .eyebrow { color: var(--cyan); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.not-found h1 { margin-bottom: var(--space-4); font-size: var(--fs-2xl); }
.not-found > p:not(.eyebrow) { max-width: 42rem; color: var(--text-muted); }
.not-found__links { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }

.eyebrow {
  margin-bottom: var(--space-3);
  font-family: var(--font-head); font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--cyan);
}

.grad {
  background: linear-gradient(90deg, var(--cyan), var(--violet) 55%, var(--pink));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

.section__orb {
  position: absolute; z-index: 0; width: min(70vw, 620px); aspect-ratio: 1; pointer-events: none;
  border-radius: 50%; opacity: var(--glow-alpha); will-change: transform;
}
.section__orb--violet { top: 6%; right: -22%; background: radial-gradient(circle, var(--violet-raw), transparent 65%); }
.section__orb--cyan { top: 10%; left: -24%; background: radial-gradient(circle, var(--cyan-raw), transparent 65%); }
.section__orb--pink { bottom: 8%; right: -22%; background: radial-gradient(circle, var(--pink-raw), transparent 65%); }
.section > .container { position: relative; z-index: 1; }

/* ---------- 4. Components ---------- */

/* Loader */
.loader { display: none; }
.js .loader {
  position: fixed; inset: 0; z-index: 9000; display: grid; place-content: center; justify-items: center; gap: var(--space-5);
  background: var(--bg);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
.js.is-loaded .loader { opacity: 0; visibility: hidden; }
.loader__mark { display: flex; gap: 0.1em; font-family: var(--font-head); font-weight: 800; font-size: clamp(3rem, 12vw, 5.5rem); }
.loader__mark span { display: inline-block; opacity: 0; transform: translateY(30px) rotateX(-70deg); animation: loader-in 0.8s var(--ease) forwards; }
.loader__mark span:first-child { -webkit-text-stroke: 2px var(--text); color: transparent; }
.loader__mark span:last-child { animation-delay: 0.18s; color: var(--cyan); }
.loader__bar { width: 140px; height: 3px; border-radius: 3px; background: var(--border); overflow: hidden; position: relative; }
.loader__bar::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, var(--cyan-raw), var(--violet-raw), var(--pink-raw)); transform: translateX(-100%); animation: loader-bar 1.3s ease-in-out forwards; }
@keyframes loader-in { to { opacity: 1; transform: none; } }
@keyframes loader-bar { to { transform: none; } }

/* Scroll progress */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 9500; pointer-events: none; }
.progress__bar {
  height: 100%; transform: scaleX(0); transform-origin: left;
  background: linear-gradient(90deg, var(--cyan-raw), var(--violet-raw), var(--pink-raw));
}

/* Custom cursor (desktop only; JS adds .has-cursor) */
.cursor-dot, .cursor-ring { display: none; position: fixed; top: 0; left: 0; z-index: 9800; pointer-events: none; opacity: 0; transition: opacity 0.2s ease; }
.has-cursor .cursor-dot, .has-cursor .cursor-ring { display: block; }
.has-cursor .cursor-dot.is-on, .has-cursor .cursor-ring.is-on { opacity: 1; }
.cursor-dot { width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%; background: var(--cyan-raw); }
.cursor-ring { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
.cursor-ring::before {
  content: ''; position: absolute; inset: 0; border-radius: 50%;
  border: 1.5px solid var(--text); opacity: 0.55;
  transition: transform 0.25s var(--ease), background-color 0.25s ease;
}
.cursor-ring.is-hover::before { transform: scale(1.6); background: color-mix(in srgb, var(--cyan-raw) 18%, transparent); }
.has-cursor body, .has-cursor a, .has-cursor button, .has-cursor label, .has-cursor .project, .has-cursor .sphere { cursor: none; }
.has-cursor input, .has-cursor textarea { cursor: text; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
  min-height: 48px; padding: 0.75rem 1.5rem;
  border: 1px solid transparent; border-radius: var(--radius-pill);
  font-family: var(--font-head); font-size: var(--fs-sm); font-weight: 600; line-height: 1.2; text-align: center;
  transform: translate(var(--mx, 0px), var(--my, 0px));
  transition: transform 0.25s var(--ease), box-shadow 0.25s ease, background-color 0.25s ease, border-color 0.25s ease;
}
.btn--primary { background: var(--text); color: var(--bg); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--ghost:hover { border-color: var(--cyan-raw); }
.btn--primary:hover { box-shadow: 0 0 0 4px color-mix(in srgb, var(--cyan-raw) 30%, transparent), 0 10px 40px color-mix(in srgb, var(--cyan-raw) 35%, transparent); }
.btn:active { transform: translate(var(--mx, 0px), var(--my, 0px)) scale(0.97); }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 1px solid var(--border); border-radius: 50%; background: transparent; color: var(--text);
  transition: border-color 0.25s ease, background-color 0.25s ease;
}
.icon-btn:hover { border-color: var(--cyan-raw); }

/* Navbar */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 900; height: var(--nav-h);
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(16px) saturate(140%); backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease;
}
.nav.is-scrolled { border-bottom-color: var(--border); }
.nav__inner { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.nav__logo { font-family: var(--font-head); font-weight: 800; font-size: 1.15rem; letter-spacing: 0.04em; }
.nav__logo span { color: var(--cyan); }
.nav__actions { display: flex; align-items: center; gap: var(--space-2); }

.nav__menu {
  position: fixed; top: var(--nav-h); left: 0; right: 0;
  padding: var(--space-5) var(--gutter) var(--space-6);
  background: var(--nav-bg-solid); border-bottom: 1px solid var(--border);
  max-height: calc(100vh - var(--nav-h)); max-height: calc(100dvh - var(--nav-h)); overflow-y: auto;
  visibility: hidden; opacity: 0; transform: translateY(-12px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease), visibility 0.3s;
}
.nav__menu.is-open { visibility: visible; opacity: 1; transform: none; }
.nav__list { display: grid; gap: var(--space-1); }
.nav__link {
  display: block; padding: 0.85rem 0.25rem; font-family: var(--font-head); font-size: var(--fs-lg); font-weight: 600;
  color: var(--text-muted); border-bottom: 1px solid var(--border); transition: color 0.2s ease;
}
.nav__link:hover, .nav__link[aria-current='true'] { color: var(--text); }
.nav__link[aria-current='true'] { border-bottom-color: var(--cyan-raw); }

.nav__toggle .nav__bars { display: grid; gap: 5px; width: 20px; }
.nav__bars span { display: block; height: 2px; border-radius: 2px; background: currentColor; transition: transform 0.3s var(--ease), opacity 0.2s ease; }
.nav__toggle[aria-expanded='true'] .nav__bars span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__toggle[aria-expanded='true'] .nav__bars span:nth-child(2) { opacity: 0; }
.nav__toggle[aria-expanded='true'] .nav__bars span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.nav-open body { overflow: hidden; }

/* Theme toggle: show the icon for the mode you would switch to */
.theme-toggle__moon { display: none; }
:root[data-theme='dark'] .theme-toggle__sun { display: block; }
:root[data-theme='dark'] .theme-toggle__moon { display: none; }
:root[data-theme='light'] .theme-toggle__sun { display: none; }
:root[data-theme='light'] .theme-toggle__moon { display: block; }

/* Status / badge */
.status, .badge {
  display: inline-flex; align-items: center; gap: 0.6rem; margin-bottom: var(--space-5);
  padding: 0.45rem 1rem; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 500; line-height: 1.3;
  border: 1px solid color-mix(in srgb, var(--ok-raw) 50%, transparent);
  background: color-mix(in srgb, var(--ok-raw) 12%, transparent);
}
.status__dot, .badge__dot { position: relative; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--ok-raw); }
.status__dot::after, .badge__dot::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--ok-raw); animation: pulse 2s ease-out infinite;
}
@keyframes pulse { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(3); opacity: 0; } }

/* Reveal on scroll (only hidden when JS is running) */
.js .reveal { opacity: 0; transform: perspective(900px) translateY(36px) rotateX(10deg); transform-origin: 50% 100%; }
.js .reveal.is-visible {
  opacity: 1; transform: none;
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
  transition-delay: calc(var(--i, 0) * 90ms);
}

/* ---------- 5. Sections ---------- */

/* Hero */
.hero {
  position: relative; isolation: isolate; display: grid; align-items: center;
  min-height: 100vh; min-height: 100svh;
  padding: calc(var(--nav-h) + var(--space-6)) 0 var(--space-8);
  overflow: hidden;
}
.hero__bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.hero__glow { position: absolute; width: min(80vw, 640px); aspect-ratio: 1; border-radius: 50%; opacity: var(--glow-alpha); will-change: transform; }
.hero__glow--cyan { top: -12%; left: -18%; background: radial-gradient(circle, var(--cyan-raw), transparent 65%); }
.hero__glow--violet { top: 30%; right: -20%; background: radial-gradient(circle, var(--violet-raw), transparent 65%); }
.hero__glow--pink { bottom: -20%; left: 25%; background: radial-gradient(circle, var(--pink-raw), transparent 65%); }
.hero__canvas { position: absolute; inset: 0; z-index: 1; display: block; width: 100%; height: 100%; pointer-events: none; }

.hero__inner { position: relative; z-index: 2; display: grid; gap: var(--space-7); align-items: center; }
.hero__content { min-width: 0; }

.hero__title { font-size: var(--fs-hero); font-weight: 800; letter-spacing: -0.045em; line-height: 1; margin-bottom: var(--space-5); text-shadow: 0 2px 24px color-mix(in srgb, var(--bg) 45%, transparent); }
.hero__first { display: inline-block; color: var(--text); -webkit-text-stroke: 0; }
.hero__last {
  display: inline-block; width: fit-content; margin-left: 0.08em;
  background: linear-gradient(90deg, var(--cyan), var(--violet) 55%, var(--pink));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
@supports not (-webkit-text-stroke: 1px red) { .hero__first { color: var(--text); } }

.hero__role { display: flex; align-items: center; min-height: 2.8em; margin-bottom: var(--space-3); font-family: var(--font-head); font-size: var(--fs-lg); font-weight: 600; color: var(--cyan); }
.hero__typed { overflow-wrap: anywhere; }
.hero__caret { flex: none; width: 2px; height: 1.2em; margin-left: 4px; background: var(--cyan); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.hero__tagline { max-width: 36rem; color: var(--text-muted); margin-bottom: var(--space-6); }
.hero__cta { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Hero intro animation (after loader) */
.js .hero-anim { opacity: 0; transform: translateY(26px); }
.js.is-loaded .hero-anim {
  opacity: 1; transform: none;
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: calc(var(--i, 0) * 110ms + 150ms);
}

/* Hero photo: 3D tilting frame */
.hero__visual { justify-self: center; width: min(100%, 340px); }
.photo { perspective: 1000px; animation: float 6s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-10px); } }
.photo__tilt {
  position: relative; aspect-ratio: 4 / 5; transform-style: preserve-3d;
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transition: transform 0.2s ease-out;
}
.photo__layer { position: absolute; inset: 0; border-radius: var(--radius-lg); border: 2px solid; }
.photo__layer--pink { border-color: var(--pink-raw); transform: translate3d(20px, 20px, -60px); box-shadow: 0 0 40px color-mix(in srgb, var(--pink-raw) 30%, transparent); }
.photo__layer--cyan { border-color: var(--cyan-raw); transform: translate3d(10px, 10px, -30px); box-shadow: 0 0 40px color-mix(in srgb, var(--cyan-raw) 30%, transparent); }
.photo__frame { position: absolute; inset: 0; overflow: hidden; border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--bg-elev); box-shadow: var(--shadow); }
.photo__frame img { width: 100%; height: 100%; object-fit: cover; }
.photo__chip {
  position: absolute; left: -6%; bottom: 8%; transform: translateZ(70px);
  padding: 0.5rem 0.9rem; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
}

.hero__scroll { position: absolute; left: 50%; bottom: 1.25rem; width: 28px; height: 44px; margin-left: -14px; border: 1.5px solid var(--border); border-radius: 14px; }
.hero__scroll-line { position: absolute; left: 50%; top: 8px; width: 3px; height: 8px; margin-left: -1.5px; border-radius: 2px; background: var(--cyan); animation: scroll-cue 1.8s ease-in-out infinite; }
@keyframes scroll-cue { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(16px); opacity: 0; } }

/* Fallback when WebGL is not available */
.hero__shapes { display: none; position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.hero--fallback .hero__canvas { display: none; }
.hero--fallback .hero__shapes { display: block; }
.shape { position: absolute; display: block; opacity: 0.7; animation: drift 9s ease-in-out infinite; }
.shape--ring { top: 11%; right: 6%; width: 72px; height: 72px; border: 2px solid var(--cyan-raw); border-radius: 50%; }
.shape--square { bottom: 22%; left: 5%; width: 56px; height: 56px; border: 2px solid var(--pink-raw); border-radius: 12px; animation-delay: -3s; transform: rotate(18deg); }
.shape--diamond { top: 42%; right: -22px; width: 70px; height: 70px; border: 2px solid var(--violet-raw); transform: rotate(45deg); animation-delay: -5s; }
.shape--dots { bottom: 6%; right: 10%; width: 100px; height: 100px; background-image: radial-gradient(var(--lime-raw) 2px, transparent 2px); background-size: 20px 20px; animation-delay: -7s; }
@media (min-width: 900px) {
  .shape--ring { top: 16%; right: auto; left: 3%; width: 110px; height: 110px; }
  .shape--square { bottom: auto; top: 62%; left: 46%; width: 70px; height: 70px; }
  .shape--diamond { top: 14%; right: 6%; width: 84px; height: 84px; }
  .shape--dots { bottom: 10%; right: 26%; width: 120px; height: 120px; }
}
@keyframes drift { 50% { translate: 0 -22px; } }

/* About */
.about__grid { display: grid; gap: var(--space-6); margin-bottom: var(--space-7); }
.about__text { font-size: var(--fs-lg); line-height: 1.7; }
.about__text p:last-child { margin-bottom: 0; color: var(--text-muted); font-size: var(--fs-base); }
.facts { margin: 0; padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card); }
.facts__row { display: grid; gap: 2px; padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.facts__row:first-child { padding-top: 0; }
.facts__row:last-child { padding-bottom: 0; border-bottom: 0; }
.facts dt { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.facts dd { margin: 0; font-weight: 500; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.stat { padding: var(--space-5) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card); text-align: center; }
.stat__num { display: block; font-family: var(--font-head); font-size: var(--fs-2xl); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; min-height: 1em; }
.stat:nth-child(1) .stat__num { color: var(--cyan); }
.stat:nth-child(2) .stat__num { color: var(--violet); }
.stat:nth-child(3) .stat__num { color: var(--pink); }
.stat:nth-child(4) .stat__num { color: var(--lime); }
.stat__label { display: block; margin-top: var(--space-3); font-size: var(--fs-sm); color: var(--text-muted); line-height: 1.4; }

/* Skills: sphere */
.sphere-wrap { margin-bottom: var(--space-7); text-align: center; }
.sphere {
  position: relative; width: min(100%, 460px); aspect-ratio: 1; margin-inline: auto;
  border-radius: 50%; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab;
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--violet-raw) 14%, transparent), transparent 68%);
}
.sphere.is-dragging { cursor: grabbing; }
.sphere__tag {
  position: absolute; top: 50%; left: 50%; padding: 0.3rem 0.8rem; border-radius: var(--radius-pill);
  border: 1px solid var(--tag, var(--border)); background: var(--bg-card);
  font-family: var(--font-head); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; will-change: transform, opacity;
}
.sphere__tag--0 { --tag: var(--cyan-raw); }
.sphere__tag--1 { --tag: var(--violet-raw); }
.sphere__tag--2 { --tag: var(--pink-raw); }
.sphere__tag--3 { --tag: var(--lime-raw); }
.sphere__hint { margin: var(--space-3) 0 0; font-size: var(--fs-xs); color: var(--text-muted); }

.skills__groups { display: grid; gap: var(--space-5); }
.skill-group { padding: var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card); }
.skill-group__title { margin-bottom: var(--space-4); font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chips li {
  padding: 0.4rem 0.9rem; border: 1px solid var(--border); border-radius: var(--radius-pill);
  font-size: var(--fs-sm); background: var(--bg-elev);
  transition: transform 0.25s var(--ease), border-color 0.25s ease, box-shadow 0.25s ease;
}
.chips li:hover { transform: translateY(-4px); border-color: var(--cyan-raw); box-shadow: 0 8px 22px color-mix(in srgb, var(--cyan-raw) 22%, transparent); }

/* Projects */
.projects { display: grid; gap: var(--space-5); }
.project {
  --accent: var(--cyan); --accent-raw: var(--cyan-raw);
  position: relative; display: flex; flex-direction: column; align-items: flex-start; height: 100%;
  padding: var(--space-6); border: 1px solid transparent; border-radius: var(--radius-lg);
  background:
    linear-gradient(var(--bg-card), var(--bg-card)) padding-box,
    conic-gradient(from var(--angle), var(--border) 0%, var(--accent-raw) 16%, var(--border) 34%, var(--border) 100%) border-box;
  animation: border-spin 6s linear infinite;
  transform-style: preserve-3d;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform 0.25s ease-out, box-shadow 0.3s ease;
}
.project--cyan { --accent: var(--cyan); --accent-raw: var(--cyan-raw); }
.project--pink { --accent: var(--pink); --accent-raw: var(--pink-raw); }
.project--lime { --accent: var(--lime); --accent-raw: var(--lime-raw); }
.project--violet { --accent: var(--violet); --accent-raw: var(--violet-raw); }
@keyframes border-spin { to { --angle: 360deg; } }
.project:hover, .project:focus-visible { box-shadow: 0 24px 60px color-mix(in srgb, var(--accent-raw) 22%, transparent); }
.project:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.project::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: 0; transition: opacity 0.3s ease;
  background: radial-gradient(420px circle at var(--mx-p, 50%) var(--my-p, 50%), color-mix(in srgb, var(--accent-raw) 16%, transparent), transparent 60%);
}
.project:hover::after { opacity: 1; }

.projects > li { display: block; }
.project__tag {
  transform: translateZ(30px); margin-bottom: var(--space-4); padding: 0.25rem 0.8rem; border-radius: var(--radius-pill);
  border: 1px solid var(--accent-raw); color: var(--accent); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.project__title { transform: translateZ(50px); margin-bottom: var(--space-3); font-size: var(--fs-xl); font-weight: 800; }
.project__text { transform: translateZ(25px); flex: 1; color: var(--text-muted); }
.project__domain { transform: translateZ(25px); margin-bottom: var(--space-5); font-family: var(--font-head); font-size: var(--fs-sm); font-weight: 600; color: var(--accent); overflow-wrap: anywhere; }
.project .project__btn { transform: translate3d(var(--mx, 0px), var(--my, 0px), 60px); position: relative; z-index: 1; }
.project .project__btn:active { transform: translate3d(var(--mx, 0px), var(--my, 0px), 60px) scale(0.97); }

/* Resume timeline */
.resume__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-bottom: var(--space-7); }
.timeline { position: relative; padding-left: 2.25rem; max-width: 52rem; }
.timeline::before { content: ''; position: absolute; top: 0; bottom: 0; left: 7px; width: 2px; background: var(--border); border-radius: 2px; }
.timeline__progress {
  position: absolute; top: 0; bottom: 0; left: 7px; width: 2px; border-radius: 2px; transform-origin: top; transform: scaleY(var(--p, 1));
  background: linear-gradient(var(--cyan-raw), var(--violet-raw) 60%, var(--pink-raw)); box-shadow: 0 0 12px color-mix(in srgb, var(--cyan-raw) 60%, transparent);
}
.timeline__group { margin: var(--space-6) 0 var(--space-4); font-size: var(--fs-sm); font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.timeline__group:first-of-type { margin-top: 0; }
.timeline__group--cyan { color: var(--cyan); }
.timeline__group--lime { color: var(--lime); }
.timeline__group--violet { color: var(--violet); }
.timeline__list { display: grid; gap: var(--space-4); }
.timeline__item { --dot: var(--cyan-raw); position: relative; padding: var(--space-4) var(--space-5); border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card); }
.timeline__item--cyan { --dot: var(--cyan-raw); }
.timeline__item--lime { --dot: var(--lime-raw); }
.timeline__item--violet { --dot: var(--violet-raw); }
.timeline__dot {
  position: absolute; top: 1.35rem; left: calc(-2.25rem + 0px); width: 16px; height: 16px; border-radius: 50%;
  background: var(--dot); box-shadow: 0 0 0 4px color-mix(in srgb, var(--dot) 25%, transparent), 0 0 18px var(--dot);
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}
.js .timeline__item:not(.is-lit) .timeline__dot { background: var(--bg); border: 2px solid var(--border); box-shadow: none; }
.timeline__date { margin-bottom: var(--space-1); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.timeline__title { font-size: var(--fs-lg); font-weight: 700; }
.timeline__place { margin: var(--space-2) 0 0; color: var(--text-muted); font-size: var(--fs-sm); }

/* Hire Me */
.hire {
  position: relative; overflow: hidden; padding: clamp(1.75rem, 1rem + 5vw, 4.5rem); border: 1px solid transparent; border-radius: var(--radius-lg);
  background:
    radial-gradient(600px circle at 90% 0%, color-mix(in srgb, var(--violet-raw) 22%, transparent), transparent 60%),
    radial-gradient(500px circle at 0% 100%, color-mix(in srgb, var(--cyan-raw) 18%, transparent), transparent 60%),
    linear-gradient(var(--bg-card), var(--bg-card)) padding-box,
    conic-gradient(from var(--angle), var(--border), var(--cyan-raw), var(--violet-raw), var(--pink-raw), var(--border)) border-box;
  animation: border-spin 8s linear infinite;
}
.hire__title { max-width: 18ch; margin-bottom: var(--space-4); font-size: var(--fs-2xl); font-weight: 800; }
.hire__text { max-width: 40rem; margin-bottom: var(--space-6); color: var(--text-muted); font-size: var(--fs-lg); }
.hire__actions { display: flex; flex-wrap: wrap; gap: var(--space-3); }

/* Contact */
.contact__grid { display: grid; gap: var(--space-6); align-items: start; }
.contact__cards { display: grid; gap: var(--space-4); }
.contact-card {
  display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card);
  transition: border-color 0.25s ease, transform 0.25s var(--ease);
}
.contact-card:hover { border-color: var(--cyan-raw); transform: translateY(-3px); }
.contact-card__icon { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; border: 1px solid currentColor; }
.contact-card__icon--cyan { color: var(--cyan); }
.contact-card__icon--violet { color: var(--violet); }
.contact-card__icon--pink { color: var(--pink); }
.contact-card__icon--lime { color: var(--lime); }
.contact-card__body { display: grid; min-width: 0; }
.contact-card__label { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); }
.contact-card__value { font-weight: 500; overflow-wrap: anywhere; }

.form { padding: var(--space-6); border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card); }
.form__title { margin-bottom: var(--space-5); font-size: var(--fs-xl); }
.field { margin-bottom: var(--space-4); }
.field__label { display: block; margin-bottom: var(--space-2); font-size: var(--fs-sm); font-weight: 600; }
.field__input {
  width: 100%; padding: 0.85rem 1rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elev); color: var(--text); font: inherit; font-size: 1rem; line-height: 1.4;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.field__input--area { min-height: 140px; resize: vertical; }
.field__input:focus-visible { outline: none; border-color: var(--cyan-raw); box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan-raw) 30%, transparent); }
.field__input[aria-invalid='true'] { border-color: var(--pink-raw); }
.field__error { min-height: 0; margin: var(--space-2) 0 0; font-size: var(--fs-sm); color: var(--pink); }
.field__error:empty { display: none; }
.field--trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form__submit { width: 100%; }
.form__submit[disabled] { opacity: 0.6; cursor: not-allowed; }
.form__status { margin: var(--space-4) 0 0; font-size: var(--fs-sm); }
.form__status:empty { display: none; }
.form__status.is-success { color: var(--lime); }
.form__status.is-error { color: var(--pink); }
.form__status.is-info { color: var(--text-muted); }

/* Footer */
.footer { padding: var(--space-6) 0; border-top: 1px solid var(--border); }
.footer__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-4); }
.footer__copy { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }
.footer__social { display: flex; gap: var(--space-2); }
.footer__top { min-height: 44px; padding-block: 0.5rem; }

/* ---------- 6. Hover only where hover exists ---------- */
@media (hover: none) {
  .chips li:hover, .contact-card:hover { transform: none; }
  .btn--primary:hover { box-shadow: none; }
}

/* ---------- 7. Responsive (mobile first) ---------- */
@media (max-width: 479px) {
  .contact-card { gap: var(--space-3); padding: var(--space-3) var(--space-4); }
  .contact-card__icon { width: 42px; height: 42px; }
  .contact-card__value { font-size: 0.9rem; }
  .form { padding: var(--space-5) var(--space-4); }
}

@media (min-width: 560px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .skills__groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero__role { min-height: 1.5em; }
}

@media (min-width: 760px) {
  .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about__grid { grid-template-columns: 1.4fr 1fr; align-items: start; }
}

@media (min-width: 900px) {
  .hero__inner { grid-template-columns: 1.15fr 0.85fr; }
  .hero__visual { width: min(100%, 380px); justify-self: end; }
  .contact__grid { grid-template-columns: 0.9fr 1.1fr; }
}

@media (min-width: 1000px) {
  .nav__toggle { display: none; }
  .nav__menu {
    position: static; padding: 0; background: none; border: 0; max-height: none; overflow: visible;
    visibility: visible; opacity: 1; transform: none;
  }
  .nav__list { display: flex; gap: var(--space-1); }
  .nav__link { padding: 0.5rem 0.8rem; font-size: var(--fs-sm); border: 0; border-radius: var(--radius-pill); }
  .nav__link[aria-current='true'] { background: color-mix(in srgb, var(--text) 8%, transparent); }
  .skills__groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1600px) {
  :root { --container: 1320px; }
}

/* ---------- 8. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; transition-delay: 0s !important;
  }
  .js .reveal, .js .hero-anim { opacity: 1; transform: none; }
  .photo, .project, .hire { animation: none; }
  .hero__caret { animation: none; }
  .shape { animation: none; }
  .sphere { cursor: default; }
}

/* ---------- 9. Print ---------- */
@media print {
  .hero__canvas, .hero__shapes, .hero__bg, .nav, .loader, .progress, .cursor-dot, .cursor-ring,
  .hero__scroll, .sphere-wrap, .section__orb, .form, .footer__top, .hero__cta { display: none !important; }
  :root, :root[data-theme='dark'], :root[data-theme='light'] {
    --bg: #fff; --bg-elev: #fff; --bg-card: #fff; --text: #000; --text-muted: #333; --border: #bbb;
    --cyan: #000; --violet: #000; --pink: #000; --lime: #000;
  }
  body { background: #fff; color: #000; }
  .js .reveal, .js .hero-anim { opacity: 1 !important; transform: none !important; }
  .hero { min-height: 0; padding: 1rem 0; }
  .section { padding-block: 1.5rem; overflow: visible; }
  .grad, .hero__last { background: none; -webkit-text-fill-color: #000; color: #000; }
  .hero__first { -webkit-text-stroke: 0; color: #000; }
  .project, .hire { background: #fff; animation: none; border: 1px solid #bbb; break-inside: avoid; }
  .timeline__item, .stat, .skill-group { break-inside: avoid; }
}
