/* ===========================================================
   animations.css — terminal-hacker flourishes
   scroll reveals · matrix rain · text scramble · glitch · glow
   Matches the red/black theme. No external libraries.
   =========================================================== */

/* ---- Scroll reveal (js/reveal.js) ---- */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.reveal.revealed {
  opacity: 1;
  transform: none;
}
.reveal-left {
  transform: translateX(-40px);
}
.reveal-right {
  transform: translateX(40px);
}
.reveal-left.revealed,
.reveal-right.revealed {
  transform: none;
}
.reveal-zoom {
  transform: translateY(28px) scale(0.96);
}
.reveal-zoom.revealed {
  transform: none;
}

/* =====================================================
   MATRIX RAIN — injected into the hero by js/fx.js
   ===================================================== */
#matrix-rain {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.38;
  pointer-events: none;
  /* fade out toward the bottom so it blends into the page */
  -webkit-mask-image: linear-gradient(to bottom, #000 50%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 50%, transparent 100%);
}

/* =====================================================
   HERO — glowing animated backdrop + scanlines
   ===================================================== */
.main-content {
  position: relative;
  overflow: hidden;
}
.main-content::before {
  content: "";
  position: absolute;
  top: -20%;
  left: 50%;
  width: 60vw;
  height: 60vw;
  max-width: 820px;
  max-height: 820px;
  transform: translateX(-50%);
  background: radial-gradient(
    circle,
    rgba(252, 16, 16, 0.18) 0%,
    rgba(252, 16, 16, 0.06) 35%,
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
  animation: heroPulse 6s ease-in-out infinite;
}
.main-content::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.02) 0px,
    rgba(255, 255, 255, 0.02) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 0;
}
.main-content .container {
  position: relative;
  z-index: 1;
}
@keyframes heroPulse {
  0%,
  100% {
    opacity: 0.65;
    transform: translateX(-50%) scale(1);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.08);
  }
}

/* Hero name: entrance + slow breathing glow (calmer than flicker) */
.hero-section .main-title {
  text-shadow: 0 0 18px rgba(252, 16, 16, 0.45);
  animation: heroIn 0.75s cubic-bezier(0.22, 1, 0.36, 1) both 0.28s,
    glowBreathe 5s ease-in-out infinite 1.4s;
}
@keyframes glowBreathe {
  0%,
  100% {
    text-shadow: 0 0 14px rgba(252, 16, 16, 0.35);
  }
  50% {
    text-shadow: 0 0 26px rgba(252, 16, 16, 0.6),
      0 0 60px rgba(252, 16, 16, 0.25);
  }
}

/* =====================================================
   SECTION TITLES — terminal prompt + glowing underline
   ===================================================== */
.main2-title {
  position: relative;
  display: inline-block;
}
.main2-title::before {
  content: "> ";
  color: var(--primary-color);
  text-shadow: 0 0 10px var(--primary-color);
}
.main2-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -8px;
  height: 3px;
  width: 0;
  background: var(--primary-color);
  box-shadow: 0 0 14px var(--primary-color);
  transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
}
.reveal.revealed .main2-title::after,
.main2-title.revealed::after,
.main2-title[data-scrambled]::after {
  width: 72px;
}

/* =====================================================
   CARDS — lift + pulsing red glow + scan line
   ===================================================== */
.card {
  position: relative;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.3s ease;
}
.card:hover {
  transform: translateY(-6px);
  border-color: var(--primary-color);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(252, 16, 16, 0.25);
  z-index: 3;
}
/* project cards get the full treatment */
.card-red:hover {
  transform: translateY(-8px) scale(1.02);
  animation: cardGlow 1.6s ease-in-out infinite;
}
@keyframes cardGlow {
  0%,
  100% {
    box-shadow: 0 10px 26px rgba(252, 16, 16, 0.22),
      0 0 0 1px rgba(252, 16, 16, 0.35);
  }
  50% {
    box-shadow: 0 16px 44px rgba(252, 16, 16, 0.55),
      0 0 0 1px rgba(252, 16, 16, 0.8);
  }
}
/* scan line that sweeps down a project card on hover */
.card-red::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--primary-color),
    transparent
  );
  opacity: 0;
  box-shadow: 0 0 12px var(--primary-color);
  pointer-events: none;
  z-index: 4;
}
.card-red:hover::after {
  animation: cardScan 1.5s linear infinite;
}
@keyframes cardScan {
  0% {
    top: 0;
    opacity: 0;
  }
  10% {
    opacity: 0.9;
  }
  90% {
    opacity: 0.9;
  }
  100% {
    top: 100%;
    opacity: 0;
  }
}

/* =====================================================
   PROJECT CARDS — image zoom, sheen sweep, glitch title
   ===================================================== */
.card-red .card-img-top {
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), filter 0.6s ease;
}
.card-red:hover .card-img-top {
  transform: scale(1.08);
  filter: saturate(1.15) contrast(1.05);
}
.card-red::before {
  content: "";
  position: absolute;
  top: 0;
  left: -75%;
  width: 50%;
  height: 100%;
  background: linear-gradient(
    120deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: skewX(-20deg);
  transition: left 0.7s ease;
  pointer-events: none;
  z-index: 2;
}
.card-red:hover::before {
  left: 130%;
}
/* RGB-split glitch on the project title when hovered */
.card-red:hover .card-title {
  animation: textGlitch 0.4s steps(2) 1;
}
@keyframes textGlitch {
  0% {
    text-shadow: none;
    transform: translate(0, 0);
  }
  25% {
    text-shadow: -2px 0 #ff003c, 2px 0 #00e1ff;
    transform: translate(1px, -1px);
  }
  50% {
    text-shadow: 2px 0 #ff003c, -2px 0 #00e1ff;
    transform: translate(-1px, 1px);
  }
  75% {
    text-shadow: -1px 0 #ff003c, 1px 0 #00e1ff;
    transform: translate(1px, 0);
  }
  100% {
    text-shadow: none;
    transform: translate(0, 0);
  }
}

/* =====================================================
   CARD SPOTLIGHT — red glow follows the cursor (ui.js
   injects .card-spotlight and updates --mx / --my)
   ===================================================== */
.card-spotlight {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: radial-gradient(
    220px circle at var(--mx, 50%) var(--my, 50%),
    rgba(252, 16, 16, 0.13),
    transparent 65%
  );
}
.card:hover .card-spotlight {
  opacity: 1;
}

/* fast transform tracking while a project card is being tilted */
.card-red.tilting {
  transition: transform 0.08s linear;
}

/* =====================================================
   HERO PARALLAX — content drifts + fades on scroll
   (scroll-driven animation; ignored by older browsers)
   ===================================================== */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    .hero-section > div {
      animation: heroParallax linear both;
      animation-timeline: scroll(root block);
      animation-range: 0px 700px;
    }
    @keyframes heroParallax {
      to {
        transform: translateY(130px);
        opacity: 0;
      }
    }
  }
}

/* =====================================================
   SKILL TAGS · NAV · PROFILE · BUTTONS · ICONS
   ===================================================== */
.skill-box2 {
  transition: transform 0.25s ease, background-color 0.25s ease,
    box-shadow 0.25s ease;
}
.skill-box2:hover {
  transform: translateY(-3px);
  background-color: rgba(252, 16, 16, 0.22);
  box-shadow: 0 4px 14px rgba(252, 16, 16, 0.3);
}

.nav-link {
  position: relative;
}
.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 2px;
  height: 2px;
  width: 0;
  background: var(--primary-color);
  box-shadow: 0 0 8px var(--primary-color);
  transition: width 0.3s ease;
}
.nav-link:hover::after,
.nav-link.active-link::after {
  width: 100%;
}

#portfolio-section img {
  transition: transform 0.5s ease, box-shadow 0.5s ease;
}
#portfolio-section img:hover {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(252, 16, 16, 0.35);
}

.modern-btn {
  position: relative;
  overflow: hidden;
}
.modern-btn:hover {
  box-shadow: 0 0 26px rgba(252, 16, 16, 0.6);
}

.footer a,
#portfolio-section a.primary-color {
  display: inline-block;
  transition: transform 0.25s ease, color 0.25s ease, text-shadow 0.25s ease;
}
.footer a:hover,
#portfolio-section a.primary-color:hover {
  transform: translateY(-3px) scale(1.15);
  text-shadow: 0 0 14px var(--primary-color);
}

/* =====================================================
   HERO — staggered entrance once the terminal intro reveals
   (badge → typed line → name → tagline → CTAs)
   ===================================================== */
.hero-section > div > * {
  animation: heroIn 0.75s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.hero-section > div > *:nth-child(1) {
  animation-delay: 0.05s;
}
.hero-section > div > *:nth-child(2) {
  animation-delay: 0.16s;
}
/* nth-child(3) is the name — handled above with its glow */
.hero-section > div > *:nth-child(4) {
  animation-delay: 0.42s;
}
.hero-section > div > *:nth-child(5) {
  animation-delay: 0.56s;
}
@keyframes heroIn {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* =====================================================
   Reduced-motion: turn the spectacle off
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
  .reveal,
  .reveal-left,
  .reveal-right,
  .reveal-zoom {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  #matrix-rain {
    display: none !important;
  }
  .main-content::before,
  .hero-section .main-title,
  .hero-section > div > *,
  .status-dot,
  .typing::after,
  .card:hover,
  .card-red:hover,
  .card-red:hover::after,
  .arrow {
    animation: none !important;
  }
  * {
    scroll-behavior: auto !important;
  }
}
