/* ============================================================
   animations.css — Scroll Reveals, Transitions & Keyframes
   Mariano Gendra Personal Website
   ============================================================ */

/* ── Scroll Reveal Base ── */
/*
 * visibility: hidden hides the element from accessibility tools (axe/Lighthouse)
 * before it animates in. Without it, axe factors the parent's opacity: 0 into the
 * effective foreground alpha of child text nodes, producing ~1:1 contrast → false
 * fail. When .is-visible is added, visibility flips to visible instantly (no
 * transition on that property), then opacity transitions over 0.6s — same visual.
 */
.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  visibility: hidden;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }

/* ── Fade in only (no translate) ── */
.reveal-fade {
  opacity: 0;
  transition: opacity 0.7s ease;
  visibility: hidden;
}
.reveal-fade.is-visible {
  opacity: 1;
  visibility: visible;
}

/* ── Hero Typewriter Cursor ── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.hero-cursor {
  display: inline-block;
  width: 3px;
  height: 1.1em;
  background: var(--accent);
  margin-left: 4px;
  vertical-align: middle;
  animation: blink 0.9s step-end infinite;
  border-radius: 2px;
}

/* ── Role text crossfade ── */
.hero-role-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-width: 340px;
}

.hero-role-text {
  color: var(--accent);
  font-weight: 600;
}

/* ── Back-to-top visibility ── */
#back-to-top {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#back-to-top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ── Portfolio card filter animation ── */
.portfolio-card {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.portfolio-card.hidden {
  opacity: 0;
  transform: scale(0.94);
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

/* ── Skill pill hover ── */
.skill-pill {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
}

.skill-pill:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Card hover lift ── */
.card-lift {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-hover);
}

/* ── Service card hover ── */
.service-card:hover {
  border-color: var(--accent);
}

.service-card:hover .service-icon {
  color: var(--accent);
  transform: scale(1.1);
}

.service-icon {
  transition: color 0.2s ease, transform 0.2s ease;
}

/* ── Nav link underline slide ── */
.nav-link::after {
  content: '';
  display: block;
  height: 2px;
  background: var(--accent);
  width: 0;
  transition: width 0.25s ease;
  margin-top: 2px;
  border-radius: 2px;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* ── CTA Button states ── */
.btn {
  transition: background-color 0.2s ease, color 0.2s ease,
              border-color 0.2s ease, transform 0.15s ease,
              box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

/* ── Hamburger animation ── */
.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.2s ease;
  transform-origin: center;
}

.nav-open .hamburger-line:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.nav-open .hamburger-line:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.nav-open .hamburger-line:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* ── Mobile menu slide ── */
.mobile-nav {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.mobile-nav.open {
  max-height: 480px;
}

/* ── Theme toggle icon spin ── */
#theme-toggle {
  transition: transform 0.3s ease, color 0.2s ease;
}

#theme-toggle:hover {
  transform: rotate(20deg);
  color: var(--accent);
}

/* ── Timeline entry reveal ── */
.timeline-entry {
  opacity: 0;
  transform: translateX(-24px);
  transition: opacity 0.55s ease, transform 0.55s ease;
  visibility: hidden;
}

.timeline-entry.is-visible {
  opacity: 1;
  transform: translateX(0);
  visibility: visible;
}

/* ── Stat counter number pulse ── */
@keyframes countPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.stat-number.counting {
  animation: countPulse 0.3s ease;
}

/* ── Dot grid hero background ── */
@keyframes subtle-float {
  0%, 100% { transform: translateY(0px); }
  50%       { transform: translateY(-8px); }
}

/* ── Form input focus ring ── */
.form-input,
.form-textarea,
.form-select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
  outline: none;
}

/* ── Testimonial card ── */
.testimonial-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.testimonial-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

/* ── Blog card image zoom ── */
.blog-card-img-wrap {
  overflow: hidden;
}

.blog-card-img {
  transition: transform 0.4s ease;
}

.blog-card:hover .blog-card-img {
  transform: scale(1.05);
}

/* ── Success/error state for form ── */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-success,
.form-error-banner {
  animation: slideInUp 0.4s ease;
}

/* ── Availability badge pulse ── */
@keyframes availablePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50%       { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.available-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #10B981;
  border-radius: 50%;
  animation: availablePulse 2s ease infinite;
}

/* ── Respect reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .reveal,
  .reveal-fade,
  .timeline-entry {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    visibility: visible !important;
  }

  .hero-cursor {
    animation: none;
    opacity: 1;
  }
}
