/* styles/material.css - Material Design enhancements */

/* ========================================
   1) Material Design Elevation System
   ======================================== */
:root {
  /* Elevation shadows - Material Design 3 */
  --elevation-0: none;
  --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.08);
  --elevation-2: 0 2px 4px rgba(0, 0, 0, 0.08), 0 3px 6px rgba(0, 0, 0, 0.1);
  --elevation-3: 0 4px 8px rgba(0, 0, 0, 0.1), 0 6px 12px rgba(0, 0, 0, 0.12);
  --elevation-4: 0 6px 12px rgba(0, 0, 0, 0.12), 0 8px 16px rgba(0, 0, 0, 0.14);
  --elevation-5: 0 8px 16px rgba(0, 0, 0, 0.14), 0 12px 24px rgba(0, 0, 0, 0.16);
  
  /* Surface tints */
  --surface-tint: rgba(66, 133, 244, 0.05);
  --surface-tint-hover: rgba(66, 133, 244, 0.08);
  
  /* Material spacing scale */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
  --spacing-xxl: 32px;
  
  /* Enhanced animation curves */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-decelerate: cubic-bezier(0, 0, 0.2, 1);
  --ease-accelerate: cubic-bezier(0.4, 0, 1, 1);
  --ease-sharp: cubic-bezier(0.4, 0, 0.6, 1);
  
  --duration-short: 150ms;
  --duration-medium: 250ms;
  --duration-long: 400ms;
}

html.dark-mode {
  --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);
  --elevation-2: 0 2px 4px rgba(0, 0, 0, 0.35), 0 3px 6px rgba(0, 0, 0, 0.45);
  --elevation-3: 0 4px 8px rgba(0, 0, 0, 0.4), 0 6px 12px rgba(0, 0, 0, 0.5);
  --elevation-4: 0 6px 12px rgba(0, 0, 0, 0.45), 0 8px 16px rgba(0, 0, 0, 0.55);
  --elevation-5: 0 8px 16px rgba(0, 0, 0, 0.5), 0 12px 24px rgba(0, 0, 0, 0.6);
  --surface-tint: rgba(66, 133, 244, 0.08);
  --surface-tint-hover: rgba(66, 133, 244, 0.12);
}

/* ========================================
   2) Material Card Component
   ======================================== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--elevation-2);
  padding: var(--spacing-xl);
  transition: box-shadow var(--duration-medium) var(--ease-standard),
              transform var(--duration-medium) var(--ease-standard);
}

.card:hover {
  box-shadow: var(--elevation-3);
  transform: translateY(-2px);
}

.card.elevated {
  box-shadow: var(--elevation-4);
}

.card.elevated:hover {
  box-shadow: var(--elevation-5);
  transform: translateY(-4px);
}

/* ========================================
   3) Enhanced Button Styles
   ======================================== */
.btn {
  position: relative;
  overflow: hidden;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: background var(--duration-short) var(--ease-standard),
              box-shadow var(--duration-short) var(--ease-standard),
              transform var(--duration-short) var(--ease-standard);
  user-select: none;
}

.btn-elevated {
  background: var(--primary-color);
  color: #fff;
  box-shadow: var(--elevation-2);
}

.btn-elevated:hover {
  box-shadow: var(--elevation-3);
  transform: translateY(-1px);
}

.btn-elevated:active {
  box-shadow: var(--elevation-1);
  transform: translateY(0);
}

.btn-filled {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

.btn-outlined {
  background: transparent;
  color: var(--primary-color);
  border: 1.5px solid var(--outline);
}

.btn-text {
  background: transparent;
  color: var(--primary-color);
  padding: 8px 16px;
}

.btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

/* ========================================
   4) Floating Action Button (FAB)
   ======================================== */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--primary-color);
  color: #fff;
  border: none;
  box-shadow: var(--elevation-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: box-shadow var(--duration-medium) var(--ease-standard),
              transform var(--duration-medium) var(--ease-standard),
              border-radius var(--duration-medium) var(--ease-standard);
  z-index: 999;
  overflow: hidden;
}

.fab:hover {
  box-shadow: var(--elevation-4);
  transform: scale(1.05);
}

.fab:active {
  box-shadow: var(--elevation-2);
  transform: scale(0.95);
}

.fab.fab-extended {
  width: auto;
  padding: 0 20px;
  border-radius: var(--radius-pill);
}

/* FAB entrance animation */
.fab.fab-enter {
  animation: fabEnter var(--duration-long) var(--ease-decelerate);
}

@keyframes fabEnter {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  60% {
    transform: scale(1.1) rotate(10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* ========================================
   5) Ripple Effect Enhancement
   ======================================== */
.ripple-effect {
  position: relative;
  overflow: hidden;
}

.ripple-effect::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width var(--duration-long) var(--ease-standard),
              height var(--duration-long) var(--ease-standard),
              opacity var(--duration-long) var(--ease-standard);
  opacity: 0;
  pointer-events: none;
}

.ripple-effect.ripple-active::before {
  width: 300px;
  height: 300px;
  opacity: 0;
}

/* Ripple container for custom positioned ripples */
.ripple-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: translate(-50%, -50%) scale(0);
  animation: rippleWave 0.6s var(--ease-standard);
  pointer-events: none;
}

@keyframes rippleWave {
  to {
    transform: translate(-50%, -50%) scale(4);
    opacity: 0;
  }
}

/* ========================================
   6) Elevation Utilities
   ======================================== */
.elevate-1 { box-shadow: var(--elevation-1); }
.elevate-2 { box-shadow: var(--elevation-2); }
.elevate-3 { box-shadow: var(--elevation-3); }
.elevate-4 { box-shadow: var(--elevation-4); }
.elevate-5 { box-shadow: var(--elevation-5); }

.elevate-hover:hover { box-shadow: var(--elevation-3); transform: translateY(-2px); }
.elevate-hover-strong:hover { box-shadow: var(--elevation-5); transform: translateY(-4px); }

/* ========================================
   7) Enhanced Container Styles
   ======================================== */
.container-material {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-xl);
}

.surface {
  background: var(--surface);
  color: var(--on-surface);
}

.surface-variant {
  background: var(--surface-tint);
  color: var(--on-surface);
}

/* ========================================
   8) List Item Animations
   ======================================== */
.list-item-enter {
  animation: listItemSlideIn var(--duration-medium) var(--ease-decelerate);
  animation-fill-mode: both;
}

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

/* Staggered animation delays */
.list-item-enter:nth-child(1) { animation-delay: 0ms; }
.list-item-enter:nth-child(2) { animation-delay: 50ms; }
.list-item-enter:nth-child(3) { animation-delay: 100ms; }
.list-item-enter:nth-child(4) { animation-delay: 150ms; }
.list-item-enter:nth-child(5) { animation-delay: 200ms; }
.list-item-enter:nth-child(6) { animation-delay: 250ms; }
.list-item-enter:nth-child(7) { animation-delay: 300ms; }
.list-item-enter:nth-child(8) { animation-delay: 350ms; }
.list-item-enter:nth-child(9) { animation-delay: 400ms; }
.list-item-enter:nth-child(10) { animation-delay: 450ms; }

/* ========================================
   9) Page Transitions
   ======================================== */
.page-transition-enter {
  animation: pageEnter var(--duration-long) var(--ease-decelerate);
}

.page-transition-exit {
  animation: pageExit var(--duration-medium) var(--ease-accelerate);
}

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

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

/* ========================================
   10) Enhanced Focus States
   ======================================== */
.focus-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ========================================
   11) State Layers (Material 3)
   ======================================== */
.state-layer {
  position: relative;
}

.state-layer::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: currentColor;
  opacity: 0;
  transition: opacity var(--duration-short) var(--ease-standard);
  pointer-events: none;
}

.state-layer:hover::after {
  opacity: 0.08;
}

.state-layer:active::after {
  opacity: 0.12;
}

/* ========================================
   12) Enhanced Typography
   ======================================== */
.text-display {
  font-family: var(--font-display);
  font-size: 3.5rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.text-headline {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.3;
}

.text-title {
  font-family: var(--font-sans);
  font-size: 1.375rem;
  font-weight: 500;
  line-height: 1.4;
}

.text-body {
  font-family: var(--font-text);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
}

.text-label {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.5px;
}

/* ========================================
   13) Loading States
   ======================================== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--outline) 0%,
    var(--surface-tint) 50%,
    var(--outline) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

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

.pulse {
  animation: pulse 2s var(--ease-standard) infinite;
}

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

/* ========================================
   14) Responsive Utilities
   ======================================== */
@media (max-width: 576px) {
  .fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 20px;
  }
  
  .card {
    padding: var(--spacing-lg);
  }
  
  .container-material {
    padding: var(--spacing-md);
  }
}

/* ========================================
   15) Accessibility Enhancements
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .fab.fab-enter {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn-elevated,
  .fab {
    border: 2px solid currentColor;
  }
  
  .card {
    border: 1px solid var(--outline);
  }
}
