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

body {
    font-family:'Inter', 'Courier New', Courier, monospace;
    width: 100%;
    min-height: 100vh;
    background-color: #fff;
    transition: background-color 0.2s ease;
}

/* dark mode background */
body.dark {
    background-color: #121212;
}

/* Header styles */

header {
    background-image: url('images/header.png');
    background-size: cover;
    background-position: center;
    width: 100%;
    max-width: 550px;
    height: 208px;
    background-color: #0E0E0E;
    background-blend-mode: normal;
    color: #fff;
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: 16px;
    margin: auto;
    padding: 0 16px;
}

.title {
    font-size: 2.625rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-link {
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}

.header-link:hover {
    text-decoration: underline;
    cursor: pointer;
}

/* Dark mode toggle switch */

.theme-toggle {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    transition: background-color 0.2s ease;
}

.theme-toggle .slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.theme-toggle input:checked + .slider {
    background-color: #6C63FF;
}

.theme-toggle input:checked + .slider::before {
    transform: translateX(18px);
}

/* Container styles --- Starting page */

.container {
    width: 100%;
    max-width: 550px;
    margin: auto;
    padding: 0 16px;
}

/* Search bar styles */

.search-container {
    width: 100%;
    max-width: 462px;
    height: 38px;
    margin: auto;
    display: flex;
    border: 1px solid #D1D5DB;
    border-radius: 5px;
    position: relative;
    top: -20px;
}

body.dark .search-container {
    border: none;
}

.search-bar,
#search-btn {
    height: 100%;
    border: none;
}

.search-bar {
    width: 70%;
    padding-left: 40px;
    background-image: url('images/search.png');
    background-repeat: no-repeat;
    background-position: 10px;
    background-color: #fff;
    font-size: 14px;
    border-radius: 5px 0 0 5px;
}

body.dark .search-bar {
    color: #A5A5A5;
    background-color: #2e2e2e;
}

#search-btn {
    width: 30%;
    border-left: 1px solid #D1D5DB;
    border-radius: 0 5px 5px 0;
    background-color: #fff;
}

#search-btn:hover {
    cursor: pointer;
}

body.dark #search-btn {
    background-color: #4B4B4B;
    color: #fff;
    border: none;
}

/* results styles --- starting page */

.results {
    width: 100%;
}

.empty-state {
    width: 100%;
    min-height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    position: relative;
    top: -38px;
}

.start-exploring {
    font-size: 1.125rem;
    font-weight: bold;
    color: #DFDDDD;
    margin-top: 10px;
}

body.dark .start-exploring {
    color: #4B4B4B;
}

.status-msg {
    text-align: center;
    padding: 60px 16px;
    color: #7A7A7A;
    font-size: 1rem;
}

body.dark .status-msg {
    color: #A5A5A5;
}

/* Movie grid + cards */

.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 20px;
    padding: 16px 0 32px;
    position: relative;
    top: -20px;
}

.movie-card {
    cursor: pointer;
}

.poster-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 6px;
    overflow: hidden;
    background-color: #EDEDED;
}

body.dark .poster-wrap {
    background-color: #1E1E1E;
}

.poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.watchlist-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.9);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
    cursor: pointer;
}

.watchlist-btn.add {
    background-image: url('images/add-dark.png');
}

.watchlist-btn.remove {
    background-image: url('images/remove-dark.png');
}

body.dark .watchlist-btn {
    background-color: rgba(30, 30, 30, 0.9);
}

body.dark .watchlist-btn.add {
    background-image: url('images/add-light.png');
}

body.dark .watchlist-btn.remove {
    background-image: url('images/remove-light.png');
}

.movie-title {
    margin-top: 8px;
    font-size: 0.875rem;
    font-weight: bold;
    color: #1A1A1A;
    line-height: 1.3;
}

body.dark .movie-title {
    color: #F2F2F2;
}

.movie-year {
    font-size: 0.75rem;
    color: #7A7A7A;
    margin-top: 2px;
}

body.dark .movie-year {
    color: #A5A5A5;
}

/* Pagination */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding-bottom: 40px;
}

.page-btn {
    border: 1px solid #D1D5DB;
    background-color: #fff;
    border-radius: 5px;
    padding: 6px 14px;
    font-size: 0.875rem;
    cursor: pointer;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-label {
    font-size: 0.875rem;
    color: #7A7A7A;
}

body.dark .page-btn {
    background-color: #2e2e2e;
    color: #fff;
    border: none;
}

body.dark .page-label {
    color: #A5A5A5;
}

/* Modal */

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 10;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    position: relative;
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    background-color: #fff;
    border-radius: 8px;
    display: flex;
    padding: 24px;
    gap: 20px;
}

body.dark .modal {
    background-color: #1E1E1E;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    border: none;
    background: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #7A7A7A;
}

body.dark .modal-close {
    color: #A5A5A5;
}

.modal-poster {
    width: 160px;
    min-width: 160px;
    border-radius: 6px;
    object-fit: cover;
    align-self: flex-start;
}

.modal-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #1A1A1A;
}

body.dark .modal-info {
    color: #F2F2F2;
}

.modal-title {
    font-size: 1.375rem;
}

.modal-year {
    font-weight: normal;
    color: #7A7A7A;
}

body.dark .modal-year {
    color: #A5A5A5;
}

.modal-meta {
    font-size: 0.875rem;
    color: #7A7A7A;
}

body.dark .modal-meta {
    color: #A5A5A5;
}

.modal-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
    font-size: 0.9375rem;
}

.star-icon {
    width: 16px;
    height: 16px;
}

.modal-plot {
    font-size: 0.9375rem;
    line-height: 1.5;
}

.modal-detail {
    font-size: 0.875rem;
    line-height: 1.4;
}

.modal-watchlist-btn {
    margin-top: 8px;
    align-self: flex-start;
    border: none;
    border-radius: 5px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: bold;
    cursor: pointer;
    color: #fff;
}

.modal-watchlist-btn.add {
    background-color: #6C63FF;
}

.modal-watchlist-btn.remove {
    background-color: #E5484D;
}

/* Responsive */

@media (max-width: 600px) {
    header {
        height: 160px;
    }

    .title {
        font-size: 1.75rem;
    }

    .modal {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .modal-poster {
        width: 140px;
        min-width: 140px;
    }

    .modal-info {
        align-items: center;
    }

    .modal-watchlist-btn {
        align-self: center;
    }
}
