/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #ff0050;
    /* TikTok red/pink */
    --primary-hover: #e6004c;
    --background: #121212;
    --surface: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border: #333;
    --glass: rgba(30, 30, 30, 0.8);
    --radius: 12px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Header */
header {
    position: fixed;
    top: 0;
    width: 100%;
    height: 60px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1000;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1px;
}

/* Main Container */
.container {
    margin-top: 80px;
    padding: 20px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* Drama Grid */
.drama-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
}

.drama-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
}

.drama-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.cover-wrapper {
    position: relative;
    padding-top: 140%;
    /* 5:7 aspect ratio */
}

.cover-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-info {
    padding: 10px;
}

.drama-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.drama-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}

/* TikTok Style Watch Page - Enhanced Feed */
.watch-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: #000;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2000;
    align-items: center;
}

.episode-slide {
    width: 100%;
    max-width: 500px;
    height: 100vh;
    flex-shrink: 0;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    overflow: hidden;
    background: #000;
}

.video-player-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-overlay-click {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    cursor: pointer;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Fill screen like tiktok */
    cursor: pointer;
}

/* Play/Pause Overlay */
.play-pause-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    /* Let clicks pass through to video/container */
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 20;
}

.play-pause-overlay i {
    color: white;
    font-size: 40px;
}

/* Show when paused */
.video-player-wrapper.paused .play-pause-overlay {
    opacity: 1;
}

/* Sidebar for desktop, hidden on mobile default */
.interaction-sidebar {
    width: 350px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 2001;
}

/* Action Buttons (Right side overlay on mobile) */
.action-buttons {
    position: absolute;
    right: 15px;
    bottom: 120px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    z-index: 10;
    padding: 0;
    border: none;
    background: transparent;
}

.btn-action {
    background: none;
    border: none;
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.btn-action i {
    font-size: 1.8rem;
    background: rgba(0, 0, 0, 0.4);
    /* Darker transparent bg */
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.btn-action:active i {
    transform: scale(0.9);
}

/* Bottom Info Overlay (Title & Desc) */
.mobile-info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px 80px 30px 20px;
    /* Right padding for buttons */
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    z-index: 5;
    pointer-events: none;
    /* Let clicks pass through */
}

.mobile-info-overlay * {
    pointer-events: auto;
}

.mobile-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.mobile-desc {
    font-size: 0.9rem;
    color: #e0e0e0;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
    margin-bottom: 10px;
}

/* Header Back Button Overlay */
.mobile-header {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    display: flex;
    /* Always show even on desktop for consistency in full screen */
    align-items: center;
    gap: 15px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

/* Episode Drawer / Comment Drawer Styles */
.drawer-overlay {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    z-index: 3000;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    padding-bottom: 20px;
}

.drawer-overlay.open {
    transform: translateY(0);
}

.drawer-header {
    padding: 15px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-weight: bold;
    position: relative;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
}

.close-drawer {
    position: absolute;
    right: 15px;
    top: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
}

.drawer-content {
    overflow-y: auto;
    padding: 15px;
    flex: 1;
}

@media (min-width: 769px) {
    .watch-container {
        background: #1a1a1a;
    }

    .episode-slide {
        border-right: 1px solid #333;
        border-left: 1px solid #333;
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }
}


/* Loading Overlay for Episode Transition */
.nav-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.nav-loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}