/**
 * Haiven Premium UX System
 * Apple-level micro-interactions, animations, and sensory design
 */

/* ============================================================================
   BREATHING ANIMATIONS - Make Haiven Feel Alive
   ============================================================================ */

/* Memory save breathing pulse */
@keyframes memoryAbsorb {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(31, 182, 255, 0.4);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 0 0 20px rgba(31, 182, 255, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(31, 182, 255, 0);
  }
}

@keyframes memoryPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

@keyframes gentleBreathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.005);
  }
}

@keyframes successGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.6);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(78, 205, 196, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(78, 205, 196, 0);
  }
}

@keyframes thoughtAbsorbed {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  50% {
    transform: translateY(-10px) scale(0.95);
    opacity: 0.8;
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Apply to elements */
.memory-saving {
  animation: memoryAbsorb 0.8s ease-out;
}

.memory-saved {
  animation: successGlow 0.6s ease-out;
}

.memory-card.new {
  animation: thoughtAbsorbed 0.5s ease-out;
}

/* Haiven logo breathing - subtle, always alive */
.haiven-logo,
.logo {
  animation: gentleBreathe 4s ease-in-out infinite;
}

/* ============================================================================
   MICRO-INTERACTIONS - Every Touch Feels Premium
   ============================================================================ */

/* Card lift on hover */
.memory-card,
.card,
.stat-card,
.feature-card {
  transition:
    transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease,
    border-color 0.3s ease;
}

.memory-card:hover,
.card:hover,
.stat-card:hover,
.feature-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow:
    0 20px 40px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(31, 182, 255, 0.1);
}

.memory-card:active,
.card:active {
  transform: translateY(-2px) scale(0.99);
  transition: transform 0.1s ease;
}

/* Button press feedback */
.btn,
button,
[role='button'] {
  transition:
    transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.15s ease,
    background-color 0.2s ease,
    border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.btn:hover,
button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(31, 182, 255, 0.2);
}

.btn:active,
button:active {
  transform: translateY(0) scale(0.98);
  transition: transform 0.05s ease;
}

/* Ripple effect on click */
.btn::after,
button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition:
    width 0.4s ease,
    height 0.4s ease,
    opacity 0.4s ease;
  opacity: 0;
  pointer-events: none;
}

.btn:active::after,
button:active::after {
  width: 200%;
  height: 200%;
  opacity: 1;
  transition:
    width 0s,
    height 0s,
    opacity 0s;
}

/* Input focus glow */
input,
textarea,
select {
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    transform 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--haiven-cyan, #1fb6ff);
  box-shadow:
    0 0 0 3px rgba(31, 182, 255, 0.15),
    0 4px 12px rgba(31, 182, 255, 0.1);
  outline: none;
}

/* Link hover underline animation */
a:not(.btn):not(.nav-link) {
  position: relative;
  text-decoration: none;
}

a:not(.btn):not(.nav-link)::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--haiven-cyan, #1fb6ff), var(--haiven-teal, #4ecdc4));
  transition: width 0.3s ease;
}

a:not(.btn):not(.nav-link):hover::after {
  width: 100%;
}

/* ============================================================================
   PROGRESSIVE DISCLOSURE - Reveal Complexity Gracefully
   ============================================================================ */

/* Collapsible sections */
.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease;
  opacity: 0;
}

.collapsible-content.expanded {
  max-height: 2000px;
  opacity: 1;
}

/* Progressive reveal on scroll */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition:
    opacity 0.6s ease,
    transform 0.6s ease;
}

.reveal-on-scroll.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered list animations */
.stagger-list > * {
  opacity: 0;
  transform: translateX(-20px);
  animation: staggerIn 0.4s ease forwards;
}

@keyframes staggerIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.stagger-list > *:nth-child(1) {
  animation-delay: 0.05s;
}
.stagger-list > *:nth-child(2) {
  animation-delay: 0.1s;
}
.stagger-list > *:nth-child(3) {
  animation-delay: 0.15s;
}
.stagger-list > *:nth-child(4) {
  animation-delay: 0.2s;
}
.stagger-list > *:nth-child(5) {
  animation-delay: 0.25s;
}
.stagger-list > *:nth-child(6) {
  animation-delay: 0.3s;
}
.stagger-list > *:nth-child(7) {
  animation-delay: 0.35s;
}
.stagger-list > *:nth-child(8) {
  animation-delay: 0.4s;
}
.stagger-list > *:nth-child(9) {
  animation-delay: 0.45s;
}
.stagger-list > *:nth-child(10) {
  animation-delay: 0.5s;
}

/* ============================================================================
   EMPTY STATES - Poetic, Not Functional
   ============================================================================ */

.empty-state {
  text-align: center;
  padding: 60px 40px;
  max-width: 400px;
  margin: 0 auto;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 24px;
  animation: gentleBreathe 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(31, 182, 255, 0.3));
}

.empty-state-title {
  font-size: 24px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.empty-state-subtitle {
  font-size: 16px;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
  margin-bottom: 32px;
}

.empty-state-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--haiven-cyan, #1fb6ff), var(--haiven-teal, #4ecdc4));
  color: white;
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.empty-state-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(31, 182, 255, 0.3);
}

/* ============================================================================
   AI INTELLIGENCE INDICATORS
   ============================================================================ */

/* Confidence score badge */
.confidence-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(31, 182, 255, 0.1);
  border: 1px solid rgba(31, 182, 255, 0.2);
  color: var(--haiven-cyan, #1fb6ff);
}

.confidence-badge.high {
  background: rgba(78, 205, 196, 0.1);
  border-color: rgba(78, 205, 196, 0.2);
  color: var(--haiven-teal, #4ecdc4);
}

.confidence-badge.medium {
  background: rgba(255, 193, 7, 0.1);
  border-color: rgba(255, 193, 7, 0.2);
  color: #ffc107;
}

.confidence-badge.low {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.2);
  color: #ff6b6b;
}

/* Proactive insight card */
.insight-card {
  background: linear-gradient(135deg, rgba(31, 182, 255, 0.1), rgba(78, 205, 196, 0.05));
  border: 1px solid rgba(31, 182, 255, 0.2);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.insight-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--haiven-cyan, #1fb6ff), var(--haiven-teal, #4ecdc4));
}

.insight-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.insight-card-icon {
  font-size: 20px;
  animation: gentleBreathe 2s ease-in-out infinite;
}

.insight-card-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--haiven-cyan, #1fb6ff);
}

.insight-card-title {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 8px;
}

.insight-card-content {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.5;
}

/* Learning loop - feedback buttons */
.feedback-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.feedback-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: all 0.2s ease;
}

.feedback-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.feedback-btn.positive:hover {
  background: rgba(78, 205, 196, 0.1);
  border-color: rgba(78, 205, 196, 0.3);
  color: var(--haiven-teal, #4ecdc4);
}

.feedback-btn.negative:hover {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.3);
  color: #ff6b6b;
}

/* ============================================================================
   TOAST NOTIFICATIONS - Premium Feel
   ============================================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10000;
  transform: translateY(100px);
  opacity: 0;
  transition:
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: rgba(78, 205, 196, 0.3);
}

.toast.success::before {
  content: '✓';
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: var(--haiven-teal, #4ecdc4);
  border-radius: 50%;
  font-size: 12px;
}

/* ============================================================================
   LOADING STATES - Elegant Waiting
   ============================================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

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

.thinking-dots {
  display: inline-flex;
  gap: 4px;
}

.thinking-dots span {
  width: 6px;
  height: 6px;
  background: var(--haiven-cyan, #1fb6ff);
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(1) {
  animation-delay: 0s;
}
.thinking-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.thinking-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-8px);
  }
}

/* ============================================================================
   SOUND TOGGLE - Sensory Control
   ============================================================================ */

.sound-toggle {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 100;
}

.sound-toggle:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.2);
}

.sound-toggle.muted {
  opacity: 0.5;
}

.sound-toggle svg {
  width: 20px;
  height: 20px;
  color: rgba(255, 255, 255, 0.7);
}
