/* ==========================================================================
   Cinematic layer — film grain, mesh, section glows, marquee, motion
   ========================================================================== */

/* --- Global cinematic overlays --- */
.cine {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}
.cine__mesh {
  position: absolute;
  inset: -50%;
  background:
    radial-gradient(ellipse 50% 40% at 20% 30%, rgba(0, 240, 255, 0.09) 0%, transparent 55%),
    radial-gradient(ellipse 45% 35% at 80% 20%, rgba(123, 97, 255, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse 40% 50% at 60% 80%, rgba(240, 193, 75, 0.05) 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 10% 90%, rgba(57, 255, 136, 0.04) 0%, transparent 50%);
  animation: meshDrift 25s ease-in-out infinite alternate;
}
@keyframes meshDrift {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); }
  100% { transform: translate(-3%, 2%) rotate(3deg) scale(1.05); }
}
.cine__grain {
  position: absolute;
  inset: -100%;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grainShift 0.5s steps(4) infinite;
}
@keyframes grainShift {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-2%, -2%); }
  50% { transform: translate(2%, 1%); }
  75% { transform: translate(-1%, 2%); }
}
.cine__vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 70% at 50% 50%, transparent 40%, rgba(5, 5, 8, 0.85) 100%);
}
.cine__beam {
  position: absolute;
  width: 2px;
  height: 140%;
  background: linear-gradient(180deg, transparent, rgba(0, 240, 255, 0.15), transparent);
  transform: rotate(25deg);
  opacity: 0.4;
  animation: beamSweep 12s ease-in-out infinite;
}
.cine__beam--1 { left: 20%; top: -20%; animation-delay: 0s; }
.cine__beam--2 { right: 25%; top: -30%; animation-delay: -6s; background: linear-gradient(180deg, transparent, rgba(123, 97, 255, 0.12), transparent); }
@keyframes beamSweep {
  0%, 100% { opacity: 0.15; transform: rotate(25deg) translateX(0); }
  50% { opacity: 0.5; transform: rotate(25deg) translateX(80px); }
}

.cine__progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 1001;
  background: rgba(255, 255, 255, 0.04);
}
.cine__progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00f0ff, #7b61ff, #f0c14b);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
  transform-origin: left;
}

/* --- Marquee --- */
.marquee {
  position: relative;
  z-index: 6;
  padding: 1.25rem 0;
  border-block: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(5, 5, 8, 0.6);
  backdrop-filter: blur(12px);
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee__track {
  display: flex;
  align-items: center;
  gap: 2.5rem;
  width: max-content;
  animation: marqueeScroll 40s linear infinite;
  will-change: transform;
}
.marquee__track span {
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: rgba(244, 244, 246, 0.35);
  white-space: nowrap;
}
.marquee__dot { color: var(--color-accent) !important; font-size: 0.5rem !important; letter-spacing: 0 !important; }
@keyframes marqueeScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* --- Section cinematic --- */
.section--cinematic {
  position: relative;
  isolation: isolate;
}
.section--cinematic::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(600px, 80%);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.4), rgba(123, 97, 255, 0.4), transparent);
  opacity: 0;
  animation: sectionLineIn 1.2s var(--ease-out-expo) forwards;
  animation-play-state: paused;
}
.section--cinematic.is-inview::before {
  animation-play-state: running;
}
@keyframes sectionLineIn {
  from { opacity: 0; width: 0; }
  to { opacity: 1; width: min(600px, 80%); }
}

.section__glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s ease;
  z-index: 0;
}
.section--cinematic.is-inview .section__glow { opacity: 0.35; }
.section__glow--cyan { top: -10%; right: -10%; background: rgba(0, 240, 255, 0.25); }
.section__glow--violet { top: 20%; left: -15%; background: rgba(123, 97, 255, 0.3); }
.section__glow--gold { bottom: -5%; right: 5%; background: rgba(240, 193, 75, 0.2); }
.section__glow--mint { top: 10%; right: 20%; background: rgba(57, 255, 136, 0.15); }
.section__glow--rose { bottom: 0; left: 10%; background: rgba(232, 121, 249, 0.18); }

/* --- Hero cinematic upgrades --- */
.hero__film-bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  background: #000;
  z-index: 20;
  animation: filmBars 2.2s var(--ease-out-expo) 0.3s forwards;
}
.hero__film-bar--top { top: 0; }
.hero__film-bar--bottom { bottom: 0; }
@keyframes filmBars {
  0% { height: 0; }
  40% { height: 12vh; }
  70% { height: 12vh; }
  100% { height: 0; }
}

.hero__aurora {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    conic-gradient(from 180deg at 50% 80%, transparent, rgba(0, 240, 255, 0.06), transparent, rgba(123, 97, 255, 0.08), transparent);
  animation: auroraSpin 20s linear infinite;
  opacity: 0.7;
}
@keyframes auroraSpin {
  to { transform: rotate(360deg); }
}

.hero__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  z-index: 2;
}
.hero__orb--1 {
  width: 280px;
  height: 280px;
  top: 15%;
  left: 10%;
  background: rgba(0, 240, 255, 0.15);
  animation: orbFloat 8s ease-in-out infinite;
}
.hero__orb--2 {
  width: 200px;
  height: 200px;
  bottom: 20%;
  right: 15%;
  background: rgba(123, 97, 255, 0.2);
  animation: orbFloat 10s ease-in-out infinite reverse;
}
@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -30px) scale(1.1); }
}

.hero__title-dot {
  display: inline-block;
  color: var(--color-accent);
  animation: dotPulse 2s ease infinite;
}
@keyframes dotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

[data-glitch] {
  position: relative;
}
[data-glitch].is-glitching::after {
  content: attr(data-text);
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  clip-path: inset(0 0 50% 0);
  animation: glitchSlice 0.15s steps(2) 3;
}
@keyframes glitchSlice {
  0% { transform: translate(-2px, 0); }
  50% { transform: translate(2px, 1px); }
  100% { transform: translate(0, 0); }
}

/* Split title words */
.section__title [data-word] {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}
.section__title [data-word] .word-inner {
  display: inline-block;
  transform: translateY(115%);
}
.section__title em [data-word] .word-inner {
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Enhanced buttons */
.btn {
  position: relative;
  isolation: isolate;
}
.btn::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-secondary), var(--color-accent));
  background-size: 200% 200%;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s;
  animation: borderFlow 3s linear infinite;
  animation-play-state: paused;
  z-index: -1;
}
.btn:hover::before,
.btn:focus-visible::before {
  opacity: 1;
  animation-play-state: running;
}
@keyframes borderFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
.btn--primary {
  position: relative;
  overflow: hidden;
}
.btn--primary::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transform: skewX(-20deg);
  transition: left 0.6s var(--ease-out-expo);
}
.btn--primary:hover::after {
  left: 150%;
}

/* Project cards cinematic */
.project-card {
  transition: transform 0.5s var(--ease-out-expo), box-shadow 0.5s ease, border-color 0.4s;
}
.project-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, transparent, var(--project-accent, #00f0ff), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  z-index: 4;
}
.project-card:hover::before { opacity: 0.8; }
.project-card:hover {
  box-shadow:
    0 25px 50px rgba(0, 0, 0, 0.5),
    0 0 40px color-mix(in srgb, var(--project-accent, #00f0ff) 25%, transparent);
}

.project-card__preview::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.06) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.8s var(--ease-out-expo);
}
.project-card:hover .project-card__preview::after {
  transform: translateX(100%);
}

/* Stat cards pulse */
.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.08), transparent);
  opacity: 0;
  transition: opacity 0.4s;
}
.stat-card:hover::after { opacity: 1; }

/* Timeline cinematic */
.timeline-item {
  opacity: 0.6;
  transform: translateX(-20px);
  transition: opacity 0.5s, transform 0.5s var(--ease-out-expo);
}
.timeline-item.is-active {
  opacity: 1;
  transform: translateX(0);
}
.timeline-item.is-active .timeline-item__year {
  text-shadow: 0 0 20px var(--color-neon-glow);
}

/* Skills orbit auto spin desktop */
@media (min-width: 769px) {
  .skills__orbit {
    animation: orbitSlow 60s linear infinite;
  }
  .skills__stage:hover .skills__orbit {
    animation-play-state: paused;
  }
}
@keyframes orbitSlow {
  to { transform: rotate(360deg); }
}
.skills__orbit .skill-node {
  animation: orbitCounter 60s linear infinite;
}
@keyframes orbitCounter {
  to { transform: rotate(var(--angle)) translateX(200px) rotate(calc(-1 * var(--angle) - 360deg)); }
}
.skills__stage:hover .skill-node {
  animation-play-state: paused;
}

/* Process step cinematic */
.process-step {
  opacity: 0.4;
  transform: scale(0.95);
  transition: opacity 0.5s, transform 0.5s var(--ease-out-expo);
}
.process-step.is-active {
  opacity: 1;
  transform: scale(1);
}

/* Contact form glow pulse */
.form-group.is-focused label {
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
}
.contact__form {
  position: relative;
}
.contact__form::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(0,240,255,0.2), rgba(123,97,255,0.2));
  opacity: 0;
  z-index: -1;
  filter: blur(20px);
  transition: opacity 0.5s;
}
.contact__form:focus-within::before {
  opacity: 0.5;
}

/* Nav cinematic */
.nav.is-scrolled .nav__glass {
  background: rgba(5, 5, 8, 0.82);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.nav__brand-mark {
  animation: brandGlow 4s ease-in-out infinite;
}
@keyframes brandGlow {
  0%, 100% { box-shadow: 0 0 0 transparent; }
  50% { box-shadow: 0 0 20px rgba(0, 240, 255, 0.4); }
}

/* Loader enhanced */
.loader__core {
  animation: loaderPulse 1.5s ease-in-out infinite;
}
@keyframes loaderPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 240, 255, 0.3); }
  50% { box-shadow: 0 0 40px 10px rgba(0, 240, 255, 0.15); }
}

/* Section index animated */
.section__index {
  position: relative;
  display: inline-block;
}
.section__index::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--color-accent);
  transition: width 0.8s var(--ease-out-expo);
}
.section--cinematic.is-inview .section__index::after {
  width: 100%;
}

/* Portrait cinematic */
.about__portrait-frame {
  transition: transform 0.6s var(--ease-out-expo), box-shadow 0.6s;
}
.about__portrait:hover .about__portrait-frame {
  transform: scale(1.02) rotateY(-5deg) rotateX(3deg);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4), 0 0 40px rgba(0, 240, 255, 0.15);
}

/* Principle cards */
.principle-card {
  position: relative;
  overflow: hidden;
}
.principle-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 0;
  background: linear-gradient(180deg, var(--color-accent), var(--color-accent-secondary));
  transition: height 0.5s var(--ease-out-expo);
}
.principle-card:hover::before { height: 100%; }

@media (max-width: 768px) {
  .cine__beam { display: none; }
  .hero__film-bar { display: none; }
  .marquee__track { animation-duration: 30s; }
  .skills__orbit,
  .skills__orbit .skill-node {
    animation: none !important;
  }
  .project-card::before,
  .project-card__preview::after {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cine__mesh,
  .cine__grain,
  .marquee__track,
  .hero__aurora,
  .hero__orb,
  .skills__orbit { animation: none !important; }
}
