/**
 * Perfect Contrast & Delightful Enhancements
 * Ensuring maximum readability while adding joy to interactions
 */

:root {
    /* Perfect contrast text colors */
    --text-perfect-white: #ffffff;
    --text-perfect-light: #f8f9fa;
    --text-perfect-medium: #e9ecef;
    --text-perfect-muted: #ced4da;
    
    /* Enhanced text shadows for perfect readability */
    --shadow-text-strong: 2px 2px 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.7);
    --shadow-text-medium: 1px 1px 3px rgba(0, 0, 0, 0.8), 0 0 6px rgba(0, 0, 0, 0.5);
    --shadow-text-light: 1px 1px 2px rgba(0, 0, 0, 0.7), 0 0 4px rgba(0, 0, 0, 0.3);
    
    /* Delightful animation curves */
    --ease-bounce-out: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-back-out: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --ease-elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Enhanced gradients */
    --gradient-text-glow: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    --gradient-primary-vibrant: linear-gradient(135deg, #e50914 0%, #ff1744 50%, #e50914 100%);
    --gradient-accent-shine: linear-gradient(135deg, #ffd700 0%, #ffed4e 50%, #ffd700 100%);
}

/* ==========================================================================
   PERFECT TEXT CONTRAST SYSTEM
   ========================================================================== */

/* Ultra-high contrast text for critical information */
.text-ultra-contrast {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-strong);
    font-weight: 700;
    letter-spacing: 0.025em;
}

/* High contrast text for important content */
.text-high-contrast {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-medium);
    font-weight: 600;
}

/* Medium contrast for regular content */
.text-medium-contrast {
    color: var(--text-perfect-light) !important;
    text-shadow: var(--shadow-text-light);
    font-weight: 500;
}

/* Muted but still readable text */
.text-muted-contrast {
    color: var(--text-perfect-muted) !important;
    text-shadow: var(--shadow-text-light);
    font-weight: 500;
}

/* Overlay text with maximum readability */
.text-overlay-perfect {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-strong);
    font-weight: 700;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.8) 100%);
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

/* Enhanced headings with perfect visibility */
h1, h2, h3, h4, h5, h6,
.display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-strong);
    font-weight: 700;
}

.show-title, .movie-title {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-strong);
    font-weight: 800;
    letter-spacing: -0.02em;
}

.show-year, .movie-year {
    color: var(--text-perfect-medium) !important;
    text-shadow: var(--shadow-text-medium);
    font-weight: 400;
}

/* Perfect contrast for labels and values */
.info-label {
    color: var(--text-perfect-muted) !important;
    text-shadow: var(--shadow-text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
}

.info-value {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-medium);
    font-weight: 600;
    font-size: 1rem;
}

/* Cast and crew names with perfect readability */
.cast-name, .season-name {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-medium);
    font-weight: 600;
}

.cast-character, .season-meta {
    color: var(--text-perfect-medium) !important;
    text-shadow: var(--shadow-text-light);
    font-weight: 500;
}

/* Navigation text enhancements */
.navbar-brand {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-medium);
    font-weight: 800;
}

.nav-link {
    color: var(--text-perfect-light) !important;
    text-shadow: var(--shadow-text-light);
    font-weight: 500;
    transition: all 0.3s var(--ease-smooth);
}

.nav-link:hover, .nav-link:focus {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-medium);
    transform: translateY(-1px);
}

/* ==========================================================================
   DELIGHTFUL MICRO-INTERACTIONS
   ========================================================================== */

/* Satisfying button press effects */
.btn-primary-enhanced, .btn-secondary-enhanced {
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
    backface-visibility: hidden;
}

.btn-primary-enhanced::after,
.btn-secondary-enhanced::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s var(--ease-back-out), height 0.6s var(--ease-back-out);
}

.btn-primary-enhanced:active::after,
.btn-secondary-enhanced:active::after {
    width: 300px;
    height: 300px;
    transition: width 0.2s ease-out, height 0.2s ease-out;
}

/* Magical hover effects for cards */
.info-card {
    position: relative;
    transition: all 0.4s var(--ease-smooth);
}

.info-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #e50914, #ff1744, #ffd700, #e50914);
    background-size: 400% 400%;
    border-radius: 18px;
    z-index: -1;
    opacity: 0;
    animation: gradientShift 3s ease infinite;
    transition: opacity 0.4s var(--ease-smooth);
}

.info-card:hover::before {
    opacity: 0.7;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Sparkle effect for rating stars */
.rating-star-input {
    position: relative;
    transition: all 0.3s var(--ease-elastic);
}

.rating-star-input::before {
    content: '✨';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    font-size: 0.8rem;
    opacity: 0;
    transition: all 0.3s var(--ease-bounce-out);
    pointer-events: none;
}

.rating-star-input:hover::before {
    transform: translateX(-50%) scale(1);
    opacity: 1;
    animation: sparkle 0.6s var(--ease-bounce-out);
}

@keyframes sparkle {
    0% { transform: translateX(-50%) scale(0) rotate(0deg); }
    50% { transform: translateX(-50%) scale(1.2) rotate(180deg); }
    100% { transform: translateX(-50%) scale(1) rotate(360deg); }
}

/* Floating action hint */
.cast-member, .season-card, .video-item, .image-item {
    position: relative;
}

.cast-member::after, .season-card::after, .video-item::after, .image-item::after {
    content: 'Click to explore';
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.9);
    color: var(--text-perfect-white);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px) scale(0.8);
    transition: all 0.3s var(--ease-back-out);
    pointer-events: none;
    text-shadow: none;
    z-index: 10;
}

.cast-member:hover::after,
.season-card:hover::after,
.video-item:hover::after,
.image-item:hover::after {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: gentle-bounce 2s infinite;
}

@keyframes gentle-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-2px) scale(1.02); }
}

/* Delightful genre badge interactions */
.genre-badge {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.4s var(--ease-smooth);
}

.genre-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s var(--ease-smooth);
}

.genre-badge:hover::before {
    left: 100%;
}

.genre-badge:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(229, 9, 20, 0.3);
    text-shadow: var(--shadow-text-medium);
}

/* Magical loading states */
.loading-shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 25%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.05) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    border-radius: 8px;
    position: relative;
}

.loading-shimmer::after {
    content: '✨';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    opacity: 0.3;
    animation: sparkle-rotate 3s infinite;
}

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

@keyframes sparkle-rotate {
    0% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
    25% { transform: translate(-50%, -50%) scale(1.2) rotate(90deg); }
    50% { transform: translate(-50%, -50%) scale(1) rotate(180deg); }
    75% { transform: translate(-50%, -50%) scale(1.2) rotate(270deg); }
    100% { transform: translate(-50%, -50%) scale(1) rotate(360deg); }
}

/* ==========================================================================
   TOAST NOTIFICATIONS WITH PERSONALITY
   ========================================================================== */

.toast-notification {
    position: fixed;
    top: 24px;
    right: 24px;
    min-width: 300px;
    max-width: 400px;
    padding: 16px 20px;
    border-radius: 12px;
    color: var(--text-perfect-white);
    font-weight: 600;
    text-shadow: var(--shadow-text-light);
    z-index: 10000;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transform: translateX(120%) scale(0.9);
    transition: all 0.5s var(--ease-back-out);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
}

.toast-notification.show {
    transform: translateX(0) scale(1);
}

.toast-notification::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 12px;
    padding: 2px;
    background: linear-gradient(45deg, #e50914, #ffd700, #e50914);
    background-size: 400% 400%;
    animation: gradientShift 3s ease infinite;
    z-index: -1;
}

.toast-notification.toast-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.95), rgba(5, 150, 105, 0.95));
}

.toast-notification.toast-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95), rgba(220, 38, 38, 0.95));
}

.toast-notification.toast-info {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(37, 99, 235, 0.95));
}

.toast-icon {
    font-size: 1.2rem;
    animation: pulse 2s infinite;
}

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

/* ==========================================================================
   ENHANCED RATING CELEBRATION
   ========================================================================== */

.rating-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    z-index: 10001;
    pointer-events: none;
    animation: celebration-burst 1.5s var(--ease-back-out) forwards;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
}

@keyframes celebration-burst {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(0deg);
        opacity: 0;
    }
    20% {
        transform: translate(-50%, -50%) scale(1.3) rotate(180deg);
        opacity: 1;
    }
    40% {
        transform: translate(-50%, -50%) scale(1) rotate(360deg);
        opacity: 1;
    }
    60% {
        transform: translate(-50%, -50%) scale(1.1) rotate(450deg);
        opacity: 1;
    }
    80% {
        transform: translate(-50%, -50%) scale(1) rotate(540deg);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.7) rotate(720deg);
        opacity: 0;
    }
}

/* Confetti particles */
.confetti-particle {
    position: fixed;
    width: 8px;
    height: 8px;
    background: #ffd700;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    animation: confetti-fall 3s linear forwards;
}

.confetti-particle:nth-child(2n) { background: #e50914; }
.confetti-particle:nth-child(3n) { background: #00d4ff; }
.confetti-particle:nth-child(4n) { background: #10b981; }
.confetti-particle:nth-child(5n) { background: #f59e0b; }

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* ==========================================================================
   PERFECT READABILITY GUARANTEES
   ========================================================================== */

/* Override any potential low contrast */
.movie-card-title,
.season-name,
.cast-name,
.info-card-title,
.production-company *,
.network-item *,
.review-card *,
.alert-status * {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-medium) !important;
}

/* Ensure all meta information is readable */
.movie-card-meta,
.season-meta,
.cast-character,
.info-label {
    color: var(--text-perfect-medium) !important;
    text-shadow: var(--shadow-text-light) !important;
}

/* Button text clarity */
.btn-primary-enhanced,
.btn-secondary-enhanced,
.btn-outline-light,
.watchlist-toggle-btn {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-light) !important;
    font-weight: 600 !important;
}

/* Modal content readability */
.modal-content,
.modal-header,
.modal-body,
.modal-footer {
    color: var(--text-perfect-white) !important;
}

.modal-title {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-medium) !important;
}

/* Form elements with perfect contrast */
.form-control,
.review-textarea {
    color: var(--text-perfect-white) !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.form-control::placeholder,
.review-textarea::placeholder {
    color: var(--text-perfect-muted) !important;
}

.form-label {
    color: var(--text-perfect-white) !important;
    text-shadow: var(--shadow-text-light) !important;
    font-weight: 600 !important;
}

/* ==========================================================================
   SCROLL PROGRESS & VISUAL FEEDBACK
   ========================================================================== */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 4px;
    background: var(--gradient-primary-vibrant);
    z-index: 10000;
    transition: width 0.1s var(--ease-smooth);
    box-shadow: 0 0 15px rgba(229, 9, 20, 0.6);
}

/* Page load animations */
.page-enter {
    opacity: 0;
    transform: translateY(20px);
    animation: page-enter-animation 0.8s var(--ease-back-out) forwards;
}

.page-enter:nth-child(1) { animation-delay: 0.1s; }
.page-enter:nth-child(2) { animation-delay: 0.2s; }
.page-enter:nth-child(3) { animation-delay: 0.3s; }
.page-enter:nth-child(4) { animation-delay: 0.4s; }
.page-enter:nth-child(5) { animation-delay: 0.5s; }

@keyframes page-enter-animation {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   MOBILE RESPONSIVENESS WITH PERFECT CONTRAST
   ========================================================================== */

@media (max-width: 768px) {
    .text-ultra-contrast,
    .text-high-contrast {
        font-size: 0.95em;
        text-shadow: var(--shadow-text-strong);
    }
    
    .toast-notification {
        right: 12px;
        left: 12px;
        max-width: none;
        min-width: auto;
        transform: translateY(-120%) scale(0.9);
    }
    
    .toast-notification.show {
        transform: translateY(0) scale(1);
    }
    
    .rating-celebration {
        font-size: 3rem;
    }
    
    .confetti-particle {
        width: 6px;
        height: 6px;
    }
}

/* ==========================================================================
   ACCESSIBILITY & REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .info-card::before,
    .genre-badge::before,
    .loading-shimmer,
    .scroll-progress,
    .rating-celebration,
    .confetti-particle {
        animation: none !important;
    }
    
    .cast-member:hover,
    .season-card:hover,
    .video-item:hover,
    .image-item:hover {
        transform: none !important;
    }
    
    .btn-primary-enhanced:hover,
    .btn-secondary-enhanced:hover {
        transform: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --text-perfect-white: #ffffff;
        --text-perfect-light: #ffffff;
        --text-perfect-medium: #ffffff;
        --text-perfect-muted: #cccccc;
        --shadow-text-strong: 3px 3px 0 #000000, -1px -1px 0 #000000, 1px -1px 0 #000000, -1px 1px 0 #000000;
        --shadow-text-medium: 2px 2px 0 #000000, -1px -1px 0 #000000;
        --shadow-text-light: 1px 1px 0 #000000;
    }
    
    .info-card,
    .cast-member,
    .season-card,
    .video-item,
    .image-item {
        border: 2px solid #ffffff !important;
    }
}

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

@media print {
    .toast-notification,
    .rating-celebration,
    .confetti-particle,
    .scroll-progress {
        display: none !important;
    }
    
    * {
        color: #000000 !important;
        text-shadow: none !important;
        background: transparent !important;
    }
    
    .text-ultra-contrast,
    .text-high-contrast,
    .text-medium-contrast {
        color: #000000 !important;
        font-weight: 700 !important;
    }
}