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

:root {
	--primary-color: #e50914;
	--primary-color-dark: #b8070f;
	--rating-dark: #990008;
	--dark-bg: #141414;
	--card-bg: #181818;
	--text-light: #ffffff;
	--text-med: #cccccc;
	--text-dark: #999999;
	--card-border: rgba(255, 255, 255, 0.1);
}

html {
	scrollbar-gutter: stable;
}

body {
	font-family: "Roboto", Arial, sans-serif;
	background-color: var(--dark-bg);
	color: var(--text-light);
	line-height: 1.6;
	min-height: 100dvh;
	overflow-x: hidden;
	position: relative;
}

body::before {
	content: "";
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
  background-color: #0a0a0a;
	background-image: url("../images/hero-mobile.webp");
	background-size: cover;
	background-position: center center;
	background-repeat: no-repeat;
  background-attachment: scroll;
	z-index: -1;
	transform: translateZ(0);
	will-change: opacity;
}

@media (min-width: 768px) {
    body::before {
        background-image: url("../images/large-hero1.webp");
        background-attachment: fixed;
    }
}

body.no-scroll {
    overflow: hidden;
}

.header {
	background: linear-gradient(
		90deg,
		rgba(0, 0, 0, 0.8) 0%,
		rgba(0, 0, 0, 0.4) 100%
	);
	padding: 20px;
	position: sticky;
	top: 0;
	z-index: 100;
	backdrop-filter: blur(10px);
}

.logo {
	font-size: 2.5em;
	font-weight: bold;
	color: var(--text-light);
	margin-bottom: 20px;
	text-align: center;
	cursor: pointer;
	display: flex;
	justify-content: center;
	align-items: center;
}

.logo img {
	width: 50px;
	height: auto;
}

.logo span {
	padding: 0 0.8rem;
}

.search-container {
	display: flex;
	gap: 15px;
	flex-wrap: wrap;
	justify-content: center;
	align-items: center;
    min-height: 44px;
}

.search-box {
	flex: 1;
	min-width: 300px;
	max-width: 500px;
	position: relative;
    height: 44px;
}

.search-input {
	width: 100%;
	padding: 12px 20px;
	border: 2px solid #333;
	border-radius: 25px;
	background: rgba(0, 0, 0, 0.8);
	color: white;
	font-size: 16px;
	outline: none;
	transition: all 0.3s ease;
    height: 44px;
}

.search-input:focus {
	transform: scale(1.02);
	border-color: var(--primary-color);
	box-shadow: 0 0 15px rgba(229, 9, 20, 0.5);
}

.filters {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

select {
	padding: 8px 15px;
	border: 1px solid #333;
	border-radius: 20px;
	background: rgba(0, 0, 0, 0.8);
	color: white;
	font-size: 14px;
	outline: none;
	cursor: pointer;
    height: 44px;
}

select:focus {
	border-color: var(--primary-color);
}

.btn-base {
	padding: 8px 20px;
	color: white;
	border: none;
	border-radius: 20px;
	cursor: pointer;
	font-size: 14px;
	transition: background 0.3s ease;
    height: 44px;
    white-space: nowrap;
}

.btn-primary {
	background: var(--rating-dark);
}
.btn-primary:hover {
	background: var(--primary-color-dark);
}

.btn-secondary {
	background: #444;
}
.btn-secondary:hover {
	background: #555;
}

.clear-btn {
	display: none;
}

.clear-btn.show {
	display: inline-block;
}

.main-content {
	padding: 20px;
	max-width: 1400px;
	margin: 0 auto;
}

.section-title {
	font-size: 1.8em;
	margin-bottom: 20px;
	color: var(--text-light);
	font-weight: 600;
    min-height: 40px;
}

.carousel-container {
	position: relative;
	margin-bottom: 50px;
	min-height: 450px;
    contain: layout;
}

.carousel {
	display: flex;
	overflow-x: auto;
	scroll-behavior: smooth;
	gap: 15px;
	padding: 20px 0;
	scrollbar-width: none;
	-ms-overflow-style: none;
    min-height: 370px;
}

.carousel::-webkit-scrollbar {
	display: none;
}

/* Base card styles */
.base-card {
	position: relative;
	border-radius: 15px;
	overflow: hidden;
	cursor: pointer;
	transition: all 0.3s ease;
	background: var(--card-bg);
    contain: layout;
}

.base-card .movie-poster {
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.base-card:hover {
	transform: scale(1.05);
	box-shadow: 0 20px 40px rgba(229, 9, 20, 0.3);
}

.base-card:hover .movie-poster {
	transform: scale(1.1);
}

/* Favorite Button */
.favorite-btn {
	position: absolute;
	top: 15px;
	right: 15px;
	background: rgba(0, 0, 0, 0.7);
	border: none;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	display: flex;
	justify-content: center;
	align-items: center;
	cursor: pointer;
	z-index: 10;
	transition: all 0.2s ease;
}

.favorite-btn:hover {
	background: var(--primary-color);
}

.favorite-btn svg {
	width: 20px;
	height: 20px;
	fill: white;
	transition: all 0.2s ease;
}

.favorite-btn.active svg {
	fill: var(--primary-color);
}
.favorite-btn.active:hover svg {
	fill: white;
}

.trending-card {
	min-width: 300px;
	height: 450px;
	background: linear-gradient(45deg, rgba(229, 9, 20, 0.1), rgba(0, 0, 0, 0.8));
}

.trending-rank {
	position: absolute;
	top: 15px;
	left: 15px;
	background: rgba(0, 0, 0, 0.8);
	color: var(--text-light);
	font-size: 2.5em;
	font-weight: bold;
	padding: 10px 15px;
	border-radius: 10px;
	z-index: 5;
	text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
	border: 2px solid var(--primary-color);
}

.trending-overlay {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
	padding: 40px 20px 20px;
	color: white;
}

.trending-title {
	font-size: 1.4em;
	font-weight: bold;
	margin-bottom: 8px;
	text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.trending-details {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 0.9em;
	opacity: 0.9;
}

.trending-genres {
	font-size: 0.98em;
	color: var(--text-med);
	margin-top: 5px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.trending-rating {
	background: var(--rating-dark);
	padding: 4px 8px;
	border-radius: 12px;
	font-weight: bold;
	font-size: 0.98em;
}

.carousel-btn {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background: rgba(0, 0, 0, 0.8);
	color: white;
	border: none;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	cursor: pointer;
	font-size: 24px;
	z-index: 10;
	transition: all 0.3s ease;
	backdrop-filter: blur(10px);
}

.carousel-btn:hover {
	background: rgba(229, 9, 20, 0.8);
	transform: translateY(-50%) scale(1.1);
}

.carousel-btn.prev {
	left: -30px;
}

.carousel-btn.next {
	right: -30px;
}

.movies-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
	gap: 20px;
	margin-bottom: 40px;
	min-height: 500px;
    contain: layout;
}

.movie-card {
	background: var(--card-bg);
	border-radius: 10px;
	overflow: hidden;
	transition: all 0.3s ease;
	cursor: pointer;
	/* min-height: 450px; */
	backdrop-filter: blur(10px);
	border: 1px solid var(--card-border);
    content-visibility: auto;
}

.movie-card:hover {
	transform: translateY(-10px);
	box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
	border-color: var(--primary-color);
}

.movie-poster {
	width: 100%;
	height: 300px;
	object-fit: cover;
	transition: transform 0.3s ease;
    aspect-ratio: 2/3;
    background-color: #222;
}

.movie-card .movie-poster {
	height: 100%;
}

.movie-card:hover .movie-poster {
	transform: scale(1.05);
}

.movie-info {
	/* padding: 15px; */
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
	padding: 40px 20px 20px;
}

.movie-title {
	font-size: 1.2em;
	font-weight: bold;
	margin-bottom: 8px;
	color: var(--text-light);
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.movie-details {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 10px;
	font-size: 0.9em;
	color: var(--text-med);
}

.movie-genres {
	font-size: 0.98em;
	color: var(--text-med);
	margin-bottom: 8px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.movie-rating {
	background: var(--rating-dark);
	padding: 2px 8px;
	border-radius: 12px;
	font-weight: bold;
	font-size: 0.98em;
}

.movie-rating,
.trending-rating {
	color: var(--text-light);
}

.movie-year,
.trending-year {
	font-size: 0.98em;
}

.movie-description {
	display: none;
	color: var(--text-dark);
	font-size: 0.85em;
	line-height: 1.4;
	/* display: -webkit-box; */
	line-clamp: 3;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-bottom: 8px;
}

.loading,
.error,
.no-results {
	grid-column: 1 / -1; /* Span all columns */
	text-align: center;
	padding: 60px 20px;
	color: var(--text-med);
}

.error {
	color: var(--primary-color);
	font-size: 1.1em;
}

.no-results h2 {
	font-size: 2em;
	margin-bottom: 15px;
}

/* --- title icon --- */
#randomSectionTitle {
	display: flex;
	align-items: center;
	gap: 10px;
}

#randomSectionTitle svg {
	height: 1em;
	width: 1em;
}

/* Movie Details Modal */
.modal-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.9);
	z-index: 1000;
	display: none; /* Hidden by default */
	justify-content: center;
	align-items: center;
	overflow-y: auto;
	padding: 20px;
}

.modal-content {
	background: var(--card-bg);
	border-radius: 15px;
	width: 100%;
	max-width: 900px;
	max-height: 90vh;
	overflow-y: auto;
	position: relative;
	animation: fadeIn 0.3s ease;
}

.modal-close-btn {
	position: absolute;
	top: 15px;
	right: 15px;
	background: rgba(0, 0, 0, 0.7);
	border: none;
	border-radius: 50%;
	width: 40px;
	height: 40px;
	color: white;
	font-size: 20px;
	font-weight: bold;
	cursor: pointer;
	z-index: 10;
	transition: all 0.2s ease;
}
.modal-close-btn:hover {
	background: var(--primary-color);
}

.modal-header {
	position: relative;
	height: 400px;
}

.modal-poster {
	width: 100%;
	height: 100%;
	object-fit: cover;
	border-radius: 15px 15px 0 0;
}

.modal-poster-overlay {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	height: 50%;
	background: linear-gradient(transparent, var(--card-bg));
}

.modal-title {
	position: absolute;
	bottom: 20px;
	left: 20px;
	font-size: 2.5em;
	font-weight: bold;
	color: var(--text-light);
	text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.modal-body {
	padding: 20px;
}

.modal-details {
	display: flex;
	gap: 20px;
	margin-bottom: 20px;
	font-size: 1em;
	color: var(--text-med);
}

.modal-rating {
	color: var(--primary-color);
	font-weight: bold;
}

.modal-genres {
	font-style: italic;
}

.modal-overview {
	font-size: 1.1em;
	line-height: 1.7;
	margin-bottom: 30px;
}

.modal-trailer-container {
	position: relative;
	padding-bottom: 56.25%; /* 16:9 aspect ratio */
	height: 0;
	overflow: hidden;
	border-radius: 10px;
}

.modal-trailer-container iframe {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

.modal-no-trailer {
	text-align: center;
	padding: 40px;
	color: var(--text-dark);
	font-size: 1.1em;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: scale(0.95);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

footer {
	background: linear-gradient(
		90deg,
		rgba(0, 0, 0, 0.8) 0%,
		rgba(0, 0, 0, 0.4) 100%
	);
	display: flex;
	justify-content: center;
	flex-direction: column;
	align-items: center;
	width: 100%;
	padding: 20px 0;
	margin-top: auto;
}

.social-icons {
	display: flex;
	justify-content: space-evenly;
	gap: 1rem;
	padding: 16px;
	align-items: center;
}

.social-icon {
	text-decoration: none;
	cursor: pointer;
	svg {
		height: 40px;
		width: 40px;
		fill: var(--rating-dark);
	}
}
.social-icon:hover {
	svg {
		opacity: 0.5;
	}
}

.skeleton {
    background: #222; 
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; } 
    50% { opacity: 0.8; } 
    100% { opacity: 0.6; }
}

@media (max-width: 768px) {
	.search-container {
		flex-direction: column;
	}

	.search-box {
		min-width: 100%;
	}

	.filters {
		justify-content: center;
		width: 100%;
	}

	.movies-grid {
		grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
		gap: 15px;
	}

	.carousel-btn {
		display: none;
	}

	.section-title {
		font-size: 1.5em;
	}

	.modal-title {
		font-size: 1.8em;
	}
}

/* --- Hamburger Menu Styles --- */

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 101;
}

.icon-close {
    display: none;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}


@media (max-width: 768px) {
    .header-top {
        justify-content: space-between;
        padding-bottom: 5px;
    }

    .menu-toggle {
        display: block;
    }

    .search-container {
        display: none;
        flex-direction: column;
        width: 100%;
        padding-top: 15px;
        gap: 15px;
        border-top: 1px solid rgba(255,255,255,0.1);
        animation: slideDown 0.3s ease forwards;
    }

    .search-container.active {
        display: flex;
    }

    .menu-toggle.active .icon-menu {
        display: none;
    }
    .menu-toggle.active .icon-close {
        display: block;
    }

	.search-box, .filters, .filters select, .btn-base {
        width: 100%;
        max-width: 100%;
    }

    .filters {
        flex-direction: column;
    }

    .logo {
        margin-bottom: 0;
        font-size: 1.8em;
    }
}

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