/* ============================================================
   ANIMATIONS — Score bars, result reveal, transitions
   Sponsorship Intelligence Tool
   ============================================================ */

/* ============================================================
   KEYFRAMES
   ============================================================ */

/* Spinner rotation for loading state */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Skeleton pulse for loading placeholders */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* Blinking cursor after streaming text */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* Score bar fill — grows from 0 to target width */
/* Width is supplied via the inline style: style="--score-target: 72%" */
@keyframes fillBar {
  from { width: 0; }
  to   { width: var(--score-target, 0%); }
}

/* Result card fade + lift in from below */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dimension card pop-in individually */
@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.95);
  }
  60% {
    transform: scale(1.02);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Checkmark confirmation bounce (copy button) */
@keyframes checkBounce {
  0%   { transform: scale(0.8); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Subtle shake for form validation error */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-5px); }
  40%       { transform: translateX(5px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* ============================================================
   SCORE BAR ANIMATION
   Applied by JS: bar.classList.add('score-bar-fill--animated')
   after component mounts. Fires once only.
   ============================================================ */

.score-bar-fill--animated {
  animation: fillBar 400ms ease-out forwards;  /* forwards: stay at final value */
}

/* ============================================================
   RESULT REVEAL
   Applied by JS when each result section mounts.
   ============================================================ */

.result-reveal {
  animation: fadeUp 350ms ease-out both;
}

/* Stagger delays for the 5 dimension cards */
.dimension-card:nth-child(1) { animation-delay: 0ms; }
.dimension-card:nth-child(2) { animation-delay: 60ms; }
.dimension-card:nth-child(3) { animation-delay: 120ms; }
.dimension-card:nth-child(4) { animation-delay: 180ms; }
.dimension-card:nth-child(5) { animation-delay: 240ms; }

/* Dimension card mount animation */
.dimension-card--mounted {
  animation: popIn 300ms ease-out both;
}

/* Analysis summary mount — offset after scores */
.analysis-summary--mounted {
  animation: fadeUp 400ms ease-out 100ms both;
}

/* Comparables table mount — offset slightly after analysis */
.comparables-table-wrap--mounted {
  animation: fadeUp 400ms ease-out 150ms both;
}

/* ============================================================
   COPY CONFIRMATION
   JS adds .copy-icon--confirmed, removes after 1500ms
   ============================================================ */

.copy-icon--confirmed {
  animation: checkBounce 250ms ease-out both;
}

/* ============================================================
   FORM ERROR SHAKE
   JS adds .form-input--shake, removes after animation
   ============================================================ */

.form-input--shake {
  animation: shake 300ms ease-out;
}

/* ============================================================
   TABLE ROW EXPAND
   Inline note row height transition (max-height trick)
   ============================================================ */

/* Note cell default — collapsed */
.tr-note td > .note-inner {
  max-height: 0;
  overflow: hidden;
  transition: max-height 250ms ease-out, padding 250ms ease-out;
  padding-top: 0;
  padding-bottom: 0;
}

/* Expanded — JS adds tr--expanded to the main row */
.tr--expanded + .tr-note td > .note-inner {
  max-height: 120px;           /* Generous max — actual content is short */
  padding-top: var(--space-2);
  padding-bottom: var(--space-4);
}

/* ============================================================
   EXPORT BAR REVEAL
   Slides up from below when results complete
   ============================================================ */

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.export-bar.export-bar--visible {
  animation: slideUp 300ms ease-out both;
}

/* ============================================================
   LOADING STATUS MESSAGE FADE
   JS cycles through messages using this class
   ============================================================ */

@keyframes messageFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.loading-status {
  animation: messageFadeIn 200ms ease-out both;
}

/* Re-trigger animation by toggling class via JS */
.loading-status--refresh {
  animation: none;
}

/* ============================================================
   CONTEXT ACCORDION EXPAND
   ============================================================ */

@keyframes accordionOpen {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.context-accordion.context-accordion--open {
  animation: accordionOpen 180ms ease-out both;
}

/* ============================================================
   REDUCED MOTION — respect user preference
   ============================================================ */

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

  /* Score bars: just snap to final value immediately */
  .score-bar-fill--animated {
    width: var(--score-target, 0%);
    animation: none;
  }
}
