/* =============================================================================
   VIDUR FOUNDATION — ANIMATIONS
   Scroll reveals, counters, hero transitions.
   ============================================================================= */

/* ── Scroll Reveal System ─────────────────────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(32px);
  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.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered child reveals */
.stagger > * {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.stagger.is-visible > *:nth-child(1) { opacity: 1; transform: none; transition-delay: 0.05s; }
.stagger.is-visible > *:nth-child(2) { opacity: 1; transform: none; transition-delay: 0.15s; }
.stagger.is-visible > *:nth-child(3) { opacity: 1; transform: none; transition-delay: 0.25s; }
.stagger.is-visible > *:nth-child(4) { opacity: 1; transform: none; transition-delay: 0.35s; }
.stagger.is-visible > *:nth-child(5) { opacity: 1; transform: none; transition-delay: 0.45s; }
.stagger.is-visible > *:nth-child(6) { opacity: 1; transform: none; transition-delay: 0.55s; }

/* Fade only (no translate) */
.reveal--fade {
  opacity: 0;
  transform: none;
}
.reveal--fade.is-visible { opacity: 1; }

/* ── Keyframes ────────────────────────────────────────────────────────────── */
@keyframes slideUpFade {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50%       { transform: translateY(10px); opacity: 1; }
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.7; }
}

@keyframes orbFloat {
  0%, 100% { transform: translate(50%, -50%) scale(1); opacity: 0.8; }
  33%       { transform: translate(46%, -56%) scale(1.08); opacity: 1; }
  66%       { transform: translate(54%, -43%) scale(0.94); opacity: 0.6; }
}

/* ── Hero Load Animations (CSS-driven, no JS needed) ─────────────────────── */
.hero-eyebrow  { animation: slideUpFade 0.7s ease both; }
.hero-title    { animation: slideUpFade 0.7s 0.12s ease both; }
.hero-description { animation: slideUpFade 0.7s 0.22s ease both; }
.hero-actions  { animation: slideUpFade 0.7s 0.32s ease both; }
.hero-scroll-indicator { animation: slideUpFade 0.7s 0.5s ease both; }

/* Scroll indicator bounce */
.scroll-arrow { animation: scrollBounce 2.2s ease-in-out infinite; }

/* Hero background glow */
.hero-glow { animation: glowPulse 4s ease-in-out infinite; }

/* ── Back to Top Button ───────────────────────────────────────────────────── */
#back-to-top {
  position: fixed;
  bottom: var(--space-8);
  right: var(--space-8);
  width: 44px; height: 44px;
  background: #1D1D1F;
  color: #F5F5F7;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, background 0.15s ease;
  z-index: var(--z-sticky);
}

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

#back-to-top:hover {
  background: #3D3D3F;
  color: #F5F5F7;
}

#back-to-top svg { display: block; }

/* ── Table of Contents ────────────────────────────────────────────────────── */
.toc {
  background: #F5F5F7;
  border: 1px solid #D2D2D7;
  border-left: 3px solid #C9922A;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-6);
  margin: var(--space-8) 0 var(--space-10);
}

/* details/summary — collapsible on mobile */
.toc summary.toc__label {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.toc summary.toc__label::-webkit-details-marker { display: none; }

.toc summary.toc__label::after {
  content: '+';
  font-size: var(--text-base);
  font-weight: 400;
  color: #A8731A;
  line-height: 1;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.toc[open] summary.toc__label::after { content: '−'; }

/* Divider between summary and list when open */
.toc[open] #toc-auto { margin-top: var(--space-4); }

/* Desktop — always open, not interactive */
@media (min-width: 768px) {
  .toc summary.toc__label {
    cursor: default;
    pointer-events: none;
  }
  .toc summary.toc__label::after { display: none; }
}

.toc__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-gold-600);
}

.toc:not(details) .toc__label,
.toc[open] .toc__label { margin-bottom: var(--space-4); }

.toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc__list li + li { margin-top: var(--space-2); }

.toc__list a {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
  display: flex;
  gap: var(--space-2);
  align-items: baseline;
}

.toc__list a::before {
  content: '—';
  color: var(--border-medium);
  flex-shrink: 0;
  font-size: var(--text-xs);
}

.toc__list a:hover { color: var(--color-gold-500); }

/* ── Reduced Motion: Disable everything ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .reveal, .stagger > *, .reveal--fade,
  .hero-eyebrow, .hero-title, .hero-description, .hero-actions,
  .hero-scroll-indicator, .scroll-arrow, .hero-glow {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
