/*
Theme Name: CineStream
Theme URI: https://example.com/cinestream
Author: Your Name (with AI Assistant)
Author URI: https://example.com/
Description: A companion theme for The Cinematheque and The Stream plugins, featuring a dynamic dark/light mode and a responsive, modern layout.
Version: 1.0.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: cinestream
Tags: two-column, left-sidebar, right-sidebar, custom-header, custom-menu, social, movies
*/


        /* 1. Use a more-intuitive box-sizing model */
        *, *::before, *::after {
          box-sizing: border-box;
        }
        /* 2. Remove default margin */
        * {
          margin: 0;
          box-sizing: border-box;
        }
        /* 3. Enable keyword animations */
        @media (prefers-reduced-motion: no-preference) {
          html {
            interpolate-size: allow-keywords;
          }
        }
        body {
          /* 4. Add accessible line-height */
          line-height: 1.5;
          /* 5. Improve text rendering */
          -webkit-font-smoothing: antialiased;
        }
        /* 6. Improve media defaults */
        img, picture, video, canvas, svg {
          display: block;
          max-width: 100%;
        }
        /* 7. Inherit fonts for form controls */
        input, button, textarea, select {
          font: inherit;
        }
        /* 8. Avoid text overflows */
        p, h1, h2, h3, h4, h5, h6 {
          overflow-wrap: break-word;
        }
        /* 9. Improve line wrapping */
        p {
          text-wrap: pretty;
        }
        h1, h2, h3, h4, h5, h6 {
          text-wrap: balance;
        }
        /*
          10. Create a root stacking context
        */
        #root, #__next {
          isolation: isolate;
        }
        
        /* --- THEME COLOR VARIABLES --- */
        :root {
            --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        }

        .theme-light {
            --bg-primary: #f0f2f5; /* Light grey */
            --bg-secondary: #ffffff; /* White */
            --text-primary: #050505; /* Black */
            --text-secondary: #65676b; /* Grey */
            --border-color: #ced0d4;
            --accent-color: #1877f2; /* Blue */
            --header-bg: #ffffff;
        }

        .theme-dark {
            --bg-primary: #202020; /* Almost black */
            --bg-secondary: #242526; /* Lighter black */
            --text-primary: #e4e6eb; /* Light grey */
            --text-secondary: #b0b3b8; /* Darker grey */
            --border-color: #3e4042;
            --accent-color: #2374e1; /* Brighter blue */
            --header-bg: #242526;
        }

        .nowrap { text-wrap: nowrap; }
        
        /* --- BASE STYLES --- */
        body {
            background-color: var(--bg-primary);
            color: var(--text-primary);
            font-family: var(--font-sans);
            margin: 0;
            padding-top: 56px; /* Space for the fixed header */
        }
        
        /* --- LAYOUT & CONTENT STYLES --- */
        .site-content {
            padding: 0; /* 24px vertical, 10px horizontal padding */
        }
        
        /* UPDATED: Constrain width on non-Stream (dark theme) pages */
        body:not(.theme-light) .site-content {
            max-width: 1280px;
            margin-left: auto;
            margin-right: auto;
        }

        @media (min-width: 768px) {
            .site-content {
                padding: 0; /* 32px vertical, 16px horizontal */
            }
        }

        /* --- HEADER STYLES --- */
        .site-header {
            background-color: var(--header-bg);
            border-bottom: 1px solid var(--border-color);
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            height: 56px;
            z-index: 100;
            padding: 0 10px; /* Max 10px padding on small screens */
            width: 100%;
        }

        .header-inner {
            display: flex;
            align-items: center;
            justify-content: space-between;
            height: 100%;
            width: 100%;
            margin: 0 auto;
        }

        /* Header Sections */
        .header-left, .header-right {
            display: flex;
            align-items: center;
            flex-shrink: 0;
        }
        .header-center {
            flex-grow: 1;
            display: flex;
            justify-content: center;
        }

        /* Logo */
        .site-logo .custom-logo {
            height: 40px;
            width: auto;
            display: block;
        }
        .site-logo .text-logo {
            color: var(--accent-color);
            font-weight: 800;
            font-size: 1.75rem;
            text-decoration: none;
            line-height: 1;
        }

        /* Search Bar */
        .header-search-container {
            display: flex;
            align-items: center;
            margin-left: 10px;
            position: relative;
        }
        #live-search-input {
            background-color: var(--bg-primary);
            border: 1px solid var(--border-color);
            border-radius: 20px;
            padding: 7px 15px;
            color: var(--text-primary);
            width: 240px;
            box-sizing: border-box;
        }
        #live-search-input::placeholder { color: var(--text-secondary); }
        .search-toggle-icon { display: none; }
        #live-search-results {
            position: absolute;
            top: 100%;
            left: 0;
            width: 100%;
            min-width: 280px;
            background-color: var(--bg-secondary);
            border: 1px solid var(--border-color);
            border-radius: 8px;
            margin-top: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
            max-height: 400px;
            overflow-y: auto;
            display: none;
        }
        .live-search-item {
            display: flex;
            align-items: center;
            padding: 8px;
            border-bottom: 1px solid var(--bg-primary);
            text-decoration: none;
        }
        .live-search-item:last-child { border-bottom: none; }
        .live-search-item:hover { background-color: var(--bg-primary); }
        .live-search-item .result-image { width: 40px; height: 60px; object-fit: cover; border-radius: 4px; margin-right: 10px; flex-shrink: 0; }
        .live-search-item .result-details { display: flex; flex-direction: column; }
        .live-search-item .result-title { font-weight: 600; color: var(--text-primary); }
        .live-search-item .result-context { font-size: 0.8rem; color: var(--text-secondary); font-style: italic; }
        .live-search-item .result-type { font-size: 0.75rem; color: var(--text-secondary); text-transform: capitalize; }


        /* Main Navigation (Cinematheque) */
        .main-navigation { width: 100%; }
        .main-navigation ul {
            display: flex;
            justify-content: center;
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .main-navigation li a {
            color: var(--text-secondary);
            text-decoration: none;
            font-weight: 600;
            padding: 16px;
            display: block;
            border-bottom: 3px solid transparent;
        }
        .main-navigation li.current-menu-item a,
        .main-navigation li a:hover {
            color: var(--accent-color);
            border-bottom-color: var(--accent-color);
        }

        /* Stream Icon Menu Wrapper */
        .ts-icon-menu-wrapper {
            width: 100%;
            max-width: 680px; /* Max width on desktop */
            margin: 0 auto; /* Center it */
        }

        /* Right-side Icons */
        .header-right .ts-dropdown, .header-right .ts-mobile-menu-container {
            margin-left: 8px;
        }
        .header-right .ts-dropdown-toggle, .header-right .ts-mobile-menu-toggle {
            background-color: var(--bg-primary);
            color: var(--text-primary);
            border-radius: 50%;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            cursor: pointer;
        }

        /* --- MOBILE RESPONSIVENESS (Mobile First Approach) --- */
        .main-navigation, .ts-icon-menu-wrapper { display: none; }
        .ts-mobile-menu-container { display: block; }
        .header-search-container #live-search-input { display: none; }
        .search-toggle-icon {
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            border-radius: 50%;
            width: 40px;
            height: 40px;
            cursor: pointer;
            border: none;
        }

        /* Desktop & Tablet View */
        @media (min-width: 768px) {
            .site-header { padding: 0 16px; }
            .main-navigation, .ts-icon-menu-wrapper { display: block; }
            .ts-mobile-menu-container { display: none; }
            .search-toggle-icon { display: none !important; }
            .header-search-container #live-search-input { display: block; }
        }

        /* Mobile View Specifics */
        @media (max-width: 767px) {
            .header-center {
                flex-grow: 0; /* Don't let it take up space */
            }
            
            .header-search-container.is-active {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 56px;
                background-color: var(--header-bg);
                padding: 8px;
                z-index: 101;
                box-sizing: border-box;
                display: flex;
                align-items: center;
            }
            .header-search-container.is-active #live-search-input {
                display: block;
                width: 100%;
            }
            .header-search-container.is-active .search-toggle-icon {
                display: none;
            }

            body.theme-light .ts-icon-menu-wrapper {
                display: block;
                position: fixed;
                bottom: 0;
                left: 0;
                right: 0;
                background-color: var(--header-bg);
                border-top: 1px solid var(--border-color);
                z-index: 100;
                box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
            }
        }
        
/*--------------------------------------------------------------
# Responsive Hamburger Menu
--------------------------------------------------------------*/

/* Hamburger Toggle Button Styles */
.primary-menu-toggle {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
    margin-right: 8px; /* Space between hamburger and logo */
    line-height: 0;
    z-index: 101;
}
.primary-menu-toggle .icon-close {
    display: none;
}
.primary-menu-toggle.is-active .icon-menu {
    display: none;
}
.primary-menu-toggle.is-active .icon-close {
    display: block;
}

/* Mobile Menu Styles */
@media (max-width: 767px) {
    .primary-menu-toggle {
        display: block; /* Show the hamburger button */
    }

    /* Style the mobile dropdown menu */
    .main-navigation {
        display: none; /* Hide the nav by default */
        position: absolute;
        top: 56px; /* Position below the header */
        left: 0;
        right: 0;
        background-color: var(--header-bg);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        z-index: 99;
    }
    
    .main-navigation.is-active {
        display: block; /* Show the nav when active */
    }
    
    .main-navigation ul {
        flex-direction: column; /* Stack menu items vertically */
    }

    .main-navigation li a {
        padding: 16px 20px;
        border-bottom: 1px solid var(--border-color);
    }
    .main-navigation li:last-child a {
        border-bottom: none;
    }
    .main-navigation li.current-menu-item a,
    .main-navigation li a:hover {
        border-bottom: 1px solid var(--border-color); /* Remove the thick underline on mobile */
        color: var(--text-primary);
        background-color: var(--bg-primary);
    }
}

        /* Stream Icon Menu Wrapper */
        .ts-icon-menu-wrapper {
            width: 100%;
            max-width: 680px; /* Max width on desktop */
            margin: 0 auto; /* Center it */
        }

        /* Right-side Icons */
        .header-right .ts-dropdown, .header-right .ts-mobile-menu-container {
            margin-left: 8px;
        }
        .header-right .ts-dropdown-toggle, .header-right .ts-mobile-menu-toggle {
            background-color: var(--bg-primary);
            color: var(--text-primary);
            border-radius: 50%;
            width: 40px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
            border: none;
            cursor: pointer;
        }

        /* --- MOBILE RESPONSIVENESS (Mobile First Approach) --- */
        .main-navigation, .ts-icon-menu-wrapper { display: none; }
        .ts-mobile-menu-container { display: block; }
        .header-search-container #live-search-input { display: none; }
        .search-toggle-icon {
            display: flex;
            align-items: center;
            justify-content: center;
            background-color: var(--bg-primary);
            color: var(--text-primary);
            border-radius: 50%;
            width: 40px;
            height: 40px;
            cursor: pointer;
            border: none;
        }

        /* Desktop & Tablet View */
        @media (min-width: 768px) {
            .site-header { padding: 0 16px; }
            .main-navigation, .ts-icon-menu-wrapper { display: block; }
            .ts-mobile-menu-container { display: none; }
            .search-toggle-icon { display: none !important; }
            .header-search-container #live-search-input { display: block; }
        }

        /* Mobile View Specifics */
        @media (max-width: 767px) {
            .header-center { display: none; }
            
            .header-search-container.is-active {
                position: absolute;
                top: 0;
                left: 0;
                width: 100%;
                height: 56px;
                background-color: var(--header-bg);
                padding: 8px;
                z-index: 101;
                box-sizing: border-box;
                display: flex;
                align-items: center;
            }
            .header-search-container.is-active #live-search-input {
                display: block;
                width: 100%;
            }
            .header-search-container.is-active .search-toggle-icon {
                display: none;
            }

            body.theme-light .ts-icon-menu-wrapper {
                display: block;
                position: fixed;
                bottom: 0;
                left: 0;
                right: 0;
                background-color: var(--header-bg);
                border-top: 1px solid var(--border-color);
                z-index: 100;
                box-shadow: 0 -2px 5px rgba(0,0,0,0.1);
            }
        }
        
        

/*--------------------------------------------------------------
# Dynamic Carousel & Results Grid
--------------------------------------------------------------*/

/* FIX: Use a poster aspect ratio for dynamic carousel cards */
.dynamic-carousel .episode-card-image {
    aspect-ratio: 2 / 3;
}

/* Page header for the results page */
.archive-header {
    padding: 30px 40px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.archive-title {
    margin: 0;
    font-size: 36px;
}

/* Grid for single-carousel.php */
.results-grid-container {
    padding: 24px 40px;
}
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
}
.result-card a {
    text-decoration: none;
}
.result-card-image {
    aspect-ratio: 2 / 3;
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--bg-secondary);
}
.result-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.result-card a:hover .result-card-image img {
    transform: scale(1.05);
}
.card-item-title {
    font-size: 15px;
    color: var(--text-primary);
    margin: 8px 0 0;
    font-weight: 600;
}

/* Pagination Styling */
.pagination-container {
    margin-top: 48px;
    text-align: center;
}
.pagination-container .page-numbers {
    padding: 8px 14px;
    margin: 0 4px;
    border-radius: 6px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s ease;
}
.pagination-container .page-numbers:hover {
    background-color: var(--accent-color);
    color: var(--text-white);
}
.pagination-container .page-numbers.current {
    background-color: var(--accent-color);
    color: var(--text-white);
    font-weight: 700;
}

/*--------------------------------------------------------------
# Single Video Stream Template
--------------------------------------------------------------*/
/* Hide header/footer for an immersive experience */
.video-stream-template .site-header,
.video-stream-template .site-footer {
    display: none;
}
.video-stream-template body {
    padding-top: 0; /* Remove padding from header */
}
.video-stream-template #main {
    padding: 0;
    max-width: none;
}

.video-player-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    background-color: #000;
}
.video-player-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-main-content-wrap {
    display: grid;
    grid-template-columns: minmax(0, 3fr) 1fr; /* 75% content, 25% sidebar */
    gap: 24px;
    padding: 24px 40px;
    max-width: 1400px;
    margin: 0 auto;
}

.video-title {
    font-size: 28px;
    margin: 0 0 8px 0;
}

.video-parent-link {
    font-size: 15px;
    color: var(--text-secondary);
}
.video-parent-link a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}
.video-parent-link a:hover {
    text-decoration: underline;
}

.up-next-sidebar .sidebar-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-white);
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.up-next-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.up-next-item {
    display: flex;
    gap: 12px;
    text-decoration: none;
    align-items: center;
}

.up-next-thumbnail {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background-color: var(--bg-medium);
}

.up-next-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.4;
    display: block;
}

.up-next-parent {
    font-size: 13px;
    color: var(--text-secondary);
    display: block;
    margin-top: 4px;
}

/* Responsive for Video Page */
@media (max-width: 900px) {
    .video-main-content-wrap {
        grid-template-columns: 1fr; /* Stack sidebar below content */
    }
}

/*--------------------------------------------------------------
# Archive Page Layout (Paginated)
--------------------------------------------------------------*/
.archive-container-paginated {
    padding: 24px 40px;
}

.archive-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding-bottom: 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.archive-filters-bar .filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 200px;
    flex-grow: 1;
}

.archive-filters-bar .filter-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.results-content .results-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.card-item-year {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.no-results {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

/*--------------------------------------------------------------
# Single Ship Template
--------------------------------------------------------------*/
.ship-profile-header {
    position: relative;
    min-height: 350px;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-medium); /* Fallback */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 24px;
}

.ship-header-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(32, 32, 32, 0.7);
    backdrop-filter: blur(8px);
}

.ship-header-content {
    position: relative;
    z-index: 2;
    color: var(--text-white);
}

.ship-paired-images {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.ship-paired-images .person-avatar-link img {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    border: 3px solid #fff;
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.ship-paired-images .person-avatar-link:first-child {
    margin-right: -15px;
}
.ship-paired-images .person-avatar-link:last-child {
    margin-left: -15px;
}

.ship-heart-icon {
    width: 32px;
    height: 32px;
    color: #ff4d6d; /* A pink/red heart color */
    fill: #ff4d6d;
    stroke-width: 0;
    z-index: 5;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.ship-title {
    font-size: 42px;
    font-weight: 800;
    margin: 0;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.ship-person-names {
    margin-top: 8px;
    font-size: 18px;
    font-weight: 500;
}
.ship-person-names a {
    color: var(--text-white);
    text-decoration: none;
}
.ship-person-names a:hover {
    text-decoration: underline;
}
.ship-person-names span {
    margin: 0 8px;
    color: var(--text-secondary);
}

.ship-main-content {
    padding: 24px 40px;
}

.ship-description {
    max-width: 800px;
    margin: 0 auto 32px;
    text-align: center;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-light-gray);
}

.ship-appears-in-section .section-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

/*--------------------------------------------------------------
# Archive Ship Template
--------------------------------------------------------------*/
.ships-archive-grid {
    display: grid;
    /* 3 columns on desktop */
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.ship-archive-card {
    position: relative;
    min-height: 250px;
    background-size: cover;
    background-position: center;
    background-color: var(--bg-medium); /* Fallback */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text-white);
    transition: transform 0.3s ease;
}

.ship-archive-card:hover {
    transform: scale(1.03);
}

/* Re-using overlay and content structure from single-ship template */
.ship-archive-card .ship-header-overlay {
    z-index: 1;
}
.ship-archive-card .ship-header-content {
    z-index: 2;
}

/* Adapting single-ship header styles for the smaller card */
.ship-archive-card .ship-paired-images .person-avatar-link img {
    width: 80px;
    height: 80px;
}

.ship-archive-card .ship-heart-icon {
    width: 24px;
    height: 24px;
}

.ship-archive-card .ship-title {
    font-size: 28px;
    margin-top: 12px;
}

.ship-archive-card .ship-person-names {
    font-size: 14px;
    margin-top: 6px;
}
.ship-archive-card .ship-person-names a {
    color: var(--text-white);
    pointer-events: none; /* Prevent nested links */
}

/* Responsive Grid for Ships */
@media (max-width: 900px) {
    .ships-archive-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .ships-archive-grid {
        /* 1 column on mobile */
        grid-template-columns: 1fr;
    }
    .ship-archive-card .ship-title {
        font-size: 24px;
    }
}

/*--------------------------------------------------------------
# Pagination
--------------------------------------------------------------*/
.pagination-container .pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    list-style: none;
    padding: 0;
    gap: 8px;
}

.pagination-container .page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.pagination-container .page-numbers:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
}

.pagination-container .page-numbers.current {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: #fff;
    font-weight: 700;
    cursor: default;
}

.pagination-container .page-numbers.dots {
    border: none;
    background-color: transparent;
}

/*Stream Icon Menu*/
.header-center .ts-icon-menu-wrapper {
    box-shadow: none;
    padding: 0;
}

.ts-dropdown-menu {
    z-index: 40;
}