/* General Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #141414; /* Deep dark background */
    color: #EAEAEA; /* Light text color */
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- Header Styling --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5%;
    background-color: #1F1F1F;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.8em;
    font-weight: bold;
    color: #E50914; /* Netflix Red accent */
}

/* Desktop Navigation */
.nav-links {
    display: flex; /* Ensure horizontal layout on desktop */
    align-items: center;
}

.nav-links a {
    margin-left: 25px;
    font-size: 1.1em;
    transition: color 0.3s;
}

.nav-links a:hover {
    color: #E50914;
}

.menu-toggle {
    display: none; /* Hide on desktop, shown in mobile media query */
    background: none;
    border: none;
    color: #EAEAEA;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0; /* Clean up padding */
}

/* --- Hero Section Styling --- */
.hero-section {
    /* Always ensure a fallback color for the background */
    background: #000 url('hero-bg.jpg') center/cover no-repeat; 
    background-blend-mode: multiply; /* Helps darkening the image */
    background-color: rgba(0, 0, 0, 0.7); /* Darkening layer */
    height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0 20px;
}

.hero-title {
    font-size: 2.5em;
    margin-bottom: 25px;
}

/* Search Box Styling */
.search-box {
    display: flex;
    width: 100%;
    max-width: 500px;
    border-radius: 50px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.search-input {
    flex-grow: 1;
    padding: 15px 20px;
    border: none;
    font-size: 1em;
    outline: none;
    background-color: #2D2D2D;
    color: #EAEAEA;
}

.search-button {
    padding: 15px 20px;
    background-color: #E50914;
    color: white;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s;
}

.search-button:hover {
    background-color: #F40F1F;
}

/* --- Movie Grid and Cards --- */
.movie-section {
    padding: 40px 5%;
}

.section-title {
    font-size: 2em;
    margin-bottom: 30px;
    border-left: 5px solid #E50914;
    padding-left: 15px;
}

.movie-grid {
    display: grid;
    /* Default: 2 columns for smaller screens */
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); 
    gap: 20px;
    /* Forces cards to fill the available height in their grid cell */
    grid-auto-rows: 1fr; 
}

.movie-card {
    background-color: #1F1F1F;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    /* Display flex column to push the movie-info to the bottom of the card */
    display: flex;
    flex-direction: column;
    height: 100%; /* Important for grid-auto-rows: 1fr to work */
}

.movie-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(229, 9, 20, 0.4);
}

/* Aspect Ratio Container for Poster */
.movie-poster-container {
    position: relative;
    width: 100%;
    /* 150% padding-top creates a 2:3 poster aspect ratio (standard movie poster) */
    padding-top: 150%; 
    overflow: hidden;
}

/* The image fills the container */
.movie-poster {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%; 
    display: block;
    object-fit: cover; /* Ensures image covers the area without distorting */
}

.movie-info {
    padding: 15px;
    /* Pushes the info block to the bottom of the card, accommodating variable image heights */
    margin-top: auto; 
}

.movie-info h3 {
    font-size: 1.1em;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.movie-info p {
    font-size: 0.9em;
    color: #A0A0A0;
}

/* --- Footer Styling --- */
footer {
    text-align: center;
    padding: 20px;
    background-color: #1F1F1F;
    color: #A0A0A0;
    margin-top: 30px;
}

/*
============================================================
           Responsive Adjustments
============================================================
*/

/* Desktop and Larger Tablets */
@media (min-width: 768px) {
    .movie-grid {
        /* Larger screens: 4 columns */
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    }
    
    .hero-title {
        font-size: 3.5em;
    }
}

/* Mobile and Smaller Tablets */
@media (max-width: 767px) {
    /* --- Header & Navigation for Mobile --- */
    .main-header {
        /* Allow logo and toggle button to sit on the first line, menu below */
        flex-wrap: wrap; 
        padding: 15px 5%;
    }

    .nav-links {
        /* Overriding desktop display:flex */
        display: none; 
        width: 100%; 
        flex-direction: column;
        text-align: center;
        padding-top: 10px;
        background-color: #1F1F1F;
    }
    
    .nav-links a {
        margin: 10px 0;
        padding: 10px;
        margin-left: 0; /* Remove left margin for block display */
        border-bottom: 1px solid #2d2d2d;
    }

    .nav-links a:last-child {
        border-bottom: none;
    }

    .menu-toggle {
        display: block; /* Show the hamburger icon */
    }
    
    /* JavaScript will add the 'active' class to show the menu */
    .nav-links.active {
        display: flex; /* Show the navigation links stacked vertically */
    }

    /* --- Other Mobile Adjustments --- */
    .hero-section {
        height: 50vh;
    }

    .hero-title {
        font-size: 2em;
    }

    .search-box {
        max-width: 90%;
    }

    .section-title {
        font-size: 1.5em;
    }

    .movie-grid {
        /* Make columns slightly smaller on very small screens */
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); 
    }
}
