/**
 * Format Editor Animations & Premium Interactions
 * Based on UX Design Specification
 */

/* ============================================
   CSS Variables - Animation System
   ============================================ */
:root {
    /* Timing functions */
    --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);

    /* Durations */
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Shadows for lift effect */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(212, 175, 55, 0.15);

    /* Colors for states */
    --color-primary: var(--accent-gold, #d4af37);
    --color-primary-glow: rgba(212, 175, 55, 0.15);
    --color-success: #22c55e;
}

/* ============================================
   Keyframe Animations
   ============================================ */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

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

@keyframes checkmark {
    0% { stroke-dashoffset: 24; }
    100% { stroke-dashoffset: 0; }
}

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

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

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

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

/* ============================================
   Content Type Cards - Premium Interactions
   ============================================ */
.fe-content-grid-large {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.fe-content-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out-expo);
    position: relative;
}

/* Hover state - Lift effect */
.fe-content-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-gold);
    box-shadow: var(--shadow-lg), 0 0 20px var(--color-primary-glow);
}

/* Active state - Press effect */
.fe-content-card:active {
    transform: translateY(-2px) scale(0.98);
    transition-duration: var(--duration-fast);
}

/* Selected state */
.fe-content-card.selected {
    border-color: var(--accent-gold);
    background: var(--gold-dim);
    box-shadow: var(--shadow-glow);
}

/* Focus state for accessibility */
.fe-content-card:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

.fe-content-emoji {
    font-size: 28px;
    flex-shrink: 0;
}

.fe-content-info {
    flex: 1;
    min-width: 0;
}

.fe-content-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.fe-content-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Checkmark container */
.fe-content-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--duration-normal) var(--ease-out-expo);
    opacity: 0;
    transform: scale(0.8);
}

.fe-content-card.selected .fe-content-check {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    opacity: 1;
    transform: scale(1);
}

.fe-content-card.selected .fe-content-check svg {
    color: #000;
    stroke-dasharray: 24;
    stroke-dashoffset: 0;
    animation: checkmark var(--duration-slow) var(--ease-out-expo);
}

/* ============================================
   Tone Selection - Pill Style
   ============================================ */
.fe-tone-grid {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.fe-tone-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.fe-tone-item:hover {
    border-color: var(--border-gold);
    transform: translateY(-2px);
}

.fe-tone-item:active {
    transform: translateY(0) scale(0.98);
}

.fe-tone-item.selected {
    border-color: var(--accent-gold);
    background: var(--gold-dim);
}

.fe-tone-item:focus-visible {
    outline: 2px solid var(--accent-gold);
    outline-offset: 2px;
}

.fe-tone-emoji {
    font-size: 18px;
}

.fe-tone-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: color var(--duration-fast);
}

.fe-tone-item.selected .fe-tone-label {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   Density Slider - Enhanced
   ============================================ */
.fe-density-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    transition: background var(--duration-fast);
}

.fe-density-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: var(--accent-gold);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 12px var(--gold-glow);
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.fe-density-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 0 20px var(--gold-glow);
}

.fe-density-slider:active::-webkit-slider-thumb {
    transform: scale(1.2);
}

.fe-density-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: var(--accent-gold);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 12px var(--gold-glow);
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.fe-density-slider::-moz-range-thumb:hover {
    transform: scale(1.15);
}

/* Density value animation */
.fe-density-val {
    transition: transform var(--duration-fast) var(--ease-out-back);
}

.fe-density-val.updating {
    transform: scale(1.1);
}

/* Estimates animation */
.fe-est-val {
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.fe-est-val.updating {
    color: var(--accent-gold);
    transform: scale(1.05);
}

/* ============================================
   Preview Panel - Morph Transitions
   ============================================ */
.fe-preview-content {
    transition: opacity var(--duration-normal) var(--ease-out-expo);
}

.fe-preview-content.morphing {
    opacity: 0.5;
}

/* Preview elements stagger animation */
.fe-preview-content > * {
    animation: fadeInUp var(--duration-normal) var(--ease-out-expo);
    animation-fill-mode: both;
}

.fe-preview-content > *:nth-child(1) { animation-delay: 0ms; }
.fe-preview-content > *:nth-child(2) { animation-delay: 50ms; }
.fe-preview-content > *:nth-child(3) { animation-delay: 100ms; }
.fe-preview-content > *:nth-child(4) { animation-delay: 150ms; }
.fe-preview-content > *:nth-child(5) { animation-delay: 200ms; }
.fe-preview-content > *:nth-child(6) { animation-delay: 250ms; }
.fe-preview-content > *:nth-child(7) { animation-delay: 300ms; }
.fe-preview-content > *:nth-child(8) { animation-delay: 350ms; }

/* Config summary tags animation */
.fe-config-tag {
    animation: slideIn var(--duration-normal) var(--ease-out-expo);
    animation-fill-mode: both;
}

.fe-config-tag:nth-child(1) { animation-delay: 0ms; }
.fe-config-tag:nth-child(2) { animation-delay: 75ms; }
.fe-config-tag:nth-child(3) { animation-delay: 150ms; }

/* ============================================
   Save Button - Success Animation
   ============================================ */
.fe-btn-primary {
    position: relative;
    overflow: hidden;
    transition: all var(--duration-normal) var(--ease-out-expo);
}

.fe-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px var(--gold-glow);
}

.fe-btn-primary:active {
    transform: translateY(0) scale(0.98);
}

/* Saving state */
.fe-btn-primary.is-saving {
    pointer-events: none;
    opacity: 0.8;
}

.fe-btn-primary.is-saving::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
    margin-left: 8px;
}

/* Success state */
.fe-btn-primary.is-success {
    background: var(--color-success);
    animation: successPulse var(--duration-slow) var(--ease-out-back);
}

/* Error state */
.fe-btn-primary.is-error {
    animation: shake 0.5s var(--ease-out-expo);
}

/* ============================================
   Back Button - Subtle Interaction
   ============================================ */
.fe-back-btn {
    transition: all var(--duration-fast) var(--ease-out-expo);
}

.fe-back-btn:hover {
    color: var(--accent-gold);
    transform: translateX(-4px);
}

.fe-back-btn:hover svg {
    transform: translateX(-2px);
}

.fe-back-btn svg {
    transition: transform var(--duration-fast) var(--ease-out-expo);
}

/* ============================================
   Reduced Motion Support
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .fe-content-card:hover,
    .fe-tone-item:hover,
    .fe-btn-primary:hover {
        transform: none;
    }
}
