/**
 * Tecnologolilla Motion Catalog
 * All animations are pure CSS. Only transform and opacity are animated.
 * Wrap scroll-driven animations in @supports (animation-timeline: view())
 * and provide a static fallback for older browsers.
 * prefers-reduced-motion: reduce disables all motion.
 */

/* ---------------------------------------------------------------------------
 * 1. GLOBAL MOTION RESET
 * --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------------------------
 * 2. KEYFRAMES
 * Only transform and opacity are used. No width/height/margin/top.
 * --------------------------------------------------------------------------- */
/* Transform-only by design: the guidebook's own accessibility section
 * promises "content is always visible" and "no content is hidden behind
 * motion or JS" - that guarantee takes precedence over animating opacity
 * here. An opacity 0 -> 1 keyframe combined with animation-timeline: view()
 * and fill-mode both computes to opacity: 0 at scroll position zero for any
 * .reveal section below the entry threshold, which is exactly the "hidden
 * behind motion" case the guidebook forbids and breaks screenshot-at-load
 * rendering (crawlers, AdSense review). Do not reintroduce the fade; let
 * the base .reveal rule below (outside @supports) own opacity at all times
 * and have this keyframe only move the element. */
@keyframes reveal-up {
  from {
    transform: translateY(24px);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes pulse-dot {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.4);
    opacity: 0.7;
  }
}

@keyframes chevron-nudge {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(3px);
  }
}

/* ---------------------------------------------------------------------------
 * 3. SCROLL-DRIVEN REVEAL
 * Recipe: elements enter viewport and slide up. Opacity is never animated
 * here - see the comment above @keyframes reveal-up.
 * --------------------------------------------------------------------------- */
.reveal {
  opacity: 1;
  transform: translateY(0);
}

@supports (animation-timeline: view()) {
  .reveal {
    animation: reveal-up auto linear both;
    animation-timeline: view();
    animation-range: entry 8% cover 22%;
  }
}

/* ---------------------------------------------------------------------------
 * 4. HOVER MICRO-INTERACTIONS
 * Recipe: small, purposeful transitions.
 * --------------------------------------------------------------------------- */
.hover-lift {
  transition: transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out);
}

.hover-lift:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.hover-scale {
  transition: transform var(--duration-fast) var(--ease-out);
}

.hover-scale:hover {
  transform: scale(1.02);
}

/* Image zoom inside card media */
.card__media-zoom {
  overflow: hidden;
}

.card__media-zoom img {
  transition: transform var(--duration-slow) var(--ease-out);
}

.card__media-zoom:hover img,
.card:hover .card__media-zoom img {
  transform: scale(1.03);
}

/* Section title chevron nudge */
.section-title a:hover .section-title__chevron {
  transform: translateX(3px);
}

/* ---------------------------------------------------------------------------
 * 5. SKELETON LOADING
 * Recipe: placeholder gradient sweep while data is fetched.
 * Only safe because it is decorative and hidden when loaded.
 * --------------------------------------------------------------------------- */
.skeleton {
  background: var(--color-bg-muted);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.skeleton::after {
  animation: shimmer var(--duration-slow) infinite;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.35),
    transparent
  );
  content: "";
  inset: 0;
  position: absolute;
  transform: translateX(-100%);
}

@media (prefers-color-scheme: dark) {
  .skeleton::after {
    background: linear-gradient(
      90deg,
      transparent,
      rgba(255, 255, 255, 0.08),
      transparent
    );
  }
}

/* ---------------------------------------------------------------------------
 * 6. EMPTY STATE PULSE
 * Recipe: subtle indicator for "집계 중" / loading.
 * --------------------------------------------------------------------------- */
.status-dot {
  animation: pulse-dot 2s ease-in-out infinite;
  background: var(--color-warm-500);
  border-radius: var(--radius-full);
  display: inline-block;
  height: 8px;
  width: 8px;
}

/* ---------------------------------------------------------------------------
 * 7. DIALOG OPEN/CLOSE
 * Recipe: native <dialog> fades in when shown.
 * --------------------------------------------------------------------------- */
.mobile-drawer {
  opacity: 0;
  transform: translateX(100%);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.mobile-drawer[open] {
  opacity: 1;
  transform: translateX(0);
}

.mobile-drawer::backdrop {
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
}

.mobile-drawer[open]::backdrop {
  opacity: 1;
}

/* ---------------------------------------------------------------------------
 * 8. REDUCED MOTION: suppress all above
 * --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    animation: none !important;
  }

  .skeleton::after {
    animation: none !important;
  }

  .status-dot {
    animation: none !important;
  }

  .mobile-drawer,
  .mobile-drawer[open] {
    opacity: 1;
    transform: none;
  }

  .mobile-drawer::backdrop,
  .mobile-drawer[open]::backdrop {
    opacity: 1;
  }
}
