/* ==========================================================================
   COLEGIO SALZILLO — Advanced Animation Styles
   Version: 1.0.0
   Pairs with: js/main.js & js/gsap-animations.js
   ========================================================================== */

/* ==========================================================================
   §1. SCROLL-TRIGGERED REVEAL CLASSES
   All elements with these classes start invisible and become visible
   when IntersectionObserver adds the .revealed class.
   ========================================================================== */

/* ── Reveal Up ───────────────────────────────────────────────────────────── */
.reveal-up {
  opacity: 0;
  transform: translateY(60px);
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity, transform;
}

.reveal-up.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ── Reveal Down ─────────────────────────────────────────────────────────── */
.reveal-down {
  opacity: 0;
  transform: translateY(-60px);
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity, transform;
}

.reveal-down.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* ── Reveal Left ─────────────────────────────────────────────────────────── */
.reveal-left {
  opacity: 0;
  transform: translateX(-80px);
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity, transform;
}

.reveal-left.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* ── Reveal Right ────────────────────────────────────────────────────────── */
.reveal-right {
  opacity: 0;
  transform: translateX(80px);
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity, transform;
}

.reveal-right.revealed {
  opacity: 1;
  transform: translateX(0);
}

/* ── Reveal Scale ────────────────────────────────────────────────────────── */
.reveal-scale {
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity, transform;
}

.reveal-scale.revealed {
  opacity: 1;
  transform: scale(1);
}

/* ── Reveal Fade ─────────────────────────────────────────────────────────── */
.reveal-fade {
  opacity: 0;
  transition: opacity 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity;
}

.reveal-fade.revealed {
  opacity: 1;
}

/* ── Reveal Rotate ───────────────────────────────────────────────────────── */
.reveal-rotate {
  opacity: 0;
  transform: rotate(-5deg) translateY(40px);
  transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity, transform;
}

.reveal-rotate.revealed {
  opacity: 1;
  transform: rotate(0deg) translateY(0);
}

/* ── Reveal Clip (from bottom) ───────────────────────────────────────────── */
.reveal-clip {
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: clip-path;
}

.reveal-clip.revealed {
  clip-path: inset(0 0 0 0);
}

.reveal-perspective {
  will-change: transform, opacity;
}

/* ==========================================================================
   §2. STAGGER DELAY UTILITIES
   Apply these to children of a container for cascading reveals.
   ========================================================================== */
.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.4s; }
.delay-5 { transition-delay: 0.5s; }
.delay-6 { transition-delay: 0.6s; }
.delay-7 { transition-delay: 0.7s; }
.delay-8 { transition-delay: 0.8s; }

/* GSAP-controlled stagger (uses data attribute for flexibility) */
[data-delay] {
  transition-delay: calc(var(--stagger-delay, 0) * 1s);
}

/* ==========================================================================
   §3. HERO TEXT SPLIT-LETTER ANIMATION
   Used for the hero H1 letter-by-letter reveal.
   Letters are wrapped in spans by JavaScript.
   ========================================================================== */
.split-text {
  overflow: hidden;
}

.split-text .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(120%) rotateX(-80deg);
  transform-origin: center bottom;
  transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: opacity, transform;
}

.split-text.animate .char {
  opacity: 1;
  transform: translateY(0) rotateX(0deg);
}

/* Each character gets a stagger via CSS custom property */
.split-text .char {
  transition-delay: calc(var(--char-index, 0) * 0.03s);
}

/* Word-level split */
.split-words .word-wrap {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding-bottom: 0.08em; /* Prevent descender clipping */
}

.split-words .word-inner {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

.split-words.animate .word-inner {
  transform: translateY(0);
}

.split-words .word-inner {
  transition-delay: calc(var(--word-index, 0) * 0.08s);
}

/* Line-level split for subtitles */
.split-lines .line-wrap {
  display: block;
  overflow: hidden;
}

.split-lines .line-inner {
  display: block;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform, opacity;
}

.split-lines.animate .line-inner {
  transform: translateY(0);
  opacity: 1;
}

.split-lines .line-inner {
  transition-delay: calc(var(--line-index, 0) * 0.12s);
}

/* ==========================================================================
   §4. PARALLAX LAYERS
   Elements that move at different speeds on scroll (controlled via JS).
   ========================================================================== */
.parallax-layer {
  will-change: transform;
  transition: none; /* JS controls this directly */
}

.parallax-shape {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
}

.parallax-shape--sm {
  width: 60px;
  height: 60px;
}

.parallax-shape--md {
  width: 120px;
  height: 120px;
}

.parallax-shape--lg {
  width: 200px;
  height: 200px;
}

.parallax-shape--xl {
  width: 340px;
  height: 340px;
}

/* Shape colors */
.parallax-shape--primary   { background: rgba(var(--primary-rgb), 0.06); }
.parallax-shape--secondary { background: rgba(var(--secondary-rgb), 0.06); }
.parallax-shape--accent    { background: rgba(var(--accent-rgb), 0.08); }
.parallax-shape--cream     { background: var(--cream); }

/* Blob shape variants */
.parallax-shape--blob-1 { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }
.parallax-shape--blob-2 { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
.parallax-shape--blob-3 { border-radius: 40% 60% 65% 35% / 40% 55% 45% 60%; }

/* Ring shapes */
.parallax-ring {
  position: absolute;
  border-radius: 50%;
  border: 2px solid rgba(var(--primary-rgb), 0.08);
  pointer-events: none;
  will-change: transform;
}

/* Dot grid pattern */
.parallax-dots {
  position: absolute;
  width: 120px;
  height: 120px;
  background-image: radial-gradient(circle, var(--gray-300) 1px, transparent 1px);
  background-size: 16px 16px;
  pointer-events: none;
  will-change: transform;
  opacity: 0.4;
}

/* ==========================================================================
   §5. MAGNETIC BUTTON EFFECT
   The button subtly follows the cursor when hovered.
   JS applies transform based on mouse position.
   ========================================================================== */
.magnetic-btn {
  position: relative;
  display: inline-flex;
  will-change: transform;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.magnetic-btn__inner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

/* When JS is not active, the button behaves normally */
.no-js .magnetic-btn {
  transition: none;
}

/* ==========================================================================
   §6. IMAGE REVEAL (CLIP-PATH) ANIMATION
   Used for hero images, about images, gallery items.
   ========================================================================== */
.img-reveal {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-2xl);
}

.img-reveal__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.3);
  transition: transform 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

/* Curtain overlay that slides away */
.img-reveal::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--primary);
  transform-origin: right;
  transform: scaleX(1);
  transition: transform 1s cubic-bezier(0.77, 0, 0.175, 1) 0.2s;
  will-change: transform;
}

.img-reveal.revealed::after {
  transform: scaleX(0);
}

.img-reveal.revealed .img-reveal__image {
  transform: scale(1);
}

/* Clip-path variant (left to right reveal) */
.img-clip-reveal {
  clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
  transition: clip-path 1.2s cubic-bezier(0.77, 0, 0.175, 1);
  will-change: clip-path;
}

.img-clip-reveal.revealed {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

/* Circle expand reveal */
.img-circle-reveal {
  clip-path: circle(0% at 50% 50%);
  transition: clip-path 1.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: clip-path;
}

.img-circle-reveal.revealed {
  clip-path: circle(75% at 50% 50%);
}

/* ==========================================================================
   §7. COUNTER DIGIT SLIDE ANIMATION
   Each digit column slides down to reveal the target number.
   ========================================================================== */
.counter-animate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.counter-animate__col {
  display: inline-block;
  height: 1em;
  overflow: hidden;
  line-height: 1;
  position: relative;
}

.counter-animate__strip {
  display: flex;
  flex-direction: column;
  transition: transform 1.5s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}

.counter-animate__strip span {
  display: block;
  height: 1em;
  line-height: 1;
  text-align: center;
}

/* Static suffix (e.g., +, %, años) */
.counter-animate__suffix {
  display: inline-block;
}

/* ==========================================================================
   §8. CARD HOVER LIFT + SHADOW EFFECT
   ========================================================================== */
.card-hover {
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              box-shadow 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform, box-shadow;
}

.card-hover:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1),
              0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Card tilt 3D effect (JS applies perspective transform on mouse move) */
.card-tilt {
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-style: preserve-3d;
  perspective: 1000px;
  will-change: transform;
}

.card-tilt__inner {
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-style: preserve-3d;
}

/* Shine effect on card hover */
.card-shine {
  position: relative;
  overflow: hidden;
}

.card-shine::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    to bottom right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0) 40%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0) 60%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(45deg) translateX(-100%);
  transition: transform 0.6s;
  pointer-events: none;
  z-index: 1;
}

.card-shine:hover::before {
  transform: rotate(45deg) translateX(100%);
}

/* ==========================================================================
   §9. LOADING SCREEN STYLES
   ========================================================================== */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--white);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  will-change: opacity;
}

.loading-screen.fade-out {
  animation: loaderFadeOut 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes loaderFadeOut {
  0%   {
    opacity: 1;
    visibility: visible;
  }
  100% {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

/* Logo animation */
.loading-screen__logo {
  width: 70px;
  height: 70px;
  opacity: 0;
  transform: scale(0.8);
  animation: loaderLogoIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s forwards;
}

@keyframes loaderLogoIn {
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Progress bar */
.loading-screen__progress {
  width: 180px;
  height: 3px;
  background: var(--gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
  opacity: 0;
  animation: fadeIn 0.4s ease 0.5s forwards;
}

.loading-screen__progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

/* Loading counter */
.loading-screen__counter {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--gray-400);
  letter-spacing: var(--tracking-wider);
  opacity: 0;
  animation: fadeIn 0.4s ease 0.6s forwards;
}

/* Spinner fallback */
.loading-screen__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   §10. SMOOTH PAGE TRANSITIONS
   ========================================================================== */
.page-enter {
  opacity: 0;
  transform: translateY(20px);
}

.page-enter-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-exit {
  opacity: 1;
  transform: translateY(0);
}

.page-exit-active {
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Wipe transition (full-screen color slide) */
.wipe-transition {
  position: fixed;
  inset: 0;
  z-index: 99998;
  pointer-events: none;
}

.wipe-transition__layer {
  position: absolute;
  inset: 0;
  transform: scaleY(0);
  transform-origin: bottom;
  will-change: transform;
}

.wipe-transition__layer--1 { background: var(--primary); z-index: 3; }
.wipe-transition__layer--2 { background: var(--primary-light); z-index: 2; }
.wipe-transition__layer--3 { background: var(--accent); z-index: 1; }

.wipe-transition.entering .wipe-transition__layer {
  animation: wipeEnter 0.6s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

.wipe-transition.leaving .wipe-transition__layer {
  animation: wipeLeave 0.6s cubic-bezier(0.77, 0, 0.175, 1) forwards;
  transform-origin: top;
}

.wipe-transition__layer--2 { animation-delay: 0.05s !important; }
.wipe-transition__layer--3 { animation-delay: 0.1s !important; }

@keyframes wipeEnter {
  0%   { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}

@keyframes wipeLeave {
  0%   { transform: scaleY(1); }
  100% { transform: scaleY(0); }
}

/* ==========================================================================
   §11. TEXT UNDERLINE ANIMATION
   Used on links and hover effects.
   ========================================================================== */
.text-underline-anim {
  position: relative;
  display: inline;
  background-image: linear-gradient(var(--primary), var(--primary));
  background-position: 0% 100%;
  background-repeat: no-repeat;
  background-size: 0% 2px;
  transition: background-size 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  padding-bottom: 2px;
}

.text-underline-anim:hover {
  background-size: 100% 2px;
}

/* ==========================================================================
   §12. CURSOR FOLLOWER (optional decorative cursor)
   ========================================================================== */
.cursor-follower {
  position: fixed;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  pointer-events: none;
  z-index: 99997;
  transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
  transform: translate(-50%, -50%);
  will-change: transform;
  mix-blend-mode: difference;
  opacity: 0;
}

.cursor-follower.visible {
  opacity: 1;
}

.cursor-follower.hovering {
  width: 50px;
  height: 50px;
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
}

/* Hide custom cursor on touch devices */
@media (hover: none) and (pointer: coarse) {
  .cursor-follower {
    display: none;
  }
}

/* ==========================================================================
   §13. SKELETON LOADING PLACEHOLDERS
   ========================================================================== */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--gray-100);
  border-radius: var(--radius-md);
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.4) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton--text {
  height: 1em;
  width: 80%;
  margin-bottom: 0.5em;
}

.skeleton--title {
  height: 1.5em;
  width: 60%;
  margin-bottom: 0.75em;
}

.skeleton--circle {
  border-radius: 50%;
}

.skeleton--image {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-2xl);
}

/* ==========================================================================
   §14. MARQUEE TEXT ANIMATION VARIANTS
   ========================================================================== */

/* Vertical marquee */
.marquee-vertical {
  overflow: hidden;
  height: 1.4em;
}

.marquee-vertical__track {
  display: flex;
  flex-direction: column;
  animation: marqueeVertical 4s ease-in-out infinite;
}

.marquee-vertical__item {
  height: 1.4em;
  line-height: 1.4;
}

@keyframes marqueeVertical {
  0%, 25%  { transform: translateY(0); }
  33%, 58% { transform: translateY(-33.333%); }
  66%, 91% { transform: translateY(-66.666%); }
  100%     { transform: translateY(0); }
}

/* ==========================================================================
   §15. REDUCE MOTION — disable all custom animations
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .reveal-up,
  .reveal-down,
  .reveal-left,
  .reveal-right,
  .reveal-scale,
  .reveal-fade,
  .reveal-rotate,
  .reveal-clip {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    transition: none !important;
  }

  .split-text .char,
  .split-words .word-inner,
  .split-lines .line-inner {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .img-reveal::after {
    display: none !important;
  }

  .img-reveal__image {
    transform: none !important;
  }

  .parallax-layer,
  .parallax-shape {
    transform: none !important;
  }

  .cursor-follower {
    display: none !important;
  }

  .loading-screen {
    display: none !important;
  }

  .card-shine::before {
    display: none !important;
  }
}
