/* ==========================================================================
   CINEFLIX / TMDB Movie Portal - Modern CSS Design System
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Noto+Sans+KR:wght@300;400;500;700&display=swap');

:root {
    --bg-primary: #08090f;
    --bg-secondary: #10121d;
    --bg-card: rgba(22, 26, 42, 0.75);
    --bg-glass: rgba(16, 18, 29, 0.82);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(229, 9, 20, 0.5);

    --accent-red: #e50914;
    --accent-red-glow: rgba(229, 9, 20, 0.4);
    --accent-purple: #8b5cf6;
    --accent-gold: #f59e0b;
    --accent-cyan: #06b6d4;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;

    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px rgba(229, 9, 20, 0.35);

    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    border: none;
    outline: none;
    cursor: pointer;
    background: none;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: #2a2e45;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-red);
}

/* Header & Navbar */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 16px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-glass);
    transition: var(--transition);
}

.navbar.scrolled {
    padding: 12px 40px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 30%, var(--accent-red) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-brand i {
    font-size: 1.8rem;
    color: var(--accent-red);
    -webkit-text-fill-color: initial;
    filter: drop-shadow(0 0 8px var(--accent-red-glow));
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.04);
    padding: 6px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-glass);
}

.nav-tab {
    padding: 10px 22px;
    border-radius: var(--radius-full);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.08);
}

.nav-tab.active {
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent-red) 0%, #ff3b47 100%);
    box-shadow: 0 4px 15px var(--accent-red-glow);
}

/* Search Box */
.search-box {
    position: relative;
    width: 280px;
    transition: var(--transition);
}

.search-box input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--accent-red);
    box-shadow: 0 0 15px rgba(229, 9, 20, 0.3);
    width: 320px;
}

.search-box i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
}

.search-clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    display: none;
    cursor: pointer;
}

.search-clear:hover {
    color: var(--text-primary);
}

/* Hero Section */
.hero-slider {
    position: relative;
    width: 100%;
    height: 75vh;
    min-height: 520px;
    margin-top: 70px;
    overflow: hidden;
}

.hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s ease-in-out, transform 0.8s ease-in-out;
    transform: scale(1.03);
    background-size: cover;
    background-position: center top;
}

.hero-slide.active {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, var(--bg-primary) 0%, rgba(8, 9, 15, 0.6) 50%, rgba(8, 9, 15, 0.8) 100%),
                linear-gradient(90deg, var(--bg-primary) 0%, rgba(8, 9, 15, 0.5) 40%, transparent 100%);
}

.hero-content {
    position: relative;
    max-width: 1300px;
    margin: 0 auto;
    height: 100%;
    padding: 0 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 10;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(229, 9, 20, 0.2);
    border: 1px solid var(--accent-red);
    border-radius: var(--radius-full);
    color: #ff4d58;
    font-size: 0.85rem;
    font-weight: 700;
    width: fit-content;
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hero-title {
    font-size: 3.2rem;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 16px;
    max-width: 750px;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

.hero-meta {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.hero-meta-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hero-meta-item.rating {
    color: var(--accent-gold);
    font-weight: 700;
}

.hero-meta-item.d-day {
    background: linear-gradient(135deg, var(--accent-red), var(--accent-purple));
    color: white;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 700;
}

.hero-overview {
    font-size: 1.05rem;
    color: rgba(248, 250, 252, 0.85);
    max-width: 650px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 28px;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    gap: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    border-radius: var(--radius-full);
    font-size: 1rem;
    font-weight: 700;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-red) 0%, #ff3b47 100%);
    color: white;
    box-shadow: 0 6px 20px var(--accent-red-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(229, 9, 20, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-2px);
}

/* Slider Controls */
.hero-controls {
    position: absolute;
    bottom: 30px;
    right: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20;
}

.hero-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: var(--transition);
    cursor: pointer;
}

.hero-dot.active {
    width: 32px;
    border-radius: 6px;
    background: var(--accent-red);
    box-shadow: 0 0 10px var(--accent-red-glow);
}

/* Main Container */
.main-container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 40px 40px 80px;
    width: 100%;
    flex: 1;
}

/* Section Header */
.section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 16px;
}

.section-title-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.section-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, rgba(229, 9, 20, 0.2), rgba(139, 92, 246, 0.2));
    border: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-red);
    font-size: 1.3rem;
}

.section-title {
    font-size: 1.8rem;
    font-weight: 800;
}

.section-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Genre Filter Chips */
.genre-container {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    padding: 4px 0 20px;
    margin-bottom: 30px;
}

.genre-container::-webkit-scrollbar {
    height: 4px;
}

.genre-chip {
    padding: 8px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    transition: var(--transition);
    cursor: pointer;
}

.genre-chip:hover {
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
}

.genre-chip.active {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

/* Movie Grid */
.movie-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 28px;
}

/* Movie Card */
.movie-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-glass);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.movie-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--border-hover);
    box-shadow: var(--shadow-soft), var(--shadow-glow);
}

.poster-wrap {
    position: relative;
    width: 100%;
    padding-top: 148%;
    background: #141724;
    overflow: hidden;
}

.poster-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.movie-card:hover .poster-img {
    transform: scale(1.08);
}

/* Card Badges */
.card-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 700;
    backdrop-filter: blur(8px);
    z-index: 5;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.card-badge.d-day {
    background: linear-gradient(135deg, var(--accent-red), #ff5252);
    color: white;
}

.card-badge.released {
    background: rgba(16, 185, 129, 0.88);
    color: white;
}

.card-badge.rating {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(10, 12, 20, 0.82);
    border: 1px solid var(--border-glass);
    color: var(--accent-gold);
    display: flex;
    align-items: center;
    gap: 4px;
}

.card-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(22, 26, 42, 0.6) 0%, rgba(16, 18, 29, 0.95) 100%);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.35;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-date {
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-overview-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

/* Loading & Empty States */
.state-container {
    grid-column: 1 / -1;
    padding: 80px 20px;
    text-align: center;
    color: var(--text-secondary);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--accent-red);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Detail Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(4, 5, 10, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    padding: 20px;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    position: relative;
    width: 100%;
    max-width: 960px;
    max-height: 90vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8);
    transform: scale(0.92);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.modal-backdrop.active .modal-container {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-glass);
    color: white;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--accent-red);
    transform: rotate(90deg);
}

.modal-header-bg {
    position: relative;
    width: 100%;
    height: 340px;
    background-size: cover;
    background-position: center;
}

.modal-header-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, var(--bg-secondary) 0%, rgba(16, 18, 29, 0.4) 60%, rgba(0,0,0,0.6) 100%);
}

.modal-body {
    padding: 0 36px 36px;
    margin-top: -120px;
    position: relative;
    z-index: 10;
}

.modal-meta-header {
    display: flex;
    gap: 28px;
    margin-bottom: 28px;
}

.modal-poster {
    width: 180px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0,0,0,0.7);
    border: 2px solid var(--border-glass);
    flex-shrink: 0;
}

.modal-info {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.modal-title {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 8px;
    line-height: 1.2;
}

.modal-tagline {
    font-size: 1rem;
    font-style: italic;
    color: var(--accent-cyan);
    margin-bottom: 14px;
}

.modal-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.modal-stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-stat-item.rating {
    color: var(--accent-gold);
    font-weight: 700;
}

.modal-genres {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.modal-genre-tag {
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.modal-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 28px 0 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.modal-section-title i {
    color: var(--accent-red);
}

.modal-overview {
    font-size: 1rem;
    line-height: 1.7;
    color: rgba(248, 250, 252, 0.88);
}

/* Cast Grid */
.cast-scroll {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 12px;
}

.cast-card {
    flex: 0 0 110px;
    text-align: center;
}

.cast-img {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 8px;
    border: 2px solid var(--border-glass);
    background: #141724;
}

.cast-name {
    font-size: 0.85rem;
    font-weight: 600;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cast-character {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Video Player Wrap */
.video-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border-glass);
}

.video-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-glass);
    padding: 30px 40px;
    text-align: center;
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-top: auto;
}

.footer-logo {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

/* Responsive Media Queries */
@media (max-width: 900px) {
    .navbar {
        padding: 14px 20px;
    }
    .hero-slider {
        height: 60vh;
    }
    .hero-title {
        font-size: 2.2rem;
    }
    .search-box {
        width: 180px;
    }
    .search-box input:focus {
        width: 220px;
    }
    .main-container {
        padding: 24px 20px 60px;
    }
    .modal-meta-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .modal-body {
        margin-top: -60px;
    }
}

@media (max-width: 600px) {
    .nav-menu {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        border-radius: 0;
        justify-content: space-around;
        padding: 10px;
        z-index: 1000;
        background: var(--bg-glass);
        border-top: 1px solid var(--border-glass);
    }
    .nav-tab span {
        display: none;
    }
    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 16px;
    }
    .hero-title {
        font-size: 1.7rem;
    }
}
