/* ═══════════════════════════════════════════════════════════════
   TrickForge — Global Animation & Polish System
   Emil Kowalski-inspired: spring physics, staggered reveals,
   micro-interactions, scroll-triggered animations.
   ═══════════════════════════════════════════════════════════════ */

/* ── Animation Custom Properties ─────────────────────────────── */
:root {
  /* Timing */
  --tf-duration-fast: 150ms;
  --tf-duration-base: 200ms;
  --tf-duration-medium: 300ms;
  --tf-duration-slow: 500ms;
  --tf-duration-reveal: 700ms;

  /* Spring-like easings (cubic-bezier approximations) */
  --tf-ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --tf-ease-spring-bouncy: cubic-bezier(0.34, 1.56, 0.64, 1);
  --tf-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --tf-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Stagger */
  --tf-stagger: 60ms;

  /* Shadows (layered depth system) */
  --tf-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.15);
  --tf-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.15), 0 0 1px rgba(201, 168, 76, 0.1);
  --tf-shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.2), 0 0 1px rgba(201, 168, 76, 0.15);
  --tf-shadow-glow: 0 0 20px rgba(201, 168, 76, 0.15), 0 0 40px rgba(201, 168, 76, 0.05);

  /* Polish */
  --tf-radius: 8px;
  --tf-radius-sm: 4px;
  --tf-radius-lg: 12px;
  --tf-focus-ring: 0 0 0 2px rgba(201, 168, 76, 0.4), 0 0 0 4px rgba(201, 168, 76, 0.1);
}

/* ── Scroll Progress Bar ─────────────────────────────────────── */
.tf-scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent, #c9a84c), var(--accent-glow, #e8c95a));
  z-index: 9999;
  transition: none;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.tf-scroll-progress.tf-visible {
  opacity: 1;
}

/* ── Keyframe Animations ─────────────────────────────────────── */
@keyframes tf-fade-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tf-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes tf-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes tf-slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes tf-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes tf-pulse-soft {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes tf-thinking-dots {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes tf-glow-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(201, 168, 76, 0.2); }
  50% { box-shadow: 0 0 20px rgba(201, 168, 76, 0.4); }
}

/* ── Scroll Reveal Classes ───────────────────────────────────── */
/* Elements start invisible, animate in when IntersectionObserver triggers */
.tf-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--tf-duration-reveal) var(--tf-ease-spring),
              transform var(--tf-duration-reveal) var(--tf-ease-spring);
  will-change: opacity, transform;
}

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

/* Stagger children — each child delays by --tf-stagger * n */
.tf-stagger > .tf-reveal:nth-child(1) { transition-delay: calc(var(--tf-stagger) * 0); }
.tf-stagger > .tf-reveal:nth-child(2) { transition-delay: calc(var(--tf-stagger) * 1); }
.tf-stagger > .tf-reveal:nth-child(3) { transition-delay: calc(var(--tf-stagger) * 2); }
.tf-stagger > .tf-reveal:nth-child(4) { transition-delay: calc(var(--tf-stagger) * 3); }
.tf-stagger > .tf-reveal:nth-child(5) { transition-delay: calc(var(--tf-stagger) * 4); }
.tf-stagger > .tf-reveal:nth-child(6) { transition-delay: calc(var(--tf-stagger) * 5); }
.tf-stagger > .tf-reveal:nth-child(7) { transition-delay: calc(var(--tf-stagger) * 6); }
.tf-stagger > .tf-reveal:nth-child(8) { transition-delay: calc(var(--tf-stagger) * 7); }
.tf-stagger > .tf-reveal:nth-child(9) { transition-delay: calc(var(--tf-stagger) * 8); }
.tf-stagger > .tf-reveal:nth-child(10) { transition-delay: calc(var(--tf-stagger) * 9); }
.tf-stagger > .tf-reveal:nth-child(n+11) { transition-delay: calc(var(--tf-stagger) * 10); }

/* Scale reveal variant */
.tf-reveal-scale {
  opacity: 0;
  transform: scale(0.95);
  transition: opacity var(--tf-duration-reveal) var(--tf-ease-spring),
              transform var(--tf-duration-reveal) var(--tf-ease-spring);
  will-change: opacity, transform;
}

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

/* Left slide reveal */
.tf-reveal-left {
  opacity: 0;
  transform: translateX(-20px);
  transition: opacity var(--tf-duration-reveal) var(--tf-ease-spring),
              transform var(--tf-duration-reveal) var(--tf-ease-spring);
  will-change: opacity, transform;
}

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

/* ── Page Load Animation ─────────────────────────────────────── */
.tf-page-enter {
  animation: tf-fade-up var(--tf-duration-reveal) var(--tf-ease-spring) both;
}

.tf-page-enter-delay-1 { animation-delay: 80ms; }
.tf-page-enter-delay-2 { animation-delay: 160ms; }
.tf-page-enter-delay-3 { animation-delay: 240ms; }
.tf-page-enter-delay-4 { animation-delay: 320ms; }

/* ── Button Micro-interactions ───────────────────────────────── */
/* Apply .tf-btn to all interactive buttons/links */
.tf-btn {
  transition: transform var(--tf-duration-fast) var(--tf-ease-spring),
              background var(--tf-duration-base) var(--tf-ease-out),
              box-shadow var(--tf-duration-base) var(--tf-ease-out),
              color var(--tf-duration-base) var(--tf-ease-out),
              border-color var(--tf-duration-base) var(--tf-ease-out),
              opacity var(--tf-duration-base) var(--tf-ease-out);
  cursor: pointer;
}

.tf-btn:hover {
  transform: translateY(-1px) scale(1.02);
}

.tf-btn:active {
  transform: translateY(0) scale(0.98);
  transition-duration: 80ms;
}

/* Primary CTA variant — stronger hover */
.tf-btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: var(--tf-shadow-lg), var(--tf-shadow-glow);
}

.tf-btn-primary:active {
  transform: translateY(0) scale(0.97);
  transition-duration: 80ms;
}

/* ── Card Hover Polish ───────────────────────────────────────── */
.tf-card-hover {
  transition: transform var(--tf-duration-medium) var(--tf-ease-spring),
              box-shadow var(--tf-duration-medium) var(--tf-ease-out),
              border-color var(--tf-duration-medium) var(--tf-ease-out);
}

.tf-card-hover:hover {
  transform: translateY(-3px);
  box-shadow: var(--tf-shadow-lg);
}

/* ── Tag/Chip Hover ──────────────────────────────────────────── */
.tf-chip-hover {
  transition: border-color var(--tf-duration-base) var(--tf-ease-out),
              background var(--tf-duration-base) var(--tf-ease-out),
              color var(--tf-duration-base) var(--tf-ease-out),
              box-shadow var(--tf-duration-base) var(--tf-ease-out);
}

.tf-chip-hover:hover {
  border-color: rgba(201, 168, 76, 0.3);
  background: rgba(201, 168, 76, 0.12);
  box-shadow: 0 0 12px rgba(201, 168, 76, 0.08);
}

/* ── Input Focus Polish ──────────────────────────────────────── */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent, #c9a84c) !important;
  box-shadow: var(--tf-focus-ring);
  transition: border-color var(--tf-duration-base) var(--tf-ease-out),
              box-shadow var(--tf-duration-base) var(--tf-ease-out);
}

/* ── Focus Ring (Accessibility) ──────────────────────────────── */
*:focus-visible {
  outline: none;
  box-shadow: var(--tf-focus-ring);
}

/* ── Skeleton Loader (Shimmer) ───────────────────────────────── */
.tf-skeleton {
  background: linear-gradient(
    90deg,
    rgba(201, 168, 76, 0.04) 25%,
    rgba(201, 168, 76, 0.1) 50%,
    rgba(201, 168, 76, 0.04) 75%
  );
  background-size: 200% 100%;
  animation: tf-shimmer 1.8s ease-in-out infinite;
  border-radius: var(--tf-radius-sm);
}

.tf-skeleton-text {
  height: 14px;
  border-radius: 3px;
  margin-bottom: 8px;
}

.tf-skeleton-text:last-child {
  width: 60%;
}

.tf-skeleton-heading {
  height: 24px;
  width: 40%;
  border-radius: 4px;
  margin-bottom: 16px;
}

.tf-skeleton-block {
  height: 120px;
  border-radius: var(--tf-radius);
}

/* ── AI Thinking State ───────────────────────────────────────── */
.tf-thinking {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}

.tf-thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #c9a84c);
  animation: tf-thinking-dots 1.4s ease-in-out infinite;
}

.tf-thinking-dot:nth-child(2) { animation-delay: 0.16s; }
.tf-thinking-dot:nth-child(3) { animation-delay: 0.32s; }

/* Alternative: soft pulse on container */
.tf-ai-pulse {
  animation: tf-pulse-soft 2s ease-in-out infinite;
}

/* ── Modal Animations ────────────────────────────────────────── */
.tf-modal-backdrop {
  opacity: 0;
  backdrop-filter: blur(0px);
  transition: opacity var(--tf-duration-medium) var(--tf-ease-out),
              backdrop-filter var(--tf-duration-medium) var(--tf-ease-out);
}

.tf-modal-backdrop.tf-visible {
  opacity: 1;
  backdrop-filter: blur(4px);
}

.tf-modal-content {
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  transition: opacity var(--tf-duration-medium) var(--tf-ease-spring),
              transform var(--tf-duration-medium) var(--tf-ease-spring);
}

.tf-modal-content.tf-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
}

/* ── Nav Link Hover Enhancement ──────────────────────────────── */
.tf-nav-link {
  position: relative;
  transition: color var(--tf-duration-base) var(--tf-ease-out);
}

.tf-nav-link::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--accent, #c9a84c);
  transition: width var(--tf-duration-medium) var(--tf-ease-spring);
}

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

/* ── Clickable cursor enforcement ────────────────────────────── */
a, button, [role="button"], [onclick], .tf-btn,
input[type="submit"], input[type="button"],
label[for], summary, .pillar-card, .nav-hamburger {
  cursor: pointer;
}

/* ── Color transitions on ALL interactive elements ───────────── */
a {
  transition: color var(--tf-duration-base) var(--tf-ease-out),
              opacity var(--tf-duration-base) var(--tf-ease-out);
}

button {
  transition: transform var(--tf-duration-fast) var(--tf-ease-spring),
              background var(--tf-duration-base) var(--tf-ease-out),
              box-shadow var(--tf-duration-base) var(--tf-ease-out),
              color var(--tf-duration-base) var(--tf-ease-out),
              border-color var(--tf-duration-base) var(--tf-ease-out),
              opacity var(--tf-duration-base) var(--tf-ease-out);
}

/* ── Section divider animation ───────────────────────────────── */
.divider {
  transition: width var(--tf-duration-slow) var(--tf-ease-spring);
}

.divider.tf-visible {
  width: 80px;
}

/* ── Tooltip style (optional utility) ────────────────────────── */
[data-tf-tooltip] {
  position: relative;
}

[data-tf-tooltip]::before {
  content: attr(data-tf-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--bg-card, #12121a);
  color: var(--text, #e8e6e0);
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: var(--tf-radius-sm);
  border: 1px solid var(--border, rgba(201, 168, 76, 0.15));
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--tf-duration-base) var(--tf-ease-out),
              transform var(--tf-duration-base) var(--tf-ease-spring);
  z-index: 100;
}

[data-tf-tooltip]:hover::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

  .tf-reveal,
  .tf-reveal-scale,
  .tf-reveal-left {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .tf-scroll-progress {
    display: none;
  }
}
