/* ============================================================
   ECBC Compliance Portal — Utilities & Animations
   ============================================================ */

/* ── Page Load Transition (prevent FOUC) ───────────────────── */
body:not(.page-ready) {
    visibility: hidden;
    opacity: 0;
}
body.page-ready {
    visibility: visible;
    opacity: 1;
    animation: ecp-pageIn 0.15s ease;
}
@keyframes ecp-pageIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Animations ────────────────────────────────────────────── */

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

@keyframes ecp-fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ecp-fadeInDown {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ecp-slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes ecp-slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

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

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

@keyframes ecp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes ecp-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes ecp-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes ecp-countUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ecp-progressBar {
  from { width: 0; }
}

@keyframes ecp-dotPulse {
  0%, 80%, 100% { transform: scale(0); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

@keyframes ecp-ripple {
  to { transform: scale(4); opacity: 0; }
}


/* ── Animation Classes ─────────────────────────────────────── */

.ecp-animate-in {
  animation: ecp-fadeInUp 0.5s ease forwards;
  opacity: 0;
}

.ecp-animate-fade {
  animation: ecp-fadeIn 0.3s ease forwards;
}

.ecp-animate-scale {
  animation: ecp-scaleIn 0.3s ease forwards;
}

.ecp-animate-slide-left {
  animation: ecp-slideInLeft 0.4s ease forwards;
  opacity: 0;
}

.ecp-animate-slide-right {
  animation: ecp-slideInRight 0.4s ease forwards;
  opacity: 0;
}

/* Staggered reveal for lists/grids */
.ecp-stagger > * {
  opacity: 0;
  animation: ecp-fadeInUp 0.5s ease forwards;
}
.ecp-stagger > *:nth-child(1) { animation-delay: 0.05s; }
.ecp-stagger > *:nth-child(2) { animation-delay: 0.1s; }
.ecp-stagger > *:nth-child(3) { animation-delay: 0.15s; }
.ecp-stagger > *:nth-child(4) { animation-delay: 0.2s; }
.ecp-stagger > *:nth-child(5) { animation-delay: 0.25s; }
.ecp-stagger > *:nth-child(6) { animation-delay: 0.3s; }
.ecp-stagger > *:nth-child(7) { animation-delay: 0.35s; }
.ecp-stagger > *:nth-child(8) { animation-delay: 0.4s; }

/* Scroll reveal (applied via IntersectionObserver) */
.ecp-reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.ecp-reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.ecp-reveal-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.ecp-reveal-left.is-visible {
  opacity: 1;
  transform: translateX(0);
}
.ecp-reveal-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.ecp-reveal-right.is-visible {
  opacity: 1;
  transform: translateX(0);
}


/* ── Hover Effects ─────────────────────────────────────────── */

.ecp-hover-lift {
  transition: transform var(--ecp-transition-base), box-shadow var(--ecp-transition-base);
}
.ecp-hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--ecp-shadow-2);
}

.ecp-hover-glow {
  transition: box-shadow var(--ecp-transition-base);
}
.ecp-hover-glow:hover {
  box-shadow: 0 0 0 4px rgba(var(--ecp-primary-rgb), 0.1), var(--ecp-shadow-2);
}

.ecp-hover-border {
  transition: border-color var(--ecp-transition-fast);
}
.ecp-hover-border:hover {
  border-color: var(--ecp-primary);
}

.ecp-hover-bg {
  transition: background-color var(--ecp-transition-fast);
}
.ecp-hover-bg:hover {
  background-color: var(--ecp-primary-bg);
}

/* Button press effect */
.ecp-press:active {
  transform: scale(0.97);
}


/* ── Skeleton Loading ──────────────────────────────────────── */

.ecp-skeleton {
  background: linear-gradient(90deg, var(--ecp-gray-100) 25%, var(--ecp-gray-200) 50%, var(--ecp-gray-100) 75%);
  background-size: 200% 100%;
  animation: ecp-shimmer 1.5s infinite ease-in-out;
  border-radius: var(--ecp-radius-sm);
}

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

.ecp-skeleton-text.w-75 { width: 75%; }
.ecp-skeleton-text.w-50 { width: 50%; }
.ecp-skeleton-text.w-25 { width: 25%; }

.ecp-skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.ecp-skeleton-card {
  height: 120px;
  border-radius: var(--ecp-radius-lg);
}

.ecp-skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}


/* ── Empty States ──────────────────────────────────────────── */

.ecp-empty-state {
  text-align: center;
  padding: var(--ecp-space-16) var(--ecp-space-8);
}

.ecp-empty-state-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--ecp-space-6);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--ecp-gray-100);
  color: var(--ecp-gray-400);
  font-size: 32px;
}

.ecp-empty-state-title {
  font-size: var(--ecp-font-h3);
  font-weight: var(--ecp-weight-semibold);
  color: var(--ecp-text-primary);
  margin-bottom: var(--ecp-space-2);
}

.ecp-empty-state-text {
  font-size: var(--ecp-font-small);
  color: var(--ecp-text-muted);
  max-width: 360px;
  margin: 0 auto;
}


/* ── Loading Spinner ───────────────────────────────────────── */

.ecp-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ecp-gray-200);
  border-top-color: var(--ecp-primary);
  border-radius: 50%;
  animation: ecp-spin 0.6s linear infinite;
  display: inline-block;
}
.ecp-spinner-sm { width: 14px; height: 14px; border-width: 1.5px; }
.ecp-spinner-lg { width: 32px; height: 32px; border-width: 3px; }


/* ── Loading Dots ──────────────────────────────────────────── */

.ecp-loading-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.ecp-loading-dots span {
  width: 6px;
  height: 6px;
  background: var(--ecp-primary);
  border-radius: 50%;
  animation: ecp-dotPulse 1.4s infinite ease-in-out both;
}
.ecp-loading-dots span:nth-child(1) { animation-delay: 0s; }
.ecp-loading-dots span:nth-child(2) { animation-delay: 0.16s; }
.ecp-loading-dots span:nth-child(3) { animation-delay: 0.32s; }


/* ── Utility Classes ───────────────────────────────────────── */

/* Text truncation */
.ecp-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ecp-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ecp-truncate-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Glass/frosted effect */
.ecp-glass {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.ecp-glass-dark {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Gradient text */
.ecp-gradient-text {
  background: linear-gradient(135deg, var(--ecp-primary), var(--ecp-primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Dividers */
.ecp-divider {
  height: 1px;
  background: var(--ecp-gray-200);
  border: none;
  margin: var(--ecp-space-6) 0;
}

.ecp-divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--ecp-gray-200);
}

/* Scrollable container */
.ecp-scrollable {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar */
.ecp-no-scrollbar::-webkit-scrollbar { display: none; }
.ecp-no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Screen reader only */
.ecp-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Ratio boxes */
.ecp-aspect-square { aspect-ratio: 1 / 1; }
.ecp-aspect-video { aspect-ratio: 16 / 9; }
.ecp-aspect-4-3 { aspect-ratio: 4 / 3; }

/* Subtle backgrounds */
.ecp-bg-dots {
  background-image: radial-gradient(circle, var(--ecp-gray-200) 1px, transparent 1px);
  background-size: 20px 20px;
}

.ecp-bg-grid {
  background-image:
    linear-gradient(var(--ecp-gray-100) 1px, transparent 1px),
    linear-gradient(90deg, var(--ecp-gray-100) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* Progress bar animation */
.ecp-progress-animate {
  animation: ecp-progressBar 1s ease forwards;
}


/* ── Responsive Helpers ────────────────────────────────────── */

.ecp-hide-mobile { display: block; }
.ecp-show-mobile { display: none; }

@media (max-width: 767.98px) {
  .ecp-hide-mobile { display: none !important; }
  .ecp-show-mobile { display: block !important; }
}

.ecp-hide-tablet { display: block; }
.ecp-show-tablet { display: none; }

@media (max-width: 991.98px) {
  .ecp-hide-tablet { display: none !important; }
  .ecp-show-tablet { display: block !important; }
}
