/* Base Reset, Layered Background System & Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 1.5rem);
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  position: relative;
  background-color: var(--bg-page);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* ========================================================
   BACKGROUND LAYERING SYSTEM (Order: 1 to 5)
   1. Base near-black background (#08090c)
   2. Background image at ~50% opacity
   3. Dark overlay for contrast
   4. Animated gradients and subtle technical effects
   5. Website content & navigation
   ======================================================== */

.bg-system {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
  background: var(--bg-page);
}

/* Layer 2: Dedicated background image at approximately 50% opacity */
/* Layer 2: Dedicated background image at approximately 50% opacity */
.bg-image-layer {
  position: absolute;
  top: -2%;
  left: -2%;
  width: 104%;
  height: 104%;
  background-image: url('../assets/tech_bg.jpg');
  background-position: center center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0.52;
  transform: translate3d(0, 0, 0);
  pointer-events: none;
  z-index: 1;
}

/* Layer 3: Dark contrast overlay to guarantee sharp text readability */
.bg-contrast-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 50% 30%, rgba(10, 15, 28, 0.40) 0%, rgba(10, 15, 28, 0.70) 65%, rgba(10, 15, 28, 0.90) 100%),
    linear-gradient(180deg, rgba(10, 15, 28, 0.25) 0%, rgba(10, 15, 28, 0.60) 60%, rgba(10, 15, 28, 0.92) 100%);
  pointer-events: none;
  z-index: 2;
}

/* Layer 4: Animated moving gradient lighting & subtle technical effects */
.bg-animated-mesh {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

/* Performant ambient lighting - zero heavy blur filters for high FPS */
.ambient-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.22;
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.orb-cyan {
  width: 550px;
  height: 550px;
  top: -120px;
  left: 15%;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.35) 0%, rgba(6, 182, 212, 0.15) 35%, transparent 70%);
  animation: moveOrbCyan 24s ease-in-out infinite alternate;
}

.orb-violet {
  width: 500px;
  height: 500px;
  top: 30%;
  right: 8%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.32) 0%, rgba(139, 92, 246, 0.12) 35%, transparent 70%);
  animation: moveOrbViolet 28s ease-in-out infinite alternate;
}

.orb-blue {
  width: 480px;
  height: 480px;
  bottom: 5%;
  left: 20%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.32) 0%, rgba(59, 130, 246, 0.12) 35%, transparent 70%);
  animation: moveOrbBlue 26s ease-in-out infinite alternate;
}

@keyframes moveOrbCyan {
  0% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(60px, 40px, 0); }
  100% { transform: translate3d(-30px, 70px, 0); }
}

@keyframes moveOrbViolet {
  0% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(-50px, -40px, 0); }
  100% { transform: translate3d(40px, -60px, 0); }
}

@keyframes moveOrbBlue {
  0% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(40px, -30px, 0); }
  100% { transform: translate3d(-40px, -20px, 0); }
}

/* Subtle Animated Technical Grid */
.bg-tech-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 30%, black 20%, rgba(0, 0, 0, 0.6) 60%, transparent 85%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 30%, black 20%, rgba(0, 0, 0, 0.6) 60%, transparent 85%);
  animation: gridBreathe 12s ease-in-out infinite alternate;
}

@keyframes gridBreathe {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

/* Layer 4 (Part 3): Sparingly used gentle glowing points / particles canvas */
.bg-particles-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

/* ========================================================
   TYPOGRAPHY & SELECTION
   ======================================================== */

::selection {
  background: rgba(0, 229, 255, 0.25);
  color: #ffffff;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}

/* Typography Defaults */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-primary);
  line-height: 1.15;
  letter-spacing: -0.03em;
  font-weight: 700;
}

p {
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.65;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: inherit;
  outline: none;
}

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent-cyan);
  outline-offset: 2px;
}

/* Containers */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2.5rem);
  position: relative;
  z-index: 10;
}

.container-narrow {
  width: 100%;
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 4vw, 2rem);
  position: relative;
  z-index: 10;
}

.section {
  padding: var(--section-padding) 0;
  position: relative;
  z-index: 10;
}

.section-header {
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.section-header.center {
  text-align: center;
  max-width: 680px;
  margin-left: auto;
  margin-right: auto;
}

.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  margin-bottom: 0.85rem;
  font-family: var(--font-mono);
}

.section-tag::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.section-title {
  font-size: clamp(2rem, 3.8vw, 3rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

.section-desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.cyan-gradient-text {
  background: linear-gradient(135deg, #ffffff 40%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Scroll reveal helper class */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

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

@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;
  }
  .orb-cyan, .orb-violet, .orb-blue, .bg-tech-grid {
    animation: none !important;
  }
  .reveal-on-scroll {
    opacity: 1 !important;
    transform: none !important;
  }
}
