/* ==========================================================================
   Marvel Cinematic Multiverse — light theme with an MCU cinematic feel
   ========================================================================== */

:root {
    --marvel-red: #ed1d24;
    --marvel-red-dark: #b3151b;
    --marvel-red-light: #ff4b4f;
    --gold: #c9a24b;
    --ink: #1a1a1e;
    --ink-soft: #4a4a52;
    --muted: #8b8b93;
    --bg: #f4f4f7;
    --bg-alt: #ebebf1;
    --surface: #ffffff;
    --border: #e2e2ea;
    --border-strong: #d3d3dd;
    --shadow-sm: 0 1px 3px rgba(20, 20, 30, 0.06), 0 1px 2px rgba(20, 20, 30, 0.08);
    --shadow-md: 0 8px 24px rgba(20, 20, 30, 0.08), 0 2px 6px rgba(20, 20, 30, 0.06);
    --shadow-lg: 0 20px 45px rgba(20, 20, 30, 0.12), 0 6px 16px rgba(20, 20, 30, 0.08);
    --radius: 10px;
    --radius-lg: 16px;
    --font-display: 'Bebas Neue', 'Oswald', 'Arial Narrow', sans-serif;
    --font-body: 'Oswald', 'Segoe UI', Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background:
        radial-gradient(1200px 500px at 50% -10%, rgba(237, 29, 36, 0.06), transparent 60%),
        var(--bg);
    color: var(--ink);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: var(--marvel-red);
    color: #fff;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-alt);
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--marvel-red), var(--marvel-red-dark));
    border-radius: 10px;
    border: 2px solid var(--bg-alt);
}

a {
    color: var(--marvel-red-dark);
}

.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ==========================================================================
   Header — cinematic banner, evokes the Marvel Studios logo card
   ========================================================================== */

.header {
    position: relative;
    background:
        linear-gradient(120deg, #ffffff 0%, #fff6f6 45%, #ffe9e9 100%);
    border-bottom: 4px solid var(--marvel-red);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            100deg,
            rgba(237, 29, 36, 0.05) 0px,
            rgba(237, 29, 36, 0.05) 2px,
            transparent 2px,
            transparent 60px
        );
    pointer-events: none;
}

.header::after {
    content: '';
    position: absolute;
    right: -10%;
    top: -60%;
    width: 480px;
    height: 480px;
    background: radial-gradient(circle, rgba(201, 162, 75, 0.18), transparent 70%);
    pointer-events: none;
}

.header .container {
    position: relative;
    padding: 42px 24px 34px;
}

.header h1 {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(34px, 5vw, 56px);
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 400;
    background: linear-gradient(180deg, var(--ink) 0%, var(--ink) 55%, var(--marvel-red-dark) 130%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.header h1::after {
    content: '';
    display: block;
    width: 84px;
    height: 4px;
    margin-top: 12px;
    background: linear-gradient(90deg, var(--marvel-red), var(--gold));
    border-radius: 4px;
}

/* ==========================================================================
   Filters panel
   ========================================================================== */

.filters-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 18px;
    margin: 24px 0;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink-soft);
    user-select: none;
}

.filter-group input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-strong);
    border-radius: 5px;
    cursor: pointer;
    position: relative;
    transition: border-color 0.15s ease, background 0.15s ease;
    background: var(--bg);
}

.filter-group input[type="checkbox"]:checked {
    background: var(--marvel-red);
    border-color: var(--marvel-red);
}

.filter-group input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 4px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.filter-group label {
    cursor: pointer;
}

.search-box {
    flex: 1 1 260px;
    min-width: 220px;
}

.search-box input[type="text"] {
    width: 100%;
    padding: 10px 16px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.search-box input[type="text"]::placeholder {
    color: var(--muted);
}

.search-box input[type="text"]:focus {
    background: var(--surface);
    border-color: var(--marvel-red);
    box-shadow: 0 0 0 4px rgba(237, 29, 36, 0.12);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    border-radius: 999px;
    white-space: nowrap;
}

.status-badge.loading {
    background: #fff4e0;
    color: #a6710a;
    border: 1px solid #f2d79a;
}

.status-badge.ready {
    background: #e6f6ea;
    color: #1e7a3c;
    border: 1px solid #b7e3c3;
}

.status-badge.error {
    background: #fdeceb;
    color: var(--marvel-red-dark);
    border: 1px solid #f4b8ba;
}

/* ==========================================================================
   Layout — sidebar + main content
   ========================================================================== */

.content-wrapper {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 24px;
    align-items: start;
    padding-bottom: 60px;
}

.sidebar {
    position: sticky;
    top: 20px;
}

.sidebar-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.sidebar-header {
    padding: 14px 18px;
    font-family: var(--font-display);
    font-size: 18px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(120deg, var(--marvel-red) 0%, var(--marvel-red-dark) 100%);
}

.category-list {
    max-height: 70vh;
    overflow-y: auto;
    padding: 8px;
}

.category-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    margin-bottom: 4px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-soft);
    border-radius: 8px;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.category-item:hover {
    background: var(--bg-alt);
    transform: translateX(2px);
}

.category-item.active {
    background: linear-gradient(90deg, rgba(237, 29, 36, 0.1), rgba(237, 29, 36, 0.02));
    border-left-color: var(--marvel-red);
    color: var(--ink);
    font-weight: 600;
}

.category-count {
    flex-shrink: 0;
    min-width: 24px;
    padding: 2px 8px;
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
    color: var(--ink-soft);
    background: var(--bg-alt);
    border-radius: 999px;
}

.category-item.active .category-count {
    color: #fff;
    background: var(--marvel-red);
}

/* ==========================================================================
   Main content — card grid
   ========================================================================== */

.main-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    align-content: start;
}

.loader {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 20px;
    color: var(--muted);
}

.loader p {
    margin: 0;
    font-size: 14px;
    letter-spacing: 0.4px;
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--border);
    border-top-color: var(--marvel-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Cards */

.mcu-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.mcu-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-strong);
}

.card-header {
    position: relative;
    padding: 16px 18px;
    color: #fff;
    background: linear-gradient(120deg, var(--marvel-red) 0%, var(--marvel-red-dark) 100%);
}

.card-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), transparent 70%);
    opacity: 0.8;
}

.card-title {
    font-family: var(--font-display);
    font-size: 20px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    line-height: 1.2;
}

.card-subtitle {
    margin-top: 4px;
    font-size: 12.5px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    letter-spacing: 0.3px;
}

.card-body {
    flex: 1;
    padding: 16px 18px;
    background: var(--surface);
}

.card-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.meta-item {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.meta-label {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 3px;
}

.meta-value {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
}

.meta-value a {
    color: var(--marvel-red-dark);
    text-decoration: none;
}

.meta-value a:hover {
    text-decoration: underline;
}

.card-footer {
    padding: 10px 18px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--muted);
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
}

/* Phase accent variations — falls back to the default red/gold gradient
   above for any category that doesn't match one of these known slugs. */

.card-header.phase-phase-one,
.card-header.phase-phase-1 {
    background: linear-gradient(120deg, #c9a24b 0%, #93701f 100%);
}

.card-header.phase-phase-two,
.card-header.phase-phase-2 {
    background: linear-gradient(120deg, #2e6fbb 0%, #1c4a82 100%);
}

.card-header.phase-phase-three,
.card-header.phase-phase-3 {
    background: linear-gradient(120deg, #6c3fa8 0%, #47286f 100%);
}

.card-header.phase-phase-four,
.card-header.phase-phase-4 {
    background: linear-gradient(120deg, #1f9d7c 0%, #14654f 100%);
}

.card-header.phase-phase-five,
.card-header.phase-phase-5 {
    background: linear-gradient(120deg, #d1651f 0%, #973f0f 100%);
}

.card-header.phase-phase-six,
.card-header.phase-phase-6 {
    background: linear-gradient(120deg, #17181c 0%, #3a3b42 100%);
}

.card-header.non-phase {
    background: linear-gradient(120deg, var(--ink-soft) 0%, var(--ink) 100%);
}

/* Series / episode groups */

.episode-item {
    background: var(--bg) !important;
    border-left-color: var(--border-strong) !important;
}

.episode-item:hover {
    background: #fff3cd !important;
    border-left-color: var(--marvel-red) !important;
}

.episode-details-content {
    border-color: var(--border) !important;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
    max-width: 1320px;
    margin: 0 auto 40px;
    padding: 16px 24px;
    text-align: center;
    font-size: 12.5px;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

.footer a {
    color: var(--marvel-red-dark);
    text-decoration: none;
    font-weight: 600;
}

.footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .category-list {
        max-height: 220px;
    }
}

@media (max-width: 560px) {
    .header .container {
        padding: 30px 20px 24px;
    }

    .filters-panel {
        padding: 14px;
    }

    .main-content {
        grid-template-columns: 1fr;
    }
}
