/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
    --bg:         #0f0f0f;
    --surf-1:     #1c1c1c;
    --surf-2:     #252525;
    --surf-3:     #313131;
    --accent:     #e50914;
    --accent-h:   #c10812;
    --txt:        #ffffff;
    --txt-2:      #b3b3b3;
    --txt-3:      #666666;
    --border:     rgba(255,255,255,0.08);
    --nav-h:      62px;
    --r-sm:       6px;
    --r-md:       10px;
    --r-lg:       16px;
    --t:          0.22s ease;
    --shadow-card: 0 8px 32px rgba(0,0,0,0.55);
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ============================================================
   RESET + BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-tap-highlight-color: transparent; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--txt);
    line-height: 1.5;
    overflow-x: hidden;
    min-height: 100vh;
}
a  { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
input { font: inherit; }

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav {
    position: fixed;
    inset: 0 0 auto;
    z-index: 100;
    transition: background var(--t), box-shadow var(--t);
}
.nav.scrolled {
    background: rgba(15,15,15,0.96);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 1px 0 var(--border);
}
.nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--nav-h);
    padding: 0 40px;
}
.nav__left  { display: flex; align-items: center; gap: 36px; }
.nav__right { display: flex; align-items: center; gap: 6px; }

/* Logo */
.nav__logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
    white-space: nowrap;
}
.nav__logo span { color: var(--accent); }

/* Desktop links */
.nav__menu { display: flex; gap: 2px; }
.nav__link {
    padding: 6px 12px;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--txt-2);
    transition: color var(--t), background var(--t);
}
.nav__link:hover,
.nav__link.active { color: var(--txt); background: rgba(255,255,255,0.08); }

/* Icon buttons */
.nav__search-btn,
.nav__hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 50%;
    color: var(--txt-2);
    transition: color var(--t), background var(--t);
}
.nav__search-btn:hover,
.nav__hamburger:hover { color: var(--txt); background: rgba(255,255,255,0.08); }

/* Hamburger bars */
.nav__hamburger { display: none; flex-direction: column; gap: 5px; }
.nav__hamburger span {
    display: block;
    width: 18px; height: 2px;
    background: currentColor;
    border-radius: 2px;
    transition: transform var(--t), opacity var(--t);
}
.nav__hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__hamburger.open span:nth-child(2) { opacity: 0; }
.nav__hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile menu drawer */
.nav__menu.open {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0;
    background: rgba(20,20,20,0.98);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    padding: 12px 16px 20px;
    gap: 2px;
    animation: menu-slide 0.22s ease;
}
@keyframes menu-slide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.nav__menu.open .nav__link {
    padding: 10px 14px;
    font-size: 15px;
    border-radius: var(--r-md);
}

/* Search bar */
.nav__search-bar {
    display: none;
    border-top: 1px solid var(--border);
    background: rgba(15,15,15,0.98);
    padding: 10px 40px;
}
.nav__search-bar.open { display: block; }
.nav__search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 500px;
    background: var(--surf-1);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 8px 12px;
}
.nav__search-wrap svg { color: var(--txt-3); flex-shrink: 0; }
.nav__search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--txt);
    font-size: 14px;
    caret-color: var(--accent);
}
.nav__search-input::placeholder { color: var(--txt-3); }
.nav__search-clear {
    display: none;
    padding: 2px;
    color: var(--txt-3);
    border-radius: 50%;
    transition: color var(--t);
}
.nav__search-clear:hover { color: var(--txt); }
.nav__search-clear.show { display: flex; }

/* ============================================================
   APP / MAIN
   ============================================================ */
#app { padding-top: var(--nav-h); min-height: 100vh; }

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero {
    position: relative;
    height: min(88vh, 680px);
    overflow: hidden;
    margin-bottom: -80px;
}
.hero__bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 20%;
}
.hero__bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(90deg, rgba(15,15,15,0.97) 0%, rgba(15,15,15,0.65) 45%, rgba(15,15,15,0.1) 100%),
        linear-gradient(0deg, rgba(15,15,15,1) 0%, rgba(15,15,15,0.45) 22%, transparent 55%);
}
.hero__content {
    position: relative;
    z-index: 2;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 0 40px 110px;
    max-width: 680px;
}
.hero__tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    margin-bottom: 14px;
    width: fit-content;
}
.hero__title {
    font-size: clamp(26px, 4.5vw, 52px);
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.07;
    margin-bottom: 12px;
    text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.hero__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.hero__meta-item {
    font-size: 13px;
    color: var(--txt-2);
    font-weight: 500;
}
.hero__meta-item.star { color: #fbbf24; font-weight: 700; }
.hero__sep { color: var(--txt-3); }
.hero__desc {
    font-size: 14px;
    color: var(--txt-2);
    line-height: 1.65;
    margin-bottom: 24px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}
.hero__btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: var(--r-md);
    font-size: 14px;
    font-weight: 600;
    transition: all var(--t);
    white-space: nowrap;
    cursor: pointer;
    border: none;
}
.btn--primary {
    background: var(--accent);
    color: #fff;
}
.btn--primary:hover {
    background: var(--accent-h);
    transform: translateY(-1px);
    box-shadow: 0 4px 18px rgba(229,9,20,0.35);
}
.btn--ghost {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.18);
    backdrop-filter: blur(6px);
}
.btn--ghost:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-1px);
}
.btn svg { flex-shrink: 0; }

/* ============================================================
   CONTENT SECTIONS
   ============================================================ */
.sections { position: relative; z-index: 2; padding-bottom: 64px; }

.section { margin-bottom: 44px; }

.section__hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    margin-bottom: 14px;
}
.section__title {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.2px;
}
.section__more {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.3px;
    transition: opacity var(--t);
}
.section__more:hover { opacity: 0.75; }

/* Horizontal scroll row */
.row {
    display: flex;
    gap: 10px;
    padding: 6px 40px 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.row::-webkit-scrollbar { display: none; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    position: relative;
    flex: 0 0 155px;
    scroll-snap-align: start;
    border-radius: var(--r-md);
    overflow: hidden;
    cursor: pointer;
    background: var(--surf-1);
    transition: transform var(--t), box-shadow var(--t);
}
.card:hover {
    transform: scale(1.06) translateY(-2px);
    box-shadow: var(--shadow-card);
    z-index: 5;
}
.card__img {
    aspect-ratio: 2/3;
    width: 100%;
    object-fit: cover;
    background: var(--surf-2);
    display: block;
}
.card__img-placeholder {
    aspect-ratio: 2/3;
    width: 100%;
    background: var(--surf-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: var(--txt-3);
}
.card__type {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(4px);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 4px;
}
/* Play icon overlay */
.card__play {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--t);
}
.card:hover .card__play { opacity: 1; }
.card__play-circle {
    width: 44px; height: 44px;
    background: rgba(229,9,20,0.88);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.85);
    transition: transform var(--t);
}
.card:hover .card__play-circle { transform: scale(1); }
.card__meta {
    padding: 8px 9px 10px;
}
.card__name {
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.card__sub {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--txt-3);
}
.card__star { color: #fbbf24; font-size: 10px; }

/* Wide card (16:9 aspect) */
.card--wide { flex: 0 0 230px; }
.card--wide .card__img { aspect-ratio: 16/9; }
.card--wide .card__img-placeholder { aspect-ratio: 16/9; }

/* Progress bar for continue watching */
.card__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.15);
}
.card__progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

/* ============================================================
   BROWSE PAGE (GRID)
   ============================================================ */
.browse {
    padding: 28px 40px 80px;
}
.browse__hd {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.browse__title {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 14px;
}
.grid .card { flex: none; width: 100%; }

.load-more {
    display: block;
    margin: 40px auto 0;
    padding: 11px 44px;
    background: var(--surf-2);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--txt-2);
    transition: all var(--t);
}
.load-more:hover { background: var(--surf-3); color: var(--txt); }
.load-more:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   SEARCH PAGE
   ============================================================ */
.search-pg {
    padding: 28px 40px 80px;
}
.search-pg__label {
    font-size: 14px;
    color: var(--txt-2);
    margin-bottom: 24px;
}
.search-pg__label strong { color: var(--txt); }
.search-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--txt-3);
}
.search-empty__icon { font-size: 48px; margin-bottom: 14px; }
.search-empty__msg { font-size: 16px; color: var(--txt-2); }

/* ============================================================
   SKELETON LOADERS
   ============================================================ */
@keyframes shimmer {
    from { background-position: -200% 0; }
    to   { background-position:  200% 0; }
}
.skel {
    background: linear-gradient(90deg, var(--surf-2) 25%, var(--surf-3) 50%, var(--surf-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: var(--r-sm);
}
.card-skel {
    flex: 0 0 155px;
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--surf-1);
}
.card-skel__img  { aspect-ratio: 2/3; width: 100%; }
.card-skel__line { height: 11px; margin: 8px 9px 5px; }
.card-skel__sub  { height: 10px; width: 55%; margin: 0 9px 10px; }
.hero-skel {
    height: min(88vh, 680px);
    background: var(--surf-1);
    margin-bottom: -80px;
}

/* ============================================================
   DETAIL MODAL
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
}
.modal.open { display: flex; }

@media (min-width: 600px) {
    .modal { align-items: center; }
}

.modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.82);
    animation: fade-in 0.25s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal__sheet {
    position: relative;
    z-index: 1;
    background: var(--surf-1);
    width: 100%;
    max-width: 860px;
    max-height: 93dvh;
    max-height: 93vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--surf-3) transparent;
    animation: sheet-up 0.32s cubic-bezier(0.22,1,0.36,1);
}
@media (min-width: 600px) {
    .modal__sheet {
        border-radius: var(--r-lg);
        max-height: 88vh;
    }
}
@keyframes sheet-up {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

.modal__close {
    position: sticky;
    top: 12px;
    float: right;
    margin: 12px 12px 0 0;
    width: 34px; height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    border-radius: 50%;
    z-index: 10;
    transition: background var(--t);
}
.modal__close:hover { background: rgba(0,0,0,0.85); }

/* ---- Detail body ---- */
.det__backdrop {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    background: var(--surf-2);
    display: block;
}
.det__backdrop-ph {
    width: 100%;
    aspect-ratio: 16/9;
    background: var(--surf-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    color: var(--txt-3);
}
.det__body { padding: 20px 24px 32px; }
.det__top {
    display: flex;
    gap: 18px;
    margin-bottom: 20px;
}
.det__poster {
    flex-shrink: 0;
    width: 110px;
    margin-top: -52px;
    border-radius: var(--r-md);
    overflow: hidden;
    box-shadow: var(--shadow-card);
    background: var(--surf-2);
    align-self: flex-start;
}
.det__poster img { width: 100%; display: block; }
.det__info { flex: 1; min-width: 0; padding-top: 6px; }
.det__title {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.4px;
    line-height: 1.2;
    margin-bottom: 10px;
}
.det__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge--star  { background: rgba(251,191,36,0.14); color: #fbbf24; }
.badge--info  { background: var(--surf-2); color: var(--txt-2); }
.badge--genre { background: var(--surf-2); color: var(--txt-2); border: 1px solid var(--border); }
.det__overview {
    font-size: 13.5px;
    color: var(--txt-2);
    line-height: 1.7;
    margin-bottom: 20px;
}
.det__actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* TV Season / Episode selector */
.episodes { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.episodes__title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
}
.season-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 4px;
    margin-bottom: 14px;
}
.season-tabs::-webkit-scrollbar { display: none; }
.stab {
    flex-shrink: 0;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    background: var(--surf-2);
    color: var(--txt-2);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--t);
}
.stab:hover:not(.stab--on) { background: var(--surf-3); color: var(--txt); }
.stab--on { background: var(--accent); color: #fff; border-color: var(--accent); }

.ep-list { display: grid; gap: 8px; }
.ep-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    background: var(--surf-2);
    border-radius: var(--r-md);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--t);
}
.ep-item:hover {
    background: var(--surf-3);
    border-color: var(--border);
}
.ep-num {
    flex-shrink: 0;
    width: 34px; height: 34px;
    background: var(--surf-3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--txt-2);
}
.ep-info { flex: 1; min-width: 0; }
.ep-name {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.ep-date { font-size: 11px; color: var(--txt-3); }
.ep-play {
    flex-shrink: 0;
    width: 30px; height: 30px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--t), background var(--t);
}
.ep-play:hover { background: var(--accent-h); transform: scale(1.1); }

/* ============================================================
   PLAYER MODAL
   ============================================================ */
.player {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: #000;
    flex-direction: column;
}
.player.open { display: flex; }
.player__hud {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}
.player:hover .player__hud,
.player__hud:focus-within { opacity: 1; }
.player__back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.14);
    border-radius: 50%;
    flex-shrink: 0;
    transition: background var(--t);
}
.player__back:hover { background: rgba(255,255,255,0.24); }
.player__title {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255,255,255,0.75);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.player__frame {
    width: 100%;
    flex: 1;
    border: none;
}

/* ============================================================
   SETUP / ERROR STATES
   ============================================================ */
.setup {
    max-width: 480px;
    margin: 100px auto;
    padding: 36px 32px;
    background: var(--surf-1);
    border: 1px solid rgba(229,9,20,0.25);
    border-radius: var(--r-lg);
    text-align: center;
}
.setup__icon  { font-size: 44px; margin-bottom: 18px; }
.setup__title { font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.setup__desc  { font-size: 14px; color: var(--txt-2); line-height: 1.7; }
.setup__desc a { color: var(--accent); }
.setup__desc code {
    background: var(--surf-2);
    padding: 2px 7px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12.5px;
    color: #fbbf24;
}

.err-state {
    padding: 100px 40px;
    text-align: center;
    color: var(--txt-3);
}
.err-state h2 { font-size: 18px; color: var(--txt-2); margin-bottom: 8px; }
.err-state p  { font-size: 13px; }

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
    border-top: 1px solid var(--border);
    padding: 28px 40px;
    text-align: center;
    font-size: 12.5px;
    color: var(--txt-3);
}
.footer a { color: var(--txt-2); transition: color var(--t); }
.footer a:hover { color: var(--txt); }

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 768px) {
    :root { --nav-h: 56px; }

    .nav__inner    { padding: 0 16px; }
    .nav__search-bar { padding: 10px 16px; }
    .nav__menu     { display: none; }
    .nav__hamburger { display: flex; }

    .hero { height: min(72vh, 480px); margin-bottom: -60px; }
    .hero__content { padding: 0 16px 80px; }
    .hero__desc    { display: none; }
    .hero__title   { font-size: clamp(22px, 6vw, 34px); }

    .section__hd   { padding: 0 16px; }
    .row           { padding: 6px 16px 14px; gap: 8px; }
    .card          { flex: 0 0 128px; }
    .card--wide    { flex: 0 0 200px; }

    .browse        { padding: 20px 16px 60px; }
    .browse__title { font-size: 20px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }

    .search-pg     { padding: 20px 16px 60px; }

    .det__body     { padding: 16px 16px 28px; }
    .det__poster   { width: 85px; margin-top: -38px; }
    .det__title    { font-size: 17px; }

    .footer        { padding: 24px 16px; }
}

@media (max-width: 420px) {
    .hero__btns { flex-direction: column; }
    .btn        { width: 100%; }
    .det__top   { gap: 12px; }
}

@media (min-width: 1280px) {
    .card      { flex: 0 0 175px; }
    .card--wide { flex: 0 0 265px; }
    .grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
}
