:root {
    --primary-red: #e50914;
    --dark-bg: #141414;
    --dark-search: #1c1c1c;
    --text-light: #ffffff;
    --text-muted: #e5e5e5;
    --navbar-bg: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0));
    --navbar-scrolled: #141414;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--dark-bg);
    color: var(--text-light);
    font-family: 'Outfit', sans-serif;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* Navbar - Ultra Premium Cinematic */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 35px 4%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(0,0,0,0.85) 0%, transparent 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 2000;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05); /* Inner light reflection */
}

.navbar.scrolled {
    padding: 18px 4%;
    background: rgba(8, 8, 8, 0.92);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 70px;
}

.logo {
    font-family: 'Playfair Display', serif;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 5px;
    color: #fff;
    text-transform: uppercase;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-shadow: 0 0 15px rgba(255,255,255,0.1);
    transition: transform 0.3s ease;
}

/* Subtle Shimmer Effect */
.logo::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.logo:hover {
    transform: translateY(-1px);
}

.logo:hover::before {
    left: 100%;
    transition: left 0.7s ease-in-out;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 40px;
}

.nav-links li {
    position: relative;
}

.nav-links a {
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 2px;
    transition: all 0.4s ease;
    display: inline-block;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100%;
    height: 1.5px;
    background: #fff;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    box-shadow: 0 0 8px rgba(255,255,255,0.3);
}

.nav-links a:hover {
    color: #fff;
    transform: translateY(-1px);
}

.nav-links a:active {
    transform: scale(0.95);
}

.nav-links a.active {
    color: #fff;
}

.nav-links a.active::after, .nav-links a:hover::after {
    transform: scaleX(1);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 40px;
}

/* Search Bar Minimal Premium */
.search-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-icon {
    cursor: pointer;
    color: rgba(255, 255, 255, 0.65);
    transition: all 0.3s ease;
}

.search-icon:hover {
    color: #fff;
    filter: drop-shadow(0 0 5px rgba(255,255,255,0.4));
}

#search-input {
    width: 0;
    border: none;
    background: none;
    color: #fff;
    font-size: 14px;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    border-bottom: 1px solid rgba(255,255,255,0.15);
    outline: none;
    font-family: 'Outfit', sans-serif;
}

.search-container.active #search-input {
    width: 280px;
    opacity: 1;
    padding: 8px 0;
}

/* Search Results Grid Elevation */
.search-view {
    padding: 130px 4% 50px;
    min-height: 100vh;
    animation: fadeIn 0.5s ease forwards;
    background: radial-gradient(circle at top, rgba(255,255,255,0.03) 0%, transparent 70%);
}

.search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Hero Section - Immersive Cinematic */
.hero {
    position: relative;
    height: 95vh;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    display: flex;
    align-items: center;
    padding: 0 8%;
    animation: fadeIn 1.2s cubic-bezier(0.2, 1, 0.3, 1), kenBurns 40s linear infinite alternate;
}

@keyframes kenBurns {
    from { background-size: 105%; }
    to { background-size: 115%; }
}

.hero-vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 50%, transparent 0%, rgba(10,10,10,0.4) 40%, rgba(10,10,10,0.95) 100%),
                linear-gradient(to right, rgba(10,10,10,1) 0%, rgba(10,10,10,0.8) 20%, transparent 60%),
                linear-gradient(to top, rgba(10,10,10,1) 0%, transparent 30%);
    z-index: 1;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    opacity: 0;
    transform: translateY(20px);
    animation: suiteFadeIn 1s cubic-bezier(0.2, 1, 0.3, 1) 0.5s forwards;
}

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

/* Hero UI Hierarchy */
.hero-meta {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-size: 5rem;
    font-weight: 700;
    margin-bottom: 25px;
    line-height: 1.1;
    text-shadow: 0 10px 30px rgba(0,0,0,0.5);
    background: linear-gradient(to bottom, #fff, #ccc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-description {
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.6;
    margin-bottom: 40px;
    max-width: 600px;
    font-weight: 400;
}

.hero-buttons {
    display: flex;
    gap: 20px;
}

.btn {
    padding: 14px 40px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 50px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    letter-spacing: 1px;
}

.btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
}

.btn-play {
    background-color: #fff;
    color: #000;
}

.btn-play:hover {
    background-color: #e0e0e0;
    box-shadow: 0 0 20px rgba(255,255,255,0.4);
}

.btn-info {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-info:hover {
    background-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(255,255,255,0.1);
}

/* Rows & Movie Cards */
.main-content {
    padding: 0 4%;
    position: relative;
    z-index: 2;
    margin-top: -120px; /* Overlap hero */
}

.row {
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 10;
}

.row-header {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 15px;
    padding-left: 5px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.row-posters {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: visible; /* CRITICAL FIX: allow cards to scale outside row container */
    padding: 30px 20px;
    margin: 0 -20px;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    min-height: 250px; /* CRITICAL FIX: prevents flex-collapse when images load late */
    scroll-snap-type: x mandatory;
}

.row-posters::-webkit-scrollbar {
    height: 0px; 
}

.row-posters:hover::-webkit-scrollbar {
    height: 8px;
}

.row-posters::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
}

.card {
    position: relative;
    flex: 0 0 calc(100% / 6 - 8px);
    width: calc(100% / 6 - 8px);
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.4s cubic-bezier(0.2, 1, 0.3, 1), box-shadow 0.4s ease, filter 0.3s ease;
    transform-origin: center center;
    aspect-ratio: 2/3;
    background-color: var(--dark-search);
    flex-shrink: 0; /* CRITICAL FIX: absolutely guarantees card dimensions */
    scroll-snap-align: start;
    z-index: 5;
    pointer-events: auto;
}

.search-grid .card {
    width: 100%;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    transition: opacity 0.5s ease;
    border-radius: 4px;
}

.card:hover {
    transform: scale(1.08) translateY(-10px);
    filter: brightness(1.15);
    z-index: 20;
    box-shadow: 0 15px 35px rgba(0,0,0,1);
}

/* Netflix style row expansion logic for extreme left/right edges */
.row-posters .card:first-child:hover { transform-origin: left center; }
.row-posters .card:last-child:hover { transform-origin: right center; }

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px 10px 10px;
    background: linear-gradient(to top, rgba(0,0,0,1), transparent);
    opacity: 0;
    transition: opacity 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none; /* Let clicks pass through to the card */
}

.card-overlay * {
    pointer-events: auto; /* Re-enable for buttons inside */
}

.card:hover .card-overlay {
    opacity: 1;
}

.card-overlay .play-icon {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 35px;
    height: 35px;
    background: var(--primary-red);
    border-radius: 50%;
    color: white;
    box-shadow: 0 0 10px rgba(229, 9, 20, 0.4);
    transition: transform 0.2s;
}

.card:hover .play-icon {
    transform: scale(1.1);
}

.play-icon i {
    margin-left: 2px;
}

/* Lucide adjustments */
.lucide {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

.search-icon .lucide {
    color: white;
    transition: transform 0.2s;
}

.search-icon:hover .lucide {
    transform: scale(1.1);
}


/* Animations & Skeletons */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.skeleton-text {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    color: transparent !important;
    text-shadow: none !important;
    border-radius: 4px;
}

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

/* Responsive */
@media (max-width: 1024px) {
    .card { flex: 0 0 calc(100% / 4 - 8px); }
}

@media (max-width: 768px) {
    .nav-links { display: none; }
    .hero-title { font-size: 2.5rem; }
    .card { flex: 0 0 calc(100% / 3 - 8px); }
}

/* Details Page UI Enhancements */
.fade-in {
    animation: fadeIn 0.4s ease forwards;
}
.details-hero {
    height: 70vh;
    animation: fadeIn 0.8s ease; /* No panning, maintain center */
    background-size: cover;
    background-position: center 20%;
}
.details-main {
    margin-top: -60px; /* Overlap gradient comfortably */
}
.details-meta {
    font-size: 1rem;
    color: var(--text-muted);
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 8px;
    transition: opacity 0.3s;
}
.meta-rating { color: #46d369; font-weight: 600; }
.meta-year, .meta-runtime { font-weight: 500; }

.details-genres {
    display: flex;
    gap: 10px;
    font-size: 0.9rem;
    color: #a3a3a3;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.dot { color: #555; }

/* Episodes UI */
.season-select {
    padding: 8px 16px;
    background: #242424;
    color: white;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.episodes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
    padding-bottom: 40px;
}

.episode-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 15px;
    border-radius: 4px;
    background: rgba(255,255,255,0.05);
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #333;
}
.episode-card:hover {
    background: rgba(255,255,255,0.1);
}

.ep-img {
    position: relative;
    width: 150px;
    flex-shrink: 0;
    aspect-ratio: 16/9;
}
.ep-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
}
.episode-card .play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.5);
    border: 2px solid white;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
}
.episode-card:hover .play-icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.ep-info {
    flex-grow: 1;
}
.ep-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
}
.ep-runtime {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.ep-desc {
    font-size: 0.95rem;
    color: #999;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 768px) {
    .episode-card { flex-direction: column; align-items: flex-start; gap: 10px; }
    .ep-img { width: 100%; max-width: 300px; }
}

/* --- INTERACTIVE POLISH (Card info & Buttons) --- */
.card-info-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s;
    border: 1px solid rgba(255,255,255,0.2);
}

.card:hover .card-info-btn {
    opacity: 1;
}

.card-info-btn:hover {
    background: white;
    color: black;
    transform: scale(1.1);
}

.btn-list {
    background-color: rgba(109, 109, 110, 0.7);
    color: white;
}

.btn-list:hover {
    background-color: rgba(109, 109, 110, 0.4);
}

.btn-list.added {
    background-color: white;
    color: black;
}

/* --- MINIMALIST UI CLEANUP --- */
.nav-links, .btn-list, .plus-icon {
    display: none !important;
}

.navbar {
    justify-content: space-between;
    padding-left: 5%;
    padding-right: 5%;
}

@media (min-width: 1200px) {
    .navbar {
        padding-left: 6%;
        padding-right: 6%;
    }
}
