/* Active Inference Journal — Dark/Black/Gray Theme with Crimson Red Highlights */
:root {
    --bg-primary: #0a0a0c;
    --bg-secondary: #141419;
    --bg-tertiary: #202028;
    --bg-card: #141419;
    --bg-card-hover: #1c1c24;
    
    --border: #282834;
    --border-subtle: #1c1c24;
    --border-hover: #e53935;
    
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    --accent: #e53935;
    --accent-hover: #ef5350;
    --accent-glow: rgba(229, 57, 53, 0.25);
    --accent-light: rgba(229, 57, 53, 0.12);
    --accent-dark: #b71c1c;
    
    --success: #22c55e;
    --warning: #eab308;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.4);
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-hover);
}

/* Header */
.site-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.brand-logo {
    font-size: 2.2rem;
    line-height: 1;
}

.site-title {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.site-title a {
    color: var(--text-primary);
}

.site-title a:hover {
    color: var(--accent);
}

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

.nav-links {
    display: flex;
    gap: 1.25rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.nav-link.active, .nav-link:hover {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

/* Main Container */
.main-container {
    flex: 1;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
    padding: 1.5rem;
}

/* Loading & Spinner */
.loading-state {
    text-align: center;
    padding: 5rem 1rem;
    color: var(--text-secondary);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin: 0 auto 1.25rem;
}

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

/* Stats Bar */
.stats-strip {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.stat-chip {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 0.6rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stat-chip strong {
    color: var(--accent);
    font-weight: 700;
}

/* Filter / Search Section */
.filter-section {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 1.2rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    font-size: 1.1rem;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem 0.8rem 2.8rem;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.series-pills {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    max-height: 180px;
    overflow-y: auto;
    padding-bottom: 0.25rem;
}

.pill {
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.4rem 0.85rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.pill:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.pill.active {
    background-color: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    font-weight: 600;
}

/* Video Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    gap: 1.5rem;
}

.video-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.video-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    background-color: var(--bg-card-hover);
}

.card-thumbnail {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: #000;
}

.card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.card-body {
    padding: 1.15rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-series {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.35rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: 0.6rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-guests {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-footer {
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-subtle);
    padding-top: 0.75rem;
}

.lang-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.lang-tag {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Detail View Layout */
.detail-view {
    display: grid;
    grid-template-columns: 1fr 480px;
    gap: 1.5rem;
}

@media (max-width: 1080px) {
    .detail-view {
        grid-template-columns: 1fr;
    }
}

.player-panel {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.video-frame-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.video-frame-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.detail-header {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.detail-title {
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

.detail-meta-row {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.detail-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.detail-tag {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

/* Chapters Box */
.chapters-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.chapters-card__title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chapters-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.chapter-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    cursor: pointer;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    transition: all 0.15s ease;
}

.chapter-item:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.chapter-time {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 600;
    min-width: 60px;
}

.chapter-label {
    color: var(--text-primary);
    flex: 1;
}

/* Transcript & Translation Panel */
.transcript-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 120px);
    max-height: 900px;
    position: sticky;
    top: 5rem;
    box-shadow: var(--shadow);
}

.panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.panel-title {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.lang-selector, .part-selector {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.lang-selector:focus, .part-selector:focus {
    border-color: var(--accent);
}

.btn-tool {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-tool:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

.transcript-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.cue-row {
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.15s ease;
}

.cue-row:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.cue-row.active {
    border-color: var(--accent);
    background: var(--accent-light);
    box-shadow: 0 0 0 1px var(--accent);
}

.cue-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
}

.cue-time {
    color: var(--accent);
    font-family: var(--font-mono);
    font-weight: 700;
}

.cue-speaker {
    color: var(--text-muted);
    font-weight: 600;
}

.cue-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.5;
}

/* Action Button */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1.25rem;
    padding: 0.45rem 0.9rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
}

.btn-back:hover {
    color: #ffffff;
    background: var(--accent);
    border-color: var(--accent);
}

/* Footer */
.site-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 2.5rem 1.5rem;
    margin-top: 4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

.footer-links {
    margin-top: 0.75rem;
}

.footer-links a {
    color: var(--text-secondary);
    margin: 0 0.4rem;
}

.footer-links a:hover {
    color: var(--accent);
}
