/* ============================================================
   EVERLAST CUSTOMZ - Motion System v3
   Restrained entrances, hairline reveals, hardware-feeling
   micro-interactions. Every duration/easing from tokens.
   ============================================================ */

/* --- Keyframes --- */

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

@keyframes fade-up {
  from { opacity: 0; transform: translateY(22px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-22px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-left {
  from { opacity: 0; transform: translateX(22px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fade-right {
  from { opacity: 0; transform: translateX(-22px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes scale-up {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

@keyframes skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); max-height: 120px; margin-bottom: var(--space-3); }
  to { opacity: 0; transform: translateX(24px); max-height: 0; margin-bottom: 0; padding: 0; border: 0; }
}

@keyframes badge-bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.28); }
}

/* Live-state dot — quiet, single ring, never a glow bath */
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(220, 38, 38, 0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

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

@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes slide-out-right {
  from { transform: translateX(0); }
  to { transform: translateX(100%); }
}

@keyframes slide-in-bottom {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes progress-indeterminate {
  0% { left: -40%; width: 40%; }
  50% { left: 50%; width: 30%; }
  100% { left: 100%; width: 20%; }
}

/* Hairline grows from the left — the editorial detail */
@keyframes line-grow-x {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* --- Entrance utilities --- */

.animate-fade-in {
  animation: fade-in var(--duration-slow) var(--ease-out-expo) both;
}

.animate-fade-up {
  animation: fade-up var(--duration-slow) var(--ease-out-expo) both;
}

.animate-fade-down {
  animation: fade-down var(--duration-slow) var(--ease-out-expo) both;
}

.animate-scale-in {
  animation: scale-in var(--duration-slow) var(--ease-out-expo) both;
}

.animate-spin {
  animation: spin 0.6s linear infinite;
}

.animate-shake {
  animation: shake 0.5s var(--ease-in-out);
}

/* Keep for live-state dots */
.animate-pulse-red {
  animation: pulse-red 2.4s var(--ease-in-out) infinite;
}

/* --- Staggered children --- */

.stagger-children > * {
  opacity: 0;
  animation: fade-up var(--duration-slow) var(--ease-out-expo) both;
}

.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 60ms; }
.stagger-children > *:nth-child(3) { animation-delay: 120ms; }
.stagger-children > *:nth-child(4) { animation-delay: 180ms; }
.stagger-children > *:nth-child(5) { animation-delay: 240ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }
.stagger-children > *:nth-child(7) { animation-delay: 360ms; }
.stagger-children > *:nth-child(8) { animation-delay: 420ms; }
.stagger-children > *:nth-child(9) { animation-delay: 480ms; }
.stagger-children > *:nth-child(10) { animation-delay: 540ms; }
.stagger-children > *:nth-child(11) { animation-delay: 600ms; }
.stagger-children > *:nth-child(12) { animation-delay: 660ms; }

/* --- Scroll reveal (IntersectionObserver adds .visible) --- */

.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--duration-slow) var(--ease-out-expo),
              transform var(--duration-slow) var(--ease-out-expo);
}

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

.reveal-left {
  opacity: 0;
  transform: translateX(-18px);
  transition: opacity var(--duration-slow) var(--ease-out-expo),
              transform var(--duration-slow) var(--ease-out-expo);
}

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

.reveal-right {
  opacity: 0;
  transform: translateX(18px);
  transition: opacity var(--duration-slow) var(--ease-out-expo),
              transform var(--duration-slow) var(--ease-out-expo);
}

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

.reveal-scale {
  opacity: 0;
  transform: scale(0.975);
  transition: opacity var(--duration-slow) var(--ease-out-expo),
              transform var(--duration-slow) var(--ease-out-expo);
}

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

/* Hairline that grows in on reveal */
.reveal-line {
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform var(--duration-glacial) var(--ease-out-expo);
}

.reveal-line.visible {
  transform: scaleX(1);
}

/* Stagger delays inside a reveal group */
.reveal-group .reveal:nth-child(1) { transition-delay: 0ms; }
.reveal-group .reveal:nth-child(2) { transition-delay: 70ms; }
.reveal-group .reveal:nth-child(3) { transition-delay: 140ms; }
.reveal-group .reveal:nth-child(4) { transition-delay: 210ms; }
.reveal-group .reveal:nth-child(5) { transition-delay: 280ms; }
.reveal-group .reveal:nth-child(6) { transition-delay: 350ms; }
.reveal-group .reveal:nth-child(7) { transition-delay: 420ms; }
.reveal-group .reveal:nth-child(8) { transition-delay: 490ms; }

/* --- Page load --- */

.page-enter {
  animation: fade-in var(--duration-slow) var(--ease-out-expo) both;
}

/* --- Hero entrance (index + landing pages) --- */

.hero-title {
  animation: fade-up 0.7s var(--ease-out-expo) 0.05s both;
}

.hero-subtitle {
  animation: fade-up 0.7s var(--ease-out-expo) 0.16s both;
}

.hero-cta {
  animation: fade-up 0.7s var(--ease-out-expo) 0.26s both;
}

.hero-visual {
  animation: fade-up 0.8s var(--ease-out-expo) 0.2s both;
}

.hero-spec {
  animation: fade-in 0.7s var(--ease-out-expo) 0.4s both;
}

.hero-line {
  height: 2px;
  background: var(--red-500);
  transform-origin: left center;
  animation: line-grow-x 0.8s var(--ease-out-expo) 0.35s both;
}

/* --- Hover utilities --- */

.hover-lift {
  transition: transform var(--duration-normal) var(--ease-out-expo),
              box-shadow var(--duration-normal) var(--ease-out-expo);
}

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

.hover-glow {
  transition: box-shadow var(--duration-normal) var(--ease-out-expo);
}

.hover-glow:hover {
  box-shadow: var(--shadow-card-hover);
}

.hover-scale {
  transition: transform var(--duration-normal) var(--ease-out-expo);
}

.hover-scale:hover {
  transform: scale(1.02);
}

/* --- Underline grow (legacy hook) --- */

.underline-grow {
  position: relative;
}

.underline-grow::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--red-500);
  transition: width var(--duration-normal) var(--ease-out-expo),
              left var(--duration-normal) var(--ease-out-expo);
}

.underline-grow:hover::after,
.underline-grow.active::after {
  width: 100%;
  left: 0;
}

/* --- Counter --- */

.counter {
  display: inline-block;
  animation: count-up var(--duration-slow) var(--ease-out-expo) both;
}

/* --- Indeterminate progress --- */

.progress-indeterminate {
  position: relative;
  width: 100%;
  height: 3px;
  background: var(--bg-elevated);
  overflow: hidden;
  border-radius: var(--radius-full);
}

.progress-indeterminate::after {
  content: '';
  position: absolute;
  height: 100%;
  background: var(--red-500);
  border-radius: var(--radius-full);
  animation: progress-indeterminate 1.5s var(--ease-in-out) infinite;
}

/* --- Cart drawer --- */

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: var(--z-overlay);
  transform: translateX(100%);
  transition: transform var(--duration-slow) var(--ease-out-expo);
}

.cart-drawer.open {
  transform: translateX(0);
}

.cart-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: calc(var(--z-overlay) - 1);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal);
}

.cart-drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* --- Mobile bottom nav --- */

.mobile-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(10, 10, 12, 0.92);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border-top: 1px solid var(--border);
  z-index: var(--z-sticky);
  display: none;
  padding: var(--space-1) 0;
  padding-bottom: env(safe-area-inset-bottom, var(--space-1));
}

@media (max-width: 768px) {
  .mobile-nav {
    display: flex;
  }
  .page-content {
    padding-bottom: 68px;
  }
}

.mobile-nav-items {
  display: flex;
  width: 100%;
  justify-content: space-around;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-1) var(--space-2);
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: 500;
  transition: color var(--duration-fast);
  position: relative;
  min-width: 48px;
}

.mobile-nav-item svg {
  width: 22px;
  height: 22px;
}

.mobile-nav-item.active {
  color: var(--red-500);
}

.mobile-nav-item:active {
  transform: scale(0.92);
}

/* --- Notification dot --- */

.notification-dot {
  width: 8px;
  height: 8px;
  background: var(--red-500);
  border-radius: var(--radius-full);
  position: absolute;
  top: 4px;
  right: calc(50% - 14px);
}

/* --- Sidebar (admin / dashboard) --- */

.sidebar {
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  bottom: 0;
  width: 260px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  padding: var(--space-4);
  overflow-y: auto;
  z-index: var(--z-sticky);
  transition: transform var(--duration-slow) var(--ease-out-expo);
}

.sidebar-content {
  margin-left: 260px;
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-content {
    margin-left: 0;
  }
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: rgba(220, 38, 38, 0.1);
  color: var(--red-400);
}

.sidebar-section-title {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: var(--space-4) var(--space-3) var(--space-2);
}
