/* ========== Background effects (startup/AI-style) ========== */

.bg-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

#root {
  position: relative;
  z-index: 1;
}

/* Space-style gradient (nebula / deep space) */
.bg-gradient {
  position: absolute;
  inset: -50%;
  background: 
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(15, 23, 42, 0.95) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 80% 20%, rgba(34, 211, 238, 0.08) 0%, transparent 45%),
    radial-gradient(ellipse 60% 70% at 50% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse 100% 100% at 50% 50%, rgba(10, 14, 23, 0.3) 0%, transparent 70%);
  animation: bgGradientShift 18s ease-in-out infinite alternate;
}

/* Starfield */
.bg-stars {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.bg-stars .star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
  animation: starTwinkle 3s ease-in-out infinite;
  pointer-events: none;
}

.bg-stars .star:nth-child(3n) {
  width: 1px;
  height: 1px;
  opacity: 0.7;
}

.bg-stars .star:nth-child(5n) {
  box-shadow: 0 0 6px rgba(34, 211, 238, 0.6);
  background: rgba(34, 211, 238, 0.9);
}

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

@keyframes bgGradientShift {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-3%, -2%) scale(1.05); }
  100% { transform: translate(2%, 3%) scale(0.98); }
}

/* Mouse-follow spotlight (AI-style glow under cursor) */
.bg-spotlight {
  position: absolute;
  inset: -100%;
  background: radial-gradient(
    ellipse 80vmax 60vmax at var(--mouse-x) var(--mouse-y),
    rgba(34, 211, 238, 0.08) 0%,
    rgba(6, 182, 212, 0.04) 35%,
    transparent 60%
  );
  transition: opacity 0.3s ease;
}

@media (hover: none) {
  .bg-spotlight {
    opacity: 0.5;
    background: radial-gradient(
      ellipse 90vmax 70vmax at 50% 50%,
      rgba(34, 211, 238, 0.06) 0%,
      transparent 55%
    );
  }
}

/* Geometric layer: circuit lines */
.bg-geometry {
  position: absolute;
  inset: 0;
}

.bg-circuit-lines {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image:
    linear-gradient(105deg, transparent 45%, rgba(34, 211, 238, 0.4) 50%, transparent 55%),
    linear-gradient(75deg, transparent 40%, rgba(6, 182, 212, 0.3) 50%, transparent 60%),
    linear-gradient(15deg, transparent 60%, rgba(34, 211, 238, 0.25) 65%, transparent 70%);
  background-size: 400% 300%;
  animation: bgCircuitPulse 24s ease-in-out infinite;
}

@keyframes bgCircuitPulse {
  0%, 100% { background-position: 0% 0%, 20% 10%, 80% 50%; opacity: 0.04; }
  50% { background-position: 100% 50%, 80% 90%, 20% 30%; opacity: 0.06; }
}

/* Floating nodes */
.bg-nodes {
  position: absolute;
  inset: 0;
}

.bg-node {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(34, 211, 238, 0.5);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.4);
  animation: nodeFloat 8s ease-in-out infinite;
}

.bg-node[data-node="0"] { top: 12%; left: 8%;  animation-delay: 0s;   animation-duration: 10s; }
.bg-node[data-node="1"] { top: 25%; right: 15%; animation-delay: -1s;  animation-duration: 9s; }
.bg-node[data-node="2"] { top: 45%; left: 12%;  animation-delay: -3s;  animation-duration: 11s; }
.bg-node[data-node="3"] { top: 60%; right: 8%;  animation-delay: -2s;  animation-duration: 8s; }
.bg-node[data-node="4"] { bottom: 25%; left: 20%; animation-delay: -4s;  animation-duration: 10s; }
.bg-node[data-node="5"] { bottom: 15%; right: 22%; animation-delay: -1.5s; animation-duration: 9s; }
.bg-node[data-node="6"] { top: 8%; left: 45%;  animation-delay: -2.5s; animation-duration: 12s; }
.bg-node[data-node="7"] { top: 75%; left: 35%;  animation-delay: -0.5s; animation-duration: 7s; }

@keyframes nodeFloat {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 0.85; }
}

/* Click ripple */
.bg-click-ripple {
  position: fixed;
  width: 20px;
  height: 20px;
  margin-left: -10px;
  margin-top: -10px;
  border-radius: 50%;
  border: 1px solid rgba(34, 211, 238, 0.5);
  background: transparent;
  animation: clickRipple 0.8s ease-out forwards;
  pointer-events: none;
}

@keyframes clickRipple {
  to {
    width: 120px;
    height: 120px;
    margin-left: -60px;
    margin-top: -60px;
    opacity: 0;
    border-width: 2px;
  }
}

/* Shooting star – left-to-right or right-to-left, trail behind, angle matches direction */
.shooting-star {
  position: fixed;
  --star-top: 20%;
  top: var(--star-top);
  left: -15%;
  width: 70px;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(34, 211, 238, 0.08) 15%,
    rgba(34, 211, 238, 0.2) 35%,
    rgba(34, 211, 238, 0.5) 60%,
    rgba(255, 255, 255, 0.85) 85%,
    rgba(255, 255, 255, 1) 92%,
    transparent 100%
  );
  transform: rotate(6deg);
  transform-origin: left center;
  animation: shootingStar 1.28s linear forwards;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.4);
}

/* Right-to-left: reverse animation, flip streak so head leads; -6deg so tilt is downward */
.shooting-star-rtl {
  left: 115%;
  top: calc(var(--star-top) + 22vh);
  transform: scaleX(-1) rotate(-6deg);
  animation-direction: reverse;
}

@keyframes shootingStar {
  0% {
    left: -15%;
    top: var(--star-top);
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  95% {
    opacity: 1;
  }
  100% {
    left: 115%;
    top: calc(var(--star-top) + 22vh);
    opacity: 0;
  }
}

/* Subtle grid overlay */
.bg-grid {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(rgba(34, 211, 238, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, black 20%, transparent 70%);
}

/* Noise texture */
.bg-noise {
  position: absolute;
  inset: 0;
  opacity: 0.035;
  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.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ========== Hero gradient text + glow ========== */

/* Dark mode: blue/cyan–black gradient */
.hero-title-gradient {
  color: var(--color-text);
  background: linear-gradient(135deg, #0A0E17 0%, #1C1917 35%, var(--color-accent) 70%, #06B6D4 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: heroTitleShimmer 8s ease-in-out infinite;
}

@supports (background-clip: text) or (-webkit-background-clip: text) {
  .hero-title-gradient {
    color: transparent;
  }
}

@keyframes heroTitleShimmer {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 100% center; }
}

.hero-glow {
  text-shadow: 0 0 40px rgba(34, 211, 238, 0.15);
}

/* ========== Shimmer on primary buttons ========== */

.button-shimmer {
  position: relative;
  overflow: hidden;
}

.button-shimmer::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 45%,
    transparent 55%,
    transparent 100%
  );
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.button-shimmer:hover::before {
  transform: translateX(100%);
}

/* ========== Animated gradient border on cards ========== */

.card-glow-border {
  position: relative;
}

.card-glow-border::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, var(--color-accent), transparent 40%, transparent 60%, 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.5;
  animation: borderFlow 6s linear infinite;
}

@keyframes borderFlow {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* ========== Section heading subtle glow ========== */

section h2 {
  transition: text-shadow 0.5s ease;
}

section h2:hover {
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.12);
}

/* ========== Hero image soft glow on hover ========== */

.about-image {
  transition: box-shadow 0.5s ease, transform 0.5s ease;
}

.about-image:hover {
  box-shadow: 0 0 40px rgba(34, 211, 238, 0.2), 0 8px 32px rgba(0, 0, 0, 0.4);
  transform: scale(1.02);
}

/* ========== Reduce motion ========== */

/* ========== Light theme overrides for background effects ========== */

[data-theme="light"] .bg-gradient {
  background:
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(241, 245, 249, 0.98) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 80% 20%, rgba(224, 120, 45, 0.06) 0%, transparent 45%),
    radial-gradient(ellipse 60% 70% at 50% 80%, rgba(194, 101, 34, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse 100% 100% at 50% 50%, rgba(226, 232, 240, 0.4) 0%, transparent 70%);
}

[data-theme="light"] .bg-stars .star {
  background: rgba(120, 53, 15, 0.4);
  box-shadow: 0 0 4px rgba(120, 53, 15, 0.3);
}

[data-theme="light"] .bg-stars .star:nth-child(5n) {
  box-shadow: 0 0 6px rgba(180, 83, 9, 0.4);
  background: rgba(217, 119, 6, 0.5);
}

[data-theme="light"] .bg-spotlight {
  background: radial-gradient(
    ellipse 80vmax 60vmax at var(--mouse-x) var(--mouse-y),
    rgba(251, 191, 36, 0.06) 0%,
    rgba(253, 224, 71, 0.02) 35%,
    transparent 60%
  );
}

@media (hover: none) {
  [data-theme="light"] .bg-spotlight {
    background: radial-gradient(
      ellipse 90vmax 70vmax at 50% 50%,
      rgba(251, 191, 36, 0.05) 0%,
      transparent 55%
    );
  }
}

[data-theme="light"] .bg-circuit-lines {
  opacity: 0.03;
  background-image:
    linear-gradient(105deg, transparent 45%, rgba(251, 191, 36, 0.2) 50%, transparent 55%),
    linear-gradient(75deg, transparent 40%, rgba(245, 158, 11, 0.15) 50%, transparent 60%),
    linear-gradient(15deg, transparent 60%, rgba(251, 191, 36, 0.12) 65%, transparent 70%);
}

[data-theme="light"] .bg-node {
  background: rgba(217, 119, 6, 0.35);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.2);
}

[data-theme="light"] .bg-click-ripple {
  border-color: rgba(245, 158, 11, 0.4);
}

[data-theme="light"] .bg-grid {
  background-image:
    linear-gradient(rgba(180, 83, 9, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180, 83, 9, 0.08) 1px, transparent 1px);
}

[data-theme="light"] .shooting-star {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(251, 191, 36, 0.05) 15%,
    rgba(251, 191, 36, 0.12) 35%,
    rgba(245, 158, 11, 0.3) 60%,
    rgba(120, 53, 15, 0.6) 85%,
    rgba(120, 53, 15, 0.8) 92%,
    transparent 100%
  );
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.2);
}

/* Light mode: warm orange/amber gradient (daytime) */
[data-theme="light"] .hero-title-gradient {
  background: linear-gradient(135deg, #1C1917 0%, #57534E 35%, #B45309 70%, #C2410C 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: heroTitleShimmer 8s ease-in-out infinite;
}

[data-theme="light"] .hero-glow {
  text-shadow: 0 0 40px rgba(251, 191, 36, 0.12);
}

[data-theme="light"] section h2:hover {
  text-shadow: 0 0 24px rgba(251, 191, 36, 0.15);
}

[data-theme="light"] .about-image:hover {
  box-shadow: 0 0 40px rgba(251, 191, 36, 0.12), 0 8px 32px rgba(0, 0, 0, 0.08);
}

/* ========== Reduce motion ========== */

@media (prefers-reduced-motion: reduce) {
  .bg-gradient,
  .bg-circuit-lines,
  .bg-node,
  .bg-stars .star,
  .shooting-star,
  .bg-click-ripple,
  .hero-title-gradient,
  .card-glow-border::before {
    animation: none;
  }
  .bg-stars .star {
    opacity: 0.8;
  }
  .about-image:hover {
    transform: none;
  }
}
