/* LibStream Custom Styles */

/* ======================================
   CSS Custom Properties (Design Tokens)
   ====================================== */
:root {
    /* Blue color variants */
    --color-blue-500: #3b82f6;
    --color-blue-600: #2563eb;
    --color-blue-700: #1d4ed8;
    --color-blue-rgba-08: rgba(37, 99, 235, 0.08);
    --color-blue-rgba-10: rgba(37, 99, 235, 0.1);
    --color-blue-rgba-15: rgba(37, 99, 235, 0.15);
    --color-blue-rgba-20: rgba(37, 99, 235, 0.2);
    --color-blue-rgba-25: rgba(37, 99, 235, 0.25);
    --color-blue-rgba-30: rgba(37, 99, 235, 0.3);
    --color-blue-rgba-40: rgba(37, 99, 235, 0.4);

    /* Red color variants */
    --color-red-500: #ef4444;
    --color-red-600: #dc2626;
    --color-red-rgba-08: rgba(220, 38, 38, 0.08);
    --color-red-rgba-15: rgba(220, 38, 38, 0.15);
    --color-red-rgba-20: rgba(220, 38, 38, 0.2);
    --color-red-rgba-25: rgba(220, 38, 38, 0.25);
    --color-red-rgba-30: rgba(220, 38, 38, 0.3);

    /* Green color (for trends) */
    --color-green-500: #22c55e;
    --color-green-rgba-15: rgba(34, 197, 94, 0.15);

    /* Slate color variants */
    --color-slate-800: #1e293b;
    --color-slate-600: #475569;
    --color-slate-500: #64748b;

    /* Shadows */
    --shadow-hover: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
    --shadow-card-lg: 0 15px 30px -10px rgba(0, 0, 0, 0.4);
    --shadow-blue-hover: 0 25px 50px -12px var(--color-blue-rgba-25);
    --shadow-red-hover: 0 25px 50px -12px var(--color-red-rgba-25);

    /* Transitions */
    --transition-fast: all 0.2s ease;
    --transition-medium: all 0.25s ease;
    --transition-slow: all 0.3s ease;

    /* Animation stagger base delay */
    --stagger-delay: 0.03s;
}

/* Custom scrollbar for dark theme */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-slate-800);
}

::-webkit-scrollbar-thumb {
    background: var(--color-slate-600);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-slate-500);
}

/* ======================================
   Gradient Backgrounds
   ====================================== */

/* Subtle gradient overlays for cards */
.gradient-blue-subtle {
    background: linear-gradient(135deg, var(--color-blue-rgba-15) 0%, transparent 50%);
}

.gradient-red-subtle {
    background: linear-gradient(135deg, var(--color-red-rgba-15) 0%, transparent 50%);
}

/* Hero section gradient */
.hero-gradient {
    background: linear-gradient(180deg, var(--color-blue-rgba-10) 0%, transparent 100%);
}

/* Card inner glow effect */
.glow-blue {
    box-shadow: inset 0 1px 0 0 var(--color-blue-rgba-20),
                0 0 20px -5px var(--color-blue-rgba-30);
}

.glow-red {
    box-shadow: inset 0 1px 0 0 var(--color-red-rgba-20),
                0 0 20px -5px var(--color-red-rgba-30);
}

/* ======================================
   Card Styles
   ====================================== */

/* Card hover effects */
.creator-card {
    transition: var(--transition-medium), box-shadow 0.25s ease, border-color 0.25s ease;
    position: relative;
    overflow: hidden;
}

.creator-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(180deg, transparent 60%, rgba(0, 0, 0, 0.3) 100%);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.creator-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-hover);
}

.creator-card:hover::before {
    opacity: 1;
}

/* Liberal card accent */
.creator-card.liberal {
    border-left: 4px solid var(--color-blue-600);
    background: linear-gradient(135deg, var(--color-blue-rgba-08) 0%, var(--color-slate-800) 50%);
}

.creator-card.liberal:hover {
    border-color: var(--color-blue-500);
    box-shadow: var(--shadow-blue-hover);
}

/* Conservative card accent */
.creator-card.conservative {
    border-left: 4px solid var(--color-red-600);
    background: linear-gradient(135deg, var(--color-red-rgba-08) 0%, var(--color-slate-800) 50%);
}

.creator-card.conservative:hover {
    border-color: var(--color-red-500);
    box-shadow: var(--shadow-red-hover);
}

/* Stat card styling */
.stat-card {
    transition: var(--transition-fast), box-shadow 0.2s ease;
    position: relative;
}

.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

.stat-card:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-card);
}

/* Video card hover */
.video-card {
    transition: var(--transition-fast), box-shadow 0.2s ease;
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-card-lg);
}

/* ======================================
   Trend Indicators
   ====================================== */

.trend-up {
    color: var(--color-green-500);
}

.trend-down {
    color: var(--color-red-500);
}

.trend-up svg, .trend-down svg {
    filter: drop-shadow(0 0 3px currentColor);
}

/* ======================================
   Chart & Data Display
   ====================================== */

.sparkline-container {
    height: 40px;
    width: 100%;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Time range buttons */
.time-range-btn {
    transition: var(--transition-fast);
}

.time-range-btn:hover {
    background-color: var(--color-slate-600);
}

.time-range-btn.active {
    background: linear-gradient(135deg, var(--color-blue-600) 0%, var(--color-blue-700) 100%);
    color: white;
    box-shadow: 0 4px 12px -2px var(--color-blue-rgba-40);
}

/* ======================================
   Comparison Page
   ====================================== */

.comparison-liberal {
    border-color: var(--color-blue-600);
}

.comparison-conservative {
    border-color: var(--color-red-600);
}

/* Winner highlight in comparison table */
.winner-cell {
    background: linear-gradient(90deg, var(--color-green-rgba-15) 0%, transparent 100%);
    position: relative;
}

.winner-cell::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--color-green-500);
}

/* ======================================
   Animations
   ====================================== */

/* Smooth fade-in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Staggered animation for grid items */
.creator-card:nth-child(1) { animation-delay: 0.03s; }
.creator-card:nth-child(2) { animation-delay: 0.06s; }
.creator-card:nth-child(3) { animation-delay: 0.09s; }
.creator-card:nth-child(4) { animation-delay: 0.12s; }
.creator-card:nth-child(5) { animation-delay: 0.15s; }
.creator-card:nth-child(6) { animation-delay: 0.18s; }
.creator-card:nth-child(7) { animation-delay: 0.21s; }
.creator-card:nth-child(8) { animation-delay: 0.24s; }
.creator-card:nth-child(9) { animation-delay: 0.27s; }
.creator-card:nth-child(10) { animation-delay: 0.30s; }
.creator-card:nth-child(11) { animation-delay: 0.33s; }
.creator-card:nth-child(12) { animation-delay: 0.36s; }
.creator-card:nth-child(13) { animation-delay: 0.39s; }
.creator-card:nth-child(14) { animation-delay: 0.42s; }
.creator-card:nth-child(15) { animation-delay: 0.45s; }
.creator-card:nth-child(16) { animation-delay: 0.48s; }
.creator-card:nth-child(17) { animation-delay: 0.51s; }
.creator-card:nth-child(18) { animation-delay: 0.54s; }
.creator-card:nth-child(19) { animation-delay: 0.57s; }
.creator-card:nth-child(20) { animation-delay: 0.60s; }
.creator-card:nth-child(21) { animation-delay: 0.63s; }
.creator-card:nth-child(22) { animation-delay: 0.66s; }

/* Slide up animation for charts */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-up {
    animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Pulse animation for live indicator */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.95);
    }
}

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

/* Shimmer loading effect */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.shimmer {
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.05) 50%,
        transparent 100%);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* ======================================
   Form Elements
   ====================================== */

/* Dropdown styling for comparison page */
.creator-select {
    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='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.creator-select:hover {
    border-color: currentColor;
}

/* ======================================
   Utilities
   ====================================== */

/* Number formatting helper */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Line clamp for video titles */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Glass morphism effect */
.glass {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Gradient text */
.gradient-text-blue {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text-red {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Ring glow effects */
.ring-glow-blue {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.ring-glow-red {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3);
}

/* Button gradient hover effect */
.btn-gradient {
    background: linear-gradient(135deg, #2563eb 0%, #dc2626 100%);
    background-size: 200% 200%;
    transition: background-position 0.3s ease;
}

.btn-gradient:hover {
    background-position: 100% 100%;
}

/* ======================================
   Mobile Bottom Navigation
   ====================================== */

/* Use dynamic viewport height for proper mobile handling */
@supports (height: 100dvh) {
    .mobile-nav {
        /* Ensures nav stays visible even when browser chrome appears/disappears */
        position: fixed;
    }
}

/* Mobile nav styling */
.mobile-nav {
    /* Handle iOS Safari's rubber-banding */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Smooth scroll offset for anchor links to account for mobile nav */
@media (max-width: 639px) {
    html {
        scroll-padding-bottom: 80px;
    }

    /* Prevent content from being hidden behind nav */
    main {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* Mobile nav item touch states */
.mobile-nav-item {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mobile-nav-item:active {
    transform: scale(0.9);
    transition: transform 0.1s ease;
}

/* Compare button special styling */
.mobile-nav-compare {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mobile-nav-compare:active > div {
    transform: scale(0.92);
}

/* Split circle glow effect on compare button */
.mobile-nav-compare > div {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mobile-nav-compare:hover > div,
.mobile-nav-compare:focus > div {
    box-shadow:
        0 0 0 4px rgba(37, 99, 235, 0.2),
        0 0 0 4px rgba(220, 38, 38, 0.2),
        0 10px 25px -5px rgba(0, 0, 0, 0.4);
}

/* Animate the split colors on hover */
@keyframes splitPulse {
    0%, 100% {
        filter: brightness(1);
    }
    50% {
        filter: brightness(1.2);
    }
}

.mobile-nav-compare:hover > div > div:first-child,
.mobile-nav-compare:hover > div > div:nth-child(2) {
    animation: splitPulse 1.5s ease-in-out infinite;
}

/* Hide mobile nav when keyboard is open (rough detection) */
@media (max-height: 400px) and (max-width: 639px) {
    .mobile-nav {
        display: none;
    }
}

/* ======================================
   Heading Permalinks (Legal Pages)
   ====================================== */
.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    position: relative;
}

.prose .heading-permalink {
    position: absolute;
    right: 100%;
    padding-right: 0.5rem;
    opacity: 0;
    color: rgb(100 116 139); /* slate-500 */
    text-decoration: none;
    font-weight: normal;
    transition: opacity 0.2s ease;
}

.prose h1:hover .heading-permalink,
.prose h2:hover .heading-permalink,
.prose h3:hover .heading-permalink,
.prose h4:hover .heading-permalink,
.prose h5:hover .heading-permalink,
.prose h6:hover .heading-permalink,
.prose .heading-permalink:hover {
    opacity: 1;
    color: rgb(52 211 153); /* emerald-400 */
}

/* ======================================
   Mini Player
   ====================================== */

/* Slide in from bottom-right */
@keyframes miniPlayerSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

#mini-player.animate-slide-up {
    animation: miniPlayerSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Mobile positioning adjustment */
@media (max-width: 639px) {
    #mini-player {
        right: 0.5rem !important;
    }
}
