/* Story Wish Component System */
/* Comprehensive, DRY, accessible component library */

/* ==========================================================================
   COMPONENT BASE CLASSES
   ========================================================================== */

/* Base component styles that all components inherit */
.component-base {
  @apply transition-all duration-200 ease-smooth;
}

/* Helper utilities for My Story Wish design system */
.gradient-primary {
  @apply bg-gradient-to-r from-storybook-primary to-storybook-secondary;
}

.shadow-soft {
  @apply shadow-lg shadow-storybook-primary/20;
}

.component-focus {
  @apply focus:outline-none focus:ring-2 focus:ring-storybook-primary focus:ring-offset-2;
}

.component-disabled {
  @apply disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none;
}

/* ==========================================================================
   MATERIAL SYMBOLS ICON SYSTEM
   Required CSS for Google Material Symbols font icons
   Used by Icon.html component and navigation elements
   ========================================================================== */

/* Material Symbols Outlined - Primary icon style */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Default variable font settings */
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Material Symbols Rounded - Softer icon style */
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Default variable font settings */
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Icon size utilities for Material Symbols */
.material-symbols-outlined.text-sm,
.material-symbols-rounded.text-sm {
  font-size: 0.875rem;
}

.material-symbols-outlined.text-base,
.material-symbols-rounded.text-base {
  font-size: 1rem;
}

.material-symbols-outlined.text-lg,
.material-symbols-rounded.text-lg {
  font-size: 1.125rem;
}

.material-symbols-outlined.text-xl,
.material-symbols-rounded.text-xl {
  font-size: 1.25rem;
}

.material-symbols-outlined.text-2xl,
.material-symbols-rounded.text-2xl {
  font-size: 1.5rem;
}

.material-symbols-outlined.text-3xl,
.material-symbols-rounded.text-3xl {
  font-size: 1.875rem;
}

.material-symbols-outlined.text-4xl,
.material-symbols-rounded.text-4xl {
  font-size: 2.25rem;
}

.material-symbols-outlined.text-5xl,
.material-symbols-rounded.text-5xl {
  font-size: 3rem;
}

.material-symbols-outlined.text-6xl,
.material-symbols-rounded.text-6xl {
  font-size: 3.75rem;
}

/* Filled icon variant */
.material-symbols-outlined.icon-filled,
.material-symbols-rounded.icon-filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ==========================================================================
   BUTTON COMPONENTS
   ========================================================================== */

/* Gradient Button - STYLE_GUIDE.md 2025 */
.btn-gradient {
  background: linear-gradient(90deg, #8B5CF6 0%, #3B82F6 50%, #06B6D4 100%);
  color: #fff;
  @apply font-semibold rounded-2xl shadow-magical hover:scale-[1.02] transition-all duration-300;
  min-height: 44px;
  /* Touch target */
}

.btn-gradient:hover {
  @apply shadow-magical-lg;
}

.btn-gradient:active {
  @apply scale-95;
}

.btn-gradient:disabled {
  @apply opacity-50 cursor-not-allowed;
}

/* Base button styles - Premium with subtle press feedback */
.btn {
  @apply component-base component-focus component-disabled;
  @apply inline-flex items-center justify-center font-medium text-center;
  @apply border border-transparent rounded-2xl;
  @apply shadow-button hover:shadow-button-hover;
  @apply active:scale-[0.97] transform;  /* Slightly more subtle press */
  @apply min-h-[44px] min-w-[44px];
  /* Touch-friendly minimum size */
  @apply uppercase tracking-wide;
  @apply transition-all duration-150 ease-out;  /* Snappier easing */
  @apply overflow-visible;
  /* Ensure text is not clipped */
  display: inline-flex !important;
  /* Force inline-flex to allow width to work */
}

/* --------------------------------------------------------------------------
   Compatibility fallback: allow legacy usage like class="btn-primary ..."
   (without the base .btn class) to render consistently.
   -------------------------------------------------------------------------- */
.btn-primary:not(.btn),
.btn-secondary:not(.btn),
.btn-success:not(.btn),
.btn-warning:not(.btn),
.btn-danger:not(.btn),
.btn-ghost:not(.btn),
.btn-link:not(.btn) {
  @apply component-base component-focus component-disabled;
  @apply inline-flex items-center justify-center font-medium text-center;
  @apply border border-transparent rounded-2xl;
  @apply shadow-button hover:shadow-button-hover;
  @apply active:scale-[0.97] transform;  /* Slightly more subtle press */
  @apply min-h-[44px] min-w-[44px];
  @apply uppercase tracking-wide;
  @apply transition-all duration-150 ease-out;  /* Snappier easing */
  @apply overflow-visible;
  display: inline-flex !important;
}

/* Button variants */
.btn-primary {
  @apply gradient-primary;
  @apply text-white;
  @apply hover:from-storybook-primary/90 hover:to-storybook-secondary/90;
  @apply focus:ring-storybook-primary;
  @apply rounded-2xl;
}

.btn-secondary {
  @apply bg-white text-storybook-text;
  @apply border-storybook-border-strong;
  @apply hover:bg-storybook-gray-100;
  @apply focus:ring-storybook-primary;
}

.btn-success {
  @apply bg-storybook-success text-white;
  @apply hover:bg-green-600;
  @apply focus:ring-storybook-success;
}

.btn-warning {
  @apply bg-storybook-warning text-white;
  @apply hover:bg-amber-600;
  @apply focus:ring-storybook-warning;
}

.btn-danger {
  @apply bg-storybook-danger text-white;
  @apply hover:bg-red-600;
  @apply focus:ring-storybook-danger;
}

.btn-ghost {
  @apply bg-transparent text-storybook-text;
  @apply border-storybook-border;
  @apply hover:bg-storybook-gray-50;
  @apply focus:ring-storybook-primary;
}

.btn-link {
  @apply bg-transparent text-storybook-primary;
  @apply border-none shadow-none;
  @apply hover:text-storybook-secondary hover:underline;
  @apply focus:ring-storybook-primary;
}

/* Button sizes - More specific selectors to override base styles */
.btn.btn-sm {
  @apply px-4 py-2 text-sm;
  min-height: 36px;
  padding-left: 1rem;
  padding-right: 1rem;
}

.btn.btn-lg {
  @apply px-8 py-4 text-lg;
  min-height: 52px;
  padding-left: 2rem;
  padding-right: 2rem;
}

.btn.btn-xl {
  @apply px-12 py-6 text-xl;
  min-height: 60px;
  padding-left: 3rem;
  padding-right: 3rem;
}

/* Size classes also work without .btn (legacy templates) */
.btn-sm {
  @apply px-4 py-2 text-sm;
  min-height: 36px;
  padding-left: 1rem;
  padding-right: 1rem;
}

.btn-lg {
  @apply px-8 py-4 text-lg;
  min-height: 52px;
  padding-left: 2rem;
  padding-right: 2rem;
}

.btn-xl {
  @apply px-12 py-6 text-xl;
  min-height: 60px;
  padding-left: 3rem;
  padding-right: 3rem;
}

/* Default button size (when no size class is specified) */
.btn:not(.btn-sm):not(.btn-lg):not(.btn-xl) {
  @apply px-6 py-3 text-sm;
  min-height: 44px;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* Special buttons */
.cta-button {
  @apply btn btn-primary btn-lg;
  @apply gradient-primary;
  @apply shadow-soft hover:shadow-magical-lg;
  @apply animate-pulse-gentle;
}

/* ==========================================================================
   PRICING / MARKETING CARD UTILITIES (moved from templates to keep DRY)
   ========================================================================== */

/* Premium card emphasis for featured pricing plans */
.premium-emphasis {
  transform: scale(1.02);
  box-shadow: 0 20px 25px -5px rgba(139, 92, 246, 0.1), 0 10px 10px -5px rgba(139, 92, 246, 0.04);
  border: 2px solid rgba(139, 92, 246, 0.2);
  animation: subtle-pulse 3s ease-in-out infinite;
}

@keyframes subtle-pulse {
  0%, 100% { transform: scale(1.02); }
  50% { transform: scale(1.03); }
}

/* Reduced emphasis for free plan */
.free-plan-subdued {
  opacity: 0.85;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Enhanced hover states with design system motion */
.card-hover-enhanced {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-hover-enhanced:hover {
  transform: translateY(-4px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
}

/* Focus states for accessibility (cards used as links) */
.card-focus-enhanced:focus-visible {
  outline: 2px solid #8B5CF6;
  outline-offset: 2px;
}

/* Progress Card - STYLE_GUIDE.md 2025 */
.card-progress {
  background: var(--storybook-surface, #FFFFFF);
  border-radius: 12px;
  box-shadow: var(--shadow-md, 0 4px 6px -1px rgba(0, 0, 0, 0.1));
  @apply p-6;
}

.card-progress:hover {
  @apply shadow-card-hover;
}

/* Base card styles - Premium with subtle interactions */
.card {
  @apply component-base;
  @apply bg-white border border-storybook-border;
  @apply rounded-2xl shadow-soft;
  @apply overflow-hidden;
  @apply transition-all duration-200 ease-out;
}

.card-hover {
  @apply hover:shadow-card-hover hover:-translate-y-0.5;  /* More subtle lift */
  @apply active:scale-[0.99];  /* Subtle press feedback */
  @apply transition-all duration-200 ease-smooth;
}

.card-body {
  @apply p-6;
}

.card-header {
  @apply px-6 py-4 border-b border-storybook-border-light;
}

.card-footer {
  @apply px-6 py-4 border-t border-storybook-border-light;
  @apply bg-storybook-gray-50;
}

/* Card variants */
.card-magical {
  @apply card;
  @apply bg-gradient-to-br from-white to-storybook-gray-50;
  @apply border-storybook-primary/20;
  @apply shadow-soft;
  @apply relative;
  @apply hover:shadow-magical hover:border-storybook-primary/30;
  @apply transition-all duration-200 ease-out;
}

.card-magical::before {
  @apply absolute inset-0;
  @apply bg-gradient-to-br from-storybook-primary/5 to-storybook-secondary/5;
  @apply pointer-events-none;
  @apply rounded-2xl;
}

.card-feature {
  @apply card card-hover;
  @apply text-center;
  @apply p-8;
}

.card-pricing {
  @apply card;
  @apply relative;
  @apply p-8;
}

.card-pricing.featured {
  @apply border-2 border-storybook-primary;
  @apply shadow-soft;
  @apply scale-105;
}

/* ==========================================================================
   FORM COMPONENTS
   ========================================================================== */

/* Form group container */
.form-group {
  @apply space-y-2;
}

/* Form labels */
.form-label {
  @apply block text-lg font-medium text-storybook-text;
  @apply mb-2;
}

.form-label-required::after {
  @apply text-storybook-danger ml-1;
  content: " *";
}

/* Form inputs */
.form-input {
  @apply component-base component-focus;
  @apply w-full px-4 py-3;
  @apply border border-storybook-border rounded-xl;
  @apply bg-white text-storybook-text text-base;
  @apply placeholder-storybook-text-muted;
  @apply focus:border-storybook-primary focus:ring-1 focus:ring-storybook-primary;
  @apply disabled:bg-storybook-gray-50 disabled:text-storybook-text-muted;
}

.form-input.error {
  @apply border-storybook-danger focus:ring-storybook-danger;
}

.form-input.success {
  @apply border-storybook-success focus:ring-storybook-success;
}

/* Form textarea */
.form-textarea {
  @apply form-input;
  @apply resize-y min-h-[100px];
}

/* Form select */
.form-select {
  @apply form-input;
  @apply appearance-none;
  @apply bg-no-repeat bg-right bg-[length:16px_16px];
  @apply pr-10;
  @apply cursor-pointer;
  @apply min-h-[44px];
  /* Ensure touch-friendly minimum height */
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
}

/* Form select hover state */
.form-select:hover {
  @apply border-storybook-primary/50;
}

/* Form select focus state */
.form-select:focus {
  @apply border-storybook-primary;
  @apply ring-2 ring-storybook-primary/20;
  @apply shadow-focus;
}

/* Form select option styling - Enhanced for better readability */
.form-select option {
  @apply text-storybook-text bg-white py-3 px-4 text-base font-medium min-h-[44px];
  /* Ensure proper contrast without !important */
  color: #1F2937;
  background-color: #FFFFFF;
}

/* Additional specificity for dropdown options - using CSS custom properties */
select.form-select option {
  color: var(--storybook-text, #1F2937);
  background-color: var(--storybook-surface, #FFFFFF);
  padding: 12px 16px;
  font-size: 16px;
  font-weight: 500;
}

/* Form select option hover state */
.form-select option:hover {
  @apply bg-storybook-primary/10 text-storybook-primary;
  background-color: rgba(139, 92, 246, 0.1);
  color: #8B5CF6;
}

/* Form select option selected state */
.form-select option:checked,
.form-select option[selected] {
  @apply bg-storybook-primary text-white font-medium;
  background-color: #8B5CF6;
  color: #FFFFFF;
}

/* Form select disabled state */
.form-select:disabled {
  @apply bg-storybook-gray-50;
  @apply text-storybook-text-muted;
  @apply cursor-not-allowed;
  @apply opacity-60;
}

/* Form select error state */
.form-select.error {
  @apply border-storybook-danger;
  @apply focus:ring-storybook-danger;
}

/* Form select success state */
.form-select.success {
  @apply border-storybook-success;
  @apply focus:ring-storybook-success;
}


/* Mobile-specific dropdown improvements */
@media (max-width: 640px) {
  .form-select {
    @apply text-base;
    /* Ensure minimum readable text size */
    @apply min-h-[48px];
    /* Larger touch target on mobile */
  }

  .form-select option {
    @apply text-base;
    @apply py-4;
    /* Larger option padding on mobile */
  }
}

/* Form checkbox */
.form-checkbox {
  @apply component-focus;
  @apply w-5 h-5;
  @apply border border-storybook-border rounded;
  @apply text-storybook-primary;
  @apply focus:ring-storybook-primary;
}

/* Form radio */
.form-radio {
  @apply component-focus;
  @apply w-5 h-5;
  @apply border border-storybook-border rounded-full;
  @apply text-storybook-primary;
  @apply focus:ring-storybook-primary;
}

/* Form error messages */
.form-error {
  @apply text-sm text-storybook-danger;
  @apply mt-1;
}

.form-helper {
  @apply text-sm text-storybook-text-muted;
  @apply mt-1;
}

/* ==========================================================================
   NAVIGATION COMPONENTS
   ========================================================================== */

/* Navigation links */
.nav-link {
  @apply component-base;
  @apply px-4 py-2 text-base font-medium;
  @apply text-storybook-text-muted;
  @apply hover:text-storybook-text hover:bg-storybook-gray-50;
  @apply rounded-lg;
  @apply transition-colors duration-150;
}

.nav-link.active {
  @apply text-storybook-primary bg-storybook-primary/10;
}

/* Breadcrumbs */
.breadcrumb {
  @apply flex items-center space-x-2 text-sm;
}

.breadcrumb-item {
  @apply text-storybook-text-muted hover:text-storybook-text;
  @apply transition-colors duration-150;
}

.breadcrumb-separator {
  @apply text-storybook-text-muted;
}

/* ==========================================================================
   BADGE & STATUS COMPONENTS
   ========================================================================== */

/* Base badge styles */
.badge {
  @apply component-base;
  @apply inline-flex items-center px-3 py-1;
  @apply text-sm font-semibold;
  @apply rounded-badge;
  @apply whitespace-nowrap;
}

/* Badge variants */
.badge-primary {
  @apply bg-storybook-primary/10 text-storybook-primary;
}

.badge-secondary {
  @apply bg-storybook-gray-100 text-storybook-gray-700;
}

.badge-success {
  @apply bg-storybook-success-light text-storybook-success-dark;
}

.badge-warning {
  @apply bg-storybook-warning-light text-storybook-warning-dark;
}

.badge-danger {
  @apply bg-storybook-danger-light text-storybook-danger-dark;
}

.badge-info {
  @apply bg-storybook-info-light text-storybook-info-dark;
}

/* Status badges */
.status-badge {
  @apply badge;
  @apply px-4 py-2;
  @apply text-base font-medium;
}

.status-active {
  @apply bg-storybook-success-light text-storybook-success-dark;
}

.status-trial {
  @apply bg-storybook-info-light text-storybook-info-dark;
}

.status-cancelled {
  @apply bg-storybook-danger-light text-storybook-danger-dark;
}

.status-expired {
  @apply bg-storybook-gray-100 text-storybook-gray-800;
}

/* ==========================================================================
   MODAL COMPONENTS
   ========================================================================== */

/* Modal overlay */
.modal-overlay {
  @apply fixed inset-0 z-50;
  @apply bg-black/50 backdrop-blur-sm;
  @apply flex items-center justify-center;
  @apply p-4;
}

/* Modal container */
.modal {
  @apply component-base;
  @apply bg-white;
  @apply rounded-2xl shadow-soft;
  @apply max-w-lg w-full max-h-[90vh];
  @apply overflow-hidden;
}

.modal-lg {
  @apply max-w-2xl;
}

.modal-xl {
  @apply max-w-4xl;
}

/* Modal header */
.modal-header {
  @apply flex items-center justify-between;
  @apply px-6 py-4 border-b border-storybook-border-light;
}

.modal-title {
  @apply text-2xl font-bold text-storybook-primary;
}

.modal-close {
  @apply component-base component-focus;
  @apply p-2 text-storybook-text-muted;
  @apply hover:text-storybook-text hover:bg-storybook-gray-100;
  @apply rounded-lg;
}

/* Modal body */
.modal-body {
  @apply px-6 py-4;
  @apply overflow-y-auto;
}

/* Modal footer */
.modal-footer {
  @apply flex items-center justify-end space-x-3;
  @apply px-6 py-4 border-t border-storybook-border-light;
  @apply bg-storybook-gray-50;
}

/* ==========================================================================
   ALERT COMPONENTS
   ========================================================================== */

/* Base alert styles */
.alert {
  @apply component-base;
  @apply p-4 rounded-lg border;
  @apply flex items-start space-x-3;
}

/* Alert variants */
.alert-info {
  @apply bg-storybook-info-light border-storybook-info text-storybook-info-dark;
}

.alert-success {
  @apply bg-storybook-success-light border-storybook-success text-storybook-success-dark;
}

.alert-warning {
  @apply bg-storybook-warning-light border-storybook-warning text-storybook-warning-dark;
}

.alert-danger {
  @apply bg-storybook-danger-light border-storybook-danger text-storybook-danger-dark;
}

/* Alert content */
.alert-title {
  @apply font-semibold text-lg;
}

.alert-message {
  @apply text-base font-normal mt-1;
}

.alert-close {
  @apply component-base component-focus;
  @apply ml-auto p-1;
  @apply text-current opacity-70;
  @apply hover:opacity-100;
  @apply rounded;
}

/* ==========================================================================
   LOADING COMPONENTS
   ========================================================================== */

/* Loading spinner */
.loading-spinner {
  @apply inline-block w-5 h-5;
  @apply border-2 border-current border-t-transparent;
  @apply rounded-full;
  @apply animate-spin;
}

.loading-spinner-lg {
  @apply w-8 h-8 border-4;
}

/* Loading skeleton */
.loading-skeleton {
  @apply bg-storybook-gray-200;
  @apply animate-pulse;
  @apply rounded;
}

.loading-shimmer {
  @apply relative overflow-hidden;
}

.loading-shimmer::after {
  @apply absolute inset-0;
  @apply bg-gradient-to-r from-transparent via-white/20 to-transparent;
  @apply animate-shimmer;
  content: "";
}

/* ==========================================================================
   PROGRESS COMPONENTS
   ========================================================================== */

/* Magical progress bar */
.magical-progress {
  @apply bg-gradient-to-r from-storybook-primary via-storybook-secondary to-storybook-accent;
  @apply bg-size-400-400;
  @apply animate-gradient-shift;
  @apply relative overflow-hidden;
}

@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.bg-size-400-400 {
  background-size: 400% 400%;
}

/* Progress bar shimmer effect */
.progress-bar {
  @apply relative overflow-hidden;
}

.progress-bar::before {
  @apply absolute inset-0;
  @apply bg-gradient-to-r from-transparent via-white/30 to-transparent;
  @apply transform -skew-x-12;
  @apply animate-shimmer;
  content: "";
}

/* ==========================================================================
   UTILITY COMPONENTS
   ========================================================================== */

/* Divider */
.divider {
  @apply border-t border-storybook-border-light;
}

.divider-vertical {
  @apply border-l border-storybook-border-light;
}

/* Avatar */
.avatar {
  @apply inline-flex items-center justify-center;
  @apply w-10 h-10 rounded-full;
  @apply bg-storybook-gray-200 text-storybook-text;
  @apply font-medium text-sm;
}

.avatar-lg {
  @apply w-16 h-16 text-lg;
}

.avatar-xl {
  @apply w-20 h-20 text-xl;
}

/* Tooltip */
.tooltip {
  @apply absolute z-50;
  @apply px-3 py-2 text-sm;
  @apply bg-storybook-text text-white;
  @apply rounded-xl shadow-lg;
  @apply opacity-0 pointer-events-none;
  @apply transition-opacity duration-200;
}

.tooltip.show {
  @apply opacity-100;
}

/* ==========================================================================
   RESPONSIVE UTILITIES
   ========================================================================== */

/* Mobile-first responsive adjustments */
@media (max-width: 640px) {
  .btn {
    @apply w-full justify-center;
  }

  .btn-group {
    @apply flex-col space-y-2 space-x-0;
  }

  .card-body {
    @apply p-4;
  }

  .modal {
    @apply mx-4;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    @apply px-4 py-3;
  }

  /* Ensure minimum text size for mobile */
  .form-label {
    @apply text-base;
  }

  .nav-link {
    @apply text-base;
  }
}

/* ==========================================================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================================================== */

/* Focus visible for better keyboard navigation */
.focus-visible:focus-visible {
  @apply outline-none ring-2 ring-storybook-primary ring-offset-2;
}

/* Enhanced focus states for better accessibility */
.btn:focus-visible {
  @apply outline-none ring-2 ring-storybook-primary ring-offset-2;
}

.form-input:focus-visible {
  @apply outline-none ring-2 ring-storybook-primary ring-offset-2;
}

.nav-link:focus-visible {
  @apply outline-none ring-2 ring-storybook-primary ring-offset-2;
}


/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    @apply border-2;
  }

  .card {
    @apply border-2;
  }

  .form-input {
    @apply border-2;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .component-base {
    @apply transition-none;
  }

  .loading-spinner {
    @apply animate-none;
  }

  .loading-skeleton {
    @apply animate-none;
  }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
  .btn {
    @apply border border-gray-400 bg-white text-black;
    @apply shadow-none;
  }

  .card {
    @apply border border-gray-400 shadow-none;
  }

  .modal-overlay {
    @apply hidden;
  }

  .badge {
    @apply border border-gray-400;
  }

  /* Ensure readable text in print */
  .form-label {
    @apply text-base;
  }

  .nav-link {
    @apply text-base;
  }
}

/* ==========================================================================
   MOBILE OPTIMIZATION STYLES
   ========================================================================== */

/* Capacitor-friendly touch styles */
.touch-target {
  min-height: 44px;
  min-width: 44px;
}

/* Prevent text selection on UI elements */
.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Safe area support for iOS notch */
.safe-area-top {
  padding-top: env(safe-area-inset-top);
}

.safe-area-bottom {
  padding-bottom: env(safe-area-inset-bottom);
}

/* Smooth scrolling for mobile */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Hide scrollbars on mobile */
::-webkit-scrollbar {
  display: none;
}

/* Custom loading animation optimised for mobile */
@keyframes pulse-gentle {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.pulse-gentle {
  animation: pulse-gentle 2s ease-in-out infinite;
}

/* ==========================================================================
   USAGE INDICATOR COMPONENT
   ========================================================================== */

.usage-indicator {
  @apply bg-gradient-to-br from-storybook-surface to-storybook-surface-secondary border border-storybook-border rounded-card p-4 my-3 shadow-card;
}

.usage-bar-container {
  @apply space-y-4;
}

.usage-content {
  @apply flex flex-col items-center space-y-3;
}

.usage-tier-section {
  @apply flex items-center gap-2;
}

.usage-header {
  @apply flex items-center justify-center gap-4;
}

.usage-icon {
  @apply text-storybook-primary;
}

.tier-name {
  @apply text-sm font-semibold text-storybook-text bg-storybook-primary/10 px-3 py-1.5 rounded-badge border border-storybook-primary/20 text-center;
}

.usage-stats {
  @apply flex items-center gap-1 text-sm font-medium justify-center;
}

.usage-count {
  @apply text-storybook-primary font-bold text-lg;
}

.usage-separator {
  @apply text-storybook-text-muted;
}

.usage-limit {
  @apply text-storybook-text font-semibold;
}

.usage-label {
  @apply text-storybook-text-muted ml-1;
}

.usage-progress-container {
  @apply flex items-center gap-3 justify-center w-full;
}

.usage-progress-bar {
  @apply flex-1 h-3 bg-storybook-gray-200 rounded-full overflow-hidden shadow-inner max-w-xs;
}

.usage-progress-fill {
  @apply h-full transition-all duration-500 ease-out rounded-full;
  background: linear-gradient(90deg,
    var(--storybook-success) 0%,
    var(--storybook-warning) 70%,
    var(--storybook-danger) 90%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.usage-percentage {
  @apply text-xs font-semibold text-storybook-text-muted min-w-[3rem] text-center;
}

.usage-warning {
  @apply flex items-center gap-2 p-3 bg-storybook-warning-light border border-storybook-warning/30 rounded-lg;
}

.warning-icon {
  @apply text-storybook-warning flex-shrink-0;
}

.warning-text {
  @apply text-sm text-storybook-warning font-medium;
}

.usage-success {
  @apply mt-2 text-storybook-success font-medium;
}

/* ==========================================================================
   EMAIL COMPONENT STYLES
   ========================================================================== */

.email-body {
  @apply bg-storybook-surface-secondary rounded-lg p-4 my-5 text-center;
}

.email-body p {
  @apply m-0 text-storybook-text-muted text-sm;
}

.welcome-badge {
  @apply text-white px-6 py-3 rounded-full inline-block font-semibold mb-5 text-center w-full box-border;
  background: linear-gradient(135deg, var(--storybook-primary) 0%, var(--storybook-accent) 100%);
}

.trial-badge {
  @apply text-white px-6 py-3 rounded-full inline-block font-semibold mb-5 text-center w-full box-border;
  background: linear-gradient(135deg, var(--storybook-warning) 0%, var(--storybook-danger) 100%);
}

.email-card {
  @apply rounded-xl p-5 my-5;
  background: linear-gradient(135deg, var(--storybook-warning-light) 0%, var(--storybook-warning-light) 100%);
  border: 2px solid var(--storybook-warning);
}

.email-card-title {
  @apply m-0 mb-4 text-storybook-warning;
}

.email-feature-list {
  @apply m-0 pl-5 text-storybook-warning;
}

.email-button {
  @apply text-white px-6 py-3 rounded-lg no-underline font-semibold inline-block;
  background: linear-gradient(135deg, var(--storybook-primary) 0%, var(--storybook-accent) 100%);
}

.email-subscription-details {
  @apply flex justify-between items-center my-4 p-4 rounded-lg;
  background: var(--storybook-surface-secondary);
}

.email-subscription-info h4 {
  @apply m-0 text-base text-storybook-text;
}

.email-subscription-info span {
  @apply text-storybook-text-muted;
}

.email-subscription-price {
  @apply text-right text-xl font-bold text-storybook-primary;
}

/* ==========================================================================
   INLINE STYLE REPLACEMENTS
   ========================================================================== */

/* Animation delay utilities */
.animation-delay-1s {
  animation-delay: -1s;
}

.animation-delay-2s {
  animation-delay: -2s;
}

.animation-delay-3s {
  animation-delay: -3s;
}

.animation-delay-4s {
  animation-delay: -4s;
}

/* Display utilities */
.hidden-fallback {
  display: none;
}

/* Background gradients for landing page */
.landing-bg-gradient-1 {
  background: linear-gradient(135deg, #4d96ff 0%, #6bcf7f 100%);
}

.landing-bg-gradient-2 {
  background: linear-gradient(135deg, #9c88ff 0%, #ff6b6b 100%);
}

.landing-bg-gradient-3 {
  background: linear-gradient(135deg, #6bcf7f 0%, #4d96ff 100%);
}

/* Blur and mix-blend utilities */
.blur-3xl-multiply {
  filter: blur(3rem);
  mix-blend-mode: multiply;
}

/* Text shadow utilities */
.text-shadow-soft {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.text-shadow-strong {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Transform utilities */
.transform-center {
  transform: translate(-50%, -50%);
}

/* Opacity utilities */
.opacity-5 {
  opacity: 0.05;
}

.opacity-15 {
  opacity: 0.15;
}

.opacity-20 {
  opacity: 0.2;
}

.opacity-25 {
  opacity: 0.25;
}

.opacity-30 {
  opacity: 0.3;
}

.opacity-50 {
  opacity: 0.5;
}

.opacity-60 {
  opacity: 0.6;
}

.opacity-70 {
  opacity: 0.7;
}

/* ==========================================================================
   MAGICAL ICONS SYSTEM
   ========================================================================== */

/* Google Material Symbols (Rounded) base styles */
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Google Material Symbols (Outlined) base styles */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Icon hover effects for both Google and custom icons - WCAG AA Accessible */
.icon-hover-gradient {
  @apply transition-all duration-200 hover:scale-105 hover:text-transparent hover:bg-gradient-to-r hover:from-[#7c3aed] hover:to-[#0891b2] hover:bg-clip-text;
}

/* Base magical icon styles */
.magical-icon {
  @apply inline-block;
  width: 1em;
  height: 1em;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Icon sizes */
.icon-xs {
  @apply w-3 h-3;
  /* 12px */
}

.icon-sm {
  @apply w-4 h-4;
  /* 16px */
}

.icon-md {
  @apply w-5 h-5;
  /* 20px */
}

.icon-lg {
  @apply w-6 h-6;
  /* 24px */
}

.icon-xl {
  @apply w-8 h-8;
  /* 32px */
}

.icon-2xl {
  @apply w-12 h-12;
  /* 48px */
}

.icon-3xl {
  @apply w-16 h-16;
  /* 64px */
}

/* Icon colors */
.icon-primary {
  @apply text-storybook-primary;
}

.icon-secondary {
  @apply text-storybook-secondary;
}

.icon-accent {
  @apply text-storybook-accent;
}

.icon-success {
  @apply text-storybook-success;
}

.icon-warning {
  @apply text-storybook-warning;
}

.icon-danger {
  @apply text-storybook-danger;
}

.icon-info {
  @apply text-storybook-info;
}

.icon-muted {
  @apply text-storybook-text-muted;
}

/* Thematic icon colors */
.icon-magic {
  @apply text-storybook-primary;
}

.icon-story {
  @apply text-storybook-secondary;
}

.icon-art {
  @apply text-storybook-accent;
}

.icon-character {
  @apply text-orange-600;
}

.icon-family {
  @apply text-storybook-success;
}

.icon-star {
  @apply text-yellow-500;
}

.icon-shield {
  @apply text-indigo-600;
}

.icon-moon {
  @apply text-slate-600;
}

.icon-wand {
  @apply text-violet-600;
}

/* Icon animations */
.icon-sparkle {
  @apply animate-pulse;
}

.icon-hover-lift {
  @apply transition-transform duration-200 hover:scale-110;
}

.icon-hover-glow {
  @apply transition-all duration-200 hover:drop-shadow-lg;
}

/* Magical icon effects */
.icon-magical-glow {
  @apply drop-shadow-lg;
  filter: drop-shadow(0 0 8px rgba(155, 140, 255, 0.3));
}

.icon-magical-sparkle {
  @apply animate-pulse;
  animation: magical-sparkle 2s ease-in-out infinite;
}

/* Subtle hover effect for magical icons */
.magical-icon:hover {
  @apply scale-105;
  transition: all 200ms ease-smooth;
}

@keyframes magical-sparkle {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

/* ==========================================================================
   SPARKLE EFFECTS - STYLE_GUIDE.md 2025
   Note: Base .sparkle class and sparkle-twinkle animation are still used
   by cards and other components. Removed numbered positioning classes
   (.sparkle-1 through .sparkle-5) which were only used by deprecated
   header components (story_creation_header and hero_gradient).
   ========================================================================== */

.sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  pointer-events: none;
  animation: sparkle-twinkle 2s ease-in-out infinite;
}

@keyframes sparkle-twinkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.5);
  }

  50% {
    opacity: 1;
    transform: scale(1.2);
  }
}

/* Magical card shadows */
.shadow-card-magical {
  box-shadow: 0 10px 30px rgba(155, 140, 255, 0.15), 0 4px 12px rgba(0, 0, 0, 0.1);
}

.shadow-card-magical:hover {
  box-shadow: 0 20px 40px rgba(155, 140, 255, 0.2), 0 8px 16px rgba(0, 0, 0, 0.15);
}

/* Frosted glass effect */
.backdrop-blur-sm {
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Soft pastel gradients for main sections */
.bg-gradient-pastel-primary {
  background: linear-gradient(135deg, rgba(155, 140, 255, 0.05) 0%, rgba(255, 155, 181, 0.05) 50%, rgba(125, 211, 252, 0.05) 100%);
}

.bg-gradient-pastel-secondary {
  background: linear-gradient(135deg, rgba(255, 155, 181, 0.05) 0%, rgba(155, 140, 255, 0.05) 50%, rgba(125, 211, 252, 0.05) 100%);
}

/* Toned down header gradients */
.bg-gradient-header-subtle {
  background: linear-gradient(135deg, rgba(155, 140, 255, 0.8) 0%, rgba(255, 155, 181, 0.8) 100%);
}

.bg-gradient-cta-subtle {
  background: linear-gradient(135deg, rgba(155, 140, 255, 0.9) 0%, rgba(255, 155, 181, 0.9) 100%);
}

/* Progress bar shimmer effect */
.progress-bar-shimmer {
  position: relative;
  overflow: hidden;
}

.progress-bar-shimmer::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% {
    left: -100%;
  }

  100% {
    left: 100%;
  }
}

/* Indeterminate progress animation for character creation */
@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
    width: 50%;
  }
  50% {
    transform: translateX(50%);
    width: 75%;
  }
  100% {
    transform: translateX(200%);
    width: 50%;
  }
}

.animate-progress-indeterminate {
  animation: progress-indeterminate 2s ease-in-out infinite;
}

/* Smooth progress bar animation for determinate progress */
.progress-bar-smooth {
  transition: width 0.7s ease-out;
}

/* Fade in animation for content transitions */
.animate-fade-in {
  animation: fade-in 0.3s ease-out forwards;
}

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

/* Pulse glow effect for active step indicators */
.animate-step-active {
  animation: step-pulse 1.5s ease-in-out infinite;
}

@keyframes step-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(139, 92, 246, 0);
  }
}

/* Generation progress container styles */
.generation-progress-container {
  min-height: 140px;
  transition: opacity 0.2s ease-in-out;
}

/* Prevent layout shift during HTMX swaps */
#character-progress-container {
  min-height: 180px;
  transition: opacity 0.2s ease-in-out;
}

/* Smooth progress bar updates */
.generation-progress-container [hx-swap] {
  transition: opacity 0.15s ease-in-out;
}

/* Microanimations for hover elements */
.hover-sparkle {
  transition: all 0.3s ease;
}

.hover-sparkle:hover {
  animation: magical-sparkle 1s ease-in-out;
}

.hover-lift-subtle {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hover-lift-subtle:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(155, 140, 255, 0.15);
}

/* Improved spacing consistency */
.card-spacing {
  @apply p-6;
}

.card-spacing-lg {
  @apply p-8;
}

.section-spacing {
  @apply py-12;
}

.section-spacing-lg {
  @apply py-16;
}

/* Typography improvements for better readability */
.text-storybook-text {
  @apply text-storybook-gray-800;
}

.text-storybook-text-muted {
  @apply text-storybook-gray-600;
}

/* Accessibility improvements */
.focus-visible {
  @apply focus:outline-none focus:ring-2 focus:ring-storybook-primary focus:ring-offset-2;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

  .magical-icon,
  .hover-sparkle,
  .hover-lift-subtle,
  .progress-bar-shimmer::after {
    animation: none !important;
    transition: none !important;
  }

  .icon-magical-sparkle {
    animation: none !important;
  }
}

/* Trial Page Styles */
.trial-hero {
  @apply text-center py-16 px-4;
  background: linear-gradient(135deg, var(--storybook-warm) 0%, var(--storybook-surface) 50%, var(--storybook-surface-secondary) 100%);
}

.trial-hero h1 {
  @apply story-title text-5xl md:text-6xl mb-6;
}

.trial-hero .subtitle {
  @apply font-story text-xl md:text-2xl text-storybook-text/80 mb-8 max-w-3xl mx-auto;
}

.trial-benefits {
  @apply grid grid-cols-1 md:grid-cols-3 gap-8 max-w-4xl mx-auto mb-12;
}

.benefit-card {
  @apply card-magical p-6 text-center;
}

.benefit-icon {
  @apply text-4xl mb-4 text-storybook-primary;
}

.benefit-title {
  @apply font-heading text-xl text-storybook-text mb-3;
}

.benefit-description {
  @apply font-story text-storybook-text/80;
}

.trial-tiers {
  @apply grid grid-cols-1 md:grid-cols-3 gap-6 max-w-5xl mx-auto mb-12;
}

.trial-tier-card {
  @apply relative p-8 rounded-3xl transition-all duration-300 hover:scale-105 bg-white/95 backdrop-blur-sm shadow-xl border border-white/20 hover:shadow-2xl hover:shadow-storybook-primary/20;
}

.trial-tier-card.recommended {
  @apply border-storybook-success/50 bg-gradient-to-br from-storybook-success/5 to-storybook-secondary/5 transform scale-105;
}

.trial-badge {
  @apply absolute -top-3 left-1/2 transform -translate-x-1/2 px-4 py-2 rounded-full text-sm font-bold text-white bg-gradient-to-r from-storybook-success to-storybook-success shadow-lg;
}

.trial-tier-name {
  @apply font-heading text-2xl text-storybook-text mb-4 text-center;
}

.trial-price {
  @apply text-center mb-6;
}

.trial-price .amount {
  @apply font-heading text-4xl font-bold text-storybook-primary;
}

.trial-price .period {
  @apply text-lg text-storybook-text/60 font-normal;
}

.trial-features {
  @apply space-y-3 mb-8;
}

.trial-feature {
  @apply flex items-center text-storybook-text/90;
}

.trial-feature-icon {
  @apply w-5 h-5 text-storybook-success mr-3;
}

.trial-cta {
  @apply w-full;
}

.trial-cta-button {
  @apply btn btn-primary w-full text-lg py-4;
}

.trial-faq {
  @apply max-w-4xl mx-auto mt-16;
}

.trial-faq-header {
  @apply text-center mb-12;
}

.trial-faq-title {
  @apply text-3xl font-bold text-storybook-text mb-4;
}

.trial-faq-subtitle {
  @apply text-lg text-storybook-text/80;
}

.trial-faq-list {
  @apply space-y-6;
}

.trial-faq-item {
  @apply bg-white rounded-xl p-6 shadow-sm border border-storybook-border-light;
}

.trial-faq-question {
  @apply text-lg font-semibold text-storybook-text mb-3;
}

.trial-faq-answer {
  @apply text-storybook-text/80;
}

/* Error and Empty State Cards */
.card-error {
  @apply bg-red-50 border border-red-200 rounded-xl p-6 text-center;
}

.card-empty {
  @apply bg-storybook-gray-50 border border-storybook-border-light rounded-xl p-6 text-center;
}

/* ==========================================================================
   WIZARD STEP COMPONENTS - STYLE_GUIDE.md 2025
   ========================================================================== */

/* Wizard Option Card - Premium selectable cards */
.wizard-option-card {
  @apply relative;
  @apply bg-white;
  @apply border-2 border-storybook-border;
  @apply rounded-2xl;
  @apply transition-all duration-300 ease-smooth;
  @apply cursor-pointer;
  @apply focus-within:ring-2 focus-within:ring-storybook-primary/30;
}

.wizard-option-card:hover {
  @apply border-storybook-primary/50;
  @apply shadow-card-hover;
  @apply -translate-y-1;
}

/* Wizard Option Card - Selected State */
.wizard-radio:checked + .wizard-option-card,
.wizard-option-card.selected {
  @apply border-storybook-primary;
  @apply bg-storybook-primary/5;
  @apply shadow-magical;
  @apply ring-2 ring-storybook-primary/20;
}

.wizard-radio:checked + .wizard-option-card h3,
.wizard-option-card.selected h3 {
  @apply text-storybook-primary;
}

.wizard-radio:checked + .wizard-option-card .wizard-option-icon,
.wizard-option-card.selected .wizard-option-icon {
  @apply scale-110;
  @apply shadow-lg;
}

/* Wizard Option Selected Badge */
.wizard-option-check {
  @apply absolute;
  @apply top-3 right-3;
  @apply w-10 h-10 sm:w-11 sm:h-11;
  @apply rounded-full;
  @apply bg-storybook-primary text-white;
  @apply shadow-focus;
  @apply transition-all duration-300 ease-smooth;
  @apply ring-2 ring-white;
  @apply scale-90 opacity-0;
}

.wizard-option-check span {
  @apply text-lg;
}

.wizard-radio:checked + .wizard-option-card .wizard-option-check,
.wizard-option-card.selected .wizard-option-check {
  @apply flex items-center justify-center;
  @apply scale-100 opacity-100;
}

/* Wizard Option Icon Container */
.wizard-option-icon {
  @apply w-14 h-14;
  @apply rounded-full;
  @apply flex items-center justify-center;
  @apply mx-auto mb-4;
  @apply shadow-md;
  @apply transition-all duration-300 ease-smooth;
}

.wizard-option-icon:hover {
  @apply shadow-lg;
}

/* Wizard Option Icon Color Variants */
.wizard-option-icon-pink {
  @apply bg-gradient-to-br from-pink-400 to-rose-500;
}

.wizard-option-icon-sky {
  @apply bg-gradient-to-br from-sky-400 to-blue-500;
}

.wizard-option-icon-violet {
  @apply bg-gradient-to-br from-violet-400 to-purple-500;
}

.wizard-option-icon-emerald {
  @apply bg-gradient-to-br from-emerald-400 to-teal-500;
}

.wizard-option-icon-amber {
  @apply bg-gradient-to-br from-amber-400 to-orange-500;
}

.wizard-option-icon-indigo {
  @apply bg-gradient-to-br from-indigo-400 to-purple-500;
}

.wizard-option-icon-yellow {
  @apply bg-gradient-to-br from-yellow-400 to-orange-400;
}

.wizard-option-icon-blue {
  @apply bg-gradient-to-br from-blue-400 to-indigo-500;
}

.wizard-option-icon-red {
  @apply bg-gradient-to-br from-red-400 to-pink-500;
}

.wizard-option-icon-green {
  @apply bg-gradient-to-br from-green-400 to-emerald-500;
}

.wizard-option-icon-purple {
  @apply bg-gradient-to-br from-purple-300 to-purple-500;
}

.wizard-option-icon-primary {
  @apply bg-gradient-to-br from-storybook-primary to-storybook-secondary;
}

/* Wizard Option Premium Badge */
.wizard-premium-badge {
  @apply inline-flex items-center;
  @apply px-2.5 py-1;
  @apply rounded-full;
  @apply text-xs font-semibold;
  @apply bg-gradient-to-r from-amber-100 to-yellow-100;
  @apply text-amber-700;
  @apply border border-amber-200;
}

/* Wizard Step Header */
.wizard-step-header {
  @apply text-center mb-8;
}

.wizard-step-header-icon {
  @apply w-16 h-16;
  @apply bg-gradient-to-br from-storybook-primary to-storybook-secondary;
  @apply rounded-full;
  @apply flex items-center justify-center;
  @apply mx-auto mb-4;
  @apply shadow-magical;
}

.wizard-step-title {
  @apply text-2xl lg:text-3xl font-bold text-storybook-primary mb-2;
}

.wizard-step-subtitle {
  @apply text-base text-storybook-text-muted leading-relaxed;
}

/* Step Indicator Container */
.step-indicator {
  @apply relative flex flex-col items-center transition-all duration-300 ease-smooth;
  @apply min-w-[80px] max-w-[120px];
  @apply z-10;
  @apply mx-2;
}

/* Step Number Container */
.step-number-container {
  @apply relative flex items-center justify-center mb-3;
  @apply w-12 h-12 rounded-full;
  @apply border-2 border-storybook-border-light;
  @apply bg-storybook-surface;
  @apply transition-all duration-300 ease-smooth;
  @apply shadow-sm;
}

/* Step Number */
.step-number {
  @apply text-lg font-bold text-storybook-text-muted;
  @apply transition-all duration-300 ease-smooth;
  @apply z-10 relative;
}

/* Step Label */
.step-label {
  @apply text-sm font-medium text-storybook-text-muted;
  @apply text-center leading-tight;
  @apply transition-all duration-300 ease-smooth;
  @apply px-2;
}

/* Step Line */
.step-line {
  @apply relative w-8 h-0.5;
  @apply bg-storybook-border-light;
  @apply transition-all duration-300 ease-smooth;
  @apply z-0;
  @apply self-center;
  @apply -mx-2;
}

/* Active Step States */
.step-indicator.active .step-number-container {
  @apply border-storybook-primary bg-storybook-primary;
  @apply shadow-magical;
  @apply scale-110;
}

.step-indicator.active .step-number {
  @apply text-white;
}

.step-indicator.active .step-label {
  @apply text-storybook-primary font-semibold;
}

.step-indicator.active .step-line {
  @apply bg-storybook-primary;
}

/* Completed Step States */
.step-indicator.completed .step-number-container {
  @apply border-storybook-success bg-storybook-success;
  @apply shadow-sm;
}

.step-indicator.completed .step-number {
  @apply text-white;
}

.step-indicator.completed .step-label {
  @apply text-storybook-success font-medium;
}

.step-indicator.completed .step-line {
  @apply bg-storybook-success;
}

/* Hover States */
.step-indicator:hover .step-number-container {
  @apply border-storybook-primary/50 shadow-md;
  @apply transform scale-105;
}

.step-indicator:hover .step-label {
  @apply text-storybook-primary;
}

/* Glow Ring Animation */
.step-glow-ring {
  @apply absolute inset-0 rounded-full;
  @apply border-2 border-storybook-primary/30;
  @apply opacity-0;
  @apply transition-all duration-300 ease-smooth;
  @apply animate-ping;
}

.step-indicator.active .step-glow-ring {
  @apply opacity-100;
  @apply animate-pulse;
}

/* Progress Line Fill */
.step-line-fill {
  @apply absolute top-0 left-0 h-full;
  @apply bg-gradient-to-r from-storybook-primary to-storybook-secondary;
  @apply transition-all duration-500 ease-smooth;
  @apply z-10;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .step-indicator {
    @apply min-w-[60px] max-w-[80px];
  }

  .step-number-container {
    @apply w-10 h-10;
  }

  .step-number {
    @apply text-base;
  }

  .step-label {
    @apply text-xs;
  }
}

/* ==========================================================================
   WEEKLY BEDTIME PROGRESS COMPONENT - STYLE_GUIDE.md 2025
   ========================================================================== */

/* Weekly Bedtime Container */
.weekly-bedtime-container {
  @apply bg-gradient-to-br from-storybook-surface to-storybook-surface-secondary;
  @apply border border-storybook-border rounded-card;
  @apply p-6 shadow-card;
  @apply relative overflow-hidden;
}

.weekly-bedtime-container::before {
  @apply absolute inset-0;
  @apply bg-gradient-to-br from-storybook-primary/5 to-storybook-secondary/5;
  @apply pointer-events-none;
  @apply rounded-card;
}

/* Weekly Bedtime Header */
.weekly-bedtime-header {
  @apply flex items-center gap-3 mb-4;
  @apply relative z-10;
}

.weekly-bedtime-icon {
  @apply w-8 h-8 rounded-full;
  @apply bg-gradient-to-br from-storybook-primary to-storybook-secondary;
  @apply flex items-center justify-center;
  @apply text-white shadow-md;
}

.weekly-bedtime-title {
  @apply text-xl font-bold text-storybook-text;
  @apply flex items-center gap-2;
}

.weekly-bedtime-checkmark {
  @apply w-5 h-5 text-storybook-success;
}

/* Weekly Bedtime Stats */
.weekly-bedtime-stats {
  @apply flex items-center justify-between mb-4;
  @apply relative z-10;
}

.weekly-bedtime-count {
  @apply text-2xl font-bold text-storybook-primary;
  @apply flex items-center gap-1;
}

.weekly-bedtime-separator {
  @apply text-storybook-text-muted;
}

.weekly-bedtime-limit {
  @apply text-xl font-semibold text-storybook-text;
}

.weekly-bedtime-label {
  @apply text-sm text-storybook-text-muted ml-1;
}

/* Weekly Bedtime Progress Bar */
.weekly-bedtime-progress-container {
  @apply relative mb-4;
  @apply relative z-10;
}

.weekly-bedtime-progress-bar {
  @apply w-full h-3 bg-storybook-gray-200 rounded-full;
  @apply overflow-hidden shadow-inner;
  @apply relative;
}

.weekly-bedtime-progress-fill {
  @apply h-full rounded-full;
  @apply bg-gradient-to-r from-storybook-primary via-storybook-secondary to-storybook-accent;
  @apply transition-all duration-700 ease-out;
  @apply relative overflow-hidden;
  @apply shadow-sm;
}

.weekly-bedtime-progress-fill::before {
  @apply absolute inset-0;
  @apply bg-gradient-to-r from-transparent via-white/30 to-transparent;
  @apply transform -skew-x-12;
  @apply animate-shimmer;
  content: "";
}

.weekly-bedtime-progress-fill::after {
  @apply absolute inset-0;
  @apply bg-gradient-to-r from-storybook-primary/20 to-storybook-secondary/20;
  @apply animate-pulse;
  content: "";
}

/* Weekly Bedtime Progress Bar - Warning State (80-99% usage) */
.weekly-bedtime-progress-fill.progress-warning {
  @apply bg-gradient-to-r from-amber-500 to-orange-500;
}

.weekly-bedtime-progress-fill.progress-warning::after {
  @apply bg-gradient-to-r from-amber-500/20 to-orange-500/20;
}

/* Weekly Bedtime Progress Bar - Error State (100%+ usage / limit reached) */
.weekly-bedtime-progress-fill.progress-error {
  @apply bg-gradient-to-r from-red-500 to-red-600;
}

.weekly-bedtime-progress-fill.progress-error::after {
  @apply bg-gradient-to-r from-red-500/20 to-red-600/20;
}

.weekly-bedtime-progress-fill.progress-error::before {
  @apply hidden; /* Hide shimmer animation on error state */
}

/* Weekly Bedtime Progress Bar - Error background */
.weekly-bedtime-progress-bar.progress-bar-error {
  @apply bg-red-100;
}

/* Weekly Bedtime Percentage */
.weekly-bedtime-percentage {
  @apply text-center;
  @apply relative z-10;
}

.weekly-bedtime-percentage-value {
  @apply text-lg font-bold text-storybook-primary;
  @apply inline-flex items-center gap-1;
}

.weekly-bedtime-percentage-label {
  @apply text-sm text-storybook-text-muted;
}

/* Weekly Bedtime Sparkles */
.weekly-bedtime-sparkle {
  @apply absolute w-2 h-2 bg-storybook-primary/60 rounded-full;
  @apply animate-pulse;
  @apply pointer-events-none;
}

.weekly-bedtime-sparkle-1 {
  @apply top-4 right-4;
  @apply animation-delay-1s;
}

.weekly-bedtime-sparkle-2 {
  @apply bottom-4 left-4;
  @apply animation-delay-2s;
}

.weekly-bedtime-sparkle-3 {
  @apply top-1/2 right-8;
  @apply animation-delay-3s;
}

/* Compact Story Count Badge for Navigation */
.story-count-badge {
  @apply flex items-center;
}

.story-count-badge a {
  @apply min-h-[44px] min-w-[44px];
  @apply text-decoration-none;
}

.story-count-used {
  @apply font-bold;
}

.story-count-limit {
  @apply font-normal;
}

/* Mobile Responsive */
@media (max-width: 640px) {
  .weekly-bedtime-container {
    @apply p-4;
  }

  .weekly-bedtime-title {
    @apply text-lg;
  }

  .weekly-bedtime-count {
    @apply text-xl;
  }

  .weekly-bedtime-limit {
    @apply text-lg;
  }
}

/* ==========================================================================
   HEADER COMPONENTS - STYLE_GUIDE.md 2025
   ========================================================================== */

/* Story Library Header */
.story-library-header {
  @apply bg-storybook-surface py-12;
}

.story-library-header-icon {
  @apply mb-6;
}

.story-library-header-title {
  @apply text-4xl font-bold text-storybook-text mb-4;
}

.story-library-header-subtitle {
  @apply text-xl text-storybook-text-muted max-w-3xl mx-auto;
}

/* Characters Management Header */
.characters-header {
  @apply bg-storybook-surface border-b border-storybook-border-light py-8;
}

.characters-header-content {
  @apply flex items-center justify-between;
}

.characters-header-left {
  @apply flex items-center;
}

.characters-header-icon {
  @apply text-4xl text-storybook-primary mr-4;
}

.characters-header-title {
  @apply text-3xl font-bold text-storybook-text;
}

.characters-header-subtitle {
  @apply text-storybook-text-muted mt-1;
}

.characters-header-actions {
  @apply flex items-center space-x-3;
}

/* Personalized Welcome Header */
.personalized-welcome-header {
  @apply bg-storybook-surface py-8;
}

.personalized-welcome-content {
  @apply flex items-center justify-center;
}

.personalized-welcome-avatar {
  @apply w-16 h-16 bg-gradient-to-br from-storybook-primary to-storybook-secondary rounded-full flex items-center justify-center text-white text-2xl font-bold;
}

.personalized-welcome-title {
  @apply text-3xl font-bold bg-gradient-to-r from-storybook-primary to-storybook-secondary bg-clip-text text-transparent;
}

.personalized-welcome-subtitle {
  @apply text-xl text-storybook-text font-medium mt-1;
}

/* Story Creation Header */
.story-creation-header {
  @apply relative overflow-hidden bg-gradient-to-br from-storybook-primary via-storybook-secondary to-storybook-gradient-end;
}

.story-creation-header-content {
  @apply max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16 relative z-10;
}

.story-creation-header-title {
  @apply text-gradient-primary text-5xl md:text-6xl font-bold mb-6;
}

.story-creation-header-subtitle {
  @apply text-xl text-white/90 mb-8 max-w-3xl mx-auto;
}

.story-creation-step-indicator {
  @apply mt-8 flex justify-center items-center space-x-3 overflow-x-auto px-4;
}

.story-creation-actions {
  @apply flex flex-col sm:flex-row gap-4 justify-center mt-8;
}

/* ==========================================================================
   BOTTOM TAB NAVIGATION - STYLE_GUIDE.md 2025
   Mobile-only tab bar for app-like navigation (md:hidden)
   Using explicit CSS for reliability (not dependent on Tailwind rebuild)
   ========================================================================== */

/* Bottom Tab Navigation Container */
.bottom-tab-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: none; /* Hidden by default */
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--storybook-border-light, #E5E7EB);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Show only on mobile (below md breakpoint) */
@media (max-width: 767px) {
  .bottom-tab-nav {
    display: block;
  }
}

/* Inner flex container */
.bottom-tab-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  height: 64px;
  max-width: 32rem;
  margin: 0 auto;
  padding: 0 0.5rem;
}

/* Tab Item - Base styles */
.bottom-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  text-decoration: none;
  color: var(--storybook-text-muted, #6B7280);
  transition: all 0.2s ease;
}

.bottom-tab-item:hover {
  color: var(--storybook-primary, #8B5CF6);
  background: rgba(139, 92, 246, 0.05);
}

.bottom-tab-item:active {
  transform: scale(0.95);
  opacity: 0.8;
}

/* Tab Item - Active state */
.bottom-tab-active {
  color: var(--storybook-primary, #8B5CF6) !important;
  background: rgba(139, 92, 246, 0.1);
}

.bottom-tab-active .material-symbols-outlined {
  font-variation-settings: 'FILL' 1;
}

/* Tab Label */
.bottom-tab-label {
  font-size: 0.625rem;
  margin-top: 0.125rem;
  font-weight: 500;
  line-height: 1.2;
}

/* Create Button (Elevated CTA) */
.bottom-tab-create {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  min-width: 56px;
  margin-top: -16px;
  border-radius: 9999px;
  text-decoration: none;
  color: white;
  background: linear-gradient(135deg, var(--storybook-primary, #8B5CF6) 0%, var(--storybook-secondary, #3B82F6) 100%);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  transition: all 0.2s ease;
}

/* Twinkling sparkle animation on the icon */
.bottom-tab-create .material-symbols-outlined {
  animation: twinkle 2.5s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { 
    opacity: 1; 
    transform: scale(1) rotate(0deg);
    filter: drop-shadow(0 0 0 transparent);
  }
  25% { 
    opacity: 0.85; 
    transform: scale(0.92) rotate(-3deg);
  }
  50% { 
    opacity: 1; 
    transform: scale(1.08) rotate(0deg);
    filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
  }
  75% { 
    opacity: 0.9; 
    transform: scale(0.95) rotate(3deg);
  }
}

.bottom-tab-create:hover {
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
  transform: scale(1.05);
}

.bottom-tab-create:hover .material-symbols-outlined {
  animation-play-state: paused;
}

.bottom-tab-create:active {
  transform: scale(0.95);
}

/* Badge for notifications (optional) */
.bottom-tab-badge {
  position: absolute;
  top: -0.25rem;
  right: -0.25rem;
  width: 1.25rem;
  height: 1.25rem;
  min-width: 1.25rem;
  background: var(--storybook-danger, #EF4444);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Body padding class for pages with bottom tab */
/* Increased padding to ensure content doesn't overlap with bottom nav */
.has-bottom-tab-nav {
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* Only apply on mobile devices */
@media (min-width: 768px) {
  .has-bottom-tab-nav {
    padding-bottom: 0;
  }
}

/* Ensure main content area has proper padding on mobile */
@media (max-width: 767px) {
  main.has-bottom-tab-nav {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  .bottom-tab-nav {
    background: rgba(17, 24, 39, 0.95);
    border-color: #374151;
  }

  .bottom-tab-item {
    color: #9CA3AF;
  }

  .bottom-tab-item:hover {
    color: var(--storybook-primary, #8B5CF6);
    background: rgba(55, 65, 81, 0.5);
  }

  .bottom-tab-active {
    background: rgba(139, 92, 246, 0.2);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .bottom-tab-item,
  .bottom-tab-create {
    transition: none;
  }
  
  .bottom-tab-create .material-symbols-outlined {
    animation: none;
  }
}

/* ==========================================================================
   HTMX LOADING STATES
   ========================================================================== */

/* Loading state for HTMX targets */
.htmx-loading {
  position: relative;
  pointer-events: none;
}

.htmx-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(2px);
  border-radius: inherit;
  z-index: 10;
}

/* Optional: Add spinner to loading state */
.htmx-loading.with-spinner::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid var(--storybook-primary, #8B5CF6);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  z-index: 11;
}

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

/* Skeleton pulse animation enhancement */
.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* ==========================================================================
   OFFLINE TOAST NOTIFICATION
   Accessible toast for network status changes
   ========================================================================== */

.offline-toast {
  position: fixed;
  bottom: 5rem; /* Above bottom tab nav */
  left: 1rem;
  right: 1rem;
  max-width: 20rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  background: #1F2937;
  color: white;
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 100;
  transform: translateY(200%);
  transition: transform 0.3s ease;
}

.offline-toast.active {
  transform: translateY(0);
}

.offline-toast .material-symbols-outlined {
  color: #FBBF24; /* Amber warning color */
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* Desktop positioning */
@media (min-width: 768px) {
  .offline-toast {
    left: auto;
    right: 1rem;
    bottom: 1.5rem;
  }
}

/* ==========================================================================
   NOTE: Biometric authentication now uses native iOS/Android password
   autofill with Face ID/Touch ID. No custom components needed.
   ========================================================================== */

/* ==========================================================================
   HTMX PAGE TRANSITIONS
   Premium fade/scale transitions for HTMX-boosted navigation
   ========================================================================== */

/* During swap - content fading out */
.htmx-swapping {
  opacity: 0.5;
  transition: opacity 150ms ease-out;
}

/* During request - subtle loading state */
.htmx-request {
  opacity: 0.9;
  transition: opacity 100ms ease-out;
}

/* After swap - content fading in */
.htmx-settling {
  opacity: 1;
  animation: fadeInScale 0.25s ease-out forwards;
}

/* Disable transition when user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  .htmx-swapping,
  .htmx-request,
  .htmx-settling {
    opacity: 1;
    animation: none;
    transition: none;
  }
}

/* ==========================================================================
   WIZARD OPTION STAGGER ANIMATIONS
   Smooth reveal of wizard options with CSS nth-child delays
   ========================================================================== */

.wizard-options > * {
  opacity: 0;
  animation: fadeInUp 0.3s ease-out forwards;
}

.wizard-options > *:nth-child(1) { animation-delay: 0ms; }
.wizard-options > *:nth-child(2) { animation-delay: 50ms; }
.wizard-options > *:nth-child(3) { animation-delay: 100ms; }
.wizard-options > *:nth-child(4) { animation-delay: 150ms; }
.wizard-options > *:nth-child(5) { animation-delay: 200ms; }
.wizard-options > *:nth-child(6) { animation-delay: 250ms; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .wizard-options > * {
    opacity: 1;
    animation: none;
  }
}

/* ==========================================================================
   EMPTY STATE ANIMATIONS
   Subtle fade-in for empty state components
   ========================================================================== */

.empty-state {
  animation: fadeInUp 0.4s ease-out forwards;
}

@media (prefers-reduced-motion: reduce) {
  .empty-state {
    animation: none;
  }
}

/* ==========================================================================
   PREMIUM FOCUS STATES
   Consistent, accessible focus rings for all interactive elements
   ========================================================================== */

.focus-premium:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3), 0 0 0 4px rgba(139, 92, 246, 0.1);
  transition: box-shadow 0.15s ease-out;
}

/* ==========================================================================
   SCROLL-TRIGGERED ANIMATION OBSERVER
   Elements with this class will animate when entering viewport
   ========================================================================== */

.animate-on-scroll {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .animate-on-scroll {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ==========================================================================
   IMAGE LOADING TRANSITIONS
   Blur-to-sharp transition for story illustrations (Apple Photos pattern)
   ========================================================================== */

/* Apply to images with lazy loading - starts blurred */
.image-blur-load {
  filter: blur(8px);
  transition: filter 0.5s ease-out;
}

.image-blur-load.loaded,
.image-blur-load[data-loaded="true"] {
  filter: blur(0);
}

/* JavaScript-free version using :not([src=""]) for inline images */
img[loading="lazy"] {
  transition: filter 0.4s ease-out, opacity 0.4s ease-out;
}

/* Skeleton placeholder for images */
.image-skeleton {
  background: linear-gradient(90deg, 
    rgba(139, 92, 246, 0.05) 0%, 
    rgba(139, 92, 246, 0.1) 50%, 
    rgba(139, 92, 246, 0.05) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .image-blur-load {
    filter: none;
    transition: none;
  }
  
  .image-skeleton {
    animation: none;
  }
}

/* ==========================================================================
   BOOK READER POLISH
   Smooth scroll-snap and transitions for premium reading experience
   ========================================================================== */

/* Container with horizontal scroll-snap */
.book-pages-container {
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Each spread snaps to center */
.book-spread {
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

/* Fade-in for new content loaded via HTMX */
.book-spread.htmx-added {
  animation: fadeInScale 0.3s ease-out forwards;
}

/* Choice buttons with reveal animation */
.book-choice-container {
  opacity: 0;
  animation: fadeInUp 0.4s ease-out 0.2s forwards;
}

/* Text reveal for story content (optional class) */
.story-text-reveal {
  opacity: 0;
  animation: fadeIn 0.5s ease-out forwards;
}

@media (prefers-reduced-motion: reduce) {
  .book-pages-container {
    scroll-behavior: auto;
  }
  
  .book-spread.htmx-added,
  .book-choice-container,
  .story-text-reveal {
    animation: none;
    opacity: 1;
  }
}

/* ==========================================================================
   STORY WISH PREMIUM ANIMATION SYSTEM (sw-*)
   Bouncy micro-interactions, staggered entrances, and celebration effects
   Inspired by best-in-class mobile apps
   ========================================================================== */

/* CSS Custom Property for the signature bounce curve */
:root {
  --sw-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --sw-duration-fast: 150ms;
  --sw-duration-normal: 250ms;
  --sw-duration-slow: 350ms;
}

/* --------------------------------------------------------------------------
   SW-BUTTON: Bouncy Button Press/Release
   Applied to buttons for premium tactile feel
   -------------------------------------------------------------------------- */

.sw-button {
  transition: transform var(--sw-duration-fast) var(--sw-bounce),
              box-shadow var(--sw-duration-fast) ease-out;
  transform: translateZ(0); /* GPU acceleration */
  will-change: transform;
}

.sw-button:active {
  transform: scale(0.95);
}

/* Release with overshoot bounce */
.sw-button.sw-released {
  animation: swBounceRelease var(--sw-duration-normal) var(--sw-bounce) forwards;
}

@keyframes swBounceRelease {
  0% { transform: scale(0.95); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* --------------------------------------------------------------------------
   SW-CARD-PRESS: Card Selection/Press Feedback
   Applied to interactive cards for tactile response
   -------------------------------------------------------------------------- */

.sw-card-press {
  transition: transform var(--sw-duration-fast) ease-out,
              box-shadow var(--sw-duration-fast) ease-out;
  transform: translateZ(0);
}

.sw-card-press:active {
  transform: scale(0.97);
}

/* Selected state with glow ring */
.sw-card-press.sw-selected {
  animation: swCardGlow 0.5s ease-out forwards;
}

@keyframes swCardGlow {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
  100% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
}

/* --------------------------------------------------------------------------
   SW-STAGGER: Staggered List/Grid Entrance Animation
   Applied to items that should animate in sequentially
   -------------------------------------------------------------------------- */

.sw-stagger {
  opacity: 0;
  transform: translateY(16px);
  animation: swSlideUp var(--sw-duration-slow) var(--sw-bounce) forwards;
}

/* Re-trigger animations for HTMX-swapped content */
.sw-stagger.htmx-added,
.sw-stagger.htmx-swapping {
  opacity: 0;
  transform: translateY(16px);
}

.sw-stagger.htmx-settling {
  animation: swSlideUp var(--sw-duration-slow) var(--sw-bounce) forwards;
}

/* Stagger delays using animation-delay utility classes */
.sw-stagger:nth-child(1),
.sw-stagger.htmx-added:nth-child(1),
.sw-stagger.htmx-settling:nth-child(1) { animation-delay: 0ms; }
.sw-stagger:nth-child(2),
.sw-stagger.htmx-added:nth-child(2),
.sw-stagger.htmx-settling:nth-child(2) { animation-delay: 50ms; }
.sw-stagger:nth-child(3),
.sw-stagger.htmx-added:nth-child(3),
.sw-stagger.htmx-settling:nth-child(3) { animation-delay: 100ms; }
.sw-stagger:nth-child(4),
.sw-stagger.htmx-added:nth-child(4),
.sw-stagger.htmx-settling:nth-child(4) { animation-delay: 150ms; }
.sw-stagger:nth-child(5),
.sw-stagger.htmx-added:nth-child(5),
.sw-stagger.htmx-settling:nth-child(5) { animation-delay: 200ms; }
.sw-stagger:nth-child(6),
.sw-stagger.htmx-added:nth-child(6),
.sw-stagger.htmx-settling:nth-child(6) { animation-delay: 250ms; }
.sw-stagger:nth-child(7),
.sw-stagger.htmx-added:nth-child(7),
.sw-stagger.htmx-settling:nth-child(7) { animation-delay: 300ms; }
.sw-stagger:nth-child(8),
.sw-stagger.htmx-added:nth-child(8),
.sw-stagger.htmx-settling:nth-child(8) { animation-delay: 350ms; }
.sw-stagger:nth-child(9),
.sw-stagger.htmx-added:nth-child(9),
.sw-stagger.htmx-settling:nth-child(9) { animation-delay: 400ms; }
.sw-stagger:nth-child(10),
.sw-stagger.htmx-added:nth-child(10),
.sw-stagger.htmx-settling:nth-child(10) { animation-delay: 450ms; }
.sw-stagger:nth-child(11),
.sw-stagger.htmx-added:nth-child(11),
.sw-stagger.htmx-settling:nth-child(11) { animation-delay: 500ms; }
.sw-stagger:nth-child(12),
.sw-stagger.htmx-added:nth-child(12),
.sw-stagger.htmx-settling:nth-child(12) { animation-delay: 550ms; }

@keyframes swSlideUp {
  0% {
    opacity: 0;
    transform: translateY(16px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --------------------------------------------------------------------------
   SW-RING-PULSE: Success Ring Expansion
   Radiating glow effect for celebration moments (used by sw-success-ring)
   -------------------------------------------------------------------------- */

@keyframes swRingPulse {
  0% {
    transform: scale(0.8);
    opacity: 0;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  }
  50% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 12px rgba(16, 185, 129, 0);
  }
}

/* --------------------------------------------------------------------------
   SW-SUCCESS: Combined Success Animation Container
   Wraps checkmark + ring for celebration moments
   -------------------------------------------------------------------------- */

.sw-success {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sw-success-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  animation: swRingPulse 0.6s ease-out forwards;
}

.sw-success-icon {
  animation: swSuccessIcon 0.5s var(--sw-bounce) forwards;
}

@keyframes swSuccessIcon {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   REDUCED MOTION: Respect user preferences
   Disables all sw-* animations when user prefers reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .sw-button,
  .sw-card-press {
    transition: none;
  }
  
  .sw-button:active,
  .sw-card-press:active {
    transform: none;
  }
  
  .sw-button.sw-released,
  .sw-card-press.sw-selected,
  .sw-stagger,
  .sw-stagger.htmx-added,
  .sw-stagger.htmx-swapping,
  .sw-stagger.htmx-settling,
  .sw-success-ring,
  .sw-success-icon {
    animation: none;
    opacity: 1;
    transform: none;
  }
}
