/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-hover: #222;
    --text: #e8e8e8;
    --text-muted: #888;
    --accent: #e8b828;
    --border: #2a2a2a;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
header {
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
}

nav { max-width: 1200px; margin: 0 auto; }

.site-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}
.site-title:hover { color: var(--accent); text-decoration: none; }

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

footer {
    border-top: 1px solid var(--border);
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Controls bar */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-group select,
.filter-group input {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-size: 0.9rem;
    min-width: 140px;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.stats {
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

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

.director-heading {
    grid-column: 1 / -1;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 0 0.5rem;
    margin: 0;
}

.director-heading:first-child {
    padding-top: 0;
}

.movie-card {
    display: block;
    color: var(--text);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: transform 0.15s, border-color 0.15s;
}

.movie-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    text-decoration: none;
}

.poster-wrapper {
    aspect-ratio: 2/3;
    overflow: hidden;
    background: #111;
}

.poster-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-poster {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent);
}

.no-poster.large {
    width: 300px;
    height: 450px;
    font-size: 5rem;
    border-radius: var(--radius);
}

.card-info {
    padding: 0.75rem;
}

.card-info h3 {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Movie detail page */
.movie-detail { }

.movie-header {
    display: flex;
    gap: 2rem;
    margin-bottom: 3rem;
}

.movie-poster img {
    width: 300px;
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.movie-info {
    flex: 1;
}

.movie-info h1 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.year {
    font-weight: 400;
    color: var(--text-muted);
}

.meta-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.badge {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

.badge.rating {
    border-color: var(--accent);
    color: var(--accent);
}

.badge.tmdb-link {
    border-color: #01b4e4;
    color: #01b4e4;
}
.badge.tmdb-link:hover {
    background: #01b4e4;
    color: var(--bg);
    text-decoration: none;
}

.genres {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.genre-tag {
    background: #1a1a2e;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.overview {
    margin-bottom: 1.5rem;
    color: var(--text);
    max-width: 65ch;
}

.cast h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.cast ul {
    list-style: none;
    columns: 2;
    column-gap: 2rem;
}

.cast li {
    font-size: 0.9rem;
    padding: 0.15rem 0;
}

/* Episodes section */
.episodes-section {
    border-top: 1px solid var(--border);
    padding-top: 2rem;
}

.episodes-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.episode-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.episode-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.5rem 1rem;
    align-items: center;
}

.episode-podcast {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
}

.episode-title {
    font-size: 0.95rem;
}

.episode-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* TMDB attribution */
.tmdb-attribution {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.tmdb-logo {
    height: 16px;
    width: auto;
    max-width: 80px;
    opacity: 0.7;
}

.tmdb-attribution p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    main { padding: 1rem; }

    .movie-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 0.75rem;
    }

    .movie-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .movie-poster img { width: 200px; }
    .no-poster.large { width: 200px; height: 300px; font-size: 3rem; }

    .meta-row, .genres { justify-content: center; }

    .cast ul { columns: 1; }

    .episode-card {
        grid-template-columns: 1fr;
    }

    .controls { flex-direction: column; }
    .filter-group select,
    .filter-group input { width: 100%; }
}
