/* Movie4MM — watch.cmflix.xubi.org style (dark + red accent). */
:root {
    color-scheme: dark;
    --bg0: #05070f; --bg1: #0b0f1c; --bg2: #11172a;
    --card: #10162a; --line: #1f2942;
    --txt: #eef2ff; --mut: #8794b3;
    --acc: #e50914; --acc2: #ff2e54; --gold: #f5c518;
    --r: 14px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(229, 9, 20, .16), transparent),
        radial-gradient(900px 520px at -8% 4%, rgba(50, 90, 220, .12), transparent),
        linear-gradient(180deg, var(--bg0), var(--bg1) 55%, var(--bg2));
    color: var(--txt); min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Padauk", "Myanmar Text", sans-serif;
    -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* Topbar (glass, sticky) */
.site-header {
    position: sticky; top: 0; z-index: 200;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 12px 18px;
    background: rgba(5, 7, 15, .78);
    backdrop-filter: saturate(160%) blur(16px);
    border-bottom: 1px solid var(--line);
}
.logo { display: flex; align-items: center; gap: 11px; white-space: nowrap; }
.logo .mark {
    width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(140deg, #ff3a3f, #e50914 55%, #a3060d);
    box-shadow: 0 6px 18px rgba(229, 9, 20, .45), inset 0 1px 0 rgba(255, 255, 255, .25);
    font-weight: 900; font-size: 15px; letter-spacing: .5px; color: #fff;
    position: relative; overflow: hidden;
}
.logo .mark::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(120deg, transparent 40%, rgba(255, 255, 255, .22) 50%, transparent 60%);
}
.site-nav { display: flex; gap: 4px; }
.site-nav a { padding: 8px 12px; border-radius: 8px; color: var(--mut); font-weight: 600; font-size: 14px; }
.site-nav a.active { background: rgba(229, 9, 20, .16); color: #fff; }
.search-toggle {
    margin-left: auto; flex: 0 0 40px; width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: 0; border-radius: 50%;
    color: var(--mut); cursor: pointer; padding: 0;
}
.search-toggle:hover { color: #fff; }
.search-toggle svg { width: 20px; height: 20px; display: block; }
.search-row { flex-basis: 100%; }
.search-row[hidden] { display: none; }
.search-row .site-search { max-width: none; margin: 0; }
.site-search { flex: 1; max-width: 540px; margin: 0 auto; position: relative; display: flex; }
.site-search .si {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    opacity: .7; pointer-events: none; color: var(--mut);
}
.site-search .si svg { width: 16px; height: 16px; display: block; }
@media (max-width: 640px) {
    .site-header { gap: 10px; }
}
.ic { width: 16px; height: 16px; flex: 0 0 auto; vertical-align: middle; }
.site-search input {
    width: 100%; padding: 11px 14px 11px 40px;
    background: #0f172a; border: 1px solid var(--line); color: var(--txt);
    border-radius: 8px; font-size: 14px;
}
.site-search input:focus { outline: none; border-color: var(--acc); }

.container { max-width: 1200px; margin: 0 auto; padding: 0 16px 12px; }

/* Titles */
.page-title { font-size: 20px; margin: 14px 0 12px; }
.empty { color: var(--mut); text-align: center; padding: 40px 0; }

/* Poster grid */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(6, 1fr); } }
.card {
    display: block; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r); overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
    /* Smooth scrolling on long lists: the browser skips rendering
       off-screen cards (they still take up their estimated space). */
    content-visibility: auto; contain-intrinsic-size: auto 230px;
}
.card:hover { transform: translateY(-2px); border-color: rgba(229, 9, 20, .55); box-shadow: 0 10px 24px rgba(0, 0, 0, .45); }
.poster { aspect-ratio: 2 / 3; background: #171a21; display: flex; align-items: center; justify-content: center; overflow: hidden; }
/* YouTube-style: poster fades in gradually as it loads. */
.poster img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .3s ease; }
.poster img.loaded { opacity: 1; }
.poster-fallback { font-size: 32px; }
.poster-fallback svg { width: 36px; height: 36px; color: #64748b; display: block; }
.card-body { padding: 10px; }
.card-title { font-size: 13px; margin: 0 0 4px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: 12px; color: var(--mut); margin: 0; }

/* Pagination */
/* Infinite scroll: loading spinner + end of list */
.loader { padding: 20px 0 28px; text-align: center; }
.spinner {
    display: inline-block; width: 28px; height: 28px;
    border: 3px solid #2a2d35; border-top-color: #e50914;
    border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.list-end { text-align: center; color: var(--mut); font-size: 13px; padding: 8px 0 28px; }

/* Detail page */
.detail { max-width: 900px; margin: 0 auto; }
.backdrop { margin: 0 -16px; }
.backdrop img { width: 100%; max-height: 300px; object-fit: cover; display: block; }
.detail-head { display: flex; gap: 14px; margin-top: 14px; }
.detail-poster { width: 110px; border-radius: 10px; align-self: flex-start; border: 1px solid var(--line); }
.detail-info h1 { font-size: 22px; margin: 0 0 8px; line-height: 1.3; }
.meta { color: var(--mut); font-size: 14px; margin: 4px 0; }
.synopsis { line-height: 1.7; color: #cbd5e1; white-space: pre-line; }
.player-wrap { margin: 16px 0; }
.player-wrap video { width: 100%; border-radius: var(--r); background: #000; }
.now-playing { color: var(--mut); font-size: 14px; margin: 8px 0 0; }
.server-picker h2, .episodes h2 { font-size: 17px; margin: 18px 0 10px; }
.server-btn, .episode-btn { background: #1e293b; color: var(--txt); border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; margin: 0 8px 8px 0; cursor: pointer; font-size: 14px; }
.server-btn.active, .episode-btn.active { background: linear-gradient(140deg, #ff3a3f, #e50914 60%); border-color: var(--acc); color: #fff; }
.season-name { font-size: 15px; margin: 14px 0 8px; color: #cbd5e1; }
.episode-list { display: flex; flex-wrap: wrap; }

/* Detail hero (screenshot style: centered poster, chips, watch row) */
.detail-hero { text-align: center; padding-top: 18px; }
.detail-poster-wrap { position: relative; max-width: 220px; margin: 0 auto; }
.detail-poster-img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 16px; display: block; border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(0, 0, 0, .5); }
.quality-badge {
    position: absolute; top: 10px; right: 10px;
    background: linear-gradient(140deg, #f5c518, #b8860b);
    color: #111; font-weight: 900; font-size: 13px; letter-spacing: .5px;
    padding: 4px 9px; border-radius: 7px; box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.detail-title { font-size: 26px; margin: 18px 0 12px; line-height: 1.25; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 16px; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--card); border: 1px solid var(--line); border-radius: 999px;
    padding: 6px 11px; font-size: 13px; font-weight: 600;
}
.chip-blue { background: #2563eb; border-color: #2563eb; color: #fff; }
a.chip:hover { border-color: rgba(229, 9, 20, .55); }
.chip svg { width: 13px; height: 13px; }
.chip svg.star { fill: var(--gold); stroke: none; }
.watch-row { display: flex; gap: 10px; align-items: stretch; margin: 0 0 18px; }
.watch-btn {
    flex: 1; border: 0; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: linear-gradient(140deg, #ff3a3f, #e50914 60%);
    color: #fff; font-size: 17px; font-weight: 800;
    padding: 12px 18px; border-radius: 13px;
    box-shadow: 0 6px 18px rgba(229, 9, 20, .4);
}
.watch-btn svg { width: 19px; height: 19px; }
.icon-btn {
    flex: 0 0 50px; display: flex; align-items: center; justify-content: center;
    background: var(--card); border: 1px solid var(--line); border-radius: 13px;
    font-size: 20px; cursor: pointer; color: var(--txt);
}
.icon-btn svg { width: 21px; height: 21px; }
.synopsis.clamped {
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.synopsis.expanded { display: block; }
.read-more { background: none; border: 0; color: var(--acc2); font-weight: 800; font-size: 14px; letter-spacing: .5px; cursor: pointer; padding: 0; margin-bottom: 8px; }
/* Quality pop-up — same box design as the CM FLIX APK profile dialogs
   (ProfileActivity: dark #181A21 card, 24px radius, #363944 border,
   0.76 dim, red #E52D38 primary button, dark #2A2D35 secondary button,
   16px radius) — compacted so it fits every phone:
   max 340px wide, 48px buttons, and it never grows past 90% of the
   screen height (scrolls inside if a phone is very short). */
.modal-overlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(0, 0, 0, .76);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay[hidden] { display: none; }
.modal {
    width: 100%; max-width: 340px; max-height: 90vh; overflow-y: auto;
    background: #181A21; border: 1px solid #363944; border-radius: 24px;
    padding: 18px 20px; text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .6);
}
.modal-icon {
    width: 52px; height: 52px; margin: 0 auto; box-sizing: border-box;
    border-radius: 50%; background: #3B1D23; border: 1px solid #E52D38;
    display: flex; align-items: center; justify-content: center; padding: 13px;
}
.modal-icon svg { width: 100%; height: 100%; color: #fff; }
.modal h2 { font-size: 18px; font-weight: 800; color: #fff; margin: 10px 0 0; }
.modal-message { font-size: 14px; color: #A8ADB8; margin: 8px 0 0; }
.modal .quality-btn {
    display: block; width: 100%; margin: 18px 0 0; text-align: center;
    background: #2A2D35; color: #fff; border: 0; border-radius: 16px;
    height: 48px; line-height: 48px; padding: 0;
    font-size: 15px; font-weight: 700; cursor: pointer;
}
.modal .quality-btn + .quality-btn { margin-top: 8px; }
.modal .quality-btn-primary { background: #E52D38; }

/* Watch page — Netflix-style full-screen player (the video IS the page) */
.watch-body { margin: 0; background: #000; overflow: hidden; }
.watch-screen { position: fixed; inset: 0; background: #000; }
.watch-screen .video-js { width: 100%; height: 100%; }
.watch-top {
    position: absolute; top: 0; left: 0; right: 0; z-index: 10;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px 44px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, .7), rgba(0, 0, 0, 0));
    transition: opacity .3s; pointer-events: none;
}
.watch-top-hidden { opacity: 0; }
.watch-top a, .watch-top-text { pointer-events: auto; }
.watch-back {
    flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; background: rgba(0, 0, 0, .35);
}
.watch-back svg { width: 24px; height: 24px; }
.watch-top-text { min-width: 0; }
.watch-top-title {
    margin: 0; color: #fff; font-size: 17px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.watch-top-label { margin: 2px 0 0; color: rgba(255, 255, 255, .7); font-size: 13px; font-weight: 600; }
.player-wrap .video-js { border-radius: var(--r); overflow: hidden; width: 100%; }
.player-wrap .video-js .vjs-big-play-button { border-radius: 50%; }
