/* ================= GLOBAL ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, Helvetica, sans-serif;
}

:root {
    --bg: #080808;
    --panel: #121212;
    --panel-soft: #191919;
    --text: #ffffff;
    --muted: #b8b8b8;
    --accent: #e50914;
    --accent-hot: #ff3340;
    --line: rgba(255, 255, 255, 0.12);
}

html {
    scroll-behavior: smooth;
}

body {
    background: radial-gradient(circle at top left, #1b1b1b 0, var(--bg) 34%);
    color: var(--text);
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
}

button,
input {
    font: inherit;
}

/* ================= HEADER ================= */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 15px 30px;
    background: rgba(8, 8, 8, 0.82);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 800;
    color: white;
    white-space: nowrap;
}

.logo-mark {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: white;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 38%),
        linear-gradient(135deg, var(--accent), #7a050b);
    box-shadow: 0 10px 24px rgba(229, 9, 20, 0.28);
    font-size: 20px;
    font-weight: 900;
}

nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

nav a {
    color: #d8d8d8;
    padding: 8px 10px;
    border-radius: 6px;
    text-decoration: none;
    transition: color 0.25s ease, background 0.25s ease;
}

nav a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.search {
    position: relative;
}

.search input {
    width: min(260px, 28vw);
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid transparent;
    outline: none;
    color: white;
    background: rgba(255, 255, 255, 0.12);
    transition: border-color 0.25s ease, background 0.25s ease;
}

.search input::placeholder {
    color: #b9b9b9;
}

.search input:focus {
    border-color: rgba(229, 9, 20, 0.8);
    background: rgba(255, 255, 255, 0.16);
}

.search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: min(360px, 88vw);
    max-height: 440px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(14, 14, 14, 0.98);
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.45);
    z-index: 1500;
}

.search-dropdown.is-open {
    display: grid;
    gap: 6px;
    animation: popup 0.18s ease;
}

.search-result {
    display: grid;
    grid-template-columns: 42px 1fr;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 58px;
    padding: 8px;
    border: 0;
    border-radius: 6px;
    color: white;
    background: transparent;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.search-result:hover,
.search-result:focus-visible {
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    transform: translateX(2px);
}

.search-result img,
.search-poster-empty {
    width: 42px;
    height: 58px;
    border-radius: 5px;
    object-fit: cover;
    background: var(--panel-soft);
}

.search-result span {
    min-width: 0;
}

.search-result strong {
    display: block;
    overflow: hidden;
    color: white;
    font-size: 14px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result small,
.search-empty {
    color: var(--muted);
    font-size: 12px;
}

.search-empty {
    padding: 12px;
}

/* ================= HERO ================= */
.hero-banner {
    min-height: 74vh;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: center;
    padding: clamp(32px, 6vw, 72px);
    isolation: isolate;
}

.hero-banner::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(to top, var(--bg) 0, transparent 32%),
        linear-gradient(to right, rgba(0, 0, 0, 0.96), rgba(0, 0, 0, 0.46), rgba(0, 0, 0, 0.9));
    z-index: -1;
}

.hero-animate {
    animation: heroReveal 0.7s ease both;
}

.hero-content {
    max-width: 650px;
}

.hero-content h1 {
    font-size: clamp(34px, 6vw, 64px);
    line-height: 0.98;
    margin-bottom: 14px;
    letter-spacing: 0;
}

.hero-content p {
    color: #d5d5d5;
    line-height: 1.6;
    margin-bottom: 16px;
    max-width: 58ch;
}

.hero-meta {
    display: flex;
    gap: 10px;
    color: #dedede;
    margin-bottom: 20px;
}

.hero-meta span {
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
}

.hero-actions,
.popup-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
#playBtn {
    border: none;
    padding: 11px 18px;
    color: white;
    cursor: pointer;
    border-radius: 6px;
    transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease;
}

.primary-btn {
    background: var(--accent);
    box-shadow: 0 10px 28px rgba(229, 9, 20, 0.28);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid var(--line);
}

.primary-btn:hover,
.secondary-btn:hover,
#playBtn:hover {
    transform: translateY(-2px);
}

.primary-btn:hover {
    background: var(--accent-hot);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ================= SECTIONS ================= */
.movies {
    padding: 18px clamp(16px, 4vw, 44px);
    scroll-margin-top: 88px;
}

#heroBanner {
    scroll-margin-top: 80px;
}

.movies h2 {
    margin-bottom: 12px;
    font-size: 19px;
    border-left: 4px solid var(--accent);
    padding-left: 10px;
}

/* ================= ROW ================= */
.grid {
    display: flex;
    overflow-x: auto;
    gap: 14px;
    padding: 4px 0 14px;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
}

.grid::-webkit-scrollbar {
    height: 8px;
}

.grid::-webkit-scrollbar-track {
    background: transparent;
}

.grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 20px;
}

/* ================= CARD ================= */
.card {
    min-width: 158px;
    max-width: 158px;
    cursor: pointer;
    border: 0;
    color: white;
    background: transparent;
    text-align: left;
    scroll-snap-align: start;
    transition: transform 0.28s ease;
    animation: cardIn 0.45s ease both;
}

.poster-wrap {
    display: block;
    position: relative;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    border-radius: 8px;
    background: var(--panel-soft);
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.28);
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease, filter 0.35s ease;
}

.play-chip {
    position: absolute;
    left: 10px;
    bottom: 10px;
    opacity: 0;
    transform: translateY(8px);
    padding: 6px 9px;
    border-radius: 6px;
    background: rgba(229, 9, 20, 0.92);
    font-size: 12px;
    font-weight: 700;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.card-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 4px;
    background: var(--accent);
}

.card:hover,
.card:focus-visible {
    transform: translateY(-6px);
    z-index: 10;
    outline: none;
}

.card:hover img,
.card:focus-visible img {
    transform: scale(1.08);
    filter: brightness(0.78);
}

.card:hover .play-chip,
.card:focus-visible .play-chip {
    opacity: 1;
    transform: translateY(0);
}

.movie-info {
    display: grid;
    gap: 3px;
    padding: 8px 2px 0;
    color: #aaa;
    font-size: 12px;
}

.movie-info strong {
    color: white;
    font-size: 13px;
    line-height: 1.25;
}

/* ================= CONTINUE + HISTORY SMALL ================= */
#continueWatching .card,
#historyMovies .card {
    min-width: 128px;
    max-width: 128px;
}

/* ================= POPUP PLAYER ================= */
.popup {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.86);
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 2000;
    backdrop-filter: blur(10px);
}

.popup-content {
    width: min(1040px, 96vw);
    background: linear-gradient(180deg, #171717, #0d0d0d);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    position: relative;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    animation: popup 0.28s ease;
}

.player-copy {
    padding-right: 44px;
    margin-bottom: 12px;
}

#popupKicker {
    color: var(--accent-hot);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
    margin-bottom: 4px;
}

.popup-content h2 {
    font-size: clamp(20px, 3vw, 30px);
}

.player-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 8px;
    background: black;
}

#moviePlayer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: black;
}

.watch-progress {
    display: grid;
    gap: 8px;
    margin: 14px 0;
    color: var(--muted);
    font-size: 13px;
}

#playerHint {
    color: #d0d0d0;
    line-height: 1.4;
}

.progress-track {
    height: 6px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.13);
}

#progressFill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), var(--accent-hot));
    transition: width 0.35s ease;
}

.close {
    position: absolute;
    right: 14px;
    top: 12px;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    font-size: 27px;
    line-height: 1;
    cursor: pointer;
    color: white;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    transition: background 0.25s ease, transform 0.25s ease;
}

.close:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: rotate(90deg);
}

/* ================= ANIMATION ================= */
@keyframes popup {
    from {
        transform: translateY(12px) scale(0.98);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes heroReveal {
    from {
        opacity: 0.82;
        background-position: center 44%;
    }
    to {
        opacity: 1;
        background-position: center;
    }
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

/* ================= MOBILE ================= */
@media (max-width: 820px) {
    header {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
        padding: 14px 16px;
    }

    nav {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .search input {
        width: 100%;
    }

    .search-dropdown {
        left: 0;
        right: auto;
        width: 100%;
    }

    .hero-banner {
        min-height: 68vh;
        align-items: flex-end;
        padding: 28px 18px 44px;
    }

    .hero-content p {
        display: -webkit-box;
        -webkit-line-clamp: 4;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .card {
        min-width: 128px;
        max-width: 128px;
    }

    .popup {
        padding: 10px;
    }

    .popup-content {
        width: 100%;
        padding: 12px;
    }
}
