/*Base*/

body {
    font-family: Arial, sans-serif;
    background-color: black;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('https://davidignatiev.github.io/movie-searcher/images/jozefm84-camera-4091991_1920.png');
    background-attachment: fixed;
    background-size: 300px auto;
    background-repeat: round;
    opacity: 0.2;
    z-index: -1;
}

/*Header*/

header {
    display: flex;
    align-items: center;
    padding: 30px 50px;
    background-color: black;
    box-shadow: 0px 70px 50px black;
}

.logoBlock {
    display: flex;
    align-items: center;
    gap: 20px;
    cursor: pointer;
}

.logoBlock h1 {
    color: white;
    font-size: 2em;
    font-weight: bold;
    cursor: pointer;
}

#logo {
    width: clamp(40px, 4vw, 70px);
    height: clamp(40px, 4vw, 70px);
}

/*Search*/

.searchBlock {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

#search {
    width: 250px;
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    background-color: white;
    color: black;
    font-size: 15px;
    font-weight: bold;
    outline: none;
}

#search:focus {
    opacity: 0.9;
}

#searchBtn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    background-color: white;
    color: black;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

#searchBtn:hover {
    background-color: #4a42c5;
}

#saved {
    padding: 5px 15px;
    border: none;
    border-radius: 25px;
    background-color: #ffd700;
    color: black;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

#saved:hover {
    background-color: #e6c200;
}

/*Main*/

main {
    margin-top: 100px;
}

.moviesContainer {
    max-width: 2000px;
    width: 100%;
    margin: 0 auto;
    padding: 0 50px;
    box-sizing: border-box;
}

/*Loader */

#loader {
    display: none;
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top: 4px solid #4a42c5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

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

/*Error */

#errorMsg {
    color: red;
    font-size: 2em;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
}

/*Movies Grid */

#popularMovies {
    display: grid;
    gap: 50px;
    grid-template-columns: repeat(auto-fill, 200px);
    justify-content: center;
}

.popularMovie {
    width: 200px;
    position: relative;
    cursor: pointer;
}

.popularMovie img {
    width: 200px;
    height: 300px;
    object-fit: cover;
    border-radius: 10px;
}

.popularDescription {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
    color: white;
    font-weight: bold;
}

.popularDescription h1 {
    font-size: 1.2em;
}

.popularDescription p {
    font-size: 0.8em;
    font-weight: normal;
    color: #aaa;
}

/*Overlay*/

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s;
}

.popularMovie:hover .overlay {
    opacity: 1;
}

/*Favorites button */

.saveToFavorites {
    background: none;
    border: none;
    font-size: 1.5em;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s;
}

.saveToFavorites.active {
    color: #ffd700;
}

.popularMovie .saveToFavorites {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 1.8em;
    z-index: 10;
}

#modal .saveToFavorites {
    display: block;
    font-size: 3em;
    text-align: center;
    margin-top: 10px;
}

/*modal*/

#overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    z-index: 99;
}

#modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: row;
    gap: 20px;
    padding: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    min-height: 200px;
    background-color: #1a1a1a;
    border-radius: 10px;
    overflow-y: auto;
    color: white;
    z-index: 100;
    opacity: 0.99;
}

#modal h1 {
    font-size: 1.5em;
    font-weight: bold;
    color: rgb(218, 224, 93);
}

#modal p {
    font-weight: bold;
}

#modal img {
    width: 150px;
    height: 220px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
}

.modalPoster {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.modalInfo {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.ratings {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rating {
    font-size: 0.85em;
    color: #ffd700;
}

/*Back Button*/

#backBtnBlock {
    padding: 0 0 20px 0;
}

#backBtn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    background-color: white;
    color: black;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

#backBtn:hover {
    background-color: #4a42c5;
}



/*Responsive*/

@media (max-width: 600px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px 20px;
        gap: 15px;
    }

    .searchBlock {
        margin-left: 0;
        width: 100%;
    }

    #search {
        width: 100%;
        flex: 1;
    }
}