/* CSS Custom Properties for a Modern Dark Theme */
:root {
    /* Color Palette */
    --bg-base: #0a0a0c;
    /* Very dark background */
    --bg-surface: #141417;
    /* Slightly lighter surface */
    --bg-surface-hover: #1e1e24;
    /* Hover state for surfaces */

    /* Text Colors */
    --text-primary: #f1f1f2;
    /* High contrast text */
    --text-secondary: #a1a1aa;
    /* Medium contrast text */
    --text-tertiary: #71717a;
    /* Low contrast text */

    /* Accent Colors (YouTube inspired but modernized) */
    --accent-primary: #ff2a2a;
    /* Vibrant YouTube-like red */
    --accent-hover: #ff4d4d;
    /* Lighter red for hover states */
    --accent-glow: rgba(255, 42, 42, 0.4);

    /* Structural Elements */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(255, 42, 42, 0.5);

    /* Transitions */
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* Sizing */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
    --border-radius-pill: 9999px;

    /* Shadows */
    --shadow-glow: 0 0 20px var(--accent-glow);
    --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.5);
}

/* Global Reset and Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    /* subtle background noise/gradient could go here, but keeping it clean */
    background-image: radial-gradient(circle at 50% 0%, rgba(30, 30, 35, 1) 0%, var(--bg-base) 60%);
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Utilities */
.hidden {
    display: none !important;
}

.text-accent {
    color: var(--accent-primary);
}

.text-5xl {
    font-size: 3rem;
}

/* Layout */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Hero Section */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 60vh;
    transition: var(--transition-slow);
}

.hero-compact {
    min-height: 30vh;
    margin-bottom: 2rem;
}

.logo-container {
    margin-bottom: 1.5rem;
    animation: float 6s ease-in-out infinite;
}

.hero h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #ffffff 0%, #a1a1aa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero .subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin-bottom: 3rem;
}

/* Search Bar Component */
.search-bar-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 680px;
    position: relative;
    z-index: 10;
}

@media (min-width: 640px) {
    .search-bar-container {
        flex-direction: row;
        background: rgba(20, 20, 23, 0.6);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid var(--border-subtle);
        border-radius: var(--border-radius-pill);
        padding: 0.5rem;
        box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
        transition: var(--transition-normal);
    }

    .search-bar-container:focus-within {
        border-color: var(--border-focus);
        box-shadow: var(--shadow-glow), 0 4px 30px rgba(0, 0, 0, 0.5);
    }
}

.input-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 1.25rem;
    font-size: 1.25rem;
    color: var(--text-tertiary);
    pointer-events: none;
}

#search-input {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-pill);
    padding: 1rem 1rem 1rem 3rem;
    font-size: 1.05rem;
    color: var(--text-primary);
    font-family: inherit;
    outline: none;
    transition: var(--transition-fast);
}

@media (min-width: 640px) {
    #search-input {
        background: transparent;
        border: none;
        border-radius: 0;
        padding-left: 3.5rem;
    }
}

#search-input::placeholder {
    color: var(--text-tertiary);
}

#search-button {
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius-pill);
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition-normal);
    white-space: nowrap;
}

#search-button i {
    font-size: 1.25rem;
    transition: transform 0.2s ease;
}

#search-button:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 15px rgba(255, 42, 42, 0.4);
    transform: translateY(-1px);
}

#search-button:hover i {
    transform: translateX(4px);
}

#search-button:active {
    transform: translateY(1px);
}

/* Results Area */
.results-container {
    width: 100%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    animation: fade-in 0.5s ease-out forwards;
}

.section-header {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

#query-display {
    color: var(--accent-primary);
}

/* Videos Grid */
.videos-grid {
    display: grid;
    /* Make columns much larger to emphasize video frames/stills */
    grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
    gap: 3rem;
    width: 100%;
}

/* Video Card styling */
.video-card {
    position: relative;
    text-decoration: none;
    color: inherit;
    background: var(--bg-surface);
    border-radius: var(--border-radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    transition: var(--transition-normal);
    display: flex;
    opacity: 0;
    transform: translateY(20px);
    animation: slide-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    aspect-ratio: 16 / 9;
}

.video-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-card);
    border-color: rgba(255, 255, 255, 0.15);
}

.thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.video-card:hover .thumbnail {
    transform: scale(1.05);
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 3rem 1.5rem 1.5rem 1.5rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-normal);
}

.video-card:hover .card-overlay {
    opacity: 1;
    transform: translateY(0);
}

.video-title {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--text-primary);
    /* Multi-line truncation */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.video-card:hover .video-title {
    color: var(--accent-hover);
}

.channel-name {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: auto;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 0;
    gap: 1.5rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 42, 42, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Error Message */
.error-message {
    background: rgba(255, 42, 42, 0.1);
    border: 1px solid rgba(255, 42, 42, 0.2);
    color: #ff8a8a;
    padding: 1.5rem;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0;
}

.error-message i {
    font-size: 1.5rem;
}

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

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .app-container {
        padding: 1.5rem 1rem;
    }

    .hero h1 {
        font-size: 2rem;
    }
}